Merge "Wait for Wi-Fi validation after reconnect" into main
This commit is contained in:
commit
056966f164
1 changed files with 23 additions and 14 deletions
|
|
@ -484,7 +484,10 @@ public class ConnectivityManagerTest {
|
|||
final TestableNetworkCallback callback =
|
||||
networkCallbackRule.registerDefaultNetworkCallback();
|
||||
assertNotNull("Couldn't restore Internet connectivity",
|
||||
callback.eventuallyExpect(CallbackEntry.AVAILABLE));
|
||||
callback.eventuallyExpect(CallbackEntry.NETWORK_CAPS_UPDATED,
|
||||
NETWORK_CALLBACK_TIMEOUT_MS,
|
||||
entry -> ((CallbackEntry.CapabilitiesChanged) entry)
|
||||
.getCaps().hasCapability(NET_CAPABILITY_VALIDATED)));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1172,6 +1175,7 @@ public class ConnectivityManagerTest {
|
|||
mCtsNetUtils.restorePrivateDnsSetting();
|
||||
// Toggle networks to make sure they are re-validated
|
||||
mCtsNetUtils.reconnectWifiIfSupported();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
mCtsNetUtils.reconnectCellIfSupported();
|
||||
}
|
||||
}
|
||||
|
|
@ -1418,7 +1422,7 @@ public class ConnectivityManagerTest {
|
|||
if (firstIntent != null) mCm.unregisterNetworkCallback(firstIntent);
|
||||
if (secondIntent != null) mCm.unregisterNetworkCallback(secondIntent);
|
||||
if (receiver != null) mContext.unregisterReceiver(receiver);
|
||||
mCtsNetUtils.ensureWifiConnected();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1516,6 +1520,7 @@ public class ConnectivityManagerTest {
|
|||
assumeTrue(mPackageManager.hasSystemFeature(FEATURE_WIFI));
|
||||
|
||||
mCtsNetUtils.reconnectWifiAndWaitForConnectivityAction();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
}
|
||||
|
||||
/** Verify restricted networks cannot be requested. */
|
||||
|
|
@ -2407,6 +2412,7 @@ public class ConnectivityManagerTest {
|
|||
// Restore the previous state of airplane mode and permissions:
|
||||
runShellCommand("cmd connectivity airplane-mode "
|
||||
+ (isAirplaneModeEnabled ? "enable" : "disable"));
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2836,7 +2842,7 @@ public class ConnectivityManagerTest {
|
|||
ConnectivitySettingsManager.setPrivateDnsMode(mContext, curPrivateDnsMode);
|
||||
tetherUtils.unregisterTetheringEventCallback(tetherEventCallback);
|
||||
tetherUtils.stopAllTethering();
|
||||
mCtsNetUtils.ensureWifiConnected();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3081,6 +3087,12 @@ public class ConnectivityManagerTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureWifiIsValidatedIfSupported() {
|
||||
if (mPackageManager.hasSystemFeature(FEATURE_WIFI)) {
|
||||
new ConnectUtil(mContext).ensureWifiValidated();
|
||||
}
|
||||
}
|
||||
|
||||
@AppModeFull(reason = "WRITE_DEVICE_CONFIG permission can't be granted to instant apps")
|
||||
@Test
|
||||
public void testAcceptPartialConnectivity_validatedNetwork() throws Exception {
|
||||
|
|
@ -3102,7 +3114,7 @@ public class ConnectivityManagerTest {
|
|||
expectNetworkHasCapability(network, NET_CAPABILITY_VALIDATED, WIFI_CONNECT_TIMEOUT_MS);
|
||||
} finally {
|
||||
mHttpServer.stop();
|
||||
mTestValidationConfigRule.runAfterNextCleanup(this::reconnectWifi);
|
||||
mTestValidationConfigRule.runAfterNextCleanup(this::reconnectWifiAndEnsureValidated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3132,7 +3144,7 @@ public class ConnectivityManagerTest {
|
|||
// apply here. Thus, turn off wifi first and restart to restore.
|
||||
mTestValidationConfigRule.runAfterNextCleanup(() -> {
|
||||
mCtsNetUtils.disableWifi();
|
||||
mCtsNetUtils.ensureWifiConnected();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3178,7 +3190,7 @@ public class ConnectivityManagerTest {
|
|||
// apply here. Thus, turn off wifi first and restart to restore.
|
||||
mTestValidationConfigRule.runAfterNextCleanup(() -> {
|
||||
mCtsNetUtils.disableWifi();
|
||||
mCtsNetUtils.ensureWifiConnected();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3242,7 +3254,7 @@ public class ConnectivityManagerTest {
|
|||
} finally {
|
||||
resetAvoidBadWifi(previousAvoidBadWifi);
|
||||
mHttpServer.stop();
|
||||
mTestValidationConfigRule.runAfterNextCleanup(this::reconnectWifi);
|
||||
mTestValidationConfigRule.runAfterNextCleanup(this::reconnectWifiAndEnsureValidated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3291,9 +3303,9 @@ public class ConnectivityManagerTest {
|
|||
mHttpServer.start();
|
||||
}
|
||||
|
||||
private Network reconnectWifi() {
|
||||
private Network reconnectWifiAndEnsureValidated() {
|
||||
mCtsNetUtils.ensureWifiDisconnected(null /* wifiNetworkToCheck */);
|
||||
return mCtsNetUtils.ensureWifiConnected();
|
||||
return new ConnectUtil(mContext).ensureWifiValidated();
|
||||
}
|
||||
|
||||
private Network prepareValidatedNetwork() throws Exception {
|
||||
|
|
@ -3307,10 +3319,7 @@ public class ConnectivityManagerTest {
|
|||
prepareHttpServer();
|
||||
configTestServer(Status.NO_CONTENT, Status.NO_CONTENT);
|
||||
// Disconnect wifi first then start wifi network with configuration.
|
||||
final Network wifiNetwork = reconnectWifi();
|
||||
|
||||
return expectNetworkHasCapability(wifiNetwork, NET_CAPABILITY_VALIDATED,
|
||||
WIFI_CONNECT_TIMEOUT_MS);
|
||||
return reconnectWifiAndEnsureValidated();
|
||||
}
|
||||
|
||||
private Network preparePartialConnectivity() throws Exception {
|
||||
|
|
@ -3387,7 +3396,7 @@ public class ConnectivityManagerTest {
|
|||
testAndCleanup(() -> {
|
||||
// New default network connected will trigger a network activity notification.
|
||||
if (supportWifi) {
|
||||
mCtsNetUtils.ensureWifiConnected();
|
||||
ensureWifiIsValidatedIfSupported();
|
||||
} else {
|
||||
networkCallbackRule.requestCell();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue