From e7d5155abee039a9000e8b80bed5201520cb6577 Mon Sep 17 00:00:00 2001 From: ntoskrnl Date: Mon, 12 Jul 2021 21:43:32 -0400 Subject: Ability to pass extras when starting VPN via AIDL using inline config. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To preserve backward compatibility, a new method is created: IOpenVPNAPIService#startVPNwithExtras(String, Bundle). Currently only one parameter is supported: de.blinkt.openvpn.api.ALLOW_VPN_BYPASS – boolean. --- .../aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl | 4 ++++ .../java/de/blinkt/openvpn/api/ExternalOpenVPNService.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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 ac731b56..3285432c 100644 --- a/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl +++ b/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl @@ -63,4 +63,8 @@ interface IOpenVPNAPIService { /** Use a profile with all certificates etc. embedded */ APIVpnProfile addNewVPNProfile (String name, boolean userEditable, String config); + + /** Same as startVPN(String), but also takes a Bundle with extra parameters, + * which will be applied to the created VPNProfile (e.g. allow vpn bypass). */ + void startVPNwithExtras(in String inlineconfig, in Bundle extras); } \ No newline at end of file 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 1b8512f9..690c349e 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java @@ -20,6 +20,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.net.VpnService; import android.os.Binder; import android.os.Build; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -50,6 +51,8 @@ public class ExternalOpenVPNService extends Service implements StateListener { private static final int SEND_TOALL = 0; + private static final String EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS = "de.blinkt.openvpn.api.ALLOW_VPN_BYPASS"; + final RemoteCallbackList mCallbacks = new RemoteCallbackList<>(); @@ -161,7 +164,8 @@ public class ExternalOpenVPNService extends Service implements StateListener { startProfile(vp); } - public void startVPN(String inlineConfig) throws RemoteException { + @Override + public void startVPNwithExtras(String inlineConfig, Bundle extras) throws RemoteException { String callingApp = mExtAppDb.checkOpenVPNPermission(getPackageManager()); ConfigParser cp = new ConfigParser(); @@ -174,6 +178,10 @@ public class ExternalOpenVPNService extends Service implements StateListener { vp.mProfileCreator = callingApp; + if (extras != null) { + vp.mAllowAppVpnBypass = extras.getBoolean(EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS, false); + } + /*int needpw = vp.needUserPWInput(false); if(needpw !=0) throw new RemoteException("The inline file would require user input: " + getString(needpw)); @@ -188,6 +196,10 @@ public class ExternalOpenVPNService extends Service implements StateListener { } } + @Override + public void startVPN(String inlineConfig) throws RemoteException { + startVPNwithExtras(inlineConfig, null); + } @Override public boolean addVPNProfile(String name, String config) throws RemoteException { -- cgit v1.2.3