Supports to share Wi-Fi networks of WPA3 security SAE & OWE via QR code generator

When scanned a no password ZXing QR code, add both open network &
enhanced open network to configured Wi-Fi network list because this kind
of QR code may refer to a open network or an enhanced open network.

Bug: 124131581
Test: manual
Change-Id: Id9f85ef8dcdf72347be8106938437aecd0eed9f5
This commit is contained in:
Arc Wang
2019-04-03 18:45:22 +08:00
parent 6010c3a9a8
commit 4a5ff58511
6 changed files with 192 additions and 97 deletions

View File

@@ -162,6 +162,9 @@ public class WifiDppUtils {
if (config.allowedKeyManagement.get(KeyMgmt.SAE)) {
return WifiQrCode.SECURITY_SAE;
}
if (config.allowedKeyManagement.get(KeyMgmt.OWE)) {
return WifiQrCode.SECURITY_NO_PASSWORD;
}
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ||
config.allowedKeyManagement.get(KeyMgmt.WPA2_PSK)) {
return WifiQrCode.SECURITY_WPA_PSK;
@@ -185,7 +188,7 @@ public class WifiDppUtils {
public static Intent getConfiguratorQrCodeGeneratorIntentOrNull(Context context,
WifiManager wifiManager, AccessPoint accessPoint) {
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
if (isSupportConfiguratorQrCodeGenerator(accessPoint)) {
if (isSupportConfiguratorQrCodeGenerator(context, accessPoint)) {
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
} else {
return null;
@@ -343,22 +346,24 @@ public class WifiDppUtils {
/**
* Checks if QR code generator supports to config other devices with the Wi-Fi network
*
* @param context The context to use for {@code WifiManager}
* @param accessPoint The {@link AccessPoint} of the Wi-Fi network
*/
public static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
return isSupportZxing(accessPoint.getSecurity());
public static boolean isSupportConfiguratorQrCodeGenerator(Context context,
AccessPoint accessPoint) {
return isSupportZxing(context, accessPoint.getSecurity());
}
/**
* Checks if this device supports to be configured by the Wi-Fi network of the security
*
* @param context The context to use for {@link WifiManager#isEasyConnectSupported()}
* @param context The context to use for {@code WifiManager}
* @param accesspointSecurity The security constants defined in {@link AccessPoint}
*/
public static boolean isSupportEnrolleeQrCodeScanner(Context context,
int accesspointSecurity) {
return isSupportWifiDpp(context, accesspointSecurity) ||
isSupportZxing(accesspointSecurity);
isSupportZxing(context, accesspointSecurity);
}
private static boolean isSupportHotspotConfiguratorQrCodeGenerator(
@@ -376,19 +381,38 @@ public class WifiDppUtils {
}
// DPP 1.0 only supports SAE and PSK.
if (accesspointSecurity == AccessPoint.SECURITY_SAE ||
accesspointSecurity == AccessPoint.SECURITY_PSK) {
return true;
final WifiManager wifiManager = context.getSystemService(WifiManager.class);
switch (accesspointSecurity) {
case AccessPoint.SECURITY_SAE:
if (wifiManager.isWpa3SaeSupported()) {
return true;
}
break;
case AccessPoint.SECURITY_PSK:
return true;
default:
}
return false;
}
// TODO (b/124131581 b/129396816): TO support WPA3 securities (SAE & OWE), change here at first
private static boolean isSupportZxing(int accesspointSecurity) {
if (accesspointSecurity == AccessPoint.SECURITY_PSK ||
accesspointSecurity == AccessPoint.SECURITY_WEP ||
accesspointSecurity == AccessPoint.SECURITY_NONE) {
return true;
private static boolean isSupportZxing(Context context, int accesspointSecurity) {
final WifiManager wifiManager = context.getSystemService(WifiManager.class);
switch (accesspointSecurity) {
case AccessPoint.SECURITY_PSK:
case AccessPoint.SECURITY_WEP:
case AccessPoint.SECURITY_NONE:
return true;
case AccessPoint.SECURITY_SAE:
if (wifiManager.isWpa3SaeSupported()) {
return true;
}
break;
case AccessPoint.SECURITY_OWE:
if (wifiManager.isEnhancedOpenSupported()) {
return true;
}
break;
default:
}
return false;
}