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;
}
/**
+ * 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