diff options
| author | 2022-05-13 08:06:20 +0800 | |
|---|---|---|
| committer | 2022-05-28 05:42:32 +0000 | |
| commit | 29b1b5beacdfa5412562e112c638f3ddf46753ea (patch) | |
| tree | 26843f5304fed86e604135443c1dc4767ec59ff1 | |
| parent | 09eab9ca4367a8e9342588cc40f4b5cb507e5a6f (diff) | |
Address leftover comments of ag/18112116
Bug: 225010642
Test: atest FrameworksNetTests:VpnTest
Change-Id: I0b129ec322159f608c447f608a4e11bed1971b55
(cherry picked from commit 5226b1f41610fff0fef27e7a0ed4b41e697f3b47)
Merged-In: I0b129ec322159f608c447f608a4e11bed1971b55
| -rw-r--r-- | services/core/java/com/android/server/connectivity/Vpn.java | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index a8cc2c218a7a..81a4a7cad90e 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -763,31 +763,36 @@ public class Vpn { // Also notify the new package if there was a provider change. final boolean shouldNotifyNewPkg = isVpnApp(packageName) && isPackageChanged; - if (setAlwaysOnPackageInternal(packageName, lockdown, lockdownAllowlist)) { - saveAlwaysOnPackage(); - // TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from - // ConnectivityServiceTest. - if (shouldNotifyOldPkg && SdkLevel.isAtLeastT()) { - // If both of shouldNotifyOldPkg & isPackageChanged are true, which means the - // always-on of old package is disabled or the old package is replaced with the new - // package. In this case, VpnProfileState should be disconnected. - sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED, - -1 /* errorClass */, -1 /* errorCode*/, oldPackage, - null /* sessionKey */, isPackageChanged ? makeDisconnectedVpnProfileState() - : makeVpnProfileStateLocked(), - null /* underlyingNetwork */, null /* nc */, null /* lp */); - } - // TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from - // ConnectivityServiceTest. - if (shouldNotifyNewPkg && SdkLevel.isAtLeastT()) { - sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED, - -1 /* errorClass */, -1 /* errorCode*/, packageName, - getSessionKeyLocked(), makeVpnProfileStateLocked(), - null /* underlyingNetwork */, null /* nc */, null /* lp */); - } + if (!setAlwaysOnPackageInternal(packageName, lockdown, lockdownAllowlist)) { + return false; + } + + saveAlwaysOnPackage(); + + // TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from + // ConnectivityServiceTest. + if (!SdkLevel.isAtLeastT()) { return true; } - return false; + + if (shouldNotifyOldPkg) { + // If both of shouldNotifyOldPkg & isPackageChanged are true, that means the + // always-on of old package is disabled or the old package is replaced with the new + // package. In this case, VpnProfileState should be disconnected. + sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED, + -1 /* errorClass */, -1 /* errorCode*/, oldPackage, + null /* sessionKey */, isPackageChanged ? makeDisconnectedVpnProfileState() + : makeVpnProfileStateLocked(), + null /* underlyingNetwork */, null /* nc */, null /* lp */); + } + + if (shouldNotifyNewPkg) { + sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED, + -1 /* errorClass */, -1 /* errorCode*/, packageName, + getSessionKeyLocked(), makeVpnProfileStateLocked(), + null /* underlyingNetwork */, null /* nc */, null /* lp */); + } + return true; } /** |