summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-11-01 17:06:12 -0700
committerxshu <xshu@google.com>2019-11-21 13:37:56 -0800
commit81112baaccdab303cd586a621ea611f7cdce3dfb (patch)
treed2f0667adf2280edec2c5556266f7cddcbde5c46 /service
parent622b812139bdeb88a675d6126f94b15ed1ff4336 (diff)
Add exponential backoff on the network level
Use the number of BSSIDs in the BSSID blocklist to determine how long we should temporarily disable networks. This check to re-enable networks is done every time before network selection: - if the elapsed time from now to the time the network was disabled is greater than or equal to a timeout then re-enable the network. The timeout calculated based on how many BSSIDs are in the BSSID blocklist: - 0 BSSID = 0ms (re-enable immediately) - 1 BSSID = 5 minutes - 2 BSSIDs = 10 minutes - 3 BSSIDS = 20 minutes ... Bug: 139287182 Test: atest FrameworksWifiTests Change-Id: I009c5410898b09045b42adf4a1f48c05a268fba3
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/BssidBlocklistMonitor.java9
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java17
2 files changed, 25 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
index 7aab09cc5..2f0ba5ff1 100644
--- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
+++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
@@ -283,6 +283,15 @@ public class BssidBlocklistMonitor {
}
/**
+ * @param ssid
+ * @return the number of BSSIDs currently in the blocklist for the |ssid|.
+ */
+ public int getNumBlockedBssidsForSsid(@NonNull String ssid) {
+ return (int) updateAndGetBssidBlocklistInternal()
+ .filter(entry -> ssid.equals(entry.ssid)).count();
+ }
+
+ /**
* Gets the BSSIDs that are currently in the blocklist.
* @return Set of BSSIDs currently in the blocklist
*/
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 18b5562b3..e2dd98522 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -219,6 +219,12 @@ public class WifiConfigManager {
private static final int SCAN_RESULT_MAXIMUM_AGE_MS = 40000;
/**
+ * Maximum number of blocked BSSIDs per SSID used for calcualting the duration of temporarily
+ * disabling a network.
+ */
+ private static final int MAX_BLOCKED_BSSID_PER_NETWORK = 10;
+
+ /**
* Maximum age of frequencies last seen to be included in pno scans. (30 days)
*/
@VisibleForTesting
@@ -1892,7 +1898,16 @@ public class WifiConfigManager {
long timeDifferenceMs =
mClock.getElapsedSinceBootMillis() - networkStatus.getDisableTime();
int disableReason = networkStatus.getNetworkSelectionDisableReason();
- long disableTimeoutMs = NETWORK_SELECTION_DISABLE_TIMEOUT_MS[disableReason];
+ int blockedBssids = Math.min(MAX_BLOCKED_BSSID_PER_NETWORK,
+ mWifiInjector.getBssidBlocklistMonitor()
+ .getNumBlockedBssidsForSsid(config.SSID));
+ // if no BSSIDs are blocked then we should keep trying to connect to something
+ long disableTimeoutMs = 0;
+ if (blockedBssids > 0) {
+ double multiplier = Math.pow(2.0, blockedBssids - 1.0);
+ disableTimeoutMs = (long) (NETWORK_SELECTION_DISABLE_TIMEOUT_MS[disableReason]
+ * multiplier);
+ }
if (timeDifferenceMs >= disableTimeoutMs) {
return updateNetworkSelectionStatus(
config, NetworkSelectionStatus.NETWORK_SELECTION_ENABLE);