Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56b07411 authored by Ahmed ElArabawy's avatar Ahmed ElArabawy Committed by Automerger Merge Worker
Browse files

Merge "Wifi: Add constant and utility method for bands" into rvc-dev am: 2a56a979

Change-Id: I700203402eca85b343eab77bc2394e877b334456
parents 0e6b9257 2a56a979
Loading
Loading
Loading
Loading
+18 −2
Original line number Original line Diff line number Diff line
@@ -131,10 +131,10 @@ public class WifiScanner {
    public @interface WifiBand {}
    public @interface WifiBand {}


    /**
    /**
     * Max band value
     * All bands
     * @hide
     * @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 */
    /** Minimum supported scanning period */
    public static final int MIN_SCAN_PERIOD_MS = 1000;
    public static final int MIN_SCAN_PERIOD_MS = 1000;
@@ -167,6 +167,22 @@ public class WifiScanner {
        public void onFailure(int reason, String description);
        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).
     * Returns a list of all the possible channels for the given band(s).
     *
     *
+18 −0
Original line number Original line Diff line number Diff line
@@ -613,4 +613,22 @@ public class WifiScannerTest {
        verify(mExecutor, never()).execute(any());
        verify(mExecutor, never()).execute(any());
        verify(mScanListener, never()).onResults(mScanData);
        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));
    }
}
}