Send VPN manager event when VPN is deactivated

Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: I35fc360204f0227a969ff2b12a4c47f701a55a9c
This commit is contained in:
lucaslin
2022-04-21 23:08:40 +08:00
committed by Lucas Lin
parent 48ed354751
commit 3f5bf1f059

View File

@@ -1110,6 +1110,17 @@ public class Vpn {
if (!VpnConfig.LEGACY_VPN.equals(mPackage)) {
mAppOpsManager.finishOp(
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()
mVpnRunner.exit();