Fixed Passpoint network "Not in range" issue and forget button
Passpoint networks now correctly allow the user to connect and forget from the saved networks network detail page. Bug: 130373102 Test: atest WifiDetailPreferenceControllerTest Change-Id: I6ed2817bb3a1ac657695272ceb9d5e3f3e944f16
This commit is contained in:
@@ -556,14 +556,10 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -822,7 +818,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -852,19 +849,23 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
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;
|
||||
}
|
||||
|
||||
mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
|
||||
} else {
|
||||
mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
|
||||
} 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;
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -874,7 +875,12 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
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();
|
||||
@@ -996,7 +1002,11 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
} 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) {
|
||||
|
Reference in New Issue
Block a user