Skip to content

Commit 0f43161

Browse files
committed
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
1 parent 50dabc5 commit 0f43161

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

wifi/java/android/net/wifi/WifiStateMachine.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,14 @@ public class WifiStateMachine extends StateMachine {
381381
*/
382382
private final int mDefaultSupplicantScanIntervalMs;
383383

384+
/**
385+
* Minimum time interval between enabling all networks.
386+
* A device can end up repeatedly connecting to a bad network on screen on/off toggle
387+
* due to enabling every time. We add a threshold to avoid this.
388+
*/
389+
private static final int MIN_INTERVAL_ENABLE_ALL_NETWORKS_MS = 10 * 60 * 1000; /* 10 minutes */
390+
private long mLastEnableAllNetworksTime;
391+
384392

385393
private static final int MIN_RSSI = -200;
386394
private static final int MAX_RSSI = 256;
@@ -2248,7 +2256,11 @@ public boolean processMessage(Message message) {
22482256
mReplyChannel.replyToMessage(message, message.what, ok ? SUCCESS : FAILURE);
22492257
break;
22502258
case CMD_ENABLE_ALL_NETWORKS:
2251-
WifiConfigStore.enableAllNetworks();
2259+
long time = android.os.SystemClock.elapsedRealtime();
2260+
if (time - mLastEnableAllNetworksTime > MIN_INTERVAL_ENABLE_ALL_NETWORKS_MS) {
2261+
WifiConfigStore.enableAllNetworks();
2262+
mLastEnableAllNetworksTime = time;
2263+
}
22522264
break;
22532265
case CMD_DISABLE_NETWORK:
22542266
ok = WifiConfigStore.disableNetwork(message.arg1, message.arg2);

0 commit comments

Comments
 (0)