commit 2403e8c33320c431e2a10bdb14d61cdcc23df0ba Author: Nathan Freitas nathan@freitas.net Date: Thu Jun 1 16:32:02 2017 -0400
improve reliability of starting and stopping --- .../java/org/torproject/android/OrbotMainActivity.java | 2 +- .../java/org/torproject/android/service/TorService.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index 8e34467..8f34e48 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -197,7 +197,7 @@ public class OrbotMainActivity extends AppCompatActivity
private void stopTor() {
- requestTorStatus(); +// requestTorStatus();
Intent torService = new Intent(OrbotMainActivity.this, TorService.class); stopService(torService); diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java index 83de202..17000a9 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java @@ -439,8 +439,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
@Override public void onDestroy() { + stopTor(); - unregisterReceiver(mNetworkStateReceiver);
try { @@ -456,13 +456,13 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
private void stopTor () { - exec(new Runnable () + new Thread(new Runnable () { public void run () { stopTorAsync(); } - }); + }).start();
}
@@ -491,6 +491,14 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon } clearNotifications(); sendCallbackStatus(STATUS_OFF); + + try { + unregisterReceiver(mNetworkStateReceiver); + } + catch (IllegalArgumentException iae) + { + //not registered yet + } }
private void killAllDaemons() throws Exception { @@ -856,7 +864,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon showToolbarNotification( getString(R.string.unable_to_start_tor) + ": " + e.getMessage(), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr); - stopTor(); + //stopTor(); } }