aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontends/android/src/org/strongswan/android/logic/VpnStateService.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/frontends/android/src/org/strongswan/android/logic/VpnStateService.java b/src/frontends/android/src/org/strongswan/android/logic/VpnStateService.java
index 2e2bce541..1c14cb601 100644
--- a/src/frontends/android/src/org/strongswan/android/logic/VpnStateService.java
+++ b/src/frontends/android/src/org/strongswan/android/logic/VpnStateService.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Callable;
import org.strongswan.android.data.VpnProfile;
import android.app.Service;
+import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
@@ -146,6 +147,24 @@ public class VpnStateService extends Service
}
/**
+ * Disconnect any existing connection and shutdown the daemon, the
+ * VpnService is not stopped but it is reset so new connections can be
+ * started.
+ */
+ public void disconnect()
+ {
+ /* as soon as the TUN device is created by calling establish() on the
+ * VpnService.Builder object the system binds to the service and keeps
+ * bound until the file descriptor of the TUN device is closed. thus
+ * calling stopService() here would not stop (destroy) the service yet,
+ * instead we call startService() with an empty Intent which shuts down
+ * the daemon (and closes the TUN device, if any) */
+ Context context = getApplicationContext();
+ Intent intent = new Intent(context, CharonVpnService.class);
+ 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.
* Also, in doing the actual state change from the main thread, listeners