Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance AIDL-API to allow passing extras during profile-import #1749

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ private void startProfile(VpnProfile vp)

}

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());
Expand All @@ -176,9 +183,7 @@ public void startVPNwithExtras(String inlineConfig, Bundle extras) throws Remote

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)
Expand Down Expand Up @@ -207,6 +212,11 @@ public boolean addVPNProfile(String name, String config) throws RemoteException

@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();
Expand All @@ -216,6 +226,7 @@ public APIVpnProfile addNewVPNProfile(String name, boolean userEditable, String
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ interface IOpenVPNAPIService {

/** Use a profile with all certificates etc. embedded */
APIVpnProfile addNewVPNProfile (String name, boolean userEditable, String config);

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