From b0a3555d8d5247f25d2e31c518f0948825b0244b Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Tue, 3 Dec 2019 12:01:55 +0200 Subject: [PATCH] wifi: add support for 60GHz band in WifiScanner Add new Wifi bands to include WIFI_BAND_60_GHZ. WIFI_BAND_24_5_6_60_GHZ and WIFI_BAND_24_5_WITH_DFS_6_60_GHZ were added and shall be used for performing full scan. Add new addResults function which receives the full ScanData and updates mBandScanned in addition to the scan results. This function is used when consolidating scan results from multiple interfaces, each one containing different bands. isFullBandScanResults function was added and returns true in case 2.4GHz and 5GHz bands are included in the scan results, as scan results from other bands may not be present. Bug: 147495503 Test: Manual - enable wifi and connect to an access point Test: atest FrameworksWifiTests Test: atest FrameworksWifiApiTests Change-Id: I907b9b3382a193ae17107fa48a50890cb45c8736 --- api/system-current.txt | 1 + wifi/api/system-current.txt | 1 + wifi/java/android/net/wifi/WifiScanner.java | 38 ++++++++++++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) mode change 100755 => 100644 api/system-current.txt diff --git a/api/system-current.txt b/api/system-current.txt old mode 100755 new mode 100644 index c3e56643a8055..ec4c5460c0a35 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -7565,6 +7565,7 @@ package android.net.wifi { field public static final int WIFI_BAND_5_GHZ = 2; // 0x2 field public static final int WIFI_BAND_5_GHZ_DFS_ONLY = 4; // 0x4 field public static final int WIFI_BAND_5_GHZ_WITH_DFS = 6; // 0x6 + field public static final int WIFI_BAND_60_GHZ = 16; // 0x10 field public static final int WIFI_BAND_6_GHZ = 8; // 0x8 field public static final int WIFI_BAND_BOTH = 3; // 0x3 field public static final int WIFI_BAND_BOTH_WITH_DFS = 7; // 0x7 diff --git a/wifi/api/system-current.txt b/wifi/api/system-current.txt index eff64a31367aa..b2c960365e699 100644 --- a/wifi/api/system-current.txt +++ b/wifi/api/system-current.txt @@ -651,6 +651,7 @@ package android.net.wifi { field public static final int WIFI_BAND_5_GHZ = 2; // 0x2 field public static final int WIFI_BAND_5_GHZ_DFS_ONLY = 4; // 0x4 field public static final int WIFI_BAND_5_GHZ_WITH_DFS = 6; // 0x6 + field public static final int WIFI_BAND_60_GHZ = 16; // 0x10 field public static final int WIFI_BAND_6_GHZ = 8; // 0x8 field public static final int WIFI_BAND_BOTH = 3; // 0x3 field public static final int WIFI_BAND_BOTH_WITH_DFS = 7; // 0x7 diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java index 94771ac4ad789..a68d7e260b6a5 100644 --- a/wifi/java/android/net/wifi/WifiScanner.java +++ b/wifi/java/android/net/wifi/WifiScanner.java @@ -68,7 +68,9 @@ public class WifiScanner { /** @hide */ public static final int WIFI_BAND_INDEX_6_GHZ = 3; /** @hide */ - public static final int WIFI_BAND_COUNT = 4; + public static final int WIFI_BAND_INDEX_60_GHZ = 4; + /** @hide */ + public static final int WIFI_BAND_COUNT = 5; /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -76,7 +78,8 @@ public class WifiScanner { WIFI_BAND_INDEX_24_GHZ, WIFI_BAND_INDEX_5_GHZ, WIFI_BAND_INDEX_5_GHZ_DFS_ONLY, - WIFI_BAND_INDEX_6_GHZ}) + WIFI_BAND_INDEX_6_GHZ, + WIFI_BAND_INDEX_60_GHZ}) public @interface WifiBandIndex {} /** no band specified; use channel list instead */ @@ -89,6 +92,8 @@ public class WifiScanner { public static final int WIFI_BAND_5_GHZ_DFS_ONLY = 1 << WIFI_BAND_INDEX_5_GHZ_DFS_ONLY; /** 6 GHz band */ public static final int WIFI_BAND_6_GHZ = 1 << WIFI_BAND_INDEX_6_GHZ; + /** 60 GHz band */ + public static final int WIFI_BAND_60_GHZ = 1 << WIFI_BAND_INDEX_60_GHZ; /** * Combination of bands @@ -113,6 +118,12 @@ public class WifiScanner { /** 2.4 GHz band and 5 GHz band; with DFS channels and 6 GHz */ public static final int WIFI_BAND_24_5_WITH_DFS_6_GHZ = WIFI_BAND_BOTH_WITH_DFS | WIFI_BAND_6_GHZ; + /** @hide */ + public static final int WIFI_BAND_24_5_6_60_GHZ = + WIFI_BAND_24_5_6_GHZ | WIFI_BAND_60_GHZ; + /** @hide */ + public static final int WIFI_BAND_24_5_WITH_DFS_6_60_GHZ = + WIFI_BAND_24_5_6_60_GHZ | WIFI_BAND_5_GHZ_DFS_ONLY; /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -127,7 +138,10 @@ public class WifiScanner { WIFI_BAND_BOTH_WITH_DFS, WIFI_BAND_6_GHZ, WIFI_BAND_24_5_6_GHZ, - WIFI_BAND_24_5_WITH_DFS_6_GHZ}) + WIFI_BAND_24_5_WITH_DFS_6_GHZ, + WIFI_BAND_60_GHZ, + WIFI_BAND_24_5_6_60_GHZ, + WIFI_BAND_24_5_WITH_DFS_6_60_GHZ}) public @interface WifiBand {} /** @@ -179,7 +193,10 @@ public class WifiScanner { * @hide */ public static boolean isFullBandScan(@WifiBand int bandScanned, boolean excludeDfs) { - return (bandScanned | WIFI_BAND_6_GHZ | (excludeDfs ? WIFI_BAND_5_GHZ_DFS_ONLY : 0)) + // 5GHz DFS channel is part of 5GHz, mark 5GHz scanned as well. + if ((bandScanned & WIFI_BAND_5_GHZ_DFS_ONLY) != 0) bandScanned |= WIFI_BAND_5_GHZ; + return (bandScanned | WIFI_BAND_6_GHZ | WIFI_BAND_60_GHZ + | (excludeDfs ? WIFI_BAND_5_GHZ_DFS_ONLY : 0)) == WIFI_BAND_ALL; } @@ -571,6 +588,19 @@ public class WifiScanner { } } + /** {@hide} */ + public void addResults(@NonNull ScanData s) { + mBandScanned |= s.mBandScanned; + mFlags |= s.mFlags; + addResults(s.getResults()); + } + + /** {@hide} */ + public boolean isFullBandScanResults() { + return (mBandScanned & WifiScanner.WIFI_BAND_24_GHZ) != 0 + && (mBandScanned & WifiScanner.WIFI_BAND_5_GHZ) != 0; + } + /** Implement the Parcelable interface {@hide} */ public int describeContents() { return 0;