From: Tobias Brunner Date: Fri, 15 Jun 2018 08:58:59 +0000 (+0200) Subject: android: Add function to quickly reconnect the current profile X-Git-Tag: 5.7.0dr5~20^2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=063230c27be070ec2fe941033bc1141676083c11;p=thirdparty%2Fstrongswan.git android: Add function to quickly reconnect the current profile --- diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java index f9eb82263a..9f11e705b1 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java @@ -19,11 +19,13 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.Binder; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import org.strongswan.android.R; import org.strongswan.android.data.VpnProfile; +import org.strongswan.android.data.VpnProfileDataSource; import org.strongswan.android.logic.imc.ImcState; import org.strongswan.android.logic.imc.RemediationInstruction; @@ -241,6 +243,26 @@ public class VpnStateService extends Service context.startService(intent); } + /** + * Reconnect to the previous profile. + */ + public void reconnect() + { + if (mProfile == null) + { + return; + } + Bundle profileInfo = new Bundle(); + profileInfo.putLong(VpnProfileDataSource.KEY_ID, mProfile.getId()); + /* pass the previous password along */ + profileInfo.putString(VpnProfileDataSource.KEY_PASSWORD, mProfile.getPassword()); + /* we assume we have the necessary permission */ + Context context = getApplicationContext(); + Intent intent = new Intent(context, CharonVpnService.class); + intent.putExtras(profileInfo); + context.startService(intent); + } + /** * Update state and notify all listeners about the change. By using a Handler * this is done from the main UI thread and not the initial reporter thread.