From 6e6546972a6adedb72a90333eb9fe12ab87aa41f Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Tue, 26 Aug 2014 23:01:46 -0400 Subject: [PATCH] ensure settings are updated and binary paths are on service restart --- .../android/service/TorService.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index af41960f..8a43dba6 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -340,6 +340,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst try { + + if (fileTor == null) + initBinariesAndDirectories(); + + updateSettings (); + mExecutor.execute (new TorStarter(intent)); return Service.START_STICKY; @@ -568,6 +574,24 @@ public class TorService extends Service implements TorServiceConstants, TorConst try { initBinariesAndDirectories(); + updateSettings(); + + new Thread(new Runnable () + { + public void run () + { + try + { + findExistingProc (); + } + catch (Exception e) + { + Log.e(TAG,"error onBind",e); + } + + } + }).start(); + } catch (Exception e) { @@ -576,21 +600,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst logNotice("There was an error installing Orbot binaries"); } - new Thread(new Runnable () - { - public void run () - { - try - { - findExistingProc (); - } - catch (Exception e) - { - Log.e(TAG,"error onBind",e); - } - - } - }).start(); } @@ -712,6 +721,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst private void updateSettings () throws TimeoutException, IOException { + SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); mHasRoot = prefs.getBoolean(PREF_HAS_ROOT,false); @@ -736,6 +746,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst currentStatus = STATUS_CONNECTING; + if (fileTor == null) + initBinariesAndDirectories(); + enableBinExec(fileTor); enableBinExec(filePolipo); enableBinExec(fileObfsclient);