[Wi-Fi] Fix a UI defect of AddAppNetworksFragment
After clicking Save button, the signal icon always shows level 0. To correctly get the signal, this change fetches both saved WifiEntries and connected/connecting WifiEntry for signal icon information. Bug: 157344581 Test: manual visual 1. Use the intent Settings.ACTION_WIFI_ADD_NETWORKS to bring up the UI. 2. Click Save button and observe the signal icon. Change-Id: If33d1c02019ea2c1acccfbbc29bd1bf42de1cc82
This commit is contained in:
@@ -750,21 +750,29 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
void updateScanResultsToUi(List<WifiEntry> allEntries) {
|
||||
void updateScanResultsToUi() {
|
||||
if (mUiToRequestedList == null) {
|
||||
// Nothing need to be updated.
|
||||
return;
|
||||
}
|
||||
|
||||
List<WifiEntry> reachableWifiEntries = null;
|
||||
if (mWifiPickerTracker.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
|
||||
reachableWifiEntries = mWifiPickerTracker.getWifiEntries();
|
||||
final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
|
||||
if (connectedWifiEntry != null) {
|
||||
reachableWifiEntries.add(connectedWifiEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the signal level of the UI networks.
|
||||
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
|
||||
uiConfigurationItem.mLevel = 0;
|
||||
if (allEntries != null) {
|
||||
final Optional<WifiEntry> matchedWifiEntry = allEntries.stream()
|
||||
if (reachableWifiEntries != null) {
|
||||
final Optional<WifiEntry> matchedWifiEntry = reachableWifiEntries.stream()
|
||||
.filter(wifiEntry -> TextUtils.equals(
|
||||
uiConfigurationItem.mWifiNetworkSuggestion.getSsid(),
|
||||
wifiEntry.getSsid()))
|
||||
.filter(wifiEntry -> !wifiEntry.isSaved())
|
||||
.findFirst();
|
||||
uiConfigurationItem.mLevel =
|
||||
matchedWifiEntry.isPresent() ? matchedWifiEntry.get().getLevel() : 0;
|
||||
@@ -797,9 +805,7 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
||||
*/
|
||||
@Override
|
||||
public void onWifiEntriesChanged() {
|
||||
updateScanResultsToUi(
|
||||
(mWifiPickerTracker.getWifiState() == WifiManager.WIFI_STATE_ENABLED)
|
||||
? mWifiPickerTracker.getWifiEntries() : null);
|
||||
updateScanResultsToUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user