update installer to get PLUTO binaries from assets

This commit is contained in:
Nathan Freitas 2015-12-16 10:27:06 -05:00
parent 7d213e24d4
commit bb55557b44
1 changed files with 10 additions and 9 deletions

View File

@ -68,6 +68,11 @@ public class TorResourceInstaller implements TorServiceConstants {
InputStream is; InputStream is;
File outFile; File outFile;
String cpuPath = "armeabi";
if (Build.CPU_ABI.contains("x86"))
cpuPath = "x86";
deleteDirectory(installFolder); deleteDirectory(installFolder);
@ -85,28 +90,24 @@ public class TorResourceInstaller implements TorServiceConstants {
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish(); shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false); streamToFile(is,outFile, false, false);
String cpuPath = null;
//only install if ARM (GoLang only supports ARM for now) //only install if ARM (GoLang only supports ARM for now)
if (Build.CPU_ABI.contains("arm")) if (cpuPath.equals("armeabi"))
{ {
is = context.getResources().openRawResource(R.raw.obfs4proxy); cpuPath = "armeabi";
is = context.getAssets().open(cpuPath + "/" + OBFSCLIENT_ASSET_KEY + ".mp3");
outFile = new File(installFolder, OBFSCLIENT_ASSET_KEY); outFile = new File(installFolder, OBFSCLIENT_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish(); shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true); streamToFile(is,outFile, false, true);
setExecutable(outFile); setExecutable(outFile);
is = context.getResources().openRawResource(R.raw.meek); is = context.getAssets().open(cpuPath + "/" + MEEK_ASSET_KEY + ".mp3");
outFile = new File(installFolder, MEEK_ASSET_KEY); outFile = new File(installFolder, MEEK_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish(); shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true); streamToFile(is,outFile, false, true);
setExecutable(outFile); setExecutable(outFile);
cpuPath = "armeabi";
} }
else if (Build.CPU_ABI.contains("x86"))
cpuPath = "x86";
is = context.getAssets().open(cpuPath + "/tor.mp3"); is = context.getAssets().open(cpuPath + "/tor.mp3");
outFile = new File(installFolder, TOR_ASSET_KEY); outFile = new File(installFolder, TOR_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish(); shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();