From fae5b6988b73c4b5e35c33b08243aaa93c487cac Mon Sep 17 00:00:00 2001 From: lucaslin Date: Fri, 24 Feb 2023 10:05:56 +0000 Subject: [PATCH] Clear the information of the underlying network The NetworkCapabilities and LinkProperties of the underlying network should be cleared when there is a new underlying network. Currently, Vpn.java only clear both NetworkCapabilities and LinkProperties of the underlying when onLost() is called or when the VPN is disconnected. But onLost() won't be fired if the device is connected to mobile data first, then connects to wifi later. For this case, both mUnderlyingNetworkCapabilities and mUnderlyingLinkProperties keep the old value until onLinkPropertiesChanged() and onNetworkCapabilitiesChanged() are called. Test: atest FrameworksNetTests Change-Id: I5caa1e0217190062eb84a064bb1bb3aff725dd66 --- services/core/java/com/android/server/connectivity/Vpn.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index ab2c002c2b248..1ce917cb78419 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -3254,6 +3254,8 @@ public class Vpn { } mActiveNetwork = network; + mUnderlyingLinkProperties = null; + mUnderlyingNetworkCapabilities = null; mRetryCount = 0; startOrMigrateIkeSession(network);