From f9b987b98584034239b217f4e2729ae71bddf18f Mon Sep 17 00:00:00 2001 From: Ahmed ElArabawy Date: Fri, 8 May 2020 12:37:55 -0700 Subject: Correct band frequency ranges Channel frequency ranges for the three bands (2.4G, 5G, and 6G) are used in different places with separate definitions or via literal numbers. Also, the values are not accurate and sometimes not consistent. This commit uses definitions and utility methods created in ScanResults. Bug: 153896822 Test: atest com.android.server.wifi Change-Id: I49551f71e54e6c96c799dd3786d441bcce7e2230 --- .../android/server/wifi/CandidateScorerTest.java | 2 +- .../com/android/server/wifi/ScoringParamsTest.java | 21 ++-- .../android/server/wifi/WakeupEvaluatorTest.java | 4 +- .../server/wifi/WifiConnectivityManagerTest.java | 6 +- .../server/wifi/WifiNetworkSelectorTest.java | 15 ++- .../wifi/scanner/KnownBandsChannelHelperTest.java | 92 +++++++------- .../wifi/scanner/ScanScheduleUtilFilterTest.java | 88 +++++++------- .../wifi/scanner/WifiScanningServiceTest.java | 132 ++++++++++----------- .../android/server/wifi/util/ApConfigUtilTest.java | 23 +--- 9 files changed, 185 insertions(+), 198 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java index 427a5b36c..7562da206 100644 --- a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java @@ -148,7 +148,7 @@ public class CandidateScorerTest extends WifiBaseTest { @Test public void testPrefer5GhzOver2GhzInNonFringeConditionsSimilarRssi() throws Exception { assertThat(evaluate(mCandidate1.setFrequency(5180).setScanRssi(-44)), - greaterThan(evaluate(mCandidate2.setFrequency(2024).setScanRssi(-44)))); + greaterThan(evaluate(mCandidate2.setFrequency(2432).setScanRssi(-44)))); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java index 3c07bce1c..bea0a1af6 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java @@ -24,6 +24,7 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; +import android.net.wifi.ScanResult; import android.net.wifi.WifiInfo; import androidx.test.filters.SmallTest; @@ -304,20 +305,20 @@ public class ScoringParamsTest extends WifiBaseTest { assertEquals(mBad2GHz, mScoringParams.getExitRssi(2412)); assertEquals(mEntry2GHz, mScoringParams.getEntryRssi(2480)); - assertEquals(mSufficient2GHz, mScoringParams.getSufficientRssi(2400)); - assertEquals(mGood2GHz, mScoringParams.getGoodRssi(2499)); - assertEquals(mGood2GHz, mScoringParams.getGoodRssi(ScoringParams.BAND2)); + assertEquals(mSufficient2GHz, mScoringParams.getSufficientRssi(2457)); + assertEquals(mGood2GHz, mScoringParams.getGoodRssi(2442)); + assertEquals(mGood2GHz, mScoringParams.getGoodRssi(ScanResult.BAND_24_GHZ_START_FREQ_MHZ)); - assertEquals(mBad5GHz, mScoringParams.getExitRssi(5000)); - assertEquals(mEntry5GHz, mScoringParams.getEntryRssi(5010)); - assertEquals(mSufficient5GHz, mScoringParams.getSufficientRssi(5100)); - assertEquals(mGood5GHz, mScoringParams.getGoodRssi(5678)); - assertEquals(mGood5GHz, mScoringParams.getGoodRssi(ScoringParams.BAND5)); + assertEquals(mBad5GHz, mScoringParams.getExitRssi(5200)); + assertEquals(mEntry5GHz, mScoringParams.getEntryRssi(5220)); + assertEquals(mSufficient5GHz, mScoringParams.getSufficientRssi(5300)); + assertEquals(mGood5GHz, mScoringParams.getGoodRssi(5745)); + assertEquals(mGood5GHz, mScoringParams.getGoodRssi(ScanResult.BAND_5_GHZ_START_FREQ_MHZ)); - assertEquals(mBad6GHz, mScoringParams.getExitRssi(5935)); + assertEquals(mBad6GHz, mScoringParams.getExitRssi(5965)); assertEquals(mEntry6GHz, mScoringParams.getEntryRssi(6095)); assertEquals(mSufficient6GHz, mScoringParams.getSufficientRssi(6255)); assertEquals(mGood6GHz, mScoringParams.getGoodRssi(6275)); - assertEquals(mGood6GHz, mScoringParams.getGoodRssi(ScoringParams.BAND6)); + assertEquals(mGood6GHz, mScoringParams.getGoodRssi(ScanResult.BAND_6_GHZ_START_FREQ_MHZ)); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WakeupEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/WakeupEvaluatorTest.java index fcbc7e2fd..bc28ce193 100644 --- a/tests/wifitests/src/com/android/server/wifi/WakeupEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WakeupEvaluatorTest.java @@ -46,8 +46,8 @@ public class WakeupEvaluatorTest extends WifiBaseTest { private static final String SAVED_SSID_2 = "saved ssid 2"; private static final String UNSAVED_SSID = "unsaved ssid"; - private static final int FREQ_24 = 2402; - private static final int FREQ_5 = 5000; + private static final int FREQ_24 = 2412; + private static final int FREQ_5 = 5200; private static final int THRESHOLD_24 = -100; private static final int THRESHOLD_5 = -90; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 093abfe50..cd9ef0243 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -2742,9 +2742,9 @@ public class WifiConnectivityManagerTest extends WifiBaseTest { scanSettingsCaptor.capture(), any(), any(), any()); assertEquals(scanSettingsCaptor.getValue().periodInMs, WifiConnectivityManager.STATIONARY_PNO_SCAN_INTERVAL_MS); - verify(mScoringParams, times(2)).getEntryRssi(ScoringParams.BAND6); - verify(mScoringParams, times(2)).getEntryRssi(ScoringParams.BAND5); - verify(mScoringParams, times(2)).getEntryRssi(ScoringParams.BAND2); + verify(mScoringParams, times(2)).getEntryRssi(ScanResult.BAND_6_GHZ_START_FREQ_MHZ); + verify(mScoringParams, times(2)).getEntryRssi(ScanResult.BAND_5_GHZ_START_FREQ_MHZ); + verify(mScoringParams, times(2)).getEntryRssi(ScanResult.BAND_24_GHZ_START_FREQ_MHZ); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index f8c47a2f6..0bd14a470 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -281,11 +281,14 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { } private void setupThresholds() { - mThresholdMinimumRssi2G = mScoringParams.getEntryRssi(ScoringParams.BAND2); - mThresholdMinimumRssi5G = mScoringParams.getEntryRssi(ScoringParams.BAND5); - - mThresholdQualifiedRssi2G = mScoringParams.getSufficientRssi(ScoringParams.BAND2); - mThresholdQualifiedRssi5G = mScoringParams.getSufficientRssi(ScoringParams.BAND5); + mThresholdMinimumRssi2G = mScoringParams.getEntryRssi( + ScanResult.BAND_24_GHZ_START_FREQ_MHZ); + mThresholdMinimumRssi5G = mScoringParams.getEntryRssi(ScanResult.BAND_5_GHZ_START_FREQ_MHZ); + + mThresholdQualifiedRssi2G = mScoringParams.getSufficientRssi( + ScanResult.BAND_24_GHZ_START_FREQ_MHZ); + mThresholdQualifiedRssi5G = mScoringParams.getSufficientRssi( + ScanResult.BAND_5_GHZ_START_FREQ_MHZ); } private void setupWifiInfo() { @@ -1591,4 +1594,4 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { WifiConfiguration wifiConfiguration = mWifiNetworkSelector.selectNetwork(candidates); assertNotNull(wifiConfiguration); } -} \ No newline at end of file +} diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/KnownBandsChannelHelperTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/KnownBandsChannelHelperTest.java index c19da30e2..3e7ad7166 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/KnownBandsChannelHelperTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/KnownBandsChannelHelperTest.java @@ -49,8 +49,8 @@ import java.util.HashSet; @RunWith(Enclosed.class) // WARNING: tests cannot be declared in the outer class public class KnownBandsChannelHelperTest { - private static final int[] CHANNELS_24_GHZ = new int[]{2400, 2450}; - private static final int[] CHANNELS_5_GHZ = new int[]{5150, 5175}; + private static final int[] CHANNELS_24_GHZ = new int[]{2412, 2450}; + private static final int[] CHANNELS_5_GHZ = new int[]{5160, 5175}; private static final int[] CHANNELS_DFS = new int[]{5600, 5650, 5660}; private static final int[] CHANNELS_DFS_OTHER = new int[]{5600, 5650, 5660, 5680}; private static final int[] CHANNELS_6_GHZ = new int[]{5945, 5985}; @@ -81,7 +81,7 @@ public class KnownBandsChannelHelperTest { */ @Test public void fewChannels() { - WifiScanner.ScanSettings testSettings = createRequest(channelsToSpec(2400, 2450, 5100), + WifiScanner.ScanSettings testSettings = createRequest(channelsToSpec(2412, 2450, 5200), 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); assertEquals(ChannelHelper.SCAN_PERIOD_PER_CHANNEL_MS * 3, @@ -221,8 +221,8 @@ public class KnownBandsChannelHelperTest { WifiScanner.ScanSettings testSettings = createRequest(channelsToSpec(), 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); - assertFalse(mChannelHelper.settingsContainChannel(testSettings, 2400)); - assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5150)); + assertFalse(mChannelHelper.settingsContainChannel(testSettings, 2412)); + assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5160)); assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5650)); } @@ -231,11 +231,11 @@ public class KnownBandsChannelHelperTest { */ @Test public void settingsWithChannels() { - WifiScanner.ScanSettings testSettings = createRequest(channelsToSpec(2400, 5650), + WifiScanner.ScanSettings testSettings = createRequest(channelsToSpec(2412, 5650), 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); - assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2400)); - assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5150)); + assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2412)); + assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5160)); assertTrue(mChannelHelper.settingsContainChannel(testSettings, 5650)); } @@ -247,9 +247,9 @@ public class KnownBandsChannelHelperTest { WifiScanner.ScanSettings testSettings = createRequest(WifiScanner.WIFI_BAND_24_GHZ, 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); - assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2400)); + assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2412)); assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2450)); - assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5150)); + assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5160)); assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5650)); } @@ -261,9 +261,9 @@ public class KnownBandsChannelHelperTest { WifiScanner.ScanSettings testSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); - assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2400)); + assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2412)); assertTrue(mChannelHelper.settingsContainChannel(testSettings, 2450)); - assertTrue(mChannelHelper.settingsContainChannel(testSettings, 5150)); + assertTrue(mChannelHelper.settingsContainChannel(testSettings, 5160)); assertFalse(mChannelHelper.settingsContainChannel(testSettings, 5650)); } } @@ -346,8 +346,8 @@ public class KnownBandsChannelHelperTest { mChannelCollection.getScanFreqs()); assertTrue(mChannelCollection.isEmpty()); - assertFalse(mChannelCollection.containsChannel(2400)); - assertFalse(mChannelCollection.containsChannel(5150)); + assertFalse(mChannelCollection.containsChannel(2412)); + assertFalse(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -367,8 +367,8 @@ public class KnownBandsChannelHelperTest { mChannelCollection.getScanFreqs()); assertTrue(mChannelCollection.isEmpty()); - assertFalse(mChannelCollection.containsChannel(2400)); - assertFalse(mChannelCollection.containsChannel(5150)); + assertFalse(mChannelCollection.containsChannel(2412)); + assertFalse(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -383,12 +383,12 @@ public class KnownBandsChannelHelperTest { mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); assertThat(bucketSettings, bandIs(WifiScanner.WIFI_BAND_24_GHZ)); - assertEquals(new HashSet(Arrays.asList(2400, 2450)), + assertEquals(new HashSet(Arrays.asList(2412, 2450)), mChannelCollection.getScanFreqs()); assertFalse(mChannelCollection.isEmpty()); - assertTrue(mChannelCollection.containsChannel(2400)); - assertFalse(mChannelCollection.containsChannel(5150)); + assertTrue(mChannelCollection.containsChannel(2412)); + assertFalse(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -397,18 +397,18 @@ public class KnownBandsChannelHelperTest { */ @Test public void addChannel_single() { - mChannelCollection.addChannel(2400); + mChannelCollection.addChannel(2412); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); - assertThat(bucketSettings, channelsAre(2400)); + assertThat(bucketSettings, channelsAre(2412)); - assertEquals(new HashSet(Arrays.asList(2400)), + assertEquals(new HashSet(Arrays.asList(2412)), mChannelCollection.getScanFreqs()); assertFalse(mChannelCollection.isEmpty()); - assertTrue(mChannelCollection.containsChannel(2400)); - assertFalse(mChannelCollection.containsChannel(5150)); + assertTrue(mChannelCollection.containsChannel(2412)); + assertFalse(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -417,19 +417,19 @@ public class KnownBandsChannelHelperTest { */ @Test public void addChannel_multiple() { - mChannelCollection.addChannel(2400); + mChannelCollection.addChannel(2412); mChannelCollection.addChannel(2450); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); - assertThat(bucketSettings, channelsAre(2400, 2450)); + assertThat(bucketSettings, channelsAre(2412, 2450)); - assertEquals(new HashSet(Arrays.asList(2400, 2450)), + assertEquals(new HashSet(Arrays.asList(2412, 2450)), mChannelCollection.getScanFreqs()); assertFalse(mChannelCollection.isEmpty()); - assertTrue(mChannelCollection.containsChannel(2400)); - assertFalse(mChannelCollection.containsChannel(5150)); + assertTrue(mChannelCollection.containsChannel(2412)); + assertFalse(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -439,18 +439,18 @@ public class KnownBandsChannelHelperTest { @Test public void addChannel_and_addBand_sameBand() { mChannelCollection.addBand(WifiScanner.WIFI_BAND_24_GHZ); - mChannelCollection.addChannel(2400); + mChannelCollection.addChannel(2412); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); assertThat(bucketSettings, bandIs(WifiScanner.WIFI_BAND_24_GHZ)); - assertEquals(new HashSet(Arrays.asList(2400, 2450)), + assertEquals(new HashSet(Arrays.asList(2412, 2450)), mChannelCollection.getScanFreqs()); assertFalse(mChannelCollection.isEmpty()); - assertTrue(mChannelCollection.containsChannel(2400)); - assertFalse(mChannelCollection.containsChannel(5150)); + assertTrue(mChannelCollection.containsChannel(2412)); + assertFalse(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -460,18 +460,18 @@ public class KnownBandsChannelHelperTest { @Test public void addChannel_and_addBand_withDifferentBandChannel() { mChannelCollection.addBand(WifiScanner.WIFI_BAND_24_GHZ); - mChannelCollection.addChannel(5150); + mChannelCollection.addChannel(5160); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); - assertThat(bucketSettings, channelsAre(2400, 2450, 5150)); + assertThat(bucketSettings, channelsAre(2412, 2450, 5160)); - assertEquals(new HashSet(Arrays.asList(2400, 2450, 5150)), + assertEquals(new HashSet(Arrays.asList(2412, 2450, 5160)), mChannelCollection.getScanFreqs()); assertFalse(mChannelCollection.isEmpty()); - assertTrue(mChannelCollection.containsChannel(2400)); - assertTrue(mChannelCollection.containsChannel(5150)); + assertTrue(mChannelCollection.containsChannel(2412)); + assertTrue(mChannelCollection.containsChannel(5160)); assertFalse(mChannelCollection.isAllChannels()); } @@ -481,7 +481,7 @@ public class KnownBandsChannelHelperTest { @Test public void addChannel_and_addBand_all() { mChannelCollection.addBand(WifiScanner.WIFI_BAND_24_5_WITH_DFS_6_GHZ); - mChannelCollection.addChannel(5150); + mChannelCollection.addChannel(5160); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); @@ -490,8 +490,8 @@ public class KnownBandsChannelHelperTest { assertNull(mChannelCollection.getScanFreqs()); assertFalse(mChannelCollection.isEmpty()); - assertTrue(mChannelCollection.containsChannel(2400)); - assertTrue(mChannelCollection.containsChannel(5150)); + assertTrue(mChannelCollection.containsChannel(2412)); + assertTrue(mChannelCollection.containsChannel(5160)); assertTrue(mChannelCollection.containsChannel(5600)); assertTrue(mChannelCollection.isAllChannels()); } @@ -516,9 +516,9 @@ public class KnownBandsChannelHelperTest { */ @Test public void addChannel_exceedMaxChannelsOnMultipleBands() { - mChannelCollection.addChannel(2400); + mChannelCollection.addChannel(2412); mChannelCollection.addChannel(2450); - mChannelCollection.addChannel(5150); + mChannelCollection.addChannel(5160); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, 2); @@ -532,9 +532,9 @@ public class KnownBandsChannelHelperTest { */ @Test public void addChannel_addAllAvailableChannels() { - mChannelCollection.addChannel(2400); + mChannelCollection.addChannel(2412); mChannelCollection.addChannel(2450); - mChannelCollection.addChannel(5150); + mChannelCollection.addChannel(5160); mChannelCollection.addChannel(5175); mChannelCollection.addChannel(5600); mChannelCollection.addChannel(5650); @@ -545,7 +545,7 @@ public class KnownBandsChannelHelperTest { WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); assertThat(bucketSettings, - channelsAre(2400, 2450, 5150, 5175, 5600, 5650, 5660, 5945, 5985)); + channelsAre(2412, 2450, 5160, 5175, 5600, 5650, 5660, 5945, 5985)); assertTrue(mChannelCollection.isAllChannels()); } } diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/ScanScheduleUtilFilterTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/ScanScheduleUtilFilterTest.java index 69a8c0ce1..429da3f7f 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/ScanScheduleUtilFilterTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/ScanScheduleUtilFilterTest.java @@ -50,8 +50,8 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Before public void setUp() throws Exception { mChannelHelper = new PresetKnownBandsChannelHelper( - new int[]{2400, 2450}, - new int[]{5150, 5175}, + new int[]{2412, 2450}, + new int[]{5160, 5175}, new int[]{5600, 5650}, new int[]{5945, 5985}); } @@ -64,7 +64,7 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { ); assertTrue(ScanScheduleUtil.shouldReportFullScanResultForSettings(mChannelHelper, - createScanResult(2400), 0, settings, -1)); + createScanResult(2412), 0, settings, -1)); } @Test @@ -75,24 +75,24 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { ); assertFalse(ScanScheduleUtil.shouldReportFullScanResultForSettings(mChannelHelper, - createScanResult(5150), 0, settings, 0)); + createScanResult(5160), 0, settings, 0)); } @Test public void reportFullResultTrueForChannelsWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); assertTrue(ScanScheduleUtil.shouldReportFullScanResultForSettings(mChannelHelper, - createScanResult(2400), 0, settings, 0)); + createScanResult(2412), 0, settings, 0)); } @Test public void reportFullResultFalseForChannelsWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -103,29 +103,29 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void reportFullResultTrueForChannelsWithBucketDefinitlyScanned() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); assertTrue(ScanScheduleUtil.shouldReportFullScanResultForSettings(mChannelHelper, - createScanResult(2400), 5, settings, 2)); + createScanResult(2412), 5, settings, 2)); } @Test public void reportFullResultFalseForChannelsWithBucketDefinitlyNotScanned() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); assertFalse(ScanScheduleUtil.shouldReportFullScanResultForSettings(mChannelHelper, - createScanResult(2400), 1, settings, 1)); + createScanResult(2412), 1, settings, 1)); } @Test public void filterScanDataEmptyWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -137,7 +137,7 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataSingleNotMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -149,7 +149,7 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataSingleNotMatchingWithDefinitlyScannedBucketIndex() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -161,7 +161,7 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataSingleNotMatchingWithBucketDefinitlyScanned() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -173,25 +173,25 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataSingleMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, - createScanDatas(new int[][]{ { 2400 } }), settings, 0); + createScanDatas(new int[][]{ { 2412 } }), settings, 0); - assertScanDataFreqsEquals(new int[][]{ { 2400 } }, results); + assertScanDataFreqsEquals(new int[][]{ { 2412 } }, results); } @Test public void filterScanDataSingleMatchingWithBucketDefinitlyNotScanned() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, - createScanDatas(new int[][]{ { 2400 } }, new int[] { 5 }), settings, 1); + createScanDatas(new int[][]{ { 2412 } }, new int[] { 5 }), settings, 1); assertScanDataFreqsEquals(null, results); } @@ -199,20 +199,20 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataSinglePartialMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, - createScanDatas(new int[][]{ { 2400, 2450, 5150, 5175 } }), settings, 0); + createScanDatas(new int[][]{ { 2412, 2450, 5160, 5175 } }), settings, 0); - assertScanDataFreqsEquals(new int[][]{ { 2400, 5150 } }, results); + assertScanDataFreqsEquals(new int[][]{ { 2412, 5160 } }, results); } @Test public void filterScanDataMultipleNotMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -224,7 +224,7 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataMultipleNotMatchingWithOneDefinitlyScanned() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); @@ -237,76 +237,76 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { @Test public void filterScanDataMultipleMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, - createScanDatas(new int[][]{ { 2400 }, {2400, 5150} }), settings, 0); + createScanDatas(new int[][]{ { 2412 }, {2412, 5160} }), settings, 0); - assertScanDataFreqsEquals(new int[][]{ { 2400 }, {2400, 5150} }, results); + assertScanDataFreqsEquals(new int[][]{ { 2412 }, {2412, 5160} }, results); } @Test public void filterScanDataMultiplePartialMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, - createScanDatas(new int[][]{ { 2400, 2450, 5150, 5175 }, { 2400, 2450, 5175 } }), + createScanDatas(new int[][]{ { 2412, 2450, 5160, 5175 }, { 2412, 2450, 5175 } }), settings, -1); - assertScanDataFreqsEquals(new int[][]{ { 2400, 5150 }, { 2400 } }, results); + assertScanDataFreqsEquals(new int[][]{ { 2412, 5160 }, { 2412 } }, results); } @Test public void filterScanDataMultipleDuplicateFrequenciesWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, createScanDatas(new int[][]{ - { 2400, 2450, 5150, 5175, 2400 }, - { 2400, 2450, 5175 }, - { 5175, 5175, 5150 } }), settings, 0); + { 2412, 2450, 5160, 5175, 2412 }, + { 2412, 2450, 5175 }, + { 5175, 5175, 5160 } }), settings, 0); - assertScanDataFreqsEquals(new int[][]{ { 2400, 5150, 2400 }, { 2400 }, { 5150 } }, results); + assertScanDataFreqsEquals(new int[][]{ { 2412, 5160, 2412 }, { 2412 }, { 5160 } }, results); } @Test public void filterScanDataMultipleSomeNotMatchingWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 20, + channelsToSpec(2412, 5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, createScanDatas(new int[][]{ - { 2400, 2450, 5150, 5175, 2400 }, + { 2412, 2450, 5160, 5175, 2412 }, { 5175 }, - { 5175, 5175, 5150 } }), settings, 0); + { 5175, 5175, 5160 } }), settings, 0); - assertScanDataFreqsEquals(new int[][]{ { 2400, 5150, 2400 }, { 5150 } }, results); + assertScanDataFreqsEquals(new int[][]{ { 2412, 5160, 2412 }, { 5160 } }, results); } @Test public void filterScanDataExceedMaxBssidsPerScanWithNoBucketInfo() { ScanSettings settings = createRequest( - channelsToSpec(2400, 5150), 30000, 0, 3, + channelsToSpec(2412, 5160), 30000, 0, 3, WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT ); ScanData[] results = ScanScheduleUtil.filterResultsForSettings(mChannelHelper, createScanDatas(new int[][]{ - { 2400, 2450, 5150, 5175, 2400, 2400}, + { 2412, 2450, 5160, 5175, 2412, 2412}, { 5175 }, - { 5175, 5175, 5150, 2400, 2400, 5150 } }), settings, 0); + { 5175, 5175, 5160, 2412, 2412, 5160 } }), settings, 0); - assertScanDataFreqsEquals(new int[][]{ { 2400, 5150, 2400 }, { 5150, 2400, 2400 } }, + assertScanDataFreqsEquals(new int[][]{ { 2412, 5160, 2412 }, { 5160, 2412, 2412 } }, results); } diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java index bf70af312..bccf6b49a 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java @@ -160,13 +160,13 @@ public class WifiScanningServiceTest extends WifiBaseTest { .thenReturn(mWifiPermissionsUtil); mChannelHelper0 = new PresetKnownBandsChannelHelper( - new int[]{2400, 2450}, - new int[]{5150, 5175}, + new int[]{2412, 2450}, + new int[]{5160, 5175}, new int[]{5600, 5650, 5660}, new int[]{5945, 5985}); mChannelHelper1 = new PresetKnownBandsChannelHelper( - new int[]{2400, 2450}, - new int[]{5150, 5175}, + new int[]{2412, 2450}, + new int[]{5160, 5175}, new int[]{5600, 5660, 5680}, // 5650 is missing from channelHelper0 new int[]{5945, 5985}); mLooper = new TestLooper(); @@ -701,7 +701,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2400, 5150, 5175)); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2412, 5160, 5175)); } /** @@ -709,10 +709,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendSingleScanChannelsRequest() throws Exception { - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400, 5150, 5175), + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2412, 5160, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400, 5150, 5175)); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412, 5160, 5175)); } /** @@ -721,10 +721,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { @Test public void sendSingleScanAllChannelsRequest() throws Exception { WifiScanner.ScanSettings requestSettings = createRequest( - channelsToSpec(2400, 2450, 5150, 5175, 5600, 5650, 5660), + channelsToSpec(2412, 2450, 5160, 5175, 5600, 5650, 5660), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400, 5150, 5175)); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412, 5160, 5175)); } /** @@ -749,7 +749,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { // Create a set of scan results that has results not matching the request settings, but is // limited to zero results for the expected results. ScanResults results = ScanResults.createOverflowing(0, WifiScanner.WIFI_BAND_24_GHZ, 0, - ScanResults.generateNativeResults(0, 5150, 5171)); + ScanResults.generateNativeResults(0, 5160, 5171)); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), results); } @@ -910,10 +910,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { when(mContext.checkPermission( Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid())) .thenReturn(PERMISSION_DENIED); - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400, 5150, 5175), + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2412, 5160, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), - ScanResults.create(0, 2400, 5150, 5175)); + ScanResults.create(0, 2412, 5160, 5175)); } /** @@ -1066,7 +1066,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendSingleScanRequestThenDisableWifi() { - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); int requestId = 2293; @@ -1100,9 +1100,9 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendSingleScanRequestThenDisableWifiAfterScanCompleteButBeforeReportingResults() { - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); - ScanResults results = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); int requestId = 2293; startServiceAndLoadDriver(); @@ -1141,7 +1141,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendSingleScanAndPendingScanAndListenerThenDisableWifi() { - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); int requestId1 = 2293; @@ -1196,10 +1196,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendSingleScanRequestAfterPreviousCompletes() { - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); int requestId1 = 12; - ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2450, 5175), 0, @@ -1265,10 +1265,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendSingleScanRequestWhilePreviousScanRunning() { - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); int requestId1 = 12; - ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2450, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); @@ -1334,17 +1334,17 @@ public class WifiScanningServiceTest extends WifiBaseTest { @Test public void sendSingleScanRequestWhilePreviousScanRunningWithTypesThatDoesNotSatisfy() { // Create identitical scan requests other than the types being different. - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); requestSettings1.type = WifiScanner.SCAN_TYPE_LOW_LATENCY; int requestId1 = 12; - ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); - WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); requestSettings2.type = WifiScanner.SCAN_TYPE_HIGH_ACCURACY; int requestId2 = 13; - ScanResults results2 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results2 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); startServiceAndLoadDriver(); mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog); @@ -1403,12 +1403,12 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendMultipleSingleScanRequestWhilePreviousScanRunning() throws RemoteException { - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); requestSettings1.type = WifiScanner.SCAN_TYPE_LOW_LATENCY; int requestId1 = 12; WorkSource workSource1 = new WorkSource(1121); - ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2450, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); @@ -1418,7 +1418,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { ScanResults results2 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2450, 5175, 2450); - WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(5150), 0, + WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(5160), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); requestSettings3.type = WifiScanner.SCAN_TYPE_LOW_POWER; int requestId3 = 15; @@ -1427,11 +1427,11 @@ public class WifiScanningServiceTest extends WifiBaseTest { workSource3.createWorkChain() .addNode(2292, "tag1"); ScanResults results3 = - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 5150, 5150, 5150, 5150); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 5160, 5160, 5160, 5160); WifiNative.ScanSettings nativeSettings2and3 = createSingleScanNativeSettingsForChannels( WifiScanner.SCAN_TYPE_HIGH_ACCURACY, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, - channelsToSpec(2450, 5175, 5150)); + channelsToSpec(2450, 5175, 5160)); ScanResults results2and3 = ScanResults.merge(WifiScanner.WIFI_BAND_UNSPECIFIED, results2, results3); WorkSource workSource2and3 = new WorkSource(); @@ -1521,9 +1521,9 @@ public class WifiScanningServiceTest extends WifiBaseTest { public void sendSingleScanRequestWhilePreviousScanRunningAndMergeIntoFirstScan() { // Split by frequency to make it easier to determine which results each request is expecting ScanResults results24GHz = - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2400, 2400, 2400, 2450); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2412, 2412, 2412, 2450); ScanResults results5GHz = - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 5150, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 5160, 5160, 5175); ScanResults resultsBoth = ScanResults.merge(WifiScanner.WIFI_BAND_BOTH, results24GHz, results5GHz); @@ -1588,13 +1588,13 @@ public class WifiScanningServiceTest extends WifiBaseTest { public void sendMultipleSingleScanRequestWhilePreviousScanRunningAndMergeOneIntoFirstScan() throws RemoteException { // Split by frequency to make it easier to determine which results each request is expecting - ScanResults results2400 = - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400, 2400, 2400); + ScanResults results2412 = + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412, 2412, 2412); ScanResults results2450 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2450); ScanResults results1and3 = - ScanResults.merge(WifiScanner.WIFI_BAND_UNSPECIFIED, results2400, results2450); + ScanResults.merge(WifiScanner.WIFI_BAND_UNSPECIFIED, results2412, results2450); - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400, 2450), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412, 2450), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); requestSettings1.type = WifiScanner.SCAN_TYPE_LOW_LATENCY; int requestId1 = 12; @@ -1608,12 +1608,12 @@ public class WifiScanningServiceTest extends WifiBaseTest { WorkSource workSource2 = new WorkSource(Binder.getCallingUid()); // don't explicitly set ScanResults results2 = ScanResults.create(0, 2450, 5175, 2450); - WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); requestSettings3.type = WifiScanner.SCAN_TYPE_LOW_POWER; int requestId3 = 15; WorkSource workSource3 = new WorkSource(2292); - ScanResults results3 = results2400; + ScanResults results3 = results2412; startServiceAndLoadDriver(); mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog); @@ -1697,7 +1697,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { createRequest(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults expectedResults = - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2400, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2412, 5160, 5175); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), expectedResults); @@ -1775,7 +1775,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults expectedResults = ScanResults.create( - 0, WifiScanner.WIFI_BAND_BOTH, 2400, 5150, 5175); + 0, WifiScanner.WIFI_BAND_BOTH, 2412, 5160, 5175); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), expectedResults); @@ -1795,7 +1795,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { // now update with a new scan that only has one result int secondScanRequestId = 35; - ScanResults expectedSingleResult = ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 5150); + ScanResults expectedSingleResult = ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 5160); sendSingleScanRequest(controlChannel, secondScanRequestId, requestSettings, null); mLooper.dispatchAll(); @@ -1832,7 +1832,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings fullRequestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults expectedFullResults = - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2400, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2412, 5160, 5175); doSuccessfulSingleScan(fullRequestSettings, computeSingleScanNativeSettings(fullRequestSettings), expectedFullResults); @@ -1855,7 +1855,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings partialRequestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults expectedPartialResults = - ScanResults.create(0, WifiScanner.WIFI_BAND_5_GHZ, 5150); + ScanResults.create(0, WifiScanner.WIFI_BAND_5_GHZ, 5160); sendSingleScanRequest(controlChannel, secondScanRequestId, partialRequestSettings, null); mLooper.dispatchAll(); @@ -1893,7 +1893,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults scanResults = - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2400, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2412, 5160, 5175); // Out of the 3 scan results, modify the timestamp of 2 of them to be within the expiration // age and 1 out of it. @@ -1935,7 +1935,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { createRequest(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults expectedResults = ScanResults.create( - 0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2400, 5150, 5175); + 0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2412, 5160, 5175); doSuccessfulSingleScan(requestSettings, computeSingleScanNativeSettings(requestSettings), expectedResults); @@ -1972,7 +1972,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); WifiNative.ScanSettings nativeSettings = computeSingleScanNativeSettings(requestSettings); - ScanResults results = ScanResults.create(0, 2400, 5150, 5175); + ScanResults results = ScanResults.create(0, 2412, 5160, 5175); int requestId = 12; int listenerRequestId = 13; @@ -2020,7 +2020,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); WifiNative.ScanSettings nativeSettings = computeSingleScanNativeSettings(requestSettings); - ScanResults results = ScanResults.create(0, 2400, 5150, 5175); + ScanResults results = ScanResults.create(0, 2412, 5160, 5175); int requestId = 12; int listenerRequestId = 13; @@ -2067,10 +2067,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void scanListenerReceivesAllResults() throws RemoteException { - WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0, + WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2412), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); int requestId1 = 12; - ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400); + ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412); WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2450, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); @@ -2078,14 +2078,14 @@ public class WifiScanningServiceTest extends WifiBaseTest { ScanResults results2 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2450, 5175, 2450); - WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(5150), 0, + WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(5160), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); int requestId3 = 15; ScanResults results3 = - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 5150, 5150, 5150, 5150); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 5160, 5160, 5160, 5160); WifiNative.ScanSettings nativeSettings2and3 = createSingleScanNativeSettingsForChannels( - WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, channelsToSpec(2450, 5175, 5150)); + WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, channelsToSpec(2450, 5175, 5160)); ScanResults results2and3 = ScanResults.merge(WifiScanner.WIFI_BAND_UNSPECIFIED, results2, results3); @@ -2233,13 +2233,13 @@ public class WifiScanningServiceTest extends WifiBaseTest { */ @Test public void sendBackgroundScanChannelsRequest() throws Exception { - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(5150), 30000, + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(5160), 30000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); WifiNative.ScanSettings nativeSettings = new NativeScanSettingsBuilder() .withBasePeriod(30000) .withMaxApPerScan(MAX_AP_PER_SCAN) .withMaxScansToCache(BackgroundScanScheduler.DEFAULT_MAX_SCANS_TO_BATCH) - .addBucketWithChannels(30000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, 5150) + .addBucketWithChannels(30000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, 5160) .build(); doSuccessfulBackgroundScan(requestSettings, nativeSettings); } @@ -2247,14 +2247,14 @@ public class WifiScanningServiceTest extends WifiBaseTest { private Pair createScanSettingsForHwPno() throws Exception { WifiScanner.ScanSettings requestSettings = createRequest( - channelsToSpec(0, 2400, 5150, 5175), 30000, 0, 20, + channelsToSpec(0, 2412, 5160, 5175), 30000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); WifiNative.ScanSettings nativeSettings = new NativeScanSettingsBuilder() .withBasePeriod(30000) .withMaxApPerScan(MAX_AP_PER_SCAN) .withMaxScansToCache(BackgroundScanScheduler.DEFAULT_MAX_SCANS_TO_BATCH) .addBucketWithChannels(30000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, - 0, 2400, 5150, 5175) + 0, 2412, 5160, 5175) .build(); return Pair.create(requestSettings, nativeSettings); } @@ -2289,7 +2289,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { } private ScanResults createScanResultsForPno() { - return ScanResults.create(0, 2400, 5150, 5175); + return ScanResults.create(0, 2412, 5160, 5175); } private WifiNative.PnoEventHandler verifyHwPnoForImpl(WifiScannerImpl impl, InOrder order, @@ -2484,7 +2484,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { when(mWifiScannerImpl0.startSingleScan(any(WifiNative.ScanSettings.class), any(WifiNative.ScanEventHandler.class))).thenReturn(true); - ScanResults results = ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2400); + ScanResults results = ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH, 2412); when(mWifiScannerImpl0.getLatestSingleScanResults()) .thenReturn(results.getRawScanData()); @@ -2566,10 +2566,10 @@ public class WifiScanningServiceTest extends WifiBaseTest { int requestId = 12; WorkSource workSource = new WorkSource(2292); - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400, 5150, 5175), + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2412, 5160, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); ScanResults results = - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412, 5160, 5175); when(mWifiScannerImpl0.startSingleScan(any(WifiNative.ScanSettings.class), any(WifiNative.ScanEventHandler.class))).thenReturn(true); @@ -3032,8 +3032,8 @@ public class WifiScanningServiceTest extends WifiBaseTest { WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); doSuccessfulSingleScanOnImpls(requestSettings, computeSingleScanNativeSettings(requestSettings), - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2400), - ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 5150)); + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 2412), + ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 5160)); } /** @@ -3044,11 +3044,11 @@ public class WifiScanningServiceTest extends WifiBaseTest { public void sendSingleScanChannelsRequestOnMultipleImpls() throws Exception { when(mWifiNative.getClientInterfaceNames()) .thenReturn(new ArraySet<>(Arrays.asList(TEST_IFACE_NAME_0, TEST_IFACE_NAME_1))); - WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400, 5150, 5175), + WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2412, 5160, 5175), 0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); doSuccessfulSingleScanOnImpls(requestSettings, computeSingleScanNativeSettings(requestSettings), - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400), + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412), ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 5175)); } @@ -3123,7 +3123,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); WifiNative.ScanSettings nativeSettings = computeSingleScanNativeSettings(requestSettings); ScanResults results = - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412, 5160, 5175); int requestId = 33; WorkSource workSource = new WorkSource(2292); @@ -3235,7 +3235,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); WifiNative.ScanSettings nativeSettings = computeSingleScanNativeSettings(requestSettings); ScanResults results = - ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400, 5150, 5175); + ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2412, 5160, 5175); int requestId = 33; WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set @@ -3534,7 +3534,7 @@ public class WifiScanningServiceTest extends WifiBaseTest { mLooper.stopAutoDispatchAndIgnoreExceptions(); List actual = bundle.getIntegerArrayList(GET_AVAILABLE_CHANNELS_EXTRA); - List expected = Arrays.asList(2400, 2450); + List expected = Arrays.asList(2412, 2450); assertEquals(expected, actual); } diff --git a/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java index 7ec492256..16c915729 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; import android.net.MacAddress; +import android.net.wifi.ScanResult; import android.net.wifi.SoftApCapability; import android.net.wifi.SoftApConfiguration; import android.net.wifi.SoftApConfiguration.Builder; @@ -220,25 +221,6 @@ public class ApConfigUtilTest extends WifiBaseTest { | SoftApConfiguration.BAND_6GHZ | 0x0F)); } - /** - * verify frequency to channel conversion for all possible frequencies. - */ - @Test - public void convertFrequencyToChannel() throws Exception { - for (int i = 0; i < FREQUENCY_TO_CHANNEL_MAP.length; i += 3) { - assertEquals(FREQUENCY_TO_CHANNEL_MAP[i + 2], - ApConfigUtil.convertFrequencyToChannel(FREQUENCY_TO_CHANNEL_MAP[i])); - } - } - - /** - * Verify frequency to channel conversion failed for an invalid frequency. - */ - @Test - public void convertFrequencyToChannelWithInvalidFreq() throws Exception { - assertEquals(-1, ApConfigUtil.convertFrequencyToChannel(8000)); - } - /** * verify frequency to band conversion for all possible frequencies. */ @@ -295,7 +277,8 @@ public class ApConfigUtilTest extends WifiBaseTest { .thenReturn(allowed2gChannels); int freq = ApConfigUtil.chooseApChannel(SoftApConfiguration.BAND_2GHZ, mWifiNative, mResources); - assertEquals(ApConfigUtil.DEFAULT_AP_CHANNEL, ApConfigUtil.convertFrequencyToChannel(freq)); + assertEquals(ApConfigUtil.DEFAULT_AP_CHANNEL, + ScanResult.convertFrequencyMhzToChannel(freq)); } /** -- cgit v1.2.3