Invert the order of event sending and VpnRunner.exit()

Invert the order to prevent confusing VPN disconnected
notification being sent before the runner actually exits.

Bug: 235322391
Test: atest FrameworksNetTests
Change-Id: I3b2eed8bf4de4b8dd00d4797509884ebeff9ad75
This commit is contained in:
chiachangwang
2022-08-11 01:19:01 +00:00
parent 00f823fb2a
commit 9cfd367413

View File

@@ -4042,9 +4042,11 @@ 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)) {
notifyVpnManagerVpnStopped(packageName, mOwnerUID);
// Cache ownerUid to prevent the value being changed after performing VpnRunner.exit().
final int ownerUid = mOwnerUID;
mVpnRunner.exit();
notifyVpnManagerVpnStopped(packageName, ownerUid);
}
}