mIsOutOfRange = true;
- if (mAccessPoint.getConfig() == null) {
- return;
- }
-
for (AccessPoint ap : mWifiTracker.getAccessPoints()) {
- if (ap.getConfig() != null
- && mAccessPoint.matches(ap.getConfig())) {
+ if (mAccessPoint.matches(ap)) {
mAccessPoint = ap;
+ mWifiConfig = ap.getConfig();
mIsOutOfRange = !mAccessPoint.isReachable();
return;
}
* Returns whether the network represented by this preference can be forgotten.
*/
private boolean canForgetNetwork() {
- return (mWifiInfo != null && mWifiInfo.isEphemeral()) || canModifyNetwork();
+ return (mWifiInfo != null && mWifiInfo.isEphemeral()) || canModifyNetwork()
+ || mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig();
}
/**
private void forgetNetwork() {
if (mWifiInfo != null && mWifiInfo.isEphemeral()) {
mWifiManager.disableEphemeralNetwork(mWifiInfo.getSSID());
- } else if (mWifiConfig != null) {
- if (mWifiConfig.isPasspoint()) {
- // Post a dialog to confirm if user really want to forget the passpoint network.
- if (FeatureFlagPersistent.isEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2)) {
- showConfirmForgetDialog();
- return;
- }
+ } else if (mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig()) {
+ // Post a dialog to confirm if user really want to forget the passpoint network.
+ if (FeatureFlagPersistent.isEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2)) {
+ showConfirmForgetDialog();
+ return;
+ }
- mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
- } else {
- mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
+ try {
+ mWifiManager.removePasspointConfiguration(mAccessPoint.getPasspointFqdn());
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to remove Passpoint configuration for "
+ + mAccessPoint.getPasspointFqdn());
}
+ } else if (mWifiConfig != null) {
+ mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
}
+
mMetricsFeatureProvider.action(
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
mFragment.getActivity().finish();
protected void showConfirmForgetDialog() {
final AlertDialog dialog = new AlertDialog.Builder(mContext)
.setPositiveButton(R.string.forget, ((dialog1, which) -> {
- mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
+ try {
+ mWifiManager.removePasspointConfiguration(mAccessPoint.getPasspointFqdn());
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to remove Passpoint configuration for "
+ + mAccessPoint.getPasspointFqdn());
+ }
mMetricsFeatureProvider.action(
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
mFragment.getActivity().finish();
} else if (state == STATE_CONNECTING) {
Log.d(TAG, "connecting...");
updateConnectedButton(STATE_CONNECTING);
- mWifiManager.connect(mWifiConfig.networkId, mConnectListener);
+ if (mAccessPoint.isPasspoint()) {
+ mWifiManager.connect(mWifiConfig, mConnectListener);
+ } else {
+ mWifiManager.connect(mWifiConfig.networkId, mConnectListener);
+ }
// start timer for error handling since framework didn't call back if failed
startTimer();
} else if (state == STATE_ENABLE_WIFI_FAILED) {