From: Soren Stoutner Date: Thu, 26 Jan 2017 22:59:46 +0000 (-0700) Subject: When proxying through Orbot, start Orbot if it is not currently running. Fixes https... X-Git-Tag: v1.15~11 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=03f794afc98b9c325df8b39033e6231dac336f67;p=PrivacyBrowserAndroid.git When proxying through Orbot, start Orbot if it is not currently running. Fixes https://redmine.stoutner.com/issues/83. --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java index 3a877ccb..6e751411 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/OrbotProxyHelper.java @@ -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);