Hide Wi-Fi QR code scan button for unsupported Wi-Fi networks

Wi-Fi QR code scan button only shows for the Wi-Fi network which
supports Wi-Fi Easy Connect or ZXing Wi-Fi config format.

Bug: 128847959
Test: manual
Change-Id: If6460ce88748e7b06893bf62060418a8727d3134
This commit is contained in:
Arc Wang
2019-03-28 15:39:03 +08:00
parent bab3bf6f22
commit dae6c695ca
2 changed files with 65 additions and 19 deletions

View File

@@ -323,31 +323,36 @@ public class WifiDppUtils {
}
}
/**
* Checks if QR code scanner supports to config other devices with the Wi-Fi network
*
* @param context The context to use for {@link WifiManager#isEasyConnectSupported()}
* @param accessPoint The {@link AccessPoint} of the Wi-Fi network
*/
public static boolean isSupportConfiguratorQrCodeScanner(Context context,
AccessPoint accessPoint) {
if (!isWifiDppEnabled(context)) {
return false;
}
// DPP 1.0 only supports SAE and PSK.
final int security = accessPoint.getSecurity();
if (security == AccessPoint.SECURITY_SAE || security == AccessPoint.SECURITY_PSK) {
return true;
}
return false;
return isSupportWifiDpp(context, accessPoint.getSecurity());
}
/**
* Checks if QR code generator supports to config other devices with the Wi-Fi network
*
* @param accessPoint The {@link AccessPoint} of the Wi-Fi network
*/
public static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
// QR code generator produces QR code with ZXing's Wi-Fi network config format,
// it supports PSK and WEP and non security
final int security = accessPoint.getSecurity();
if (security == AccessPoint.SECURITY_PSK || security == AccessPoint.SECURITY_WEP ||
security == AccessPoint.SECURITY_NONE) {
return true;
}
return isSupportZxing(accessPoint.getSecurity());
}
return false;
/**
* 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 accesspointSecurity The security constants defined in {@link AccessPoint}
*/
public static boolean isSupportEnrolleeQrCodeScanner(Context context,
int accesspointSecurity) {
return isSupportWifiDpp(context, accesspointSecurity) ||
isSupportZxing(accesspointSecurity);
}
private static boolean isSupportHotspotConfiguratorQrCodeGenerator(
@@ -358,4 +363,27 @@ public class WifiDppUtils {
return wifiConfiguration.allowedKeyManagement.get(KeyMgmt.WPA2_PSK) ||
wifiConfiguration.allowedKeyManagement.get(KeyMgmt.NONE);
}
private static boolean isSupportWifiDpp(Context context, int accesspointSecurity) {
if (!isWifiDppEnabled(context)) {
return false;
}
// DPP 1.0 only supports SAE and PSK.
if (accesspointSecurity == AccessPoint.SECURITY_SAE ||
accesspointSecurity == AccessPoint.SECURITY_PSK) {
return true;
}
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;
}
return false;
}
}