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

Commit 34df6c0a authored by Sundeep Ghuman's avatar Sundeep Ghuman Committed by android-build-merger
Browse files

Merge "Do not clear scores during stopTracking." into oc-dr1-dev

am: 3b63aa79

Change-Id: Iab18b4e433aa1de2bb4acde5db2e8b8ea5a56710
parents 82bc6719 3b63aa79
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -365,7 +365,7 @@ public class WifiTracker {
                mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
                mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
                mRegistered = false;
                mRegistered = false;
            }
            }
            unregisterAndClearScoreCache();
            unregisterScoreCache();
            pauseScanning();
            pauseScanning();
            mContext.getContentResolver().unregisterContentObserver(mObserver);
            mContext.getContentResolver().unregisterContentObserver(mObserver);


@@ -375,11 +375,14 @@ public class WifiTracker {
        mStaleScanResults = true;
        mStaleScanResults = true;
    }
    }


    private void unregisterAndClearScoreCache() {
    private void unregisterScoreCache() {
        mNetworkScoreManager.unregisterNetworkScoreCache(NetworkKey.TYPE_WIFI, mScoreCache);
        mNetworkScoreManager.unregisterNetworkScoreCache(NetworkKey.TYPE_WIFI, mScoreCache);
        mScoreCache.clearScores();


        // Synchronize on mLock to avoid concurrent modification during updateAccessPoints
        // We do not want to clear the existing scores in the cache, as this method is called during
        // stop tracking on activity pause. Hence, on resumption we want the ability to show the
        // last known, potentially stale, scores. However, by clearing requested scores, the scores
        // will be requested again upon resumption of tracking, and if any changes have occurred
        // the listeners (UI) will be updated accordingly.
        synchronized (mLock) {
        synchronized (mLock) {
            mRequestedScores.clear();
            mRequestedScores.clear();
        }
        }
+11 −0
Original line number Original line Diff line number Diff line
@@ -472,6 +472,17 @@ public class WifiTrackerTest {
        assertTrue(mRequestedKeys.contains(NETWORK_KEY_2));
        assertTrue(mRequestedKeys.contains(NETWORK_KEY_2));
    }
    }


    @Test
    public void stopTracking_shouldNotClearExistingScores()
            throws InterruptedException {
        // Start the tracker and inject the initial scan results and then stop tracking
        WifiTracker tracker =  createTrackerWithImmediateBroadcastsAndInjectInitialScanResults();
        updateScoresAndWaitForAccessPointsChangedCallback(tracker);
        tracker.stopTracking();

        assertThat(mScoreCacheCaptor.getValue().getScoredNetwork(NETWORK_KEY_1)).isNotNull();
    }

    @Test
    @Test
    public void scoreCacheUpdateScoresShouldTriggerOnAccessPointsChanged()
    public void scoreCacheUpdateScoresShouldTriggerOnAccessPointsChanged()
            throws InterruptedException {
            throws InterruptedException {