]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Collapse Quick Settings drawer if password entry is required
authorTobias Brunner <tobias@strongswan.org>
Wed, 13 Jun 2018 14:07:28 +0000 (16:07 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:36 +0000 (11:31 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnTileService.java

index 2527e9618e1791afee838fbaed50247aa8bceaa8..6b5cca0eb0895565179d1a624087526d61de3f8f 100644 (file)
@@ -32,6 +32,7 @@ import android.service.quicksettings.TileService;
 import org.strongswan.android.R;
 import org.strongswan.android.data.VpnProfile;
 import org.strongswan.android.data.VpnProfileDataSource;
+import org.strongswan.android.data.VpnType;
 import org.strongswan.android.logic.VpnStateService;
 import org.strongswan.android.utils.Constants;
 
@@ -131,6 +132,10 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
                        {
                                profile = getProfile();
                        }
+                       else
+                       {   /* always get the plain profile without cached password */
+                               profile = mDataSource.getVpnProfile(profile.getId());
+                       }
                        /* reconnect the profile in case of an error */
                        if (mService.getErrorState() == VpnStateService.ErrorState.NO_ERROR)
                        {
@@ -163,7 +168,15 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
                                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                intent.setAction(VpnProfileControlActivity.START_PROFILE);
                                intent.putExtra(VpnProfileControlActivity.EXTRA_VPN_PROFILE_ID, profile.getUUID().toString());
-                               startActivity(intent);
+                               if (profile.getVpnType().has(VpnType.VpnTypeFeature.USER_PASS) &&
+                                       profile.getPassword() == null)
+                               {       /* the user will have to enter the password, so collapse the drawer */
+                                       startActivityAndCollapse(intent);
+                               }
+                               else
+                               {
+                                       startActivity(intent);
+                               }
                                return;
                        }
                }