[Wi-Fi] Fix exception when 'Add device' with a Wi-Fi suggestion network
WifiEntry#getWifiConfiguration() may return null when WifiEntry#isSaved() is true. Use WifiEntry#canEasyConnect() which checks if WifiEntry#getWifiConfiguration() returns a non-null value. Bug: 153029289 Test: manual Connect to a WPA2 Wi-Fi network, click 'Add device' in Wi-Fi detail page and see if it crashes. Change-Id: Ia15503eea795fdd54826699828f02c9ff95dcefa
This commit is contained in:
@@ -51,8 +51,7 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mWifiEntry) ? AVAILABLE
|
return mWifiEntry.canEasyConnect() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
: CONDITIONALLY_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -297,7 +297,7 @@ public class WifiDppUtils {
|
|||||||
public static Intent getConfiguratorQrCodeScannerIntentOrNull(Context context,
|
public static Intent getConfiguratorQrCodeScannerIntentOrNull(Context context,
|
||||||
WifiManager wifiManager, WifiEntry wifiEntry) {
|
WifiManager wifiManager, WifiEntry wifiEntry) {
|
||||||
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
|
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
|
||||||
if (isSupportConfiguratorQrCodeScanner(context, wifiEntry)) {
|
if (wifiEntry.canEasyConnect()) {
|
||||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -452,19 +452,6 @@ public class WifiDppUtils {
|
|||||||
return isSupportWifiDpp(context, accessPoint.getSecurity());
|
return isSupportWifiDpp(context, accessPoint.getSecurity());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 wifiEntry The {@link WifiEntry} of the Wi-Fi network
|
|
||||||
*/
|
|
||||||
public static boolean isSupportConfiguratorQrCodeScanner(Context context, WifiEntry wifiEntry) {
|
|
||||||
if (wifiEntry.isSubscription()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return isSupportWifiDpp(context, wifiEntry.getSecurity());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if QR code generator supports to config other devices with the Wi-Fi network
|
* Checks if QR code generator supports to config other devices with the Wi-Fi network
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user