[tor-commits] [orbot/master] Fixes #368 - if VPN priviliges are removed outside of Orbot, Orbot will

n8fr8 at torproject.org n8fr8 at torproject.org
Mon Aug 24 21:02:51 UTC 2020


commit 3b708b430d1053caa1495ef8663f4e4581e6fbbf
Author: bim <dsnake at protonmail.com>
Date:   Tue Jul 21 01:24:32 2020 -0400

    Fixes #368 - if VPN priviliges are removed outside of Orbot, Orbot will
    appropriately respond and turn off the VPN controls within the app.
---
 .../java/org/torproject/android/OrbotMainActivity.java | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index ea545070..3687e9cc 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -880,7 +880,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
         super.onResume();
 
         mBtnBridges.setChecked(Prefs.bridgesEnabled());
-        mBtnVPN.setChecked(Prefs.useVpn());
+        refreshVpnState();
 
         setCountrySpinner();
 
@@ -898,6 +898,22 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
 
     }
 
+    /**
+     * After granting VPN permissions in Orbot it's possible to revoke them outside of the app
+     * This method ensures that VPN permissions are still granted and if not it updates the state
+     * of the UI accordingly. see: https://github.com/guardianproject/orbot/issues/368
+     */
+    private void refreshVpnState() {
+        if (Prefs.useVpn()) {
+            Intent enableVpnIntent = VpnService.prepare(this);
+            // don't start the Intent, just update Orbot to say that VPN privileges are gone
+            if (enableVpnIntent != null) {
+                Prefs.putUseVpn(false);
+            }
+        }
+        mBtnVPN.setChecked(Prefs.useVpn());
+    }
+
     AlertDialog aDialog = null;
 
     //general alert dialog for mostly Tor warning messages





More information about the tor-commits mailing list