From: Tobias Brunner Date: Tue, 12 Jun 2018 15:05:00 +0000 (+0200) Subject: android: Allow reconnecting without confirmation in case of an error X-Git-Tag: 5.7.0dr5~20^2~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be8931078443e94400c995917c43977410b1fe6d;p=thirdparty%2Fstrongswan.git android: Allow reconnecting without confirmation in case of an error --- diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java index 9bc0cf0320..6f5cddd95e 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java @@ -191,6 +191,24 @@ public class VpnProfileControlActivity extends AppCompatActivity } } + /** + * Check if we are currently connected to a VPN connection + * + * @return true if currently connected + */ + private boolean isConnected() + { + if (mService == null) + { + return false; + } + if (mService.getErrorState() != VpnStateService.ErrorState.NO_ERROR) + { /* allow reconnecting (even to a different profile) without confirmation if there is an error */ + return false; + } + return (mService.getState() == State.CONNECTED || mService.getState() == State.CONNECTING); + } + /** * Start the given VPN profile * @@ -207,9 +225,9 @@ public class VpnProfileControlActivity extends AppCompatActivity removeFragmentByTag(DIALOG_TAG); - if (mService != null && (mService.getState() == State.CONNECTED || mService.getState() == State.CONNECTING)) + if (isConnected()) { - profileInfo.putBoolean(PROFILE_RECONNECT, mService.getProfile().getId() == profile.getId()); + profileInfo.putBoolean(PROFILE_RECONNECT, mService.getProfile().getUUID().equals(profile.getUUID())); ConfirmationDialog dialog = new ConfirmationDialog(); dialog.setArguments(profileInfo);