Merge changes from topics "RefactorIR", "appExclusionPrefix", "reStartVpnProfile"
* changes: Update method visibility for testing Stop VPN profiles by exiting VpnRunner instead of prepareInternal Update the prefix in keystore for app exclusion
This commit is contained in:
@@ -769,8 +769,7 @@ public class VpnManagerService extends IVpnManager.Stub {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@VisibleForTesting
|
private void onUserStarted(int userId) {
|
||||||
void onUserStarted(int userId) {
|
|
||||||
synchronized (mVpns) {
|
synchronized (mVpns) {
|
||||||
Vpn userVpn = mVpns.get(userId);
|
Vpn userVpn = mVpns.get(userId);
|
||||||
if (userVpn != null) {
|
if (userVpn != null) {
|
||||||
@@ -854,8 +853,7 @@ public class VpnManagerService extends IVpnManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private void onPackageRemoved(String packageName, int uid, boolean isReplacing) {
|
||||||
void onPackageRemoved(String packageName, int uid, boolean isReplacing) {
|
|
||||||
if (TextUtils.isEmpty(packageName) || uid < 0) {
|
if (TextUtils.isEmpty(packageName) || uid < 0) {
|
||||||
Log.wtf(TAG, "Invalid package in onPackageRemoved: " + packageName + " | " + uid);
|
Log.wtf(TAG, "Invalid package in onPackageRemoved: " + packageName + " | " + uid);
|
||||||
return;
|
return;
|
||||||
@@ -878,8 +876,7 @@ public class VpnManagerService extends IVpnManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private void onPackageAdded(String packageName, int uid, boolean isReplacing) {
|
||||||
void onPackageAdded(String packageName, int uid, boolean isReplacing) {
|
|
||||||
if (TextUtils.isEmpty(packageName) || uid < 0) {
|
if (TextUtils.isEmpty(packageName) || uid < 0) {
|
||||||
Log.wtf(TAG, "Invalid package in onPackageAdded: " + packageName + " | " + uid);
|
Log.wtf(TAG, "Invalid package in onPackageAdded: " + packageName + " | " + uid);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public class Vpn {
|
|||||||
private static final boolean LOGD = true;
|
private static final boolean LOGD = true;
|
||||||
private static final String ANDROID_KEYSTORE_PROVIDER = "AndroidKeyStore";
|
private static final String ANDROID_KEYSTORE_PROVIDER = "AndroidKeyStore";
|
||||||
/** Key containing prefix of vpn app excluded list */
|
/** Key containing prefix of vpn app excluded list */
|
||||||
@VisibleForTesting static final String VPN_APP_EXCLUDED = "VPN_APP_EXCLUDED_";
|
@VisibleForTesting static final String VPN_APP_EXCLUDED = "VPNAPPEXCLUDED_";
|
||||||
|
|
||||||
// Length of time (in milliseconds) that an app hosting an always-on VPN is placed on
|
// Length of time (in milliseconds) that an app hosting an always-on VPN is placed on
|
||||||
// the device idle allowlist during service launch and VPN bootstrap.
|
// the device idle allowlist during service launch and VPN bootstrap.
|
||||||
@@ -1182,20 +1182,9 @@ public class Vpn {
|
|||||||
cleanupVpnStateLocked();
|
cleanupVpnStateLocked();
|
||||||
} else if (mVpnRunner != null) {
|
} else if (mVpnRunner != null) {
|
||||||
if (!VpnConfig.LEGACY_VPN.equals(mPackage)) {
|
if (!VpnConfig.LEGACY_VPN.equals(mPackage)) {
|
||||||
mAppOpsManager.finishOp(
|
notifyVpnManagerVpnStopped(mPackage, mOwnerUID);
|
||||||
AppOpsManager.OPSTR_ESTABLISH_VPN_MANAGER, mOwnerUID, mPackage, null);
|
|
||||||
// The underlying network, NetworkCapabilities and LinkProperties are not
|
|
||||||
// necessary to send to VPN app since the purpose of this event is to notify
|
|
||||||
// VPN app that VPN is deactivated by the user.
|
|
||||||
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
|
|
||||||
// ConnectivityServiceTest.
|
|
||||||
if (SdkLevel.isAtLeastT()) {
|
|
||||||
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_DEACTIVATED_BY_USER,
|
|
||||||
-1 /* errorClass */, -1 /* errorCode*/, mPackage,
|
|
||||||
getSessionKeyLocked(), makeVpnProfileStateLocked(),
|
|
||||||
null /* underlyingNetwork */, null /* nc */, null /* lp */);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanupVpnStateLocked() is called from mVpnRunner.exit()
|
// cleanupVpnStateLocked() is called from mVpnRunner.exit()
|
||||||
mVpnRunner.exit();
|
mVpnRunner.exit();
|
||||||
}
|
}
|
||||||
@@ -4043,7 +4032,25 @@ public class Vpn {
|
|||||||
// To stop the VPN profile, the caller must be the current prepared package and must be
|
// To stop the VPN profile, the caller must be the current prepared package and must be
|
||||||
// running an Ikev2VpnProfile.
|
// running an Ikev2VpnProfile.
|
||||||
if (isCurrentIkev2VpnLocked(packageName)) {
|
if (isCurrentIkev2VpnLocked(packageName)) {
|
||||||
prepareInternal(VpnConfig.LEGACY_VPN);
|
notifyVpnManagerVpnStopped(packageName, mOwnerUID);
|
||||||
|
|
||||||
|
mVpnRunner.exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void notifyVpnManagerVpnStopped(String packageName, int ownerUID) {
|
||||||
|
mAppOpsManager.finishOp(
|
||||||
|
AppOpsManager.OPSTR_ESTABLISH_VPN_MANAGER, ownerUID, packageName, null);
|
||||||
|
// The underlying network, NetworkCapabilities and LinkProperties are not
|
||||||
|
// necessary to send to VPN app since the purpose of this event is to notify
|
||||||
|
// VPN app that VPN is deactivated by the user.
|
||||||
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
|
||||||
|
// ConnectivityServiceTest.
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_DEACTIVATED_BY_USER,
|
||||||
|
-1 /* errorClass */, -1 /* errorCode*/, packageName,
|
||||||
|
getSessionKeyLocked(), makeVpnProfileStateLocked(),
|
||||||
|
null /* underlyingNetwork */, null /* nc */, null /* lp */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user