From 80d0986ea4ec6d2bff2af02a9e1a31593c200540 Mon Sep 17 00:00:00 2001 From: xshu Date: Thu, 10 Sep 2020 19:46:04 -0700 Subject: Exponential backoff for external score blocklist (cherry-picked from 89ab95af87eff69a5865124fc4bc529e1f6efb52) Changes: 1. When the external scorer marks a network as unacceptable, block the BSSID for 0.5/1/2/... up to 64 minutes instead of the previous fixed 30 seconds. 2. Modified test cases to increase coverage. Bug: 158695052 Test: atest com.android.server.wifi Change-Id: I0f1413563530c8e66ea6a061c78bc49bffd61091 --- .../com/android/server/wifi/BssidBlocklistMonitor.java | 16 ++++++++++++++-- .../java/com/android/server/wifi/WifiScoreReport.java | 4 +--- service/res/values/config.xml | 7 +++++++ service/res/values/overlayable.xml | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java index d96fdb39e..e3fe32ab7 100644 --- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java +++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java @@ -330,8 +330,7 @@ public class BssidBlocklistMonitor { if (shouldWaitForWatchdogToTriggerFirst(bssid, reasonCode)) { return false; } - int baseBlockDurationMs = mContext.getResources().getInteger( - R.integer.config_wifiBssidBlocklistMonitorBaseBlockDurationMs); + int baseBlockDurationMs = getBaseBlockDurationForReason(reasonCode); addToBlocklist(entry, getBlocklistDurationWithExponentialBackoff(currentStreak, baseBlockDurationMs), reasonCode, rssi); @@ -341,6 +340,17 @@ public class BssidBlocklistMonitor { return false; } + private int getBaseBlockDurationForReason(int blockReason) { + switch (blockReason) { + case REASON_FRAMEWORK_DISCONNECT_CONNECTED_SCORE: + return mContext.getResources().getInteger(R.integer + .config_wifiBssidBlocklistMonitorConnectedScoreBaseBlockDurationMs); + default: + return mContext.getResources().getInteger( + R.integer.config_wifiBssidBlocklistMonitorBaseBlockDurationMs); + } + } + /** * Note a failure event on a bssid and perform appropriate actions. * @return True if the blocklist has been modified. @@ -383,6 +393,8 @@ public class BssidBlocklistMonitor { ssid, bssid, connectionTime); if (connectionTime - prevConnectionTime > ABNORMAL_DISCONNECT_RESET_TIME_MS) { mWifiScoreCard.resetBssidBlocklistStreak(ssid, bssid, REASON_ABNORMAL_DISCONNECT); + mWifiScoreCard.resetBssidBlocklistStreak(ssid, bssid, + REASON_FRAMEWORK_DISCONNECT_CONNECTED_SCORE); } BssidStatus status = mBssidStatusMap.get(bssid); diff --git a/service/java/com/android/server/wifi/WifiScoreReport.java b/service/java/com/android/server/wifi/WifiScoreReport.java index 80a561d05..bd92c6dac 100644 --- a/service/java/com/android/server/wifi/WifiScoreReport.java +++ b/service/java/com/android/server/wifi/WifiScoreReport.java @@ -60,7 +60,6 @@ public class WifiScoreReport { private static final int WIFI_CONNECTED_NETWORK_SCORER_IDENTIFIER = 0; private static final int INVALID_SESSION_ID = -1; private static final long MIN_TIME_TO_WAIT_BEFORE_BLOCKLIST_BSSID_MILLIS = 29000; - private static final long DURATION_TO_BLOCKLIST_BSSID_AFTER_FIRST_EXITING_MILLIS = 30000; private static final long INVALID_WALL_CLOCK_MILLIS = -1; /** @@ -751,9 +750,8 @@ public class WifiScoreReport { if ((mLastScoreBreachLowTimeMillis != INVALID_WALL_CLOCK_MILLIS) && ((millis - mLastScoreBreachLowTimeMillis) >= MIN_TIME_TO_WAIT_BEFORE_BLOCKLIST_BSSID_MILLIS)) { - mBssidBlocklistMonitor.blockBssidForDurationMs(mWifiInfo.getBSSID(), + mBssidBlocklistMonitor.handleBssidConnectionFailure(mWifiInfo.getBSSID(), mWifiInfo.getSSID(), - DURATION_TO_BLOCKLIST_BSSID_AFTER_FIRST_EXITING_MILLIS, BssidBlocklistMonitor.REASON_FRAMEWORK_DISCONNECT_CONNECTED_SCORE, mWifiInfo.getRssi()); mLastScoreBreachLowTimeMillis = INVALID_WALL_CLOCK_MILLIS; diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 1220c260a..0264c3eae 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -355,6 +355,13 @@ config_wifiBssidBlocklistMonitorFailureStreakCap is set to 7--> 300000 + + 30000 +