summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-11-04 17:29:10 -0800
committerxshu <xshu@google.com>2019-11-21 13:38:02 -0800
commitab76156ea09cd07865322a077801d86b99b5ea25 (patch)
tree625f6aecfc0d30dcbeb792ed327c6007280ed615
parent81112baaccdab303cd586a621ea611f7cdce3dfb (diff)
Clear the Bssid blocklist when network is removed
The SSID blocklist is already being cleared when the network get removed. This CL makes it so that the BSSID blocklist is reset as well when a network is removed from the internal database for any reason. Bug: 139287182 Test: atest FrameworksWifiTests Change-Id: Ie0ba28bfb3cbfe8e996960f7a96ccf556dd77e48
-rw-r--r--service/java/com/android/server/wifi/BssidBlocklistMonitor.java10
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java1
-rw-r--r--service/java/com/android/server/wifi/WifiScoreCard.java16
-rw-r--r--tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java22
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java40
6 files changed, 89 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
index 2f0ba5ff1..72bbd4937 100644
--- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
+++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
@@ -259,6 +259,16 @@ public class BssidBlocklistMonitor {
}
/**
+ * Note the removal of a network from the Wifi stack's internal database and reset
+ * appropriate failure counters.
+ * @param ssid
+ */
+ public void handleNetworkRemoved(@NonNull String ssid) {
+ clearBssidBlocklistForSsid(ssid);
+ mWifiScoreCard.resetBssidBlocklistStreakForSsid(ssid);
+ }
+
+ /**
* Clears the blocklist for BSSIDs associated with the input SSID only.
* @param ssid
*/
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index e2dd98522..7a3250c98 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1488,6 +1488,7 @@ public class WifiConfigManager {
mScanDetailCaches.remove(config.networkId);
// Stage the backup of the SettingsProvider package which backs this up.
mBackupManagerProxy.notifyDataChanged();
+ mWifiInjector.getBssidBlocklistMonitor().handleNetworkRemoved(config.SSID);
localLog("removeNetworkInternal: removed config."
+ " netId=" + config.networkId
diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java
index 19f74d0f2..4a28452bd 100644
--- a/service/java/com/android/server/wifi/WifiScoreCard.java
+++ b/service/java/com/android/server/wifi/WifiScoreCard.java
@@ -406,6 +406,22 @@ public class WifiScoreCard {
lookupBssid(ssid, bssid).blocklistStreakCount[reason] = 0;
}
+ /**
+ * Clear the blocklist streak count for all APs that belong to this SSID.
+ */
+ public void resetBssidBlocklistStreakForSsid(@NonNull String ssid) {
+ Iterator<Map.Entry<MacAddress, PerBssid>> it = mApForBssid.entrySet().iterator();
+ while (it.hasNext()) {
+ PerBssid perBssid = it.next().getValue();
+ if (!ssid.equals(perBssid.ssid)) {
+ continue;
+ }
+ for (int i = 0; i < perBssid.blocklistStreakCount.length; i++) {
+ perBssid.blocklistStreakCount[i] = 0;
+ }
+ }
+ }
+
final class PerBssid {
public int id;
public final String l2Key;
diff --git a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
index 068859c78..16eb976ea 100644
--- a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
@@ -449,7 +449,8 @@ public class BssidBlocklistMonitorTest {
}
/**
- * Verify that the BSSID blocklist is cleared for the entire network.
+ * Verify that clearBssidBlocklistForSsid removes all BSSIDs for that network from the
+ * blocklist.
*/
@Test
public void testClearBssidBlocklistForSsid() {
@@ -462,5 +463,24 @@ public class BssidBlocklistMonitorTest {
Set<String> bssidList = mBssidBlocklistMonitor.updateAndGetBssidBlocklist();
assertEquals(1, bssidList.size());
assertTrue(bssidList.contains(TEST_BSSID_3));
+ verify(mWifiScoreCard, never()).resetBssidBlocklistStreakForSsid(TEST_SSID_1);
+ }
+
+ /**
+ * Verify that handleNetworkRemoved removes all BSSIDs for that network from the blocklist
+ * and also reset the blocklist streak count from WifiScoreCard.
+ */
+ @Test
+ public void testHandleNetworkRemovedResetsState() {
+ verifyAddMultipleBssidsToBlocklist();
+
+ // Clear the blocklist for SSID 1.
+ mBssidBlocklistMonitor.handleNetworkRemoved(TEST_SSID_1);
+
+ // Verify that the blocklist is deleted for SSID 1 and the BSSID for SSID 2 still remains.
+ Set<String> bssidList = mBssidBlocklistMonitor.updateAndGetBssidBlocklist();
+ assertEquals(1, bssidList.size());
+ assertTrue(bssidList.contains(TEST_BSSID_3));
+ verify(mWifiScoreCard).resetBssidBlocklistStreakForSsid(TEST_SSID_1);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index dd1f46db4..4cde2e5d0 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -5381,6 +5381,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
verifyNetworkRemoveBroadcast(configuration);
// Verify if the config store write was triggered without this new configuration.
verifyNetworkNotInConfigStoreData(configuration);
+ verify(mBssidBlocklistMonitor, atLeastOnce()).handleNetworkRemoved(configuration.SSID);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
index f1590144a..c02ecf0f8 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
@@ -154,6 +154,46 @@ public class WifiScoreCardTest extends WifiBaseTest {
}
/**
+ * Test clearing the blocklist streak for all APs belonging to a SSID.
+ */
+ @Test
+ public void testClearBssidBlocklistStreakForSsid() {
+ // Increment and verify the blocklist streak for SSID_1, BSSID_1
+ mWifiInfo.setSSID(TEST_SSID_1);
+ mWifiInfo.setBSSID(TEST_BSSID_1.toString());
+ mWifiScoreCard.noteIpConfiguration(mWifiInfo);
+ for (int i = 1; i < 3; i++) {
+ assertEquals(i, mWifiScoreCard.incrementBssidBlocklistStreak(
+ mWifiInfo.getSSID(), mWifiInfo.getBSSID(), TEST_BSSID_FAILURE_REASON));
+ assertEquals(i, mWifiScoreCard.getBssidBlocklistStreak(
+ mWifiInfo.getSSID(), mWifiInfo.getBSSID(), TEST_BSSID_FAILURE_REASON));
+ }
+
+ // Increment and verify the blocklist streak for SSID_2, BSSID_2
+ mWifiInfo.setSSID(TEST_SSID_2);
+ mWifiInfo.setBSSID(TEST_BSSID_2.toString());
+ mWifiScoreCard.noteIpConfiguration(mWifiInfo);
+ for (int i = 1; i < 3; i++) {
+ assertEquals(i, mWifiScoreCard.incrementBssidBlocklistStreak(
+ mWifiInfo.getSSID(), mWifiInfo.getBSSID(), TEST_BSSID_FAILURE_REASON));
+ assertEquals(i, mWifiScoreCard.getBssidBlocklistStreak(
+ mWifiInfo.getSSID(), mWifiInfo.getBSSID(), TEST_BSSID_FAILURE_REASON));
+ }
+
+ // Clear the blocklist streak for SSID_2
+ mWifiScoreCard.resetBssidBlocklistStreakForSsid(mWifiInfo.getSSID());
+ // Verify that the blocklist streak for SSID_2 is cleared.
+ assertEquals(0, mWifiScoreCard.getBssidBlocklistStreak(
+ mWifiInfo.getSSID(), mWifiInfo.getBSSID(), TEST_BSSID_FAILURE_REASON));
+
+ // verify that the blocklist streak for SSID_1 is not cleared.
+ mWifiInfo.setSSID(TEST_SSID_1);
+ mWifiInfo.setBSSID(TEST_BSSID_1.toString());
+ assertEquals(2, mWifiScoreCard.getBssidBlocklistStreak(
+ mWifiInfo.getSSID(), mWifiInfo.getBSSID(), TEST_BSSID_FAILURE_REASON));
+ }
+
+ /**
* Test identifiers.
*/
@Test