update to use faux .so shared library method for loading tor binary

This commit is contained in:
n8fr8 2018-05-09 12:47:25 -04:00
parent 9abac285db
commit 1b1f64d376
7 changed files with 24 additions and 15 deletions

View File

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.1.1'
} }
} }

View File

@ -1,5 +1,6 @@
#Wed May 09 12:39:36 EDT 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip

View File

@ -1,8 +1,8 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion 25 compileSdkVersion 27
buildToolsVersion '26.0.2' buildToolsVersion '27.0.3'
sourceSets { sourceSets {
main { main {
@ -13,7 +13,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 25 targetSdkVersion 27
versionCode 3210 versionCode 3210
versionName "0.3.2.10" versionName "0.3.2.10"
@ -27,7 +27,7 @@ android {
} }
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.so']) implementation fileTree(dir: 'libs', include: ['*.so'])
} }
apply plugin: 'maven' apply plugin: 'maven'

View File

@ -4,6 +4,7 @@
package org.torproject.android.binary; package org.torproject.android.binary;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -15,6 +16,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
@ -50,7 +52,6 @@ public class TorResourceInstaller implements TorServiceConstants {
} }
} }
private final static String MP3_EXT = ".mp3";
// //
/* /*
* Extract the Tor resources from the APK file using ZIP * Extract the Tor resources from the APK file using ZIP
@ -58,24 +59,30 @@ public class TorResourceInstaller implements TorServiceConstants {
public boolean installResources () throws IOException, TimeoutException public boolean installResources () throws IOException, TimeoutException
{ {
String cpuPath = "armeabi";
if (Build.CPU_ABI.contains("x86"))
cpuPath = "x86";
deleteDirectory(installFolder); deleteDirectory(installFolder);
installFolder.mkdirs(); installFolder.mkdirs();
assetToFile(COMMON_ASSET_KEY + TORRC_ASSET_KEY, TORRC_ASSET_KEY, false, false); assetToFile(COMMON_ASSET_KEY + TORRC_ASSET_KEY, TORRC_ASSET_KEY, false, false);
assetToFile(cpuPath + '/' + TOR_ASSET_KEY + MP3_EXT, TOR_ASSET_KEY, true, true); InputStream is = new FileInputStream(new File(getNativeLibraryDir(context),TOR_ASSET_KEY + ".so"));
File outFile = new File(installFolder, TOR_ASSET_KEY);
streamToFile(is,outFile, false, true);
setExecutable(outFile);
installGeoIP(); installGeoIP();
return true; return true;
} }
// Return Full path to the directory where native JNI libraries are stored.
private static String getNativeLibraryDir(Context context) {
ApplicationInfo appInfo = context.getApplicationInfo();
return appInfo.nativeLibraryDir;
}
public boolean updateTorConfigCustom (File fileTorRcCustom, String extraLines) throws IOException, FileNotFoundException, TimeoutException public boolean updateTorConfigCustom (File fileTorRcCustom, String extraLines) throws IOException, FileNotFoundException, TimeoutException
{ {
if (fileTorRcCustom.exists()) if (fileTorRcCustom.exists())

View File

@ -0,0 +1 @@
libs