From e9cbf1b69895a59277d72ed562d8bad84b650ce8 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Wed, 20 May 2020 16:33:31 -0700 Subject: [PATCH] Create new WifiEntryPreference if WifiEntry object changes WifiSettings2 should create a new WifiEntryPreference for a cached WifiEntry key in case the underlying object has changed, so that updates to the WifiEntry are still being listened to. This may happen in situations where WifiPickerTracker swaps WifiEntries objects with the same key in the getWifiEntries() list, such as when handling network suggestions (which are kept as separate objects from the non-suggestion entries). Bug: 157174114 Test: manual visual verification in wifi picker of adding a network suggestion and seeing the entry summary for that SSID change to the suggestion summary. Change-Id: I9cfdae8207ae919e9e1cbf4c200eaa951a229b3f Merged-In: I48ac11364b06887cc4059bcda863b456e206c9bd --- src/com/android/settings/wifi/WifiSettings2.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java index 3b18f5a4fc7..79f48fb95b1 100644 --- a/src/com/android/settings/wifi/WifiSettings2.java +++ b/src/com/android/settings/wifi/WifiSettings2.java @@ -763,8 +763,13 @@ public class WifiSettings2 extends RestrictedSettingsFragment LongPressWifiEntryPreference pref = (LongPressWifiEntryPreference) getCachedPreference(key); if (pref != null) { - pref.setOrder(index++); - continue; + if (pref.getWifiEntry() == wifiEntry) { + pref.setOrder(index++); + continue; + } else { + // Create a new preference if the underlying WifiEntry object has changed + removePreference(key); + } } pref = createLongPressWifiEntryPreference(wifiEntry);