[tor-commits] [orbot/master] make sure receiver unregisters when destroyed

n8fr8 at torproject.org n8fr8 at torproject.org
Wed Oct 25 02:16:50 UTC 2017


commit b322e530da659d714dc28679b158c3ed8fee8d7b
Author: n8fr8 <nathan at freitas.net>
Date:   Mon Oct 16 23:36:14 2017 -0400

    make sure receiver unregisters when destroyed
---
 .../java/org/torproject/android/service/TorService.java  | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

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 597e59e2..36c1b229 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -428,6 +428,14 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
     @Override
     public void onDestroy() {
 
+        try {
+            unregisterReceiver(mNetworkStateReceiver);
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //not registered yet
+        }
+
         stopTor();
 
         /**
@@ -476,13 +484,7 @@ 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 {





More information about the tor-commits mailing list