Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af15d3de authored by Quang Luong's avatar Quang Luong
Browse files

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
parent c1a72db8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -549,8 +549,6 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
                configsByKey.put(AccessPoint.getKey(config), config);
            }
        }
        ArrayMap<String, List<ScanResult>> scanResultsByApKey =
                updateScanResultCache(newScanResults);

        WifiConfiguration connectionConfig = null;
        if (mLastInfo != null) {
@@ -560,6 +558,9 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
        // 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);