From 063230c27be070ec2fe941033bc1141676083c11 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 15 Jun 2018 10:58:59 +0200 Subject: [PATCH] android: Add function to quickly reconnect the current profile --- .../android/logic/VpnStateService.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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 f9eb82263..9f11e705b 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.