Address leftover comments of ag/18112116

Bug: 225010642
Test: atest FrameworksNetTests:VpnTest
Change-Id: I0b129ec322159f608c447f608a4e11bed1971b55
(cherry picked from commit 5226b1f416)
Merged-In: I0b129ec322159f608c447f608a4e11bed1971b55
This commit is contained in:
lucaslin
2022-05-13 08:06:20 +08:00
committed by Cherrypicker Worker
parent 09eab9ca43
commit 29b1b5beac

View File

@@ -763,12 +763,20 @@ public class Vpn {
// Also notify the new package if there was a provider change. // Also notify the new package if there was a provider change.
final boolean shouldNotifyNewPkg = isVpnApp(packageName) && isPackageChanged; final boolean shouldNotifyNewPkg = isVpnApp(packageName) && isPackageChanged;
if (setAlwaysOnPackageInternal(packageName, lockdown, lockdownAllowlist)) { if (!setAlwaysOnPackageInternal(packageName, lockdown, lockdownAllowlist)) {
return false;
}
saveAlwaysOnPackage(); saveAlwaysOnPackage();
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from // TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
// ConnectivityServiceTest. // ConnectivityServiceTest.
if (shouldNotifyOldPkg && SdkLevel.isAtLeastT()) { if (!SdkLevel.isAtLeastT()) {
// If both of shouldNotifyOldPkg & isPackageChanged are true, which means the return true;
}
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 // always-on of old package is disabled or the old package is replaced with the new
// package. In this case, VpnProfileState should be disconnected. // package. In this case, VpnProfileState should be disconnected.
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED, sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED,
@@ -777,9 +785,8 @@ public class Vpn {
: makeVpnProfileStateLocked(), : makeVpnProfileStateLocked(),
null /* underlyingNetwork */, null /* nc */, null /* lp */); null /* underlyingNetwork */, null /* nc */, null /* lp */);
} }
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
// ConnectivityServiceTest. if (shouldNotifyNewPkg) {
if (shouldNotifyNewPkg && SdkLevel.isAtLeastT()) {
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED, sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED,
-1 /* errorClass */, -1 /* errorCode*/, packageName, -1 /* errorClass */, -1 /* errorCode*/, packageName,
getSessionKeyLocked(), makeVpnProfileStateLocked(), getSessionKeyLocked(), makeVpnProfileStateLocked(),
@@ -787,8 +794,6 @@ public class Vpn {
} }
return true; return true;
} }
return false;
}
/** /**
* Configures an always-on VPN connection through a specific application, the same as {@link * Configures an always-on VPN connection through a specific application, the same as {@link