diff options
author | Roshan Pius <rpius@google.com> | 2020-05-29 22:12:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-05-29 22:12:46 +0000 |
commit | 47d386420fb3e3523f643f0d1e1fd3496c5f6aeb (patch) | |
tree | e99cec188d8b1fde599c80004b30d4f714346a71 /tests | |
parent | 6230ee509760f2351d5ec99547522e79de0c5f8a (diff) | |
parent | ec1025373054e637e3b0e4e25ecafb18a4086e29 (diff) |
Merge changes I88af4e2d,I85cc20bd into rvc-dev
* changes:
WifiNetworkFactory: Stop scanning once user selects a network
ConfigurationMap: Don't cache specifier ScanResultMatchInfo
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java | 19 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java | 47 |
2 files changed, 58 insertions, 8 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java index b433d94cf..02994ecad 100644 --- a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java @@ -333,4 +333,23 @@ public class ConfigurationMapTest extends WifiBaseTest { mConfigs.clear(); assertNull(mConfigs.getByScanResultForCurrentUser(scanResult)); } + + @Test + public void testScanResultDoesNotMatchForWifiNetworkSpecifier() { + // Add regular saved network, this should create a scan result match info cache entry. + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + ScanResult scanResult = createScanResultForNetwork(config); + config.networkId = 5; + mConfigs.put(config); + assertNotNull(mConfigs.getByScanResultForCurrentUser(scanResult)); + + mConfigs.clear(); + + // Create WifiNetworkSpecifier network, this should not create a scan result match info + // cache entry. + config.ephemeral = true; + config.fromWifiNetworkSpecifier = true; + mConfigs.put(config); + assertNull(mConfigs.getByScanResultForCurrentUser(scanResult)); + } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java index 25aaeffd6..5f9e0333e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java @@ -644,6 +644,35 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { } /** + * Verify the periodic scan back off to find a network matching the network specifier + * is cancelled when the user selects a network. + */ + @Test + public void testPeriodicScanCancelOnUserSelectNetwork() throws Exception { + attachDefaultWifiNetworkSpecifierAndAppInfo(TEST_UID_1, false); + mWifiNetworkFactory.needNetworkFor(mNetworkRequest, 0); + + mWifiNetworkFactory.addCallback(mAppBinder, mNetworkRequestMatchCallback, + TEST_CALLBACK_IDENTIFIER); + verify(mNetworkRequestMatchCallback).onUserSelectionCallbackRegistration( + mNetworkRequestUserSelectionCallback.capture()); + + verifyPeriodicScans(0, + PERIODIC_SCAN_INTERVAL_MS, // 10s + PERIODIC_SCAN_INTERVAL_MS); // 10s + + // Now trigger user selection to one of the network. + mSelectedNetwork = WifiConfigurationTestUtil.createPskNetwork(); + mSelectedNetwork.SSID = "\"" + TEST_SSID_1 + "\""; + sendUserSelectionSelect(mNetworkRequestUserSelectionCallback.getValue(), mSelectedNetwork); + mLooper.dispatchAll(); + + // Cancel the alarm set for the next scan. + verify(mAlarmManager).cancel(mPeriodicScanListenerArgumentCaptor.getValue()); + } + + + /** * Verify callback registration/unregistration. */ @Test @@ -1345,7 +1374,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { } mInOrder = inOrder(mAlarmManager, mClientModeImpl); - validateConnectionRetryAttempts(); + validateConnectionRetryAttempts(true); // Fail the request after all the retries are exhausted. verify(mNetworkRequestMatchCallback).onAbort(); @@ -1373,7 +1402,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { mLooper.dispatchAll(); mInOrder = inOrder(mAlarmManager, mClientModeImpl); - validateConnectionRetryAttempts(); + validateConnectionRetryAttempts(false); // Fail the request after all the retries are exhausted. verify(mNetworkRequestMatchCallback).onAbort(); @@ -1407,7 +1436,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { } mInOrder = inOrder(mAlarmManager, mClientModeImpl); - validateConnectionRetryAttempts(); + validateConnectionRetryAttempts(false); verify(mNetworkRequestMatchCallback).onAbort(); // Verify that we sent the connection failure callback. @@ -1453,7 +1482,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { } mInOrder = inOrder(mAlarmManager, mClientModeImpl); - validateConnectionRetryAttempts(); + validateConnectionRetryAttempts(false); // Verify that we sent the connection failure callback. verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure( @@ -2783,11 +2812,13 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { } } - private void validateConnectionRetryAttempts() { + private void validateConnectionRetryAttempts(boolean onTimeout) { for (int i = 0; i < WifiNetworkFactory.USER_SELECTED_NETWORK_CONNECT_RETRY_MAX; i++) { - // Cancel the existing connection timeout. - mInOrder.verify(mAlarmManager).cancel( - mConnectionTimeoutAlarmListenerArgumentCaptor.getValue()); + if (!onTimeout) { + // Cancel the existing connection timeout. + mInOrder.verify(mAlarmManager).cancel( + mConnectionTimeoutAlarmListenerArgumentCaptor.getValue()); + } // Trigger new connection. mInOrder.verify(mClientModeImpl).connect(eq(null), eq(TEST_NETWORK_ID_1), |