[tor-commits] [tor-browser/tor-browser-52.7.2esr-8.0-1] Orfox: receive Tor status in thread so they arrive when event sync blocks

gk at torproject.org gk at torproject.org
Tue Mar 20 11:26:34 UTC 2018


commit 444e865687a56e630fc511173a67d7e06acf746c
Author: Hans-Christoph Steiner <hans at eds.org>
Date:   Thu Sep 10 12:52:52 2015 +0200

    Orfox: receive Tor status in thread so they arrive when event sync blocks
    
    Run in thread so Tor status updates will be received while the Gecko event
    sync is blocking the main thread.  This might not be the best approach
    since it probably means that the main UI will be frozen waiting for Tor to
    reach ON status.
    
    Signed-off-by: Amogh Pradeep <amoghbl1 at gmail.com>
---
 mobile/android/base/java/org/mozilla/gecko/BrowserApp.java | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
index b57fe27705fb..34f93ee56cdb 100644
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -139,6 +139,9 @@ import android.nfc.NfcAdapter;
 import android.nfc.NfcEvent;
 import android.os.Build;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
 import android.os.StrictMode;
 import android.support.design.widget.Snackbar;
 import android.support.v4.app.Fragment;
@@ -1119,6 +1122,14 @@ public class BrowserApp extends GeckoApp
         if (mIsAbortingAppLaunch) {
             return;
         }
+        /* run in thread so Tor status updates will be received while the
+         * Gecko event sync is blocking the main thread */
+        HandlerThread handlerThread = new HandlerThread("torStatusReceiver");
+        handlerThread.start();
+        Looper looper = handlerThread.getLooper();
+        Handler handler = new Handler(looper);
+        registerReceiver(torStatusReceiver, new IntentFilter(OrbotHelper.ACTION_STATUS),
+                null, handler);
 
         checkStartOrbot();
 





More information about the tor-commits mailing list