added support for unpacking split binary into one tor exe; supports devices with 1M raw resource limit
This commit is contained in:
parent
9c31399663
commit
0bfad80ca6
|
@ -58,18 +58,26 @@ public class TorBinaryInstaller implements TorServiceConstants {
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
InputStream is = context.getResources().openRawResource(R.raw.tor);
|
InputStream is = context.getResources().openRawResource(R.raw.toraa);
|
||||||
streamToFile(is,installPath + TOR_BINARY_ASSET_KEY);
|
streamToFile(is,installPath + TOR_BINARY_ASSET_KEY, false);
|
||||||
|
|
||||||
|
is = context.getResources().openRawResource(R.raw.torab);
|
||||||
|
streamToFile(is,installPath + TOR_BINARY_ASSET_KEY, true);
|
||||||
|
|
||||||
|
is = context.getResources().openRawResource(R.raw.torac);
|
||||||
|
streamToFile(is,installPath + TOR_BINARY_ASSET_KEY, true);
|
||||||
|
|
||||||
|
is = context.getResources().openRawResource(R.raw.torad);
|
||||||
|
streamToFile(is,installPath + TOR_BINARY_ASSET_KEY, true);
|
||||||
|
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.torrc);
|
is = context.getResources().openRawResource(R.raw.torrc);
|
||||||
streamToFile(is,installPath + TORRC_ASSET_KEY);
|
streamToFile(is,installPath + TORRC_ASSET_KEY, false);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.privoxy);
|
is = context.getResources().openRawResource(R.raw.privoxy);
|
||||||
streamToFile(is,installPath + PRIVOXY_ASSET_KEY);
|
streamToFile(is,installPath + PRIVOXY_ASSET_KEY, false);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.privoxy_config);
|
is = context.getResources().openRawResource(R.raw.privoxy_config);
|
||||||
streamToFile(is,installPath + PRIVOXYCONFIG_ASSET_KEY);
|
streamToFile(is,installPath + PRIVOXYCONFIG_ASSET_KEY, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,9 +85,8 @@ public class TorBinaryInstaller implements TorServiceConstants {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extract the Tor binary from the APK file using ZIP
|
|
||||||
*/
|
|
||||||
private void installFromZip ()
|
private void installFromZip ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -89,7 +96,7 @@ public class TorBinaryInstaller implements TorServiceConstants {
|
||||||
ZipFile zip = new ZipFile(apkPath);
|
ZipFile zip = new ZipFile(apkPath);
|
||||||
|
|
||||||
ZipEntry zipen = zip.getEntry(ASSETS_BASE + TOR_BINARY_ASSET_KEY);
|
ZipEntry zipen = zip.getEntry(ASSETS_BASE + TOR_BINARY_ASSET_KEY);
|
||||||
streamToFile(zip.getInputStream(zipen),installPath + TOR_BINARY_ASSET_KEY);
|
streamToFile(zip.getInputStream(zipen),installPath + TOR_BINARY_ASSET_KEY, false);
|
||||||
|
|
||||||
zipen = zip.getEntry(ASSETS_BASE + TORRC_ASSET_KEY);
|
zipen = zip.getEntry(ASSETS_BASE + TORRC_ASSET_KEY);
|
||||||
streamToFile(zip.getInputStream(zipen),installPath + TORRC_ASSET_KEY);
|
streamToFile(zip.getInputStream(zipen),installPath + TORRC_ASSET_KEY);
|
||||||
|
@ -115,11 +122,12 @@ public class TorBinaryInstaller implements TorServiceConstants {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write the inputstream contents to the file
|
* Write the inputstream contents to the file
|
||||||
*/
|
*/
|
||||||
private static void streamToFile(InputStream stm, String targetFilename)
|
private static void streamToFile(InputStream stm, String targetFilename, boolean append)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -133,7 +141,8 @@ public class TorBinaryInstaller implements TorServiceConstants {
|
||||||
File outFile = new File(targetFilename);
|
File outFile = new File(targetFilename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
outFile.createNewFile();
|
if (!append)
|
||||||
|
outFile.createNewFile();
|
||||||
|
|
||||||
stmOut = new FileOutputStream(outFile);
|
stmOut = new FileOutputStream(outFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue