diff options
| author | 2018-11-08 14:21:58 -0800 | |
|---|---|---|
| committer | 2018-11-14 15:16:51 -0800 | |
| commit | e3cc06875fc41f0102f900a84ae3f41f1a467c0b (patch) | |
| tree | 15e7b8b7e8e02b304d6832631122965980144720 | |
| parent | ebebce29f9f8849eaa62694d3c014c86d7c0bf2f (diff) | |
[WPA3] Filter unsupported networks from scan results
Filter unsupported networks from scan results. New WPA3 networks and OWE
networks may not be compatible with the device HW/SW, and such networks
will not appear in the scan results view.
Bug: 112195778
Test: Functional test with WPA3/OWE AP and confirming filtered correctly
Change-Id: Ic79e533a0e99aa38366b178feafb28bd286202d1
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java index 0dbc037f2298..2f082b959e68 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java @@ -152,7 +152,11 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro private boolean mNetworkScoringUiEnabled; private long mMaxSpeedLabelScoreCacheAge; - + private static final String WIFI_SECURITY_PSK = "PSK"; + private static final String WIFI_SECURITY_EAP = "EAP"; + private static final String WIFI_SECURITY_SAE = "SAE"; + private static final String WIFI_SECURITY_OWE = "OWE"; + private static final String WIFI_SECURITY_SUITE_B_192 = "SUITE_B_192"; @VisibleForTesting Scanner mScanner; @@ -505,13 +509,18 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro * {@link #updateAccessPoints(List, List)}. */ private void fetchScansAndConfigsAndUpdateAccessPoints() { - final List<ScanResult> newScanResults = mWifiManager.getScanResults(); + List<ScanResult> newScanResults = mWifiManager.getScanResults(); + + // Filter all unsupported networks from the scan result list + final List<ScanResult> filteredScanResults = + filterScanResultsByCapabilities(newScanResults); + if (isVerboseLoggingEnabled()) { - Log.i(TAG, "Fetched scan results: " + newScanResults); + Log.i(TAG, "Fetched scan results: " + filteredScanResults); } List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks(); - updateAccessPoints(newScanResults, configs); + updateAccessPoints(filteredScanResults, configs); } /** Update the internal list of access points. */ @@ -937,4 +946,49 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro mListener.onAccessPointsChanged(); } + + /** + * Filters unsupported networks from scan results. New WPA3 networks and OWE networks + * may not be compatible with the device HW/SW. + * @param scanResults List of scan results + * @return List of filtered scan results based on local device capabilities + */ + private List<ScanResult> filterScanResultsByCapabilities(List<ScanResult> scanResults) { + if (scanResults == null) { + return null; + } + + // Get and cache advanced capabilities + final boolean isOweSupported = mWifiManager.isOweSupported(); + final boolean isSaeSupported = mWifiManager.isWpa3SaeSupported(); + final boolean isSuiteBSupported = mWifiManager.isWpa3SuiteBSupported(); + + List<ScanResult> filteredScanResultList = new ArrayList<>(); + + // Iterate through the list of scan results and filter out APs which are not + // compatible with our device. + for (ScanResult scanResult : scanResults) { + if (scanResult.capabilities.contains(WIFI_SECURITY_PSK)) { + // All devices (today) support RSN-PSK or WPA-PSK + // Add this here because some APs may support both PSK and SAE and the check + // below will filter it out. + filteredScanResultList.add(scanResult); + continue; + } + + if ((scanResult.capabilities.contains(WIFI_SECURITY_SUITE_B_192) && !isSuiteBSupported) + || (scanResult.capabilities.contains(WIFI_SECURITY_SAE) && !isSaeSupported) + || (scanResult.capabilities.contains(WIFI_SECURITY_OWE) && !isOweSupported)) { + if (isVerboseLoggingEnabled()) { + Log.v(TAG, "filterScanResultsByCapabilities: Filtering SSID " + + scanResult.SSID + " with capabilities: " + scanResult.capabilities); + } + } else { + // Safe to add + filteredScanResultList.add(scanResult); + } + } + + return filteredScanResultList; + } } |