From 0f7435453ecbf405e12b175b5ebfdc74659f83c7 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sun, 9 Nov 2014 23:07:43 +0100 Subject: Implement removal of profiles via external API --- .../de/blinkt/openvpn/api/IOpenVPNAPIService.aidl | 3 ++ .../blinkt/openvpn/api/ExternalOpenVPNService.java | 37 +++++++++++++++------- 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'main/src') diff --git a/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl b/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl index 794e3aad..f1c108ea 100644 --- a/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl +++ b/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl @@ -14,6 +14,9 @@ interface IOpenVPNAPIService { /** Use a profile with all certificates etc. embedded */ boolean addVPNProfile (String name, String config); + + /** Remove a profile by UUID */ + void removeProfile (String profileUUID); /** start a profile using an config */ void startVPN (String inlineconfig); diff --git a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java index 4b07c7ab..06b116fe 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java @@ -5,12 +5,6 @@ package de.blinkt.openvpn.api; -import java.io.IOException; -import java.io.StringReader; -import java.lang.ref.WeakReference; -import java.util.LinkedList; -import java.util.List; - import android.annotation.TargetApi; import android.app.Service; import android.content.ComponentName; @@ -21,20 +15,31 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.VpnService; -import android.os.*; +import android.os.Binder; +import android.os.Build; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.RemoteCallbackList; +import android.os.RemoteException; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.ref.WeakReference; +import java.util.LinkedList; +import java.util.List; -import de.blinkt.openvpn.LaunchVPN; import de.blinkt.openvpn.R; import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.ConfigParser; import de.blinkt.openvpn.core.ConfigParser.ConfigParseError; import de.blinkt.openvpn.core.OpenVPNService; -import de.blinkt.openvpn.core.VpnStatus; -import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus; -import de.blinkt.openvpn.core.VpnStatus.StateListener; import de.blinkt.openvpn.core.OpenVPNService.LocalBinder; import de.blinkt.openvpn.core.ProfileManager; import de.blinkt.openvpn.core.VPNLaunchHelper; +import de.blinkt.openvpn.core.VpnStatus; +import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus; +import de.blinkt.openvpn.core.VpnStatus.StateListener; @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) public class ExternalOpenVPNService extends Service implements StateListener { @@ -161,6 +166,8 @@ public class ExternalOpenVPNService extends Service implements StateListener { } } + + @Override public boolean addVPNProfile(String name, String config) throws RemoteException { checkOpenVPNPermission(); @@ -183,6 +190,14 @@ public class ExternalOpenVPNService extends Service implements StateListener { return true; } + @Override + public void removeProfile(String profileUUID) throws RemoteException { + checkOpenVPNPermission(); + ProfileManager pm = ProfileManager.getInstance(getBaseContext()); + VpnProfile vp = ProfileManager.get(getBaseContext(), profileUUID); + pm.removeProfile(ExternalOpenVPNService.this, vp); + } + @Override public Intent prepare(String packagename) { -- cgit v1.2.3