From b4038a5b889fdfc301e54f3f1a5e9d111b07253f Mon Sep 17 00:00:00 2001 From: lucaslin Date: Mon, 4 Oct 2021 09:58:18 +0800 Subject: [PATCH] Update underlying networks if it is changed It's possible that the VPN app updates its underlying networks through Vpn#establish() instead of Vpn#setUnderlyingNetworks, so establish() should also consider this case. Bug: 191918368 Test: atest CtsHostsideNetworkTests:HostsideVpnTests Change-Id: Iabcf0538121aeb839c6acfcc9b0005df5488a436 --- services/core/java/com/android/server/connectivity/Vpn.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index c3e240a673e4b..1db9f749c45b6 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -1398,7 +1398,10 @@ public class Vpn { // parameters. If that fails, disconnect. if (oldConfig != null && updateLinkPropertiesInPlaceIfPossible(mNetworkAgent, oldConfig)) { - // Keep mNetworkAgent unchanged + // Update underlying networks if it is changed. + if (!Arrays.equals(oldConfig.underlyingNetworks, config.underlyingNetworks)) { + setUnderlyingNetworks(config.underlyingNetworks); + } } else { // Initialize the state for a new agent, while keeping the old one connected // in case this new connection fails.