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

Commit 68bd84c0 authored by Jason Monk's avatar Jason Monk Committed by The Android Automerger
Browse files

Fix wifi crash

Handle clearing state for resume on the same worker thread as everything
else, this way there can't be concurrent modification.

Bug: 22040227
Change-Id: I9ac78a19fc126c8103f3218e657ca93911d3890d
parent 8e85349e
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -176,10 +176,7 @@ public class WifiTracker {
            mScanner = new Scanner();
        }

        mScanResultCache.clear();
        mSeenBssids.clear();
        mScanId = 0;

        mWorkHandler.sendEmptyMessage(WorkHandler.MSG_RESUME);
        if (mWifiManager.isWifiEnabled()) {
            mScanner.resume();
        }
@@ -251,6 +248,12 @@ public class WifiTracker {
        }
    }

    private void handleResume() {
        mScanResultCache.clear();
        mSeenBssids.clear();
        mScanId = 0;
    }

    private Collection<ScanResult> fetchScanResults() {
        mScanId++;
        final List<ScanResult> newResults = mWifiManager.getScanResults();
@@ -544,6 +547,7 @@ public class WifiTracker {
    private final class WorkHandler extends Handler {
        private static final int MSG_UPDATE_ACCESS_POINTS = 0;
        private static final int MSG_UPDATE_NETWORK_INFO = 1;
        private static final int MSG_RESUME = 2;

        public WorkHandler(Looper looper) {
            super(looper);
@@ -558,6 +562,9 @@ public class WifiTracker {
                case MSG_UPDATE_NETWORK_INFO:
                    updateNetworkInfo((NetworkInfo) msg.obj);
                    break;
                case MSG_RESUME:
                    handleResume();
                    break;
            }
        }
    }