[Wi-Fi] Apply cache in WifiTracker to update the signal icon immediatelly.
issue: Signal icon on the add wifi network feature need to wait for the scan result. Solution: Apply the cache in the WifiTracker to update signal icon for shortening the waiting time of new scan result. Bug: 146842198 Test: Add following unit test cases to test signal level has been updated correctly: 1. withOneSuggestion_whenScanResultChangedButWifiOff_uiListShouldHaveZeroLevel. Change-Id: Id72e2b43e020f2cafa2af4af5ffb1c28529002bd
This commit is contained in:
@@ -715,7 +715,7 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateScanResults(List<AccessPoint> allAccessPoints) {
|
||||
void updateScanResultsToUi(List<AccessPoint> allAccessPoints) {
|
||||
if (mUiToRequestedList == null) {
|
||||
// Nothing need to be updated.
|
||||
return;
|
||||
@@ -723,13 +723,16 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
||||
|
||||
// Update the signal level of the UI networks.
|
||||
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
|
||||
final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
|
||||
.stream()
|
||||
.filter(accesspoint -> accesspoint.matches(
|
||||
uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
|
||||
.findFirst();
|
||||
uiConfigurationItem.mLevel =
|
||||
matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
|
||||
uiConfigurationItem.mLevel = 0;
|
||||
if (allAccessPoints != null) {
|
||||
final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
|
||||
.stream()
|
||||
.filter(accesspoint -> accesspoint.matches(
|
||||
uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
|
||||
.findFirst();
|
||||
uiConfigurationItem.mLevel =
|
||||
matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mIsSingleNetwork) {
|
||||
@@ -741,8 +744,18 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
onAccessPointsChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the results when data changes
|
||||
*/
|
||||
@Override
|
||||
public void onAccessPointsChanged() {
|
||||
updateScanResults(mWifiTracker.getAccessPoints());
|
||||
updateScanResultsToUi(
|
||||
mWifiTracker.getManager().isWifiEnabled() ? mWifiTracker.getAccessPoints() : null);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user