]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Use activity when reconnecting without (or a possibly wrong) password
authorTobias Brunner <tobias@strongswan.org>
Wed, 20 Jun 2018 10:25:09 +0000 (12:25 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:40 +0000 (11:31 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java

index 9fd5a42d75a16afd436716e6a17e9fe662d64b0f..4be782640b1d0b04a822f8423b2fd42919e4983d 100644 (file)
@@ -29,8 +29,10 @@ import android.support.v4.content.ContextCompat;
 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.imc.ImcState;
 import org.strongswan.android.logic.imc.RemediationInstruction;
+import org.strongswan.android.ui.VpnProfileControlActivity;
 
 import java.lang.ref.WeakReference;
 import java.util.Collections;
@@ -313,6 +315,25 @@ public class VpnStateService extends Service
                {
                        return;
                }
+               if (mProfile.getVpnType().has(VpnType.VpnTypeFeature.USER_PASS))
+               {
+                       if (mProfile.getPassword() == null ||
+                               mError == ErrorState.AUTH_FAILED)
+                       {       /* show a dialog if we either don't have the password or if it might be the wrong
+                                * one (which is or isn't stored with the profile, let the activity decide)  */
+                               Intent intent = new Intent(this, VpnProfileControlActivity.class);
+                               intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                               intent.setAction(VpnProfileControlActivity.START_PROFILE);
+                               intent.putExtra(VpnProfileControlActivity.EXTRA_VPN_PROFILE_ID, mProfile.getUUID().toString());
+                               startActivity(intent);
+                               /* reset the retry timer immediately in case the user needs more time to enter the password */
+                               notifyListeners(() -> {
+                                       resetRetryTimer();
+                                       return true;
+                               });
+                               return;
+                       }
+               }
                connect(null, true);
        }