From 670ff07dc34640e5e455b649b49633f697f85df6 Mon Sep 17 00:00:00 2001 From: Ahmed ElArabawy Date: Wed, 22 Jan 2020 02:00:57 -0800 Subject: Perform partial initial scan with reduced channels This commit adds an optional feature to perform a fast initial scanning with a reduced number of channels from the connected channel history. The maximum number of channels in the reduced scan, and the maximum age for the history are configurable. Bug: 141893780 Test: atest com.android.server.wifi Change-Id: I93081524b9fee6db13cfc989533cf38f6d270874 --- .../android/server/wifi/WifiConfigManagerTest.java | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index b7d5c3a04..e1c5c1d6f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -2883,6 +2883,92 @@ public class WifiConfigManagerTest extends WifiBaseTest { } } + /** + * Verifies the creation of channel list using + * {@link WifiConfigManager#fetchChannelSetForPartialScan(long, int)}. + */ + @Test + public void testFetchChannelSetForPartialScan() { + WifiConfiguration network1 = WifiConfigurationTestUtil.createPskNetwork(); + NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(network1); + + // Set it to enabled. + verifyUpdateNetworkSelectionStatus( + result.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + + WifiConfiguration network2 = WifiConfigurationTestUtil.createOpenNetwork(); + result = verifyAddNetworkToWifiConfigManager(network2); + // Set it to enabled. + verifyUpdateNetworkSelectionStatus( + result.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + + // Create 3 scan results with different bssid's & frequencies to network1 + String test_bssid_base = "af:89:56:34:56:6"; + for (int i = 0; i < 3; i++) { + ScanDetail networkScanDetail = + createScanDetailForNetwork( + network1, test_bssid_base + Integer.toString(i), 0, TEST_FREQ_LIST[i]); + assertNotNull( + mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + networkScanDetail)); + } + + // Create 2 scan results with different bssid's & frequencies to network2 + for (int i = 3; i < TEST_FREQ_LIST.length; i++) { + ScanDetail networkScanDetail = + createScanDetailForNetwork( + network2, test_bssid_base + Integer.toString(i), 0, TEST_FREQ_LIST[i]); + assertNotNull( + mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + networkScanDetail)); + } + + assertEquals(new HashSet(Arrays.asList(TEST_FREQ_LIST)), + mWifiConfigManager.fetchChannelSetForPartialScan(100, 5)); + } + + /** + * Verify that the length of frequency set will not exceed the provided max value + */ + @Test + public void testFetchChannelSetForPartialScanMaxCount() { + WifiConfiguration network1 = WifiConfigurationTestUtil.createPskNetwork(); + NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(network1); + + // Set it to enabled. + verifyUpdateNetworkSelectionStatus( + result.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + + WifiConfiguration network2 = WifiConfigurationTestUtil.createOpenNetwork(); + result = verifyAddNetworkToWifiConfigManager(network2); + // Set it to enabled. + verifyUpdateNetworkSelectionStatus( + result.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + + // Create 3 scan results with different bssid's & frequencies to network1 + String test_bssid_base = "af:89:56:34:56:6"; + for (int i = 0; i < 3; i++) { + ScanDetail networkScanDetail = + createScanDetailForNetwork( + network1, test_bssid_base + Integer.toString(i), 0, TEST_FREQ_LIST[i]); + assertNotNull( + mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + networkScanDetail)); + } + + // Create 2 scan results with different bssid's & frequencies to network2 + for (int i = 3; i < TEST_FREQ_LIST.length; i++) { + ScanDetail networkScanDetail = + createScanDetailForNetwork( + network2, test_bssid_base + Integer.toString(i), 0, TEST_FREQ_LIST[i]); + assertNotNull( + mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache( + networkScanDetail)); + } + + assertEquals(3, mWifiConfigManager.fetchChannelSetForPartialScan(100, 3).size()); + } + /** * Verifies the creation of channel list using * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)}. -- cgit v1.2.3