summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author lucaslin <lucaslin@google.com> 2022-09-08 13:21:51 +0800
committer Lucas Lin <lucaslin@google.com> 2022-09-12 07:55:17 +0000
commit737d5033cc0db91c3e5359792f2f86e7d0810cfc (patch)
treea29f95e6c39a777ac3e9ff5c64db6149b7f494ed
parent29e60dca123fb95c5e734dac4406c68e52fc1d5c (diff)
Remove parameter from stopVpnRunnerAndNotifyAppLocked()
The current design makes the caller can pass any package name, but in fact, stopVpnRunnerAndNotifyAppLocked() only cares about the current prepared package. So if the caller pass a package name which is not the current prepared, the method will not work. Remove the parameter and use mPackage directly to prevent the caller misuses this method. Bug: 236409954 Test: atest FrameworksNetTests:VpnTest Change-Id: I9297bf97fdcd7cef8ab0dadff3e6c05bf77fc667
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 9cb1f1dafed8..431be88bd892 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -1198,7 +1198,7 @@ public class Vpn {
mContext.unbindService(mConnection);
cleanupVpnStateLocked();
} else if (mVpnRunner != null) {
- stopVpnRunnerAndNotifyAppLocked(mPackage);
+ stopVpnRunnerAndNotifyAppLocked();
}
try {
@@ -4061,7 +4061,7 @@ public class Vpn {
}
@GuardedBy("this")
- private void stopVpnRunnerAndNotifyAppLocked(@NonNull String packageName) {
+ private void stopVpnRunnerAndNotifyAppLocked() {
// Build intent first because the sessionKey will be reset after performing
// VpnRunner.exit(). Also, cache mOwnerUID even if ownerUID will not be changed in
// VpnRunner.exit() to prevent design being changed in the future.
@@ -4069,17 +4069,17 @@ public class Vpn {
// ConnectivityServiceTest.
final int ownerUid = mOwnerUID;
Intent intent = null;
- if (SdkLevel.isAtLeastT() && isVpnApp(packageName)) {
+ if (SdkLevel.isAtLeastT() && isVpnApp(mPackage)) {
intent = buildVpnManagerEventIntent(
VpnManager.CATEGORY_EVENT_DEACTIVATED_BY_USER,
- -1 /* errorClass */, -1 /* errorCode*/, packageName,
+ -1 /* errorClass */, -1 /* errorCode*/, mPackage,
getSessionKeyLocked(), makeVpnProfileStateLocked(),
null /* underlyingNetwork */, null /* nc */, null /* lp */);
}
// cleanupVpnStateLocked() is called from mVpnRunner.exit()
mVpnRunner.exit();
- if (intent != null && isVpnApp(packageName)) {
- notifyVpnManagerVpnStopped(packageName, ownerUid, intent);
+ if (intent != null && isVpnApp(mPackage)) {
+ notifyVpnManagerVpnStopped(mPackage, ownerUid, intent);
}
}
@@ -4099,7 +4099,7 @@ public class Vpn {
// To stop the VPN profile, the caller must be the current prepared package and must be
// running an Ikev2VpnProfile.
if (isCurrentIkev2VpnLocked(packageName)) {
- stopVpnRunnerAndNotifyAppLocked(packageName);
+ stopVpnRunnerAndNotifyAppLocked();
}
}