Merge "Wifi: Add constant and utility method for bands" into rvc-dev am: 2a56a97972
Change-Id: Ia8ca7a087e97f27f37237c98636b623ba0a7b558
This commit is contained in:
@@ -131,10 +131,10 @@ public class WifiScanner {
|
||||
public @interface WifiBand {}
|
||||
|
||||
/**
|
||||
* Max band value
|
||||
* All bands
|
||||
* @hide
|
||||
*/
|
||||
public static final int WIFI_BAND_MAX = 0x10;
|
||||
public static final int WIFI_BAND_ALL = (1 << WIFI_BAND_COUNT) - 1;
|
||||
|
||||
/** Minimum supported scanning period */
|
||||
public static final int MIN_SCAN_PERIOD_MS = 1000;
|
||||
@@ -167,6 +167,22 @@ public class WifiScanner {
|
||||
public void onFailure(int reason, String description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if scan is a full scan. i.e. scanning all available bands.
|
||||
* For backward compatibility, since some apps don't include 6GHz in their requests yet,
|
||||
* lacking 6GHz band does not cause the result to be false.
|
||||
*
|
||||
* @param bandScanned bands that are fully scanned
|
||||
* @param excludeDfs when true, DFS band is excluded from the check
|
||||
* @return true if all bands are scanned, false otherwise
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isFullBandScan(@WifiBand int bandScanned, boolean excludeDfs) {
|
||||
return (bandScanned | WIFI_BAND_6_GHZ | (excludeDfs ? WIFI_BAND_5_GHZ_DFS_ONLY : 0))
|
||||
== WIFI_BAND_ALL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all the possible channels for the given band(s).
|
||||
*
|
||||
|
||||
@@ -613,4 +613,22 @@ public class WifiScannerTest {
|
||||
verify(mExecutor, never()).execute(any());
|
||||
verify(mScanListener, never()).onResults(mScanData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests isFullBandScan() method with and without DFS check
|
||||
*/
|
||||
@Test
|
||||
public void testIsFullBandScan() throws Exception {
|
||||
assertFalse(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_24_GHZ, true));
|
||||
assertFalse(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_5_GHZ, true));
|
||||
assertFalse(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_6_GHZ, true));
|
||||
assertFalse(WifiScanner.isFullBandScan(
|
||||
WifiScanner.WIFI_BAND_6_GHZ | WifiScanner.WIFI_BAND_5_GHZ, true));
|
||||
assertTrue(WifiScanner.isFullBandScan(
|
||||
WifiScanner.WIFI_BAND_24_GHZ | WifiScanner.WIFI_BAND_5_GHZ, true));
|
||||
assertFalse(WifiScanner.isFullBandScan(
|
||||
WifiScanner.WIFI_BAND_24_GHZ | WifiScanner.WIFI_BAND_5_GHZ, false));
|
||||
assertTrue(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, true));
|
||||
assertTrue(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, false));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user