[tor-commits] [orbot/master] unregister receive and check for alternate library path

n8fr8 at torproject.org n8fr8 at torproject.org
Fri Jan 10 03:01:52 UTC 2014


commit 852792962e9c2d9fefe16f458db46eeeb435aba6
Author: Nathan Freitas <nathan at freitas.net>
Date:   Thu Jan 9 21:14:01 2014 -0500

    unregister receive and check for alternate library path
---
 src/org/torproject/android/service/TorService.java |   32 +++++++++++---------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 4413bd8..ff5da45 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -259,7 +259,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
 		catch (Exception 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);
@@ -332,12 +332,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
     {
     	super.onDestroy();
     	
-    	Log.d(TAG,"onDestroy called");
+    	//Log.d(TAG,"onDestroy called");
     	
     	  // Unregister all callbacks.
         mCallbacks.kill();
         
-        
+        unregisterReceiver(mNetworkStateReceiver);
     }
     
     private void stopTor ()
@@ -528,13 +528,25 @@ public class TorService extends Service implements TorServiceConstants, TorConst
     	appCacheHome = getDir("data",Application.MODE_PRIVATE);
     	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())
     	{
     		logNotice ("Tor binary exists: " + fileTorOrig.getAbsolutePath());
     	}
     	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);
 		if (filePrivoxy.exists())
@@ -553,15 +565,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
 		if (!fileTorRc.exists())
 		{
 			TorBinaryInstaller installer = new TorBinaryInstaller(this, appBinHome); 
-			try {
-				boolean success = installer.installResources();
-			} catch (FileNotFoundException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			} catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
+			boolean success = installer.installResources();
 				
 		}
 			





More information about the tor-commits mailing list