summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2018-06-13 14:15:22 -0700
committerxshu <xshu@google.com>2018-11-05 13:05:52 -0800
commitb0447cdb964c25577b7f02e4ae8ab4b1fcd3f603 (patch)
treea6097f7d763fa982cbfb9d6275c66da052ac923a /service
parent65ebbf8cdfddfe9aad4f94439bea59139e4616d7 (diff)
Pno channel culling: add frequencies to PnoNetworks
timestamped frequencies for each configured network are obtained from mScanDetailCaches. These frequencies are then linked to pno networks to pass down for frequency culling. Bug: 64312268 Test: compile Test: turn wifi verbose logging on; connect to TP-LINK_B6C1_5G with shield box open. Close shield box and wait for wifi to disconnect. Turn screen off and verify print out with logcat: WifiConfigManager: retrievePnoNetworkList "TP-LINK_B6C1_5G":[5785] Change-Id: I716d17a32528b2f78c977b463792f01df6712894
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java60
1 files changed, 58 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 4b622bf31..1fdabfa07 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -61,6 +61,7 @@ import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collection;
@@ -212,6 +213,12 @@ public class WifiConfigManager {
* Maximum age of scan results that can be used for averaging out RSSI value.
*/
private static final int SCAN_RESULT_MAXIMUM_AGE_MS = 40000;
+
+ /**
+ * Maximum age of frequencies last seen to be included in pno scans. (30 days)
+ */
+ @VisibleForTesting
+ public static final long MAX_PNO_SCAN_FREQUENCY_AGE_MS = (long) 1000 * 3600 * 24 * 30;
/**
* General sorting algorithm of all networks for scanning purposes:
* Place the configurations in descending order of their |numAssociation| values. If networks
@@ -278,6 +285,7 @@ public class WifiConfigManager {
* Number of channels to scan for during partial scans initiated while connected.
*/
private final int mMaxNumActiveChannelsForPartialScans;
+
/**
* Verbose logging flag. Toggled by developer options.
*/
@@ -374,7 +382,6 @@ public class WifiConfigManager {
R.bool.config_wifi_only_link_same_credential_configurations);
mMaxNumActiveChannelsForPartialScans = mContext.getResources().getInteger(
R.integer.config_wifi_framework_associated_partial_scan_max_num_active_channels);
-
try {
mSystemUiUid = mContext.getPackageManager().getPackageUidAsUser(SYSUI_PACKAGE_NAME,
PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM);
@@ -2358,6 +2365,42 @@ public class WifiConfigManager {
}
/**
+ * Retrieve a set of channels on which AP's for the provided network was seen using the
+ * internal ScanResult's cache {@link #mScanDetailCaches}. This is used to reduced the list
+ * of frequencies for pno scans.
+ *
+ * @param networkId network ID corresponding to the network.
+ * @param ageInMillis only consider scan details whose timestamps are earlier than this.
+ * @return Set containing the frequencies on which this network was found, null if the network
+ * was not found or there are no associated scan details in the cache.
+ */
+ private Set<Integer> fetchChannelSetForNetworkForPnoScan(int networkId, long ageInMillis) {
+ WifiConfiguration config = getInternalConfiguredNetwork(networkId);
+ if (config == null) {
+ return null;
+ }
+ ScanDetailCache scanDetailCache = getScanDetailCacheForNetwork(networkId);
+ if (scanDetailCache == null) {
+ return null;
+ }
+ if (mVerboseLoggingEnabled) {
+ Log.v(TAG, new StringBuilder("fetchChannelSetForNetworkForPnoScan ageInMillis ")
+ .append(ageInMillis)
+ .append(" for ")
+ .append(config.configKey())
+ .append(" bssids " + scanDetailCache.size())
+ .toString());
+ }
+ Set<Integer> channelSet = new HashSet<>();
+ long nowInMillis = mClock.getWallClockMillis();
+
+ // Add channels for the network to the output.
+ addToChannelSetForNetworkFromScanDetailCache(channelSet, scanDetailCache, nowInMillis,
+ ageInMillis, Integer.MAX_VALUE);
+ return channelSet;
+ }
+
+ /**
* Retrieves a list of all the saved networks before enabling disconnected/connected PNO.
*
* PNO network list sent to the firmware has limited size. If there are a lot of saved
@@ -2384,7 +2427,20 @@ public class WifiConfigManager {
Collections.sort(networks, sScanListComparator);
// The most frequently connected network has the highest priority now.
for (WifiConfiguration config : networks) {
- pnoList.add(WifiConfigurationUtil.createPnoNetwork(config));
+ WifiScanner.PnoSettings.PnoNetwork pnoNetwork =
+ WifiConfigurationUtil.createPnoNetwork(config);
+ Set<Integer> channelSet = fetchChannelSetForNetworkForPnoScan(config.networkId,
+ MAX_PNO_SCAN_FREQUENCY_AGE_MS);
+ if (channelSet != null) {
+ pnoNetwork.frequencies = channelSet.stream()
+ .mapToInt(Integer::intValue)
+ .toArray();
+ }
+ pnoList.add(pnoNetwork);
+ if (mVerboseLoggingEnabled) {
+ Log.v(TAG, "retrievePnoNetworkList " + pnoNetwork.ssid + ":"
+ + Arrays.toString(pnoNetwork.frequencies));
+ }
}
return pnoList;
}