Skip to content

Commit

Permalink
load PT binaries fromthe native library path
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed May 9, 2018
1 parent 3dc40b8 commit ad18a40
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -3,6 +3,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -16,6 +17,7 @@
import java.util.zip.ZipInputStream;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.util.Log;

Expand Down Expand Up @@ -74,12 +76,14 @@ public boolean installResources () throws IOException, FileNotFoundException, Ti
if (!installFolder.exists())
installFolder.mkdirs();

is = context.getAssets().open(cpuPath + '/' + OBFSCLIENT_ASSET_KEY + MP3_EXT);
// is = context.getAssets().open(cpuPath + '/' + OBFSCLIENT_ASSET_KEY + MP3_EXT);
is = new FileInputStream(new File(getNativeLibraryDir(context),OBFSCLIENT_ASSET_KEY + ".so"));
outFile = new File(installFolder, OBFSCLIENT_ASSET_KEY);
streamToFile(is,outFile, false, true);
setExecutable(outFile);

is = context.getAssets().open(cpuPath + '/' + PDNSD_ASSET_KEY + MP3_EXT);
// is = context.getAssets().open(cpuPath + '/' + PDNSD_ASSET_KEY + MP3_EXT);
is = new FileInputStream(new File(getNativeLibraryDir(context),PDNSD_ASSET_KEY + ".so"));
outFile = new File(installFolder, PDNSD_ASSET_KEY);
streamToFile(is,outFile, false, true);
setExecutable(outFile);
Expand All @@ -88,6 +92,12 @@ public boolean installResources () throws IOException, FileNotFoundException, Ti
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
{
if (fileTorRcCustom.exists())
Expand Down

0 comments on commit ad18a40

Please sign in to comment.