[Wi-Fi] Remove WifiTrackerLib/AccessPoint constant & API usage
Bug: 152571756 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.dpp make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.details Change-Id: I857cf0e261c1b07c3d7b6bc08632880ed8c71ee1
This commit is contained in:
@@ -65,7 +65,7 @@ public class WifiDppUtils {
|
||||
*/
|
||||
static final String TAG_FRAGMENT_ADD_DEVICE = "add_device_fragment";
|
||||
|
||||
/** The data is from {@code com.android.settingslib.wifi.AccessPoint.securityToString} */
|
||||
/** The data is one of the static String SECURITY_* in {@link WifiQrCode} */
|
||||
static final String EXTRA_WIFI_SECURITY = "security";
|
||||
|
||||
/** The data corresponding to {@code WifiConfiguration} SSID */
|
||||
@@ -251,36 +251,6 @@ public class WifiDppUtils {
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an intent to launch QR code scanner. It may return null if the security is not
|
||||
* supported by QR code 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 scanner
|
||||
*/
|
||||
public static Intent getConfiguratorQrCodeScannerIntentOrNull(Context context,
|
||||
WifiManager wifiManager, AccessPoint accessPoint) {
|
||||
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
|
||||
if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
|
||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
final WifiConfiguration wifiConfiguration = accessPoint.getConfig();
|
||||
setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration);
|
||||
|
||||
if (wifiConfiguration.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
|
||||
throw new IllegalArgumentException("Invalid network ID");
|
||||
} else {
|
||||
intent.putExtra(EXTRA_WIFI_NETWORK_ID, wifiConfiguration.networkId);
|
||||
}
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an intent to launch QR code scanner. It may return null if the security is not
|
||||
* supported by QR code scanner.
|
||||
@@ -434,20 +404,6 @@ 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 (accessPoint.isPasspoint()) {
|
||||
return false;
|
||||
}
|
||||
return isSupportWifiDpp(context, accessPoint.getSecurity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if QR code generator supports to config other devices with the Wi-Fi network
|
||||
*
|
||||
@@ -466,12 +422,11 @@ public class WifiDppUtils {
|
||||
* Checks if this device supports to be configured by the Wi-Fi network of the security
|
||||
*
|
||||
* @param context The context to use for {@code WifiManager}
|
||||
* @param accesspointSecurity The security constants defined in {@link AccessPoint}
|
||||
* @param wifiEntrySecurity The security constants defined in {@link WifiEntry}
|
||||
*/
|
||||
public static boolean isSupportEnrolleeQrCodeScanner(Context context,
|
||||
int accesspointSecurity) {
|
||||
return isSupportWifiDpp(context, accesspointSecurity) ||
|
||||
isSupportZxing(context, accesspointSecurity);
|
||||
public static boolean isSupportEnrolleeQrCodeScanner(Context context, int wifiEntrySecurity) {
|
||||
return isSupportWifiDpp(context, wifiEntrySecurity)
|
||||
|| isSupportZxing(context, wifiEntrySecurity);
|
||||
}
|
||||
|
||||
private static boolean isSupportHotspotConfiguratorQrCodeGenerator(
|
||||
@@ -483,39 +438,39 @@ public class WifiDppUtils {
|
||||
|| softApConfiguration.getSecurityType() == SoftApConfiguration.SECURITY_TYPE_OPEN;
|
||||
}
|
||||
|
||||
private static boolean isSupportWifiDpp(Context context, int accesspointSecurity) {
|
||||
private static boolean isSupportWifiDpp(Context context, int wifiEntrySecurity) {
|
||||
if (!isWifiDppEnabled(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// DPP 1.0 only supports SAE and PSK.
|
||||
final WifiManager wifiManager = context.getSystemService(WifiManager.class);
|
||||
switch (accesspointSecurity) {
|
||||
case AccessPoint.SECURITY_SAE:
|
||||
switch (wifiEntrySecurity) {
|
||||
case WifiEntry.SECURITY_SAE:
|
||||
if (wifiManager.isWpa3SaeSupported()) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case AccessPoint.SECURITY_PSK:
|
||||
case WifiEntry.SECURITY_PSK:
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isSupportZxing(Context context, int accesspointSecurity) {
|
||||
private static boolean isSupportZxing(Context context, int wifiEntrySecurity) {
|
||||
final WifiManager wifiManager = context.getSystemService(WifiManager.class);
|
||||
switch (accesspointSecurity) {
|
||||
case AccessPoint.SECURITY_PSK:
|
||||
case AccessPoint.SECURITY_WEP:
|
||||
case AccessPoint.SECURITY_NONE:
|
||||
switch (wifiEntrySecurity) {
|
||||
case WifiEntry.SECURITY_PSK:
|
||||
case WifiEntry.SECURITY_WEP:
|
||||
case WifiEntry.SECURITY_NONE:
|
||||
return true;
|
||||
case AccessPoint.SECURITY_SAE:
|
||||
case WifiEntry.SECURITY_SAE:
|
||||
if (wifiManager.isWpa3SaeSupported()) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case AccessPoint.SECURITY_OWE:
|
||||
case WifiEntry.SECURITY_OWE:
|
||||
if (wifiManager.isEnhancedOpenSupported()) {
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user