Fix NPE when forgetting networks.
- Fixed disablement of ephemeral networks - Exit out of the fragment when Forget is pressed Bug: 36723238 Test: m RunSettingsRoboTests and manual testing Change-Id: I83c09a44dbef0f02a452dc8c3163523a27bd4b63
This commit is contained in:
@@ -106,6 +106,7 @@ public class WifiDetailPreferenceController extends PreferenceController impleme
|
||||
mSignalStr = context.getResources().getStringArray(R.array.wifi_signal);
|
||||
mWifiConfig = accessPoint.getConfig();
|
||||
mWifiManager = wifiManager;
|
||||
mWifiInfo = wifiManager.getConnectionInfo();
|
||||
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
@@ -265,16 +266,25 @@ public class WifiDetailPreferenceController extends PreferenceController impleme
|
||||
mDnsPref.setDetailText(builder.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the network represented by this preference can be forgotten.
|
||||
*/
|
||||
public boolean canForgetNetwork() {
|
||||
return mWifiInfo != null && mWifiInfo.isEphemeral() || mWifiConfig != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgets the wifi network associated with this preference.
|
||||
*/
|
||||
public void forgetNetwork() {
|
||||
if (mWifiConfig.ephemeral) {
|
||||
mWifiManager.disableEphemeralNetwork(mWifiConfig.SSID);
|
||||
} else if (mWifiConfig.isPasspoint()) {
|
||||
mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
|
||||
} else {
|
||||
mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
|
||||
if (mWifiInfo != null && mWifiInfo.isEphemeral()) {
|
||||
mWifiManager.disableEphemeralNetwork(mWifiInfo.getSSID());
|
||||
} else if (mWifiConfig != null) {
|
||||
if (mWifiConfig.isPasspoint()) {
|
||||
mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
|
||||
} else {
|
||||
mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user