WifiManagerTest: Use addNetwork + enableNetwork instead of save

WifiManager.save() is an asynchronous operation. This is sometime
causing the tests to be flaky (dropShellIdentity occurs while this is
being processed). Use the synchronous legacy API's instead for rewinding
the effects of factory reset.

Bug: 152048238
Test: atest android.net.wifi.cts.WifiManagerTest
Change-Id: Ibb0e04cf931511fcda1b1a81fd6eda4583196c2e
This commit is contained in:
Roshan Pius
2020-03-23 15:54:29 -07:00
parent 50e7f5ace4
commit 6b4a05b474

View File

@@ -2183,7 +2183,9 @@ public class WifiManagerTest extends AndroidTestCase {
// Restore the original saved networks.
if (savedNetworks != null) {
for (WifiConfiguration network : savedNetworks) {
mWifiManager.save(network, null);
network.networkId = WifiConfiguration.INVALID_NETWORK_ID;
int networkId = mWifiManager.addNetwork(network);
mWifiManager.enableNetwork(networkId, false);
}
}
uiAutomation.dropShellPermissionIdentity();