diff options
author | Thomas Crusius <thomas.crusius@mobiworx.de> | 2024-08-05 09:57:37 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2024-08-05 15:35:50 +0200 |
commit | ad7dfd597299f6cdf339ca924621733d3edecb0d (patch) | |
tree | eb4e9acf2c66f4816b2da581f28df3a333d483a7 /main/src | |
parent | 0df320119c21410f5effc5f0a21294fc788f62a7 (diff) |
enhance AIDL-API to allow passing extras during profile-import
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl | 6 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java | 17 |
2 files changed, 20 insertions, 3 deletions
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 3285432c..39b53106 100644 --- a/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl +++ b/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl @@ -67,4 +67,10 @@ interface IOpenVPNAPIService { /** 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);
+
+ /** Same as addNewVPNProfile(String, boolean, String) but giving possibility to pass a Bundle like
+ * in startVPNwithExtras(String, Bundle) to apply e.g. "allow vpn bypass" to profile.
+ * up to now the only extra that can be put is a boolean "de.blinkt.openvpn.api.ALLOW_VPN_BYPASS"
+ */
+ APIVpnProfile addNewVPNProfileWithExtras (String name, boolean userEditable, String config, 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 2f1f0788..304a1f4a 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java @@ -151,6 +151,13 @@ public class ExternalOpenVPNService extends Service implements StateListener { }
+ private void updateProfileFromExtras(Bundle extras, VpnProfile vp) {
+ if (extras != null) {
+ vp.mAllowAppVpnBypass = extras.getBoolean(EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS, false);
+ VpnStatus.logDebug("got extra " + EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS + ", mAllowAppVpnBypass=" + vp.mAllowAppVpnBypass);
+ }
+ }
+
@Override
public void startProfile(String profileUUID) throws RemoteException {
mExtAppDb.checkOpenVPNPermission(getPackageManager());
@@ -176,9 +183,7 @@ public class ExternalOpenVPNService extends Service implements StateListener { vp.mProfileCreator = callingApp;
- if (extras != null) {
- vp.mAllowAppVpnBypass = extras.getBoolean(EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS, false);
- }
+ updateProfileFromExtras(extras, vp);
/*int needpw = vp.needUserPWInput(false);
if(needpw !=0)
@@ -207,6 +212,11 @@ public class ExternalOpenVPNService extends Service implements StateListener { @Override
public APIVpnProfile addNewVPNProfile(String name, boolean userEditable, String config) throws RemoteException {
+ return addNewVPNProfileWithExtras(name, userEditable, config, null);
+ }
+
+ @Override
+ public APIVpnProfile addNewVPNProfileWithExtras(String name, boolean userEditable, String config, Bundle extras) throws RemoteException {
String callingPackage = mExtAppDb.checkOpenVPNPermission(getPackageManager());
ConfigParser cp = new ConfigParser();
@@ -216,6 +226,7 @@ public class ExternalOpenVPNService extends Service implements StateListener { vp.mName = name;
vp.mProfileCreator = callingPackage;
vp.mUserEditable = userEditable;
+ updateProfileFromExtras(extras, vp);
ProfileManager pm = ProfileManager.getInstance(getBaseContext());
pm.addProfile(vp);
pm.saveProfile(ExternalOpenVPNService.this, vp);
|