Synchronized WifiTracker scan result cache update logic
Race condition seemingly leads to ConcurrentModificationExceptions in
updateScanResultCache. This should be moved to the synchronized block in
updateAccessPoints.
Test: atest WifiTrackerTest
Bug: 132049411
Change-Id: I7f6d7d51465880a61209822efd42dc9c6251906b
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
index 5f2bc4e..ab8ba63 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
@@ -549,8 +549,6 @@
configsByKey.put(AccessPoint.getKey(config), config);
}
}
- ArrayMap<String, List<ScanResult>> scanResultsByApKey =
- updateScanResultCache(newScanResults);
WifiConfiguration connectionConfig = null;
if (mLastInfo != null) {
@@ -560,6 +558,9 @@
// Rather than dropping and reacquiring the lock multiple times in this method, we lock
// once for efficiency of lock acquisition time and readability
synchronized (mLock) {
+ ArrayMap<String, List<ScanResult>> scanResultsByApKey =
+ updateScanResultCache(newScanResults);
+
// Swap the current access points into a cached list for maintaining AP listeners
List<AccessPoint> cachedAccessPoints;
cachedAccessPoints = new ArrayList<>(mInternalAccessPoints);