Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f431611 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

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
parent 50dabc5f
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -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:
                    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);