more updates to install clean-up process
This commit is contained in:
parent
f885059b94
commit
60a79a2ae0
|
@ -8,3 +8,9 @@ host = https://www.transifex.com
|
||||||
source_file = ../res/values/strings.xml
|
source_file = ../res/values/strings.xml
|
||||||
source_lang = en
|
source_lang = en
|
||||||
|
|
||||||
|
[orbot.DESCRIPTION]
|
||||||
|
file_filter=../docs/play/description-<lang>.txt
|
||||||
|
host = https://www.transifex.com
|
||||||
|
source_file = ../docs/play/description.txt
|
||||||
|
source_lang = en
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,25 @@ public class TorResourceInstaller implements TorServiceConstants {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteDirectory(File file) {
|
||||||
|
if( file.exists() ) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
File[] files = file.listFiles();
|
||||||
|
for(int i=0; i<files.length; i++) {
|
||||||
|
if(files[i].isDirectory()) {
|
||||||
|
deleteDirectory(files[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
files[i].delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static String COMMAND_RM_FORCE = "rm -f ";
|
||||||
|
|
||||||
//
|
//
|
||||||
/*
|
/*
|
||||||
* Extract the Tor resources from the APK file using ZIP
|
* Extract the Tor resources from the APK file using ZIP
|
||||||
|
@ -47,43 +66,45 @@ public class TorResourceInstaller implements TorServiceConstants {
|
||||||
InputStream is;
|
InputStream is;
|
||||||
File outFile;
|
File outFile;
|
||||||
|
|
||||||
|
deleteDirectory(installFolder);
|
||||||
|
|
||||||
installFolder.mkdirs();
|
installFolder.mkdirs();
|
||||||
|
|
||||||
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
|
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.torrc);
|
is = context.getResources().openRawResource(R.raw.torrc);
|
||||||
outFile = new File(installFolder, TORRC_ASSET_KEY);
|
outFile = new File(installFolder, TORRC_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, false);
|
streamToFile(is,outFile, false, false);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.torrctether);
|
is = context.getResources().openRawResource(R.raw.torrctether);
|
||||||
outFile = new File(installFolder, TORRC_TETHER_KEY);
|
outFile = new File(installFolder, TORRC_TETHER_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is, outFile, false, false);
|
streamToFile(is, outFile, false, false);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.privoxy_config);
|
is = context.getResources().openRawResource(R.raw.privoxy_config);
|
||||||
outFile = new File(installFolder, PRIVOXYCONFIG_ASSET_KEY);
|
outFile = new File(installFolder, PRIVOXYCONFIG_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, false);
|
streamToFile(is,outFile, false, false);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.tor);
|
is = context.getResources().openRawResource(R.raw.tor);
|
||||||
outFile = new File(installFolder, TOR_ASSET_KEY);
|
outFile = new File(installFolder, TOR_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, true);
|
streamToFile(is,outFile, false, true);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.privoxy);
|
is = context.getResources().openRawResource(R.raw.privoxy);
|
||||||
outFile = new File(installFolder, PRIVOXY_ASSET_KEY);
|
outFile = new File(installFolder, PRIVOXY_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, true);
|
streamToFile(is,outFile, false, true);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.obfsproxy);
|
is = context.getResources().openRawResource(R.raw.obfsproxy);
|
||||||
outFile = new File(installFolder, OBFSPROXY_ASSET_KEY);
|
outFile = new File(installFolder, OBFSPROXY_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, true);
|
streamToFile(is,outFile, false, true);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.xtables);
|
is = context.getResources().openRawResource(R.raw.xtables);
|
||||||
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
|
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, true);
|
streamToFile(is,outFile, false, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -136,8 +157,7 @@ public class TorResourceInstaller implements TorServiceConstants {
|
||||||
|
|
||||||
int bytecount;
|
int bytecount;
|
||||||
|
|
||||||
|
OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
|
||||||
OutputStream stmOut = new FileOutputStream(outFile, append);
|
|
||||||
ZipInputStream zis = null;
|
ZipInputStream zis = null;
|
||||||
|
|
||||||
if (zip)
|
if (zip)
|
||||||
|
|
|
@ -270,6 +270,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
*/
|
*/
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
|
||||||
|
|
||||||
appBinHome = getDir(DIRECTORY_TOR_BINARY,Application.MODE_PRIVATE);
|
appBinHome = getDir(DIRECTORY_TOR_BINARY,Application.MODE_PRIVATE);
|
||||||
appCacheHome = getDir(DIRECTORY_TOR_DATA,Application.MODE_PRIVATE);
|
appCacheHome = getDir(DIRECTORY_TOR_DATA,Application.MODE_PRIVATE);
|
||||||
|
|
||||||
|
@ -517,11 +518,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
SharedPreferences prefs = getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = getSharedPrefs(getApplicationContext());
|
||||||
String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED,null);
|
String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED,null);
|
||||||
|
|
||||||
|
logNotice("checking binary version: " + version);
|
||||||
|
|
||||||
if (version == null || (!version.equals(BINARY_TOR_VERSION)))
|
if (version == null || (!version.equals(BINARY_TOR_VERSION)))
|
||||||
{
|
{
|
||||||
stopTor();
|
stopTor();
|
||||||
|
|
||||||
|
logNotice("upgrading binaries to latest version: " + BINARY_TOR_VERSION);
|
||||||
|
|
||||||
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
|
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
|
||||||
boolean success = installer.installResources();
|
boolean success = installer.installResources();
|
||||||
|
|
||||||
|
@ -531,6 +536,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
else if (!fileTorRc.exists())
|
else if (!fileTorRc.exists())
|
||||||
{
|
{
|
||||||
stopTor();
|
stopTor();
|
||||||
|
|
||||||
|
logNotice("upgrading binaries to latest version: " + BINARY_TOR_VERSION);
|
||||||
|
|
||||||
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
|
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
|
||||||
boolean success = installer.installResources();
|
boolean success = installer.installResources();
|
||||||
|
|
|
@ -7,7 +7,7 @@ public interface TorServiceConstants {
|
||||||
public final static String TOR_APP_USERNAME = "org.torproject.android";
|
public final static String TOR_APP_USERNAME = "org.torproject.android";
|
||||||
public final static String ORWEB_APP_USERNAME = "info.guardianproject.browser";
|
public final static String ORWEB_APP_USERNAME = "info.guardianproject.browser";
|
||||||
|
|
||||||
public final static String DIRECTORY_TOR_BINARY = "bins";
|
public final static String DIRECTORY_TOR_BINARY = "bin";
|
||||||
public final static String DIRECTORY_TOR_DATA = "data";
|
public final static String DIRECTORY_TOR_DATA = "data";
|
||||||
|
|
||||||
//name of the tor C binary
|
//name of the tor C binary
|
||||||
|
@ -79,10 +79,10 @@ public interface TorServiceConstants {
|
||||||
public static final int DISABLE_TOR_MSG = 3;
|
public static final int DISABLE_TOR_MSG = 3;
|
||||||
public static final int LOG_MSG = 4;
|
public static final int LOG_MSG = 4;
|
||||||
|
|
||||||
public static final String BINARY_TOR_VERSION = "0.2.4.21-openssl1.0.1g-installfix";
|
public static final String BINARY_TOR_VERSION = "0.2.4.21-openssl1.0.1g-if6";
|
||||||
public static final String BINARY_PRIVOXY_VERSION = "3.0.12";
|
public static final String BINARY_PRIVOXY_VERSION = "3.0.12";
|
||||||
public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INTALLED";
|
public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
|
||||||
public static final String PREF_BINARY_PRIVOXY_VERSION_INSTALLED = "BINARY_PRIVOXY_VERSION_INTALLED";
|
public static final String PREF_BINARY_PRIVOXY_VERSION_INSTALLED = "BINARY_PRIVOXY_VERSION_INSTALLED";
|
||||||
|
|
||||||
//obfsproxy
|
//obfsproxy
|
||||||
public static final String OBFSPROXY_ASSET_KEY = "obfsproxy";
|
public static final String OBFSPROXY_ASSET_KEY = "obfsproxy";
|
||||||
|
|
Loading…
Reference in New Issue