summaryrefslogtreecommitdiffstats
path: root/wifi/java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-10-05 12:40:00 -0700
committerIrfan Sheriff <isheriff@google.com>2011-10-05 12:49:13 -0700
commit0f43161150903a008a5fd703078cdf446601160a (patch)
tree6c5ed6f56b7ecd74964e790adc328cc0a08d9b5c /wifi/java
parent50dabc5f0efbe2c4a987579cb2ad94132ee587be (diff)
downloadframeworks_base-0f43161150903a008a5fd703078cdf446601160a.zip
frameworks_base-0f43161150903a008a5fd703078cdf446601160a.tar.gz
frameworks_base-0f43161150903a008a5fd703078cdf446601160a.tar.bz2
Add a time threshold for re-enabling networks
Reconnecting to a bad network can be expensive (network down time wise and for the device as well). Add a minimum threshold. Bug: 5234206 Change-Id: I5ef1fe06038db73c29a3e95b6229506555f36c77
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 1e45f68..55e9587 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -381,6 +381,14 @@ public class WifiStateMachine extends StateMachine {
*/
private final int mDefaultSupplicantScanIntervalMs;
+ /**
+ * Minimum time interval between enabling all networks.
+ * A device can end up repeatedly connecting to a bad network on screen on/off toggle
+ * due to enabling every time. We add a threshold to avoid this.
+ */
+ private static final int MIN_INTERVAL_ENABLE_ALL_NETWORKS_MS = 10 * 60 * 1000; /* 10 minutes */
+ private long mLastEnableAllNetworksTime;
+
private static final int MIN_RSSI = -200;
private static final int MAX_RSSI = 256;
@@ -2248,7 +2256,11 @@ public class WifiStateMachine extends StateMachine {
mReplyChannel.replyToMessage(message, message.what, ok ? SUCCESS : FAILURE);
break;
case CMD_ENABLE_ALL_NETWORKS:
- WifiConfigStore.enableAllNetworks();
+ long time = android.os.SystemClock.elapsedRealtime();
+ if (time - mLastEnableAllNetworksTime > MIN_INTERVAL_ENABLE_ALL_NETWORKS_MS) {
+ WifiConfigStore.enableAllNetworks();
+ mLastEnableAllNetworksTime = time;
+ }
break;
case CMD_DISABLE_NETWORK:
ok = WifiConfigStore.disableNetwork(message.arg1, message.arg2);