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

Commit 1d23bcde authored by Arc Wang's avatar Arc Wang Committed by Android (Google) Code Review
Browse files

Merge "[Wi-Fi] Should not downgrade the security to connect an OWE access point"

parents d4169671 f75d7e6f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1395,7 +1395,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
        mConfig = new WifiConfiguration();
        mConfig.SSID = AccessPoint.convertToQuotedString(ssid);

        if (security == SECURITY_NONE || !getWifiManager().isEasyConnectSupported()) {
        if (security == SECURITY_NONE) {
            mConfig.allowedKeyManagement.set(KeyMgmt.NONE);
        } else {
            mConfig.allowedKeyManagement.set(KeyMgmt.OWE);
+17 −0
Original line number Diff line number Diff line
@@ -1713,4 +1713,21 @@ public class AccessPointTest {
                .setScanResults(new ArrayList<ScanResult>(Arrays.asList(scanResult)))
                .build();
    }

    @Test
    public void testGenerateOpenNetworkConfig_oweNotSupported_shouldGetCorrectSecurity() {
        when(mMockContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mMockWifiManager);
        AccessPoint oweAccessPoint = new TestAccessPointBuilder(mMockContext)
                .setSecurity(AccessPoint.SECURITY_OWE).build();
        AccessPoint noneAccessPoint = new TestAccessPointBuilder(mMockContext)
                .setSecurity(AccessPoint.SECURITY_NONE).build();

        oweAccessPoint.generateOpenNetworkConfig();
        noneAccessPoint.generateOpenNetworkConfig();

        assertThat(oweAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.NONE)).isFalse();
        assertThat(oweAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.OWE)).isTrue();
        assertThat(noneAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.NONE)).isTrue();
        assertThat(noneAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.OWE)).isFalse();
    }
}