diff options
author | Oscar Shu <xshu@google.com> | 2020-03-31 17:20:53 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-31 17:20:53 +0000 |
commit | fb2b258c11c0685f33e5d92ae6a6f37649ab5b0f (patch) | |
tree | 8884eeeff1cbf3dd7f734fd0eacc580a2d2aba08 | |
parent | b98ca721f6efed2fe85c07153e05e6410e741af4 (diff) | |
parent | 80a67d1ff05a0bdeb990b35f3e1588a83e174374 (diff) |
Merge "Treat BSSIDs blocked by MBO same as other BSSIDs" into rvc-dev
-rw-r--r-- | service/java/com/android/server/wifi/BssidBlocklistMonitor.java | 20 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java | 13 |
2 files changed, 13 insertions, 20 deletions
diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java index 897090c82..70c919340 100644 --- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java +++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java @@ -154,13 +154,10 @@ public class BssidBlocklistMonitor { pw.println("BssidBlocklistMonitor - Bssid blocklist End ----"); } - private void addToBlocklist(@NonNull BssidStatus entry, long durationMs, - boolean doNotClearUntilTimeout, String reasonString) { + private void addToBlocklist(@NonNull BssidStatus entry, long durationMs, String reasonString) { entry.addToBlocklist(durationMs); - entry.doNotClearUntilTimeout = doNotClearUntilTimeout; localLog(TAG + " addToBlocklist: bssid=" + entry.bssid + ", ssid=" + entry.ssid - + ", durationMs=" + durationMs + ", doNotClearUntilTimeout=" - + doNotClearUntilTimeout + ", reason=" + reasonString); + + ", durationMs=" + durationMs + ", reason=" + reasonString); } /** @@ -223,8 +220,7 @@ public class BssidBlocklistMonitor { // Return because this BSSID is already being blocked for a longer time. return; } - addToBlocklist(status, durationMs, true, - FAILURE_BSSID_BLOCKED_BY_FRAMEWORK_REASON_STRING); + addToBlocklist(status, durationMs, FAILURE_BSSID_BLOCKED_BY_FRAMEWORK_REASON_STRING); } private String getFailureReasonString(@FailureReason int reasonCode) { @@ -289,7 +285,7 @@ public class BssidBlocklistMonitor { } addToBlocklist(entry, getBlocklistDurationWithExponentialBackoff(currentStreak, baseBlockDurationMs), - false, getFailureReasonString(reasonCode)); + getFailureReasonString(reasonCode)); mWifiScoreCard.incrementBssidBlocklistStreak(ssid, bssid, reasonCode); return true; } @@ -403,8 +399,7 @@ public class BssidBlocklistMonitor { */ public void clearBssidBlocklistForSsid(@NonNull String ssid) { int prevSize = mBssidStatusMap.size(); - mBssidStatusMap.entrySet().removeIf(e -> !e.getValue().doNotClearUntilTimeout - && e.getValue().ssid.equals(ssid)); + mBssidStatusMap.entrySet().removeIf(e -> e.getValue().ssid.equals(ssid)); int diff = prevSize - mBssidStatusMap.size(); if (diff > 0) { localLog(TAG + " clearBssidBlocklistForSsid: SSID=" + ssid @@ -418,7 +413,7 @@ public class BssidBlocklistMonitor { public void clearBssidBlocklist() { if (mBssidStatusMap.size() > 0) { int prevSize = mBssidStatusMap.size(); - mBssidStatusMap.entrySet().removeIf(e -> !e.getValue().doNotClearUntilTimeout); + mBssidStatusMap.clear(); localLog(TAG + " clearBssidBlocklist: num BSSIDs cleared=" + (prevSize - mBssidStatusMap.size())); } @@ -506,9 +501,6 @@ public class BssidBlocklistMonitor { // The following are used to flag how long this BSSID stays in the blocklist. public boolean isInBlocklist; public long blocklistEndTimeMs; - // Indicate that this BSSID should not be removed from blacklist through other means - // such as |clearBssidBlocklist| and |clearBssidBlocklistForSsid| - public boolean doNotClearUntilTimeout; BssidStatus(String bssid, String ssid) { this.bssid = bssid; diff --git a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java index 00afa91f1..2567faa91 100644 --- a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java @@ -628,14 +628,15 @@ public class BssidBlocklistMonitorTest { when(mClock.getWallClockMillis()).thenReturn(0L); long testDuration = 5500L; mBssidBlocklistMonitor.blockBssidForDurationMs(TEST_BSSID_1, TEST_SSID_1, testDuration); + assertEquals(1, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size()); - // Verify that the BSSID is not removed from blocklist dispite of regular "clear" calls. - when(mClock.getWallClockMillis()).thenReturn(testDuration); - mBssidBlocklistMonitor.clearBssidBlocklist(); + // Verify that the BSSID is removed from blocklist by clearBssidBlocklistForSsid mBssidBlocklistMonitor.clearBssidBlocklistForSsid(TEST_SSID_1); - Set<String> bssidList = mBssidBlocklistMonitor.updateAndGetBssidBlocklist(); - assertEquals(1, bssidList.size()); - assertTrue(bssidList.contains(TEST_BSSID_1)); + assertEquals(0, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size()); + + // Add the BSSID to blocklist again. + mBssidBlocklistMonitor.blockBssidForDurationMs(TEST_BSSID_1, TEST_SSID_1, testDuration); + assertEquals(1, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size()); // Verify that the BSSID is removed from blocklist once the specified duration is over. when(mClock.getWallClockMillis()).thenReturn(testDuration + 1); |