0
0
mirror of https://github.com/schwabe/ics-openvpn.git synced 2024-09-20 03:52:27 +02:00

Ability to pass extras when starting VPN via AIDL using inline config.

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.
This commit is contained in:
ntoskrnl 2021-07-12 21:43:32 -04:00 committed by Arne Schwabe
parent 9048473a35
commit e7d5155abe
2 changed files with 17 additions and 1 deletions

View File

@ -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);
}

View File

@ -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<IOpenVPNStatusCallback> 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 {