[tor-commits] [orbot/master] clean up unbind process and service shutdown

n8fr8 at torproject.org n8fr8 at torproject.org
Sat Jun 14 10:01:22 UTC 2014


commit 156ed574e888b0801777399e11f94429945d918c
Author: Nathan Freitas <nathan at freitas.net>
Date:   Fri Jun 13 13:50:55 2014 -0400

    clean up unbind process and service shutdown
---
 src/org/torproject/android/Orbot.java |   37 +++------------------------------
 1 file changed, 3 insertions(+), 34 deletions(-)

diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index e252412..f7e0f95 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -83,9 +83,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 		/* The primary interface we will be calling on the service. */
     ITorService mService = null;
 
-    //should move this up with all the other class variables
-    private boolean mIsBound = false;
-    
 	private SharedPreferences mPrefs = null;
 
 	private boolean autoStartFromIntent = false;
@@ -431,6 +428,9 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
                         //terminology but also making sure there are clear distinctions in control
                         stopTor();
                         
+                        if (mConnection != null)
+                        	unbindService(mConnection); 
+                        
                         //perhaps this should be referenced as INTENT_TOR_SERVICE as in startService
                         stopService(new Intent(this,TorService.class));
                         
@@ -1164,8 +1164,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
         public void onServiceConnected(ComponentName className,
                 IBinder service) {
         	
-        	 mIsBound = true;
-        	 
             // 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
@@ -1215,35 +1213,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
         }
     };
     
-    
-    //unbind removes the callback, and unbinds the service
-    private void unbindService ()
-    {
-            if (mIsBound) {
-            // If we have received the service, and hence registered with
-            // it, then now is the time to unregister.
-            if (mService != null) {
-                try {
-                    mService.unregisterCallback(mCallback);
-                    
-                } catch (RemoteException e) {
-                    // There is nothing special we need to do if the service
-                    // has crashed.
-                }
-        }
-            
-            // Detach our existing connection.
-            unbindService(mConnection);
-            mIsBound = false;
-            
-            Log.d(TAG,"service was ubnound");
-
-            //maybe needs this?
-            mService = null; 
-            
-            
-        }
-    }
         
     /*
     private void createProgressDialog (String msg)





More information about the tor-commits mailing list