[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:
Arc Wang
2020-04-02 22:21:08 +08:00
parent 783b0257ad
commit 75d6c9fce3
2 changed files with 2 additions and 16 deletions

View File

@@ -51,8 +51,7 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {
@Override
public int getAvailabilityStatus() {
return WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mWifiEntry) ? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
return mWifiEntry.canEasyConnect() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override