Merge "Fix a bug where a spurious capabilities callback is sent." am: 0d4995dcb7 am: 4726fe863c am: 5cc55c46d0 am: 490480eb0f

Change-Id: I638f2a8862f15c09466bd476ff8d5e3eb76897e3
This commit is contained in:
Chalard Jean
2020-05-08 02:03:30 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 2 deletions

View File

@@ -7132,6 +7132,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
networkAgent.networkCapabilities.addCapability(NET_CAPABILITY_FOREGROUND);
if (!createNativeNetwork(networkAgent)) return;
if (networkAgent.isVPN()) {
// Initialize the VPN capabilities to their starting values according to the
// underlying networks. This will avoid a spurious callback to
// onCapabilitiesUpdated being sent in updateAllVpnCapabilities below as
// the VPN would switch from its default, blank capabilities to those
// that reflect the capabilities of its underlying networks.
updateAllVpnsCapabilities();
}
networkAgent.created = true;
}

View File

@@ -5394,8 +5394,6 @@ public class ConnectivityServiceTest {
// Even though the VPN is unvalidated, it becomes the default network for our app.
callback.expectAvailableCallbacksUnvalidated(vpnNetworkAgent);
// TODO: this looks like a spurious callback.
callback.expectCallback(CallbackEntry.NETWORK_CAPS_UPDATED, vpnNetworkAgent);
callback.assertNoCallback();
assertTrue(vpnNetworkAgent.getScore() > mEthernetNetworkAgent.getScore());