When proxying through Orbot, start Orbot if it is not currently running. Fixes https...
authorSoren Stoutner <soren@stoutner.com>
Thu, 26 Jan 2017 22:59:46 +0000 (15:59 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 26 Jan 2017 22:59:46 +0000 (15:59 -0700)
app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java

index 3a877ccbf79e377640687072e93a7a6434245353..6e751411ed0d8e4798b06a363998e9314424f458 100644 (file)
@@ -82,6 +82,11 @@ public class OrbotProxyHelper {
             try {  // Check to see if Orbot is installed.
                 PackageManager packageManager = privacyBrowserContext.getPackageManager();
                 packageManager.getPackageInfo("org.torproject.android", PackageManager.GET_ACTIVITIES);
+
+                // Send an `intent` to start Orbot.  The intent will be ignored if it is already running.
+                Intent orbotIntent = new Intent("org.torproject.android.intent.action.START");
+                orbotIntent.setPackage("org.torproject.android");
+                privacyBrowserContext.sendBroadcast(orbotIntent);
             } catch (PackageManager.NameNotFoundException exception){  // If an exception is thrown, Orbot is not installed.
                 // Build an `AlertDialog`.  `R.style.LightAlertDialog` formats the color of the button text.
                 AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(parentActivity, R.style.LightAlertDialog);