From 2412817201a39340f8f91b873fb0d1dddf3feb88 Mon Sep 17 00:00:00 2001 From: Sundeep Ghuman Date: Thu, 15 Jun 2017 17:55:21 -0700 Subject: [PATCH] APs from old scans should not have RSSI values set. This change creates parity between 'initWithScanResult' and 'update(ScanResult)' so that RSSIs are set similarly. This avoids an edge case problem when starting WifiSettings and only having very old scan results available (eg, coming from a screen off state), in which the old APs would have been shown and then instantly removed due to a sequential WifiTracker call to update the APs based on sticky broadcasts. Otherwise worded, creating an AP with a scan result and then instantly updating it with that same scan result would drastically change the state of the AccessPoint object. Bug: b/38212080 Test: With old scan results in the scanner (screen off more than 15 seconds), start wifi settings. Old APs should not be shown and then instantly removed. Change-Id: Ida13713dc115ba04882a7651eab4ebfd5cccbe7c --- .../src/com/android/settingslib/wifi/AccessPoint.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index 623d1a6716a7a..0ea9d96bbe830 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -511,7 +511,10 @@ public class AccessPoint implements Comparable { } } - mSeen = seen; + // Only replace the previous value if we have a recent scan result to use + if (seen != 0) { + mSeen = seen; + } } /** @@ -940,8 +943,10 @@ public class AccessPoint implements Comparable { security = getSecurity(result); if (security == SECURITY_PSK) pskType = getPskType(result); - mRssi = result.level; - mSeen = result.timestamp; + + mScanResultCache.put(result.BSSID, result); + updateRssi(); + mSeen = result.timestamp; // even if the timestamp is old it is still valid } public void saveWifiState(Bundle savedState) {