diff options
author | Ahmed ElArabawy <arabawy@google.com> | 2019-11-07 10:10:37 -0800 |
---|---|---|
committer | Ahmed ElArabawy <arabawy@google.com> | 2019-12-04 12:42:19 -0800 |
commit | c5072a9043c83b8638cd66a7e0022a44efc75188 (patch) | |
tree | 43403f342741bbf29e187354ade842b163661189 | |
parent | 9a090f9497b92cceece5ed493644855d6348fc0b (diff) |
Support 6GHz band for getAvailableChannels() API
This commit adds the support of 6GHz band in the system API
getAvailableChannels().
Bug: 139354972
Test: atest com.android.wifi.server
Change-Id: I69276a4783c3b20bcaa06d0c8cb273c653bb5527
15 files changed, 86 insertions, 31 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 75eac1e06..4758b9865 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1370,14 +1370,15 @@ public class WifiNative { * The result depends on the on the country code that has been set. * * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants. - * The following bands are supported: + * The following bands are supported {@link WifiBandBasic}: * WifiScanner.WIFI_BAND_24_GHZ * WifiScanner.WIFI_BAND_5_GHZ * WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY + * WifiScanner.WIFI_BAND_6_GHZ * @return frequencies vector of valid frequencies (MHz), or null for error. * @throws IllegalArgumentException if band is not recognized. */ - public int [] getChannelsForBand(int band) { + public int [] getChannelsForBand(@WifiScanner.WifiBandBasic int band) { return mWificondControl.getChannelsForBand(band); } diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java index 36a227775..4952eccb3 100644 --- a/service/java/com/android/server/wifi/WificondControl.java +++ b/service/java/com/android/server/wifi/WificondControl.java @@ -816,14 +816,15 @@ public class WificondControl implements IBinder.DeathRecipient { * The result depends on the on the country code that has been set. * * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants. - * The following bands are supported: + * The following bands are supported {@link WifiBandBasic}: * WifiScanner.WIFI_BAND_24_GHZ * WifiScanner.WIFI_BAND_5_GHZ * WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY + * WifiScanner.WIFI_BAND_6_GHZ * @return frequencies vector of valid frequencies (MHz), or null for error. * @throws IllegalArgumentException if band is not recognized. */ - public int [] getChannelsForBand(int band) { + public int [] getChannelsForBand(@WifiScanner.WifiBandBasic int band) { if (mWificond == null) { Log.e(TAG, "No valid wificond scanner interface handler"); return null; @@ -836,6 +837,8 @@ public class WificondControl implements IBinder.DeathRecipient { return mWificond.getAvailable5gNonDFSChannels(); case WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY: return mWificond.getAvailableDFSChannels(); + case WifiScanner.WIFI_BAND_6_GHZ: + return mWificond.getAvailable6gChannels(); default: throw new IllegalArgumentException("unsupported band " + band); } diff --git a/service/java/com/android/server/wifi/scanner/ChannelHelper.java b/service/java/com/android/server/wifi/scanner/ChannelHelper.java index 7aeb7d2d3..a7e50a67c 100644 --- a/service/java/com/android/server/wifi/scanner/ChannelHelper.java +++ b/service/java/com/android/server/wifi/scanner/ChannelHelper.java @@ -335,6 +335,11 @@ public abstract class ChannelHelper { } band &= ~WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS; + if ((band & WifiScanner.WIFI_BAND_6_GHZ) != 0) { + sj.add("6Ghz"); + } + band &= ~WifiScanner.WIFI_BAND_6_GHZ; + if (band != 0) { return "Invalid band"; } diff --git a/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java b/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java index 6708a1942..707b64b94 100644 --- a/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java +++ b/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java @@ -19,10 +19,12 @@ package com.android.server.wifi.scanner; import static android.net.wifi.WifiScanner.WIFI_BAND_24_GHZ; import static android.net.wifi.WifiScanner.WIFI_BAND_5_GHZ; import static android.net.wifi.WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY; +import static android.net.wifi.WifiScanner.WIFI_BAND_6_GHZ; import static android.net.wifi.WifiScanner.WIFI_BAND_COUNT; import static android.net.wifi.WifiScanner.WIFI_BAND_INDEX_24_GHZ; import static android.net.wifi.WifiScanner.WIFI_BAND_INDEX_5_GHZ; import static android.net.wifi.WifiScanner.WIFI_BAND_INDEX_5_GHZ_DFS_ONLY; +import static android.net.wifi.WifiScanner.WIFI_BAND_INDEX_6_GHZ; import static android.net.wifi.WifiScanner.WIFI_BAND_MAX; import static android.net.wifi.WifiScanner.WIFI_BAND_UNSPECIFIED; @@ -46,10 +48,13 @@ public class KnownBandsChannelHelper extends ChannelHelper { private static final int BAND_24_GHZ_END_FREQ = 2500; private static final int BAND_5_GHZ_START_FREQ = 5100; private static final int BAND_5_GHZ_END_FREQ = 6000; + private static final int BAND_6_GHZ_START_FREQ = 5925; + private static final int BAND_6_GHZ_END_FREQ = 7125; private WifiScanner.ChannelSpec[][] mBandsToChannels; - protected void setBandChannels(int[] channels2G, int[] channels5G, int[] channelsDfs) { + protected void setBandChannels(int[] channels2G, int[] channels5G, int[] channelsDfs, + int[] channels6G) { mBandsToChannels = new WifiScanner.ChannelSpec[WIFI_BAND_COUNT][]; if (channels2G.length != 0) { @@ -72,6 +77,16 @@ public class KnownBandsChannelHelper extends ChannelHelper { mBandsToChannels[WIFI_BAND_INDEX_5_GHZ_DFS_ONLY] = new WifiScanner.ChannelSpec[channelsDfs.length]; copyChannels(mBandsToChannels[WIFI_BAND_INDEX_5_GHZ_DFS_ONLY], channelsDfs); + } else { + mBandsToChannels[WIFI_BAND_INDEX_5_GHZ_DFS_ONLY] = NO_CHANNELS; + } + + if (channels6G.length != 0) { + mBandsToChannels[WIFI_BAND_INDEX_6_GHZ] = + new WifiScanner.ChannelSpec[channels6G.length]; + copyChannels(mBandsToChannels[WIFI_BAND_INDEX_6_GHZ], channels6G); + } else { + mBandsToChannels[WIFI_BAND_INDEX_6_GHZ] = NO_CHANNELS; } } @@ -155,6 +170,8 @@ public class KnownBandsChannelHelper extends ChannelHelper { } else { return WIFI_BAND_5_GHZ; } + } else if (BAND_6_GHZ_START_FREQ <= frequency && frequency < BAND_6_GHZ_END_FREQ) { + return WIFI_BAND_6_GHZ; } else { return WIFI_BAND_UNSPECIFIED; } diff --git a/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java b/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java index 2bc8b19bd..e1ddd9182 100644 --- a/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java +++ b/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java @@ -20,7 +20,8 @@ package com.android.server.wifi.scanner; * KnownBandsChannelHelper that uses a supplied list of band to channels mappings. */ public class PresetKnownBandsChannelHelper extends KnownBandsChannelHelper { - public PresetKnownBandsChannelHelper(int[] channels2G, int[] channels5G, int[] channelsDfs) { - setBandChannels(channels2G, channels5G, channelsDfs); + public PresetKnownBandsChannelHelper(int[] channels2G, int[] channels5G, int[] channelsDfs, + int[] channels6G) { + setBandChannels(channels2G, channels5G, channelsDfs, channels6G); } } diff --git a/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java b/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java index 7cfeb72d6..b52ce7e8c 100644 --- a/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java +++ b/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java @@ -33,7 +33,7 @@ public class WificondChannelHelper extends KnownBandsChannelHelper { public WificondChannelHelper(WifiNative wifiNative) { mWifiNative = wifiNative; final int[] emptyFreqList = new int[0]; - setBandChannels(emptyFreqList, emptyFreqList, emptyFreqList); + setBandChannels(emptyFreqList, emptyFreqList, emptyFreqList, emptyFreqList); updateChannels(); } @@ -47,10 +47,16 @@ public class WificondChannelHelper extends KnownBandsChannelHelper { int[] channelsDfs = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY); if (channelsDfs == null) Log.e(TAG, "Failed to get channels for 5GHz DFS only band"); - if (channels24G == null || channels5G == null || channelsDfs == null) { + int[] channels6G = + mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ); + if (channels6G == null) Log.e(TAG, "Failed to get channels for 6GHz band"); + + if (channels24G == null || channels5G == null || channelsDfs == null + || channels6G == null) { Log.e(TAG, "Failed to get all channels for band, not updating band channel lists"); - } else if (channels24G.length > 0 || channels5G.length > 0 || channelsDfs.length > 0) { - setBandChannels(channels24G, channels5G, channelsDfs); + } else if (channels24G.length > 0 || channels5G.length > 0 || channelsDfs.length > 0 + || channels6G.length > 0) { + setBandChannels(channels24G, channels5G, channelsDfs, channels6G); } else { Log.e(TAG, "Got zero length for all channel lists"); } diff --git a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java index 212937fc3..5271bc142 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java @@ -39,13 +39,15 @@ import java.util.Set; public class ScanTestUtil { public static void setupMockChannels(WifiNative wifiNative, int[] channels24, int[] channels5, - int[] channelsDfs) throws Exception { + int[] channelsDfs, int[] channels6) throws Exception { when(wifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ)) .thenReturn(channels24); when(wifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ)) .thenReturn(channels5); when(wifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY)) .thenReturn(channelsDfs); + when(wifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ)) + .thenReturn(channels6); } public static WifiScanner.ScanSettings createRequest(WifiScanner.ChannelSpec[] channels, diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java index 938ce9022..54e0c6907 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java @@ -66,7 +66,8 @@ public class BackgroundScanSchedulerTest extends WifiBaseTest { mChannelHelper = new PresetKnownBandsChannelHelper( new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5650, 5660}); + new int[]{5600, 5650, 5660}, + new int[]{5945, 5985}); mScheduler = new BackgroundScanScheduler(mChannelHelper); mScheduler.setMaxBuckets(DEFAULT_MAX_BUCKETS); mScheduler.setMaxChannelsPerBucket(DEFAULT_MAX_CHANNELS_PER_BUCKET); diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java index 5ad6c32f5..28cfd83e8 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java @@ -110,6 +110,8 @@ public class ChannelHelperTest extends WifiBaseTest { WifiScanner.WIFI_BAND_BOTH)); assertEquals("24Ghz & 5Ghz (DFS incl)", ChannelHelper.bandToString( WifiScanner.WIFI_BAND_BOTH_WITH_DFS)); + assertEquals("24Ghz & 5Ghz (DFS incl) & 6Ghz", ChannelHelper.bandToString( + WifiScanner.WIFI_BAND_24_5_WITH_DFS_6_GHZ)); assertEquals("invalid band", ChannelHelper.bandToString(-235342)); } diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java index 6348de036..7cc0367b9 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java @@ -33,7 +33,8 @@ public class HalWifiScannerTest extends BaseWifiScannerImplTest { setupMockChannels(mWifiNative, new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5650}); + new int[]{5600, 5650}, + new int[]{5945, 5985}); mScanner = new HalWifiScannerImpl(mContext, BaseWifiScannerImplTest.IFACE_NAME, mWifiNative, mWifiMonitor, mLooper.getLooper(), mClock); } 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 1261d0eae..c19da30e2 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/KnownBandsChannelHelperTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/KnownBandsChannelHelperTest.java @@ -53,6 +53,7 @@ public class KnownBandsChannelHelperTest { private static final int[] CHANNELS_5_GHZ = new int[]{5150, 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}; /** * Unit tests for @@ -71,7 +72,8 @@ public class KnownBandsChannelHelperTest { mChannelHelper = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); } /** @@ -116,7 +118,8 @@ public class KnownBandsChannelHelperTest { mChannelHelper = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); } private void testBand(int[] expectedChannels, int band) { @@ -206,7 +209,8 @@ public class KnownBandsChannelHelperTest { mChannelHelper = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); } /** @@ -278,11 +282,13 @@ public class KnownBandsChannelHelperTest { KnownBandsChannelHelper channelHelper0 = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); KnownBandsChannelHelper channelHelper1 = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); assertTrue(channelHelper0.satisfies(channelHelper1)); } @@ -294,11 +300,13 @@ public class KnownBandsChannelHelperTest { KnownBandsChannelHelper channelHelper0 = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); KnownBandsChannelHelper channelHelper1 = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS_OTHER); + CHANNELS_DFS_OTHER, + CHANNELS_6_GHZ); assertFalse(channelHelper0.satisfies(channelHelper1)); } } @@ -320,7 +328,8 @@ public class KnownBandsChannelHelperTest { KnownBandsChannelHelper channelHelper = new PresetKnownBandsChannelHelper( CHANNELS_24_GHZ, CHANNELS_5_GHZ, - CHANNELS_DFS); + CHANNELS_DFS, + CHANNELS_6_GHZ); mChannelCollection = channelHelper.createChannelCollection(); } @@ -471,12 +480,12 @@ public class KnownBandsChannelHelperTest { */ @Test public void addChannel_and_addBand_all() { - mChannelCollection.addBand(WifiScanner.WIFI_BAND_BOTH_WITH_DFS); + mChannelCollection.addBand(WifiScanner.WIFI_BAND_24_5_WITH_DFS_6_GHZ); mChannelCollection.addChannel(5150); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); - assertThat(bucketSettings, bandIs(WifiScanner.WIFI_BAND_BOTH_WITH_DFS)); + assertThat(bucketSettings, bandIs(WifiScanner.WIFI_BAND_24_5_WITH_DFS_6_GHZ)); assertNull(mChannelCollection.getScanFreqs()); @@ -530,10 +539,13 @@ public class KnownBandsChannelHelperTest { mChannelCollection.addChannel(5600); mChannelCollection.addChannel(5650); mChannelCollection.addChannel(5660); + mChannelCollection.addChannel(5945); + mChannelCollection.addChannel(5985); WifiNative.BucketSettings bucketSettings = new WifiNative.BucketSettings(); mChannelCollection.fillBucketSettings(bucketSettings, Integer.MAX_VALUE); - assertThat(bucketSettings, channelsAre(2400, 2450, 5150, 5175, 5600, 5650, 5660)); + assertThat(bucketSettings, + channelsAre(2400, 2450, 5150, 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 4bf2766ed..69a8c0ce1 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/ScanScheduleUtilFilterTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/ScanScheduleUtilFilterTest.java @@ -52,7 +52,8 @@ public class ScanScheduleUtilFilterTest extends WifiBaseTest { mChannelHelper = new PresetKnownBandsChannelHelper( new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5650}); + new int[]{5600, 5650}, + new int[]{5945, 5985}); } @Test 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 ce5a066d7..fc05aea00 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java @@ -160,12 +160,13 @@ public class WifiScanningServiceTest extends WifiBaseTest { mChannelHelper0 = new PresetKnownBandsChannelHelper( new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5650, 5660}); + new int[]{5600, 5650, 5660}, + new int[]{5945, 5985}); mChannelHelper1 = new PresetKnownBandsChannelHelper( new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5660, 5680}); // 5650 is missing from channelHelper0 - + new int[]{5600, 5660, 5680}, // 5650 is missing from channelHelper0 + new int[]{5945, 5985}); mLooper = new TestLooper(); mWifiMetrics = new WifiMetrics(mContext, mFrameworkFacade, mClock, mLooper.getLooper(), new WifiAwareMetrics(mClock), new RttMetrics(mClock), diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java index e15fa2bb1..a43950d0e 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java @@ -77,7 +77,8 @@ public class WificondPnoScannerTest extends WifiBaseTest { setupMockChannels(mWifiNative, new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5650}); + new int[]{5600, 5650}, + new int[]{5945, 5985}); when(mWifiNative.getClientInterfaceName()).thenReturn(IFACE_NAME); when(mContext.getSystemService(Context.ALARM_SERVICE)) diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java index c2a09fe27..e256e443f 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java @@ -63,7 +63,8 @@ public class WificondScannerTest extends BaseWifiScannerImplTest { setupMockChannels(mWifiNative, new int[]{2400, 2450}, new int[]{5150, 5175}, - new int[]{5600, 5650}); + new int[]{5600, 5650}, + new int[]{5945, 5985}); mWifiMonitorSpy = spy(mWifiMonitor); mScanner = new WificondScannerImpl(mContext, BaseWifiScannerImplTest.IFACE_NAME, mWifiNative, mWifiMonitorSpy, new WificondChannelHelper(mWifiNative), |