Clear underlying network info in onDefaultNetworkLost()

Fix the wrong behavior that mUnderlyingNetworkCapabilities and
mUnderlyingLinkProperties is always cleared when
handleSessionLost() is called.

mUnderlyingNetworkCapabilities and mUnderlyingLinkProperties are
the info of underlying network, they should be cleared only when
the underlying network is lost. But the current design will
always clear them when handleSessionLost() is called, which will
make the VPN app won't get NetworkCapabilities and LinkProperties
of underlying network when VpnManager event is sent.

Bug: 237050331
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ibfd4f0199eafb67bfddb4ee0664550d3866e1840
This commit is contained in:
lucaslin
2022-11-23 12:19:12 +00:00
parent 352e892f47
commit 4eac85accf

View File

@@ -3475,6 +3475,8 @@ public class Vpn {
return;
} else {
mActiveNetwork = null;
mUnderlyingNetworkCapabilities = null;
mUnderlyingLinkProperties = null;
}
if (mScheduledHandleNetworkLostFuture != null) {
@@ -3664,9 +3666,6 @@ public class Vpn {
scheduleRetryNewIkeSession();
}
mUnderlyingNetworkCapabilities = null;
mUnderlyingLinkProperties = null;
// Close all obsolete state, but keep VPN alive incase a usable network comes up.
// (Mirrors VpnService behavior)
Log.d(TAG, "Resetting state for token: " + mCurrentToken);