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;
|
mIsOutOfRange = true;
|
||||||
|
|
||||||
if (mAccessPoint.getConfig() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (AccessPoint ap : mWifiTracker.getAccessPoints()) {
|
for (AccessPoint ap : mWifiTracker.getAccessPoints()) {
|
||||||
if (ap.getConfig() != null
|
if (mAccessPoint.matches(ap)) {
|
||||||
&& mAccessPoint.matches(ap.getConfig())) {
|
|
||||||
mAccessPoint = ap;
|
mAccessPoint = ap;
|
||||||
|
mWifiConfig = ap.getConfig();
|
||||||
mIsOutOfRange = !mAccessPoint.isReachable();
|
mIsOutOfRange = !mAccessPoint.isReachable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -822,7 +818,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
|||||||
* Returns whether the network represented by this preference can be forgotten.
|
* Returns whether the network represented by this preference can be forgotten.
|
||||||
*/
|
*/
|
||||||
private boolean canForgetNetwork() {
|
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() {
|
private void forgetNetwork() {
|
||||||
if (mWifiInfo != null && mWifiInfo.isEphemeral()) {
|
if (mWifiInfo != null && mWifiInfo.isEphemeral()) {
|
||||||
mWifiManager.disableEphemeralNetwork(mWifiInfo.getSSID());
|
mWifiManager.disableEphemeralNetwork(mWifiInfo.getSSID());
|
||||||
} else if (mWifiConfig != null) {
|
} else if (mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig()) {
|
||||||
if (mWifiConfig.isPasspoint()) {
|
|
||||||
// Post a dialog to confirm if user really want to forget the passpoint network.
|
// Post a dialog to confirm if user really want to forget the passpoint network.
|
||||||
if (FeatureFlagPersistent.isEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2)) {
|
if (FeatureFlagPersistent.isEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2)) {
|
||||||
showConfirmForgetDialog();
|
showConfirmForgetDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
|
try {
|
||||||
} else {
|
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 */);
|
mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
|
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
|
||||||
mFragment.getActivity().finish();
|
mFragment.getActivity().finish();
|
||||||
@@ -874,7 +875,12 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
|||||||
protected void showConfirmForgetDialog() {
|
protected void showConfirmForgetDialog() {
|
||||||
final AlertDialog dialog = new AlertDialog.Builder(mContext)
|
final AlertDialog dialog = new AlertDialog.Builder(mContext)
|
||||||
.setPositiveButton(R.string.forget, ((dialog1, which) -> {
|
.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(
|
mMetricsFeatureProvider.action(
|
||||||
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
|
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
|
||||||
mFragment.getActivity().finish();
|
mFragment.getActivity().finish();
|
||||||
@@ -996,7 +1002,11 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
|||||||
} else if (state == STATE_CONNECTING) {
|
} else if (state == STATE_CONNECTING) {
|
||||||
Log.d(TAG, "connecting...");
|
Log.d(TAG, "connecting...");
|
||||||
updateConnectedButton(STATE_CONNECTING);
|
updateConnectedButton(STATE_CONNECTING);
|
||||||
|
if (mAccessPoint.isPasspoint()) {
|
||||||
|
mWifiManager.connect(mWifiConfig, mConnectListener);
|
||||||
|
} else {
|
||||||
mWifiManager.connect(mWifiConfig.networkId, mConnectListener);
|
mWifiManager.connect(mWifiConfig.networkId, mConnectListener);
|
||||||
|
}
|
||||||
// start timer for error handling since framework didn't call back if failed
|
// start timer for error handling since framework didn't call back if failed
|
||||||
startTimer();
|
startTimer();
|
||||||
} else if (state == STATE_ENABLE_WIFI_FAILED) {
|
} else if (state == STATE_ENABLE_WIFI_FAILED) {
|
||||||
|
Reference in New Issue
Block a user