summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2019-05-30 15:26:36 -0700
committerMichael Plass <mplass@google.com>2019-06-03 02:09:12 +0000
commit13d755aca12a1e9b252fbfb8f36670dc0fb7ed71 (patch)
treedbb9cacf044222d1c98d3d24f291f8b544f90956
parentd730fef342daccb305f4cc20576c98601d05e44b (diff)
downloadandroid_frameworks_opt_net_wifi-13d755aca12a1e9b252fbfb8f36670dc0fb7ed71.tar.gz
android_frameworks_opt_net_wifi-13d755aca12a1e9b252fbfb8f36670dc0fb7ed71.tar.bz2
android_frameworks_opt_net_wifi-13d755aca12a1e9b252fbfb8f36670dc0fb7ed71.zip
[WifiNetworkSelector] User-selected network is sufficient for a while
Skip autojoin for the first few seconds of a user-initiated connection. This avoids early disconnection before the user has had a chance to respond to a no-internet or limited internet dialog, and allows some additional time for validation to succeed in case the dialog is not noticed. Bug: 130766237 Test: atest WifiNetworkSelectorTest Change-Id: I0a06135afef1876af385829d131a0e52b1884900
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSelector.java18
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java33
2 files changed, 51 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java
index 4b7e3f02b..85bd9174a 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSelector.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java
@@ -56,6 +56,7 @@ public class WifiNetworkSelector {
private static final String TAG = "WifiNetworkSelector";
private static final long INVALID_TIME_STAMP = Long.MIN_VALUE;
+
/**
* Minimum time gap between last successful network selection and a
* new selection attempt.
@@ -64,6 +65,15 @@ public class WifiNetworkSelector {
public static final int MINIMUM_NETWORK_SELECTION_INTERVAL_MS = 10 * 1000;
/**
+ * For this duration after user selected it, consider the current network as sufficient.
+ *
+ * This delays network selection during the time that connectivity service may be posting
+ * a dialog about a no-internet network.
+ */
+ @VisibleForTesting
+ public static final int LAST_USER_SELECTION_SUFFICIENT_MS = 30_000;
+
+ /**
* Time that it takes for the boost given to the most recently user-selected
* network to decay to zero.
*
@@ -235,6 +245,14 @@ public class WifiNetworkSelector {
return false;
}
+ if (mWifiConfigManager.getLastSelectedNetwork() == network.networkId
+ && (mClock.getElapsedSinceBootMillis()
+ - mWifiConfigManager.getLastSelectedTimeStamp())
+ <= LAST_USER_SELECTION_SUFFICIENT_MS) {
+ localLog("Current network is recently user-selected.");
+ return true;
+ }
+
// OSU (Online Sign Up) network for Passpoint Release 2 is sufficient network.
if (network.osu) {
return true;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
index 53dae5229..bd7256a76 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
@@ -960,6 +960,39 @@ public class WifiNetworkSelectorTest {
}
/**
+ * New network selection is not performed if the currently connected network
+ * was recently selected.
+ */
+ @Test
+ public void networkIsSufficientWhenRecentlyUserSelected() {
+ // Approximate mClock.getElapsedSinceBootMillis value mocked by testStayOrTryToSwitch
+ long millisSinceBoot = SystemClock.elapsedRealtime()
+ + WifiNetworkSelector.MINIMUM_NETWORK_SELECTION_INTERVAL_MS + 2000;
+ when(mWifiConfigManager.getLastSelectedTimeStamp())
+ .thenReturn(millisSinceBoot
+ - WifiNetworkSelector.LAST_USER_SELECTION_SUFFICIENT_MS
+ + 1000);
+ setupWifiConfigManager(0); // testStayOrTryToSwitch first connects to network 0
+ // Rssi after connected.
+ when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1);
+ // No streaming traffic.
+ mWifiInfo.txSuccessRate = 0.0;
+ mWifiInfo.rxSuccessRate = 0.0;
+
+ testStayOrTryToSwitch(
+ // Parameters for network1:
+ mThresholdQualifiedRssi2G + 1 /* rssi before connected */,
+ false /* not a 5G network */,
+ false /* not open network */,
+ // Parameters for network2:
+ mThresholdQualifiedRssi5G + 1 /* rssi */,
+ true /* a 5G network */,
+ false /* not open network */,
+ // Should not try to switch.
+ false);
+ }
+
+ /**
* New network selection is performed if the currently connected network
* band is 2G with bad rssi.
*