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

Commit cc10721c authored by Hai Shalom's avatar Hai Shalom Committed by Android (Google) Code Review
Browse files

Merge changes I3691ab5a,Ic79e533a

* changes:
  [WPA3] Make WPA3/OWE capability query API public
  [WPA3] Filter unsupported networks from scan results
parents ba0c9799 67e43033
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -29000,11 +29000,14 @@ package android.net.wifi {
    method public boolean is5GHzBandSupported();
    method public boolean isDeviceToApRttSupported();
    method public boolean isEnhancedPowerReportingSupported();
    method public boolean isOweSupported();
    method public boolean isP2pSupported();
    method public boolean isPreferredNetworkOffloadSupported();
    method public deprecated boolean isScanAlwaysAvailable();
    method public boolean isTdlsSupported();
    method public boolean isWifiEnabled();
    method public boolean isWpa3SaeSupported();
    method public boolean isWpa3SuiteBSupported();
    method public deprecated boolean pingSupplicant();
    method public deprecated boolean reassociate();
    method public deprecated boolean reconnect();
+58 −4
Original line number Diff line number Diff line
@@ -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;
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -4256,27 +4256,21 @@ public class WifiManager {

    /**
     * @return true if this device supports WPA3-Personal SAE
     * @hide
     */
    @SystemApi
    public boolean isWpa3SaeSupported() {
        return isFeatureSupported(WIFI_FEATURE_WPA3_SAE);
    }

    /**
     * @return true if this device supports WPA3-Enterprise Suite-B-192
     * @hide
     */
    @SystemApi
    public boolean isWpa3SuiteBSupported() {
        return isFeatureSupported(WIFI_FEATURE_WPA3_SUITE_B);
    }

    /**
     * @return true if this device supports Wi-Fi Enhanced Open (OWE)
     * @hide
     */
    @SystemApi
    public boolean isOweSupported() {
        return isFeatureSupported(WIFI_FEATURE_OWE);
    }