Wait for Orbot to connect when proxying though Orbot before trying to load a URL.
[PrivacyBrowser.git] / app / src / main / java / com / stoutner / privacybrowser / helpers / OrbotProxyHelper.java
index c4cbc6b96d74a8c9eaea7a4a061d5b079f4c6da4..8d0e408262fc8d993b3660466d3a1d1bd654c7e8 100644 (file)
@@ -86,8 +86,16 @@ public class OrbotProxyHelper {
 
                 // Ask Orbot to connect if its current status is not "ON".
                 if (!MainWebView.orbotStatus.equals("ON")) {
+                    // Request Orbot to start.
                     Intent orbotIntent = new Intent("org.torproject.android.intent.action.START");
+
+                    // Send the intent to the Orbot package.
                     orbotIntent.setPackage("org.torproject.android");
+
+                    // Request a status response be sent back to this package.
+                    orbotIntent.putExtra("org.torproject.android.intent.extra.PACKAGE_NAME", privacyBrowserContext.getPackageName());
+
+                    // Make it so.
                     privacyBrowserContext.sendBroadcast(orbotIntent);
                 }
             } catch (PackageManager.NameNotFoundException exception){  // If an exception is thrown, Orbot is not installed.