[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] Fixes VPN Request Cancel Bugs



commit 2ebd338483d29588beba30323bed0ad22ed11fcb
Author: bim <dsnake@xxxxxxxxxxxxxx>
Date:   Wed Jun 26 23:12:53 2019 -0400

    Fixes VPN Request Cancel Bugs
    
    - Cancelling the VPN Permission Request left the user on a blank screen. This happened on the main activity and in the onboarding flow
    - If on the main screen you enable VPN but then deny the permission, the switch was previously activiated despite VPN permissions being
      denied.
---
 .../org/torproject/android/OrbotMainActivity.java  |  5 +-
 .../torproject/android/vpn/VPNEnableActivity.java  | 53 +++++++++-------------
 2 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 59a6d89b..e280147e 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -602,7 +602,7 @@ public class OrbotMainActivity extends AppCompatActivity
         Prefs.putUseVpn(enable);
 
         if (enable) {
-            startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
+            startActivityForResult(new Intent(OrbotMainActivity.this, VPNEnableActivity.class), REQUEST_VPN);
         } else
             stopVpnService();
 
@@ -952,8 +952,9 @@ public class OrbotMainActivity extends AppCompatActivity
 			if (response == RESULT_OK) {
                 sendIntentToService(TorServiceConstants.CMD_VPN);
             }
-			else
+			else if (response == VPNEnableActivity.ACTIVITY_RESULT_VPN_DENIED)
 			{
+			    mBtnVPN.setChecked(false);
 				Prefs.putUseVpn(false);
 			}
         }
diff --git a/app/src/main/java/org/torproject/android/vpn/VPNEnableActivity.java b/app/src/main/java/org/torproject/android/vpn/VPNEnableActivity.java
index e883913f..c1b30c50 100644
--- a/app/src/main/java/org/torproject/android/vpn/VPNEnableActivity.java
+++ b/app/src/main/java/org/torproject/android/vpn/VPNEnableActivity.java
@@ -24,20 +24,15 @@ public class VPNEnableActivity extends AppCompatActivity {
 	private Handler h = new Handler();
 	
 	@Override
-	public void onCreate( Bundle icicle ) {
-		
+	public void onCreate(Bundle icicle ) {
 		requestWindowFeature(Window.FEATURE_NO_TITLE);
-        //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 
 		super.onCreate( icicle );
 
 		Log.d("VPNEnableActivity","prompting user to start Orbot VPN");
-
-		
 	}
 	
-	public void onResume ()
-	{
+	public void onResume() {
 		super.onResume();
 		
 		if (checkVpn)
@@ -53,10 +48,9 @@ public class VPNEnableActivity extends AppCompatActivity {
 		}
 	}
 	
-	public void promptStartVpnService ()
-    {
+	public void promptStartVpnService () {
+		// todo no actual prompting happens here and this should be refactored
 		startVpnService();
-         
     }
 	 
 	private void startVpnService ()
@@ -88,27 +82,27 @@ public class VPNEnableActivity extends AppCompatActivity {
    		}
 
 	}
-	
-	  @Override
-	    protected void onActivityResult(int request, int response, Intent data) {
-	        super.onActivityResult(request, response, data);
+
+	public static final int ACTIVITY_RESULT_VPN_DENIED = 63;
+
+	@Override
+	protected void onActivityResult(int request, int response, Intent data) {
+		super.onActivityResult(request, response, data);
 	        
-	        if (request == REQUEST_VPN && response == RESULT_OK)
-	        {
-	            sendIntentToService(TorServiceConstants.CMD_VPN);	    
-	            
-	            h.postDelayed(new Runnable () {
-	            	
-	            	public void run ()
-	            	{
-	            		sendIntentToService(TorServiceConstants.ACTION_START);		
-	            		 finish();
+		if (request == REQUEST_VPN && response == RESULT_OK) {
+			sendIntentToService(TorServiceConstants.CMD_VPN);
+			h.postDelayed(new Runnable () {
+	            	@Override
+	            	public void run () {
+	            		sendIntentToService(TorServiceConstants.ACTION_START);
+	            		finish();
 	            	}
 	            }, 1000);
-	            
-	           
-	            
-	        }
+		}
+		else if (request == REQUEST_VPN && response == RESULT_CANCELED) {
+			setResult(ACTIVITY_RESULT_VPN_DENIED);
+			finish();
+		}
 	  }
 	  
 
@@ -122,8 +116,5 @@ public class VPNEnableActivity extends AppCompatActivity {
 			{
 				startService(torService);
 			}
-
-
 		}
-    
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits