[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
|
@VisibleForTesting
|
||||||
void updateScanResultsToUi(List<WifiEntry> allEntries) {
|
void updateScanResultsToUi() {
|
||||||
if (mUiToRequestedList == null) {
|
if (mUiToRequestedList == null) {
|
||||||
// Nothing need to be updated.
|
// Nothing need to be updated.
|
||||||
return;
|
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.
|
// Update the signal level of the UI networks.
|
||||||
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
|
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
|
||||||
uiConfigurationItem.mLevel = 0;
|
uiConfigurationItem.mLevel = 0;
|
||||||
if (allEntries != null) {
|
if (reachableWifiEntries != null) {
|
||||||
final Optional<WifiEntry> matchedWifiEntry = allEntries.stream()
|
final Optional<WifiEntry> matchedWifiEntry = reachableWifiEntries.stream()
|
||||||
.filter(wifiEntry -> TextUtils.equals(
|
.filter(wifiEntry -> TextUtils.equals(
|
||||||
uiConfigurationItem.mWifiNetworkSuggestion.getSsid(),
|
uiConfigurationItem.mWifiNetworkSuggestion.getSsid(),
|
||||||
wifiEntry.getSsid()))
|
wifiEntry.getSsid()))
|
||||||
.filter(wifiEntry -> !wifiEntry.isSaved())
|
|
||||||
.findFirst();
|
.findFirst();
|
||||||
uiConfigurationItem.mLevel =
|
uiConfigurationItem.mLevel =
|
||||||
matchedWifiEntry.isPresent() ? matchedWifiEntry.get().getLevel() : 0;
|
matchedWifiEntry.isPresent() ? matchedWifiEntry.get().getLevel() : 0;
|
||||||
@@ -797,9 +805,7 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onWifiEntriesChanged() {
|
public void onWifiEntriesChanged() {
|
||||||
updateScanResultsToUi(
|
updateScanResultsToUi();
|
||||||
(mWifiPickerTracker.getWifiState() == WifiManager.WIFI_STATE_ENABLED)
|
|
||||||
? mWifiPickerTracker.getWifiEntries() : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user