From 4eac85accf919f749d852e13134b96564051966c Mon Sep 17 00:00:00 2001 From: lucaslin Date: Wed, 23 Nov 2022 12:19:12 +0000 Subject: [PATCH] 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 --- services/core/java/com/android/server/connectivity/Vpn.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index bc9bc031ca359..4fcde97fc7728 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -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);