[Wi-Fi] Fix Wi-Fi wrong password notification can't launch editor

WifiPickerTracker gather WifiEntries at onStart but
WifiPickerTracker.getWifiEntries() may still have no WifiEntry
at onResume.

Check if there is a specified wrong password Wi-Fi network at
onWifiEntriesChanged.

Bug: 143328194
Test: manual
      Edit a Wi-Fi network with wrong password, click the wrong
      password notification, should see a Wi-Fi editor for the
      wrong password Wi-Fi network

Change-Id: I7de6e0e3eabb2cb00160709eca4951b655dc04d7
This commit is contained in:
Arc Wang
2020-01-10 15:51:24 +08:00
parent 824095f728
commit c4b1d0f416
2 changed files with 21 additions and 16 deletions

View File

@@ -227,7 +227,12 @@ public class WifiSettings extends RestrictedSettingsFragment
super.onCreate(icicle);
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
getContext().startActivity(new Intent("android.settings.WIFI_SETTINGS2"));
final Intent intent = new Intent("android.settings.WIFI_SETTINGS2");
final Bundle extras = getActivity().getIntent().getExtras();
if (extras != null) {
intent.putExtras(extras);
}
getContext().startActivity(intent);
finish();
return;
}

View File

@@ -405,21 +405,6 @@ public class WifiSettings2 extends RestrictedSettingsFragment
}
changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
// Edit the Wi-Fi network of specified SSID.
if (mOpenSsid != null) {
Optional<WifiEntry> matchedWifiEntry = mWifiPickerTracker.getWifiEntries().stream()
.filter(wifiEntry -> TextUtils.equals(mOpenSsid, wifiEntry.getSsid()))
.filter(wifiEntry -> wifiEntry.getSecurity() != WifiEntry.SECURITY_NONE
&& wifiEntry.getSecurity() != WifiEntry.SECURITY_OWE)
.filter(wifiEntry -> !wifiEntry.isSaved()
|| isDisabledByWrongPassword(wifiEntry))
.findFirst();
if (matchedWifiEntry.isPresent()) {
mOpenSsid = null;
launchConfigNewNetworkFragment(matchedWifiEntry.get());
}
}
}
@Override
@@ -673,6 +658,21 @@ public class WifiSettings2 extends RestrictedSettingsFragment
public void onWifiEntriesChanged() {
updateWifiEntryPreferencesDelayed();
changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
// Edit the Wi-Fi network of specified SSID.
if (mOpenSsid != null) {
Optional<WifiEntry> matchedWifiEntry = mWifiPickerTracker.getWifiEntries().stream()
.filter(wifiEntry -> TextUtils.equals(mOpenSsid, wifiEntry.getSsid()))
.filter(wifiEntry -> wifiEntry.getSecurity() != WifiEntry.SECURITY_NONE
&& wifiEntry.getSecurity() != WifiEntry.SECURITY_OWE)
.filter(wifiEntry -> !wifiEntry.isSaved()
|| isDisabledByWrongPassword(wifiEntry))
.findFirst();
if (matchedWifiEntry.isPresent()) {
mOpenSsid = null;
launchConfigNewNetworkFragment(matchedWifiEntry.get());
}
}
}
@Override