[Wi-Fi] Should not downgrade the security to connect an OWE access point
For an OWE transition mode AccessPoint, it returns the security the device can support. So an OWE transition mode AP should not be affected by the bug. For an OWE AP and a device not supports OWE, this bug may let the device try to connect to the OWE AP with SECURITY_NONE. Bug: 146105831 Test: atest AccessPointTest Change-Id: I6809aed76e399db3e3c2cbebf0bd44ebdf490755
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user