Filter out unsupported security type for DPP configuration.
There is different Wi-Fi security support between ZXing's Wi-Fi QR code format and Wi-Fi DPP QR code format. ZXing's Wi-Fi QR code format: supports WEP / WPA / none security Wi-Fi DPP: supports WPA / SAE So we will have different UI behavior for different security. WEP & none security: only support QR code generator WPA: supports both QR code generator & scanner SAE: only supports QR code scanner others: don't support. The share button is invisible Bug: 123212410 Test: manual test Change-Id: I87962d730282fc2c1b96223dca6feb79235fe5a1
This commit is contained in:
@@ -134,26 +134,36 @@ public class WifiDppUtils {
|
||||
private static String getSecurityString(AccessPoint accessPoint) {
|
||||
switch(accessPoint.getSecurity()) {
|
||||
case AccessPoint.SECURITY_WEP:
|
||||
return "WEP";
|
||||
return WifiQrCode.SECURITY_WEP;
|
||||
case AccessPoint.SECURITY_PSK:
|
||||
return "WPA";
|
||||
return WifiQrCode.SECURITY_WPA;
|
||||
case AccessPoint.SECURITY_SAE:
|
||||
return WifiQrCode.SECURITY_SAE;
|
||||
default:
|
||||
return "nopass";
|
||||
return WifiQrCode.SECURITY_NO_PASSWORD;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an intent to launch QR code generator.
|
||||
* Returns an intent to launch QR code generator or scanner according to the Wi-Fi network
|
||||
* security. It may return null if the security is not supported by QR code generator nor
|
||||
* scanner.
|
||||
*
|
||||
* @param context The context to use for the content resolver
|
||||
* @param wifiManager An instance of {@link WifiManager}
|
||||
* @param accessPoint An instance of {@link AccessPoint}
|
||||
* @return Intent for launching QR code generator
|
||||
*/
|
||||
public static Intent getConfiguratorQrCodeGeneratorIntent(Context context,
|
||||
public static Intent getConfiguratorIntentOrNull(Context context,
|
||||
WifiManager wifiManager, AccessPoint accessPoint) {
|
||||
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
|
||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||
if (isSupportConfiguratorQrCodeGenerator(accessPoint)) {
|
||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||
} else if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
|
||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
final WifiConfiguration wifiConfig = accessPoint.getConfig();
|
||||
final String ssid = removeFirstAndLastDoubleQuotes(wifiConfig.SSID);
|
||||
@@ -183,4 +193,43 @@ public class WifiDppUtils {
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Android Q supports Wi-Fi configurator by:
|
||||
*
|
||||
* 1. QR code generator of ZXing's Wi-Fi network config format.
|
||||
* and
|
||||
* 2. QR code scanner of Wi-Fi DPP QR code format.
|
||||
*/
|
||||
public static boolean isSuportConfigurator(Context context, AccessPoint accessPoint) {
|
||||
return isSupportConfiguratorQrCodeScanner(context, accessPoint) ||
|
||||
isSupportConfiguratorQrCodeGenerator(accessPoint);
|
||||
}
|
||||
|
||||
private 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;
|
||||
}
|
||||
|
||||
private 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 false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user