]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Add function to quickly reconnect the current profile
authorTobias Brunner <tobias@strongswan.org>
Fri, 15 Jun 2018 08:58:59 +0000 (10:58 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:37 +0000 (11:31 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java

index f9eb82263aaa00ccc62a2ff96d30280e41e470dc..9f11e705b1ab76a1358918d93a610610eb883fac 100644 (file)
@@ -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.