commit e6fe25267fbcb511aa0dd64a856bec934d5e6d2e
Author: Nathan Freitas <[email protected]>
Date:   Wed Apr 8 17:01:09 2015 -0400

    auto-restart Tor when config changes
---
 src/org/torproject/android/OrbotMainActivity.java |   57 ++++++++++++---------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/src/org/torproject/android/OrbotMainActivity.java 
b/src/org/torproject/android/OrbotMainActivity.java
index 405e930..26abd58 100644
--- a/src/org/torproject/android/OrbotMainActivity.java
+++ b/src/org/torproject/android/OrbotMainActivity.java
@@ -822,6 +822,7 @@ public class OrbotMainActivity extends Activity implements 
OrbotConstants, OnLon
         else if (request == REQUEST_VPN && response == RESULT_OK)
         {
             startService(TorServiceConstants.CMD_VPN);
+            restartTor ();   
         }
         
         IntentResult scanResult = 
IntentIntegrator.parseActivityResult(request, response, data);
@@ -1005,30 +1006,7 @@ public class OrbotMainActivity extends Activity 
implements OrbotConstants, OnLon
                        String bridgeList = 
mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST,null);
                        if (bridgeList != null && bridgeList.length() > 0)
                        {
-                               try
-                               {
-                                       //do auto restart
-                                       stopTor ();
-                                       
-                                       mHandler.postDelayed(new Runnable () {
-                                               
-                                               public void run ()
-                                               {
-                                                       try 
-                                                       {
-                                                               startTor();
-                                                       }
-                                                       catch (Exception e)
-                                                       {
-                                                               
Log.e(TAG,"can't start orbot",e);
-                                                       }
-                                               }
-                                       }, 2000);
-                               }
-                               catch (Exception e)
-                               {
-                                       Log.e(TAG,"can't stop orbot",e);
-                               }
+                               restartTor ();
                        }
                        
                }
@@ -1036,6 +1014,34 @@ public class OrbotMainActivity extends Activity 
implements OrbotConstants, OnLon
                
     }
     
+    private void restartTor ()
+    {
+       try
+               {
+                       //do auto restart
+                       stopTor ();
+                       
+                       mHandler.postDelayed(new Runnable () {
+                               
+                               public void run ()
+                               {
+                                       try 
+                                       {
+                                               startTor();
+                                       }
+                                       catch (Exception e)
+                                       {
+                                               Log.e(TAG,"can't start 
orbot",e);
+                                       }
+                               }
+                       }, 2000);
+               }
+               catch (Exception e)
+               {
+                       Log.e(TAG,"can't stop orbot",e);
+               }
+    }
+    
     public void promptStartVpnService ()
     {
         LayoutInflater li = LayoutInflater.from(this);
@@ -1086,13 +1092,14 @@ public class OrbotMainActivity extends Activity 
implements OrbotConstants, OnLon
         else
         {
             startService(TorServiceConstants.CMD_VPN);
-
+            restartTor ();
         }
     }
     
     public void stopVpnService ()
     {          
         startService(TorServiceConstants.CMD_VPN_CLEAR);
+        restartTor ();
     }
 
     private boolean flushTransProxy ()



_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to