summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WifiConfigManager.java
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2018-10-29 18:00:16 -0700
committerxshu <xshu@google.com>2018-11-14 15:18:14 -0800
commitcae1409e541e63d767c6d6afd0aa5cbae9c2c213 (patch)
tree703d9d5d97d28f74af7aba02b85579ebc8e82f74 /service/java/com/android/server/wifi/WifiConfigManager.java
parentf4a1d0fc56034b3e652648603c4d00bc881bc18d (diff)
downloadandroid_frameworks_opt_net_wifi-cae1409e541e63d767c6d6afd0aa5cbae9c2c213.tar.gz
android_frameworks_opt_net_wifi-cae1409e541e63d767c6d6afd0aa5cbae9c2c213.tar.bz2
android_frameworks_opt_net_wifi-cae1409e541e63d767c6d6afd0aa5cbae9c2c213.zip
Pno recency sorting
WifiConfigManager: Modify PNO list ordering The PNO network list size that most drivers support is limited to 16, so we sort the user's saved networks to ensure that the most useful ones for the user is in the PNO watch list. The current logic sorts the networks based on the number of previous connection attempts (any ties are resolved based on when it was last seen in scan results). This has now been modified to move the last connected network to the top of the list followed by the previous sorting algo. This will ensure that we always auto-connect back immediately (when screen off) if there is any intermittent disconnection. Bug: 75956033 Test: compile, unit tests Change-Id: I5a3fcb232d48b6f5d7db4929c9e0eca4de63e017
Diffstat (limited to 'service/java/com/android/server/wifi/WifiConfigManager.java')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 8c40c6a13..25830b702 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -69,6 +69,7 @@ import java.util.BitSet;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -2465,7 +2466,23 @@ public class WifiConfigManager {
iter.remove();
}
}
+ if (networks.isEmpty()) {
+ return pnoList;
+ }
+
+ // Sort the networks with the most frequent ones at the front of the network list.
Collections.sort(networks, sScanListComparator);
+ // Find the most recently connected network and add it to the front of the network list.
+ WifiConfiguration lastConnectedNetwork =
+ networks.stream()
+ .max(Comparator.comparing(
+ (WifiConfiguration config) -> config.lastConnected))
+ .get();
+ if (lastConnectedNetwork.lastConnected != 0) {
+ int lastConnectedNetworkIdx = networks.indexOf(lastConnectedNetwork);
+ networks.remove(lastConnectedNetworkIdx);
+ networks.add(0, lastConnectedNetwork);
+ }
for (WifiConfiguration config : networks) {
WifiScanner.PnoSettings.PnoNetwork pnoNetwork =
WifiConfigurationUtil.createPnoNetwork(config);