[tor-commits] [orbot/master] remove duplicate service start/bind code in onResume()

n8fr8 at torproject.org n8fr8 at torproject.org
Sun Sep 7 13:42:54 UTC 2014


commit c98509d8e620a371887a28ad5247c2cabd523664
Author: Nathan Freitas <nathan at freitas.net>
Date:   Thu Aug 28 23:22:45 2014 -0400

    remove duplicate service start/bind code in onResume()
    also disable startup button if service is null
---
 src/org/torproject/android/Orbot.java |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index e88e14d..87276ef 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -64,7 +64,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 	/* Useful UI bits */
 	private TextView lblStatus = null; //the main text display widget
 	private ImageProgressView imgStatus = null; //the main touchable image for activating Orbot
-//	private ProgressDialog progressDialog;
+
 	private MenuItem mItemOnOff = null;
     private TextView downloadText = null;
     private TextView uploadText = null;
@@ -104,6 +104,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 	
 	private void startService ()
 	{
+		appendLogTextAndScroll("starting Tor background service... ");
+		
 		Intent torService = new Intent(this, TorService.class);    	    	
 		startService(torService);
 		
@@ -125,6 +127,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
     	
     	imgStatus.setOnTouchListener(this);
     	
+    	imgStatus.setEnabled(false);
+    	
+    	lblStatus.setText("Initializing the application...");
+    	
     	downloadText = (TextView)findViewById(R.id.trafficDown);
         uploadText = (TextView)findViewById(R.id.trafficUp);
         mTxtOrbotLog = (TextView)findViewById(R.id.orbotLog);
@@ -802,20 +808,12 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 
 		setLocale();
 		
-		if (mService == null)
-		{
-			startService();
-		}
-		else
+		if (mService != null)
         {
                 try {
                 	
                 	torStatus = mService.getStatus();
                 	
-                	if (torStatus != TorServiceConstants.STATUS_ON)	
-                		mService.processSettings();
-                	
-					
 					handleIntents();
 				} catch (RemoteException e) {
 					// TODO Auto-generated catch block
@@ -981,7 +979,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 			else
 			{
 				showAlert(getString(R.string.error),"Tor Service has not started yet. Please wait and try again.",false);
-				startService ();
+				
 			}
             
     	
@@ -1177,15 +1175,22 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
      // bindService() a million times
      
     private final ServiceConnection mConnection = new ServiceConnection() {
+    	
+    	
         public void onServiceConnected(ComponentName className,
                 IBinder service) {
         	
+        	appendLogTextAndScroll("Tor background service connected.");
+    		
             // This is called when the connection with the service has been
             // established, giving us the service object we can use to
             // interact with the service.  We are communicating with our
             // service through an IDL interface, so get a client-side
             // representation of that from the raw service object.
             mService = ITorService.Stub.asInterface(service);
+            
+
+        	imgStatus.setEnabled(true);
        
             // We want to monitor the service for as long as we are
             // connected to it.
@@ -1210,11 +1215,13 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 
         public void onServiceDisconnected(ComponentName className) {
         	
+        	appendLogTextAndScroll("Tor background service disconnected.");
+
             // This is called when the connection with the service has been
             // unexpectedly disconnected -- that is, its process crashed.
         	mKeepUpdating = false;
             mService = null;
-            Log.d(TAG,"service was disconnected");
+            
             
         }
         





More information about the tor-commits mailing list