summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-07-21 22:58:35 -0700
committerOscar Shu <xshu@google.com>2020-07-31 04:20:43 +0000
commitdd6ac245bb30bf99b3ef961f7b9fa3fe82261166 (patch)
tree8f8bd8efca5cf50e374d7dbaa7ce670ffe079704 /service
parent80ba61179919184ea4fb85f033b7e8efafcaa2a9 (diff)
Update firmware roaming config for connected network
Cherry-picked from: bced67a256fc7cd7fd001ec8445a651adf3a95fd Update the firmware configuration when the BSSID blocklist for the currently connected network changes. Bug: 161331429 Test: atest com.android.server.wifi Change-Id: I16c643beac6eaf21f9515032d470d0711c98fe5b Merged-In: I16c643beac6eaf21f9515032d470d0711c98fe5b
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/BssidBlocklistMonitor.java28
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java3
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java2
4 files changed, 31 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
index dffd77443..5b151d55f 100644
--- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
+++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
@@ -18,6 +18,7 @@ package com.android.server.wifi;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.util.ArrayMap;
@@ -448,11 +449,36 @@ public class BssidBlocklistMonitor {
* @param ssid
* @return the number of BSSIDs currently in the blocklist for the |ssid|.
*/
- public int getNumBlockedBssidsForSsid(@NonNull String ssid) {
+ public int updateAndGetNumBlockedBssidsForSsid(@NonNull String ssid) {
return (int) updateAndGetBssidBlocklistInternal()
.filter(entry -> ssid.equals(entry.ssid)).count();
}
+ private int getNumBlockedBssidsForSsid(@Nullable String ssid) {
+ if (ssid == null) {
+ return 0;
+ }
+ return (int) mBssidStatusMap.values().stream()
+ .filter(entry -> entry.isInBlocklist && ssid.equals(entry.ssid))
+ .count();
+ }
+
+ /**
+ * Overloaded version of updateAndGetBssidBlocklist.
+ * Accepts a @Nullable String ssid as input, and updates the firmware roaming
+ * configuration if the blocklist for the input ssid has been changed.
+ * @param ssid to update firmware roaming configuration for.
+ * @return Set of BSSIDs currently in the blocklist
+ */
+ public Set<String> updateAndGetBssidBlocklistForSsid(@Nullable String ssid) {
+ int numBefore = getNumBlockedBssidsForSsid(ssid);
+ Set<String> bssidBlocklist = updateAndGetBssidBlocklist();
+ if (getNumBlockedBssidsForSsid(ssid) != numBefore) {
+ updateFirmwareRoamingConfiguration(ssid);
+ }
+ return bssidBlocklist;
+ }
+
/**
* 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 5b5c968c1..45a5d90b9 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1801,7 +1801,7 @@ public class WifiConfigManager {
int disableReason = networkStatus.getNetworkSelectionDisableReason();
int blockedBssids = Math.min(MAX_BLOCKED_BSSID_PER_NETWORK,
mWifiInjector.getBssidBlocklistMonitor()
- .getNumBlockedBssidsForSsid(config.SSID));
+ .updateAndGetNumBlockedBssidsForSsid(config.SSID));
// if no BSSIDs are blocked then we should keep trying to connect to something
long disableTimeoutMs = 0;
if (blockedBssids > 0) {
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 2ce0bc024..131f4d1c1 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -304,7 +304,8 @@ public class WifiConnectivityManager {
updateUserDisabledList(scanDetails);
// Check if any blocklisted BSSIDs can be freed.
- Set<String> bssidBlocklist = mBssidBlocklistMonitor.updateAndGetBssidBlocklist();
+ Set<String> bssidBlocklist = mBssidBlocklistMonitor.updateAndGetBssidBlocklistForSsid(
+ mWifiInfo.getSSID());
if (mStateMachine.isSupplicantTransientState()) {
localLog(listenerName
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index a7544e031..6c2b5e369 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -1459,7 +1459,7 @@ public class WifiMetrics {
mScanResultRssiTimestampMillis = mClock.getElapsedSinceBootMillis();
}
mCurrentConnectionEvent.mConnectionEvent.numBssidInBlocklist =
- mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(config.SSID);
+ mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(config.SSID);
mCurrentConnectionEvent.mConnectionEvent.networkType =
WifiMetricsProto.ConnectionEvent.TYPE_UNKNOWN;
mCurrentConnectionEvent.mConnectionEvent.isOsuProvisioned = false;