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
This commit is contained in:
lucaslin
2021-10-04 09:58:18 +08:00
committed by Lucas Lin
parent c7b5ac035e
commit b4038a5b88

View File

@@ -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.