summaryrefslogtreecommitdiffstats
path: root/service/java/com
diff options
context:
space:
mode:
authorvandwalle <vandwalle@google.com>2014-12-10 13:16:41 -0800
committervandwalle <vandwalle@google.com>2014-12-11 16:16:33 -0800
commit63105d275289943504a292de18e6516e79b15148 (patch)
tree8c2396e497195fc570a764e326ae1c871860b45d /service/java/com
parenta1c02f0a73ee35e198e2652cd65b8830a163d9dd (diff)
downloadandroid_frameworks_opt_net_wifi-63105d275289943504a292de18e6516e79b15148.tar.gz
android_frameworks_opt_net_wifi-63105d275289943504a292de18e6516e79b15148.tar.bz2
android_frameworks_opt_net_wifi-63105d275289943504a292de18e6516e79b15148.zip
make sure wificonfiguration scan cache doesnt grow unbounded
Bug:18703749 Change-Id: If6452e7dbaaabb164cf2a99b48b3964f4cb86ee5
Diffstat (limited to 'service/java/com')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigStore.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index cf4163557..cd7cb5789 100644
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -389,6 +389,8 @@ public class WifiConfigStore extends IpConfigStore {
public int currentNetworkBoost = 25;
public int scanResultRssiLevelPatchUp = -85;
+ public static final int maxNumScanCacheEntries = 128;
+
/**
* Regex pattern for extracting a connect choice.
* Matches a strings like the following:
@@ -2103,7 +2105,6 @@ public class WifiConfigStore extends IpConfigStore {
}
if (key.startsWith(BSSID_KEY_END)) {
-
if ((bssid != null) && (ssid != null)) {
if (config.scanResultCache == null) {
@@ -3358,6 +3359,13 @@ public class WifiConfigStore extends IpConfigStore {
scanResult.untrusted = true;
}
+ if (config.scanResultCache.size() > (maxNumScanCacheEntries+64)) {
+ // Trim the scan result cache to maxNumScanCacheEntries entries max
+ // Since this operation is expensive, make sure it is not performed
+ // until the cache has grown significantly above the trim treshold
+ config.trimScanResultsCache(maxNumScanCacheEntries);
+ }
+
// Add the scan result to this WifiConfiguration
config.scanResultCache.put(scanResult.BSSID, scanResult);
// Since we added a scan result to this configuration, re-attempt linking