Merge "Grant the ACTIVATE_PLATFORM_VPN appop if VPN app has CONTROL_VPN" am: 41142d7244 am: 58c079210b

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2141595

Change-Id: I91a776f26d0c9a33b2c233691d0e80f35b7a8f43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Lucas Lin
2022-07-20 13:51:00 +00:00
committed by Automerger Merge Worker

View File

@@ -1095,7 +1095,7 @@ public class Vpn {
// Except for Settings and VpnDialogs, the caller should be matched one of oldPackage or // Except for Settings and VpnDialogs, the caller should be matched one of oldPackage or
// newPackage. Otherwise, non VPN owner might get the VPN always-on status of the VPN owner. // newPackage. Otherwise, non VPN owner might get the VPN always-on status of the VPN owner.
// See b/191382886. // See b/191382886.
if (mContext.checkCallingOrSelfPermission(CONTROL_VPN) != PERMISSION_GRANTED) { if (!hasControlVpnPermission()) {
if (oldPackage != null) { if (oldPackage != null) {
verifyCallingUidAndPackage(oldPackage); verifyCallingUidAndPackage(oldPackage);
} }
@@ -2045,6 +2045,10 @@ public class Vpn {
"Unauthorized Caller"); "Unauthorized Caller");
} }
private boolean hasControlVpnPermission() {
return mContext.checkCallingOrSelfPermission(CONTROL_VPN) == PERMISSION_GRANTED;
}
private class Connection implements ServiceConnection { private class Connection implements ServiceConnection {
private IBinder mService; private IBinder mService;
@@ -3846,8 +3850,10 @@ public class Vpn {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
// TODO: if package has CONTROL_VPN, grant the ACTIVATE_PLATFORM_VPN appop. // If package has CONTROL_VPN, grant the ACTIVATE_PLATFORM_VPN appop.
// This mirrors the prepareAndAuthorize that is used by VpnService. if (hasControlVpnPermission()) {
setPackageAuthorization(packageName, VpnManager.TYPE_VPN_PLATFORM);
}
// Return whether the app is already pre-consented // Return whether the app is already pre-consented
return isVpnProfilePreConsented(mContext, packageName); return isVpnProfilePreConsented(mContext, packageName);