unregister receive and check for alternate library path

This commit is contained in:
Nathan Freitas 2014-01-09 21:14:01 -05:00
parent 1fa568d04c
commit 852792962e
1 changed files with 18 additions and 14 deletions

View File

@ -259,7 +259,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
catch (Exception e) catch (Exception e)
{ {
Log.e(TAG,"error setting up Tor",e); Log.e(TAG,"error setting up Tor",e);
throw new RuntimeException("Unable to start Tor"); throw new RuntimeException("Unable to start Tor",e);
} }
IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
@ -332,12 +332,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{ {
super.onDestroy(); super.onDestroy();
Log.d(TAG,"onDestroy called"); //Log.d(TAG,"onDestroy called");
// Unregister all callbacks. // Unregister all callbacks.
mCallbacks.kill(); mCallbacks.kill();
unregisterReceiver(mNetworkStateReceiver);
} }
private void stopTor () private void stopTor ()
@ -528,13 +528,25 @@ public class TorService extends Service implements TorServiceConstants, TorConst
appCacheHome = getDir("data",Application.MODE_PRIVATE); appCacheHome = getDir("data",Application.MODE_PRIVATE);
appLibsHome = new File(getApplicationInfo().nativeLibraryDir); appLibsHome = new File(getApplicationInfo().nativeLibraryDir);
fileTorOrig = new File(appLibsHome, TOR_BINARY_ASSET_KEY); if (!appLibsHome.exists())
appLibsHome = new File(getApplicationInfo().dataDir + "/lib");
fileTorOrig = new File(appLibsHome, TOR_BINARY_ASSET_KEY);
if (fileTorOrig.exists()) if (fileTorOrig.exists())
{ {
logNotice ("Tor binary exists: " + fileTorOrig.getAbsolutePath()); logNotice ("Tor binary exists: " + fileTorOrig.getAbsolutePath());
} }
else else
throw new RuntimeException("Tor binary not installed"); {
appLibsHome = new File(getApplicationInfo().dataDir + "/lib");
fileTorOrig = new File(appLibsHome, TOR_BINARY_ASSET_KEY);
if (fileTorOrig.exists())
logNotice ("Tor binary exists: " + fileTorOrig.getAbsolutePath());
else
throw new RuntimeException("Tor binary not installed");
}
filePrivoxy = new File(appLibsHome, PRIVOXY_ASSET_KEY); filePrivoxy = new File(appLibsHome, PRIVOXY_ASSET_KEY);
if (filePrivoxy.exists()) if (filePrivoxy.exists())
@ -553,15 +565,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (!fileTorRc.exists()) if (!fileTorRc.exists())
{ {
TorBinaryInstaller installer = new TorBinaryInstaller(this, appBinHome); TorBinaryInstaller installer = new TorBinaryInstaller(this, appBinHome);
try { boolean success = installer.installResources();
boolean success = installer.installResources();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }