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

Commit 7bd8eaf5 authored by Paul Jensen's avatar Paul Jensen
Browse files

Retry failed network validation every 10 minutes.

This allows for better recovery from ISP outages.

bug:18489123
Change-Id: Iefffe870bd6b7c19827fdbc323024a600a6025f9
parent c3056190
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -215,6 +215,8 @@ public class NetworkMonitor extends StateMachine {
    // Default to 5s reevaluation delay.
    private static final int DEFAULT_REEVALUATE_DELAY_MS = 5000;
    private static final int MAX_RETRIES = 10;
    // Between groups of MAX_RETRIES evaluation attempts, pause 10 mins in hopes ISP outage passes.
    private static final int REEVALUATE_PAUSE_MS = 10*60*1000;
    private final int mReevaluateDelayMs;
    private int mReevaluateToken = 0;
    private static final int INVALID_UID = -1;
@@ -345,6 +347,7 @@ public class NetworkMonitor extends StateMachine {
        public void enter() {
            mConnectivityServiceHandler.sendMessage(obtainMessage(EVENT_NETWORK_TESTED,
                    NETWORK_TEST_RESULT_INVALID, 0, mNetworkAgentInfo));
            if (!mUserDoesNotWant) sendMessageDelayed(CMD_FORCE_REEVALUATION, REEVALUATE_PAUSE_MS);
        }

        @Override
@@ -360,6 +363,15 @@ public class NetworkMonitor extends StateMachine {
                    return NOT_HANDLED;
            }
        }

        @Override
        public void exit() {
             // NOTE: This removes the delayed message posted by enter() but will inadvertently
             // remove any other CMD_FORCE_REEVALUATION in the message queue.  At the moment this
             // is harmless.  If in the future this becomes problematic a different message could
             // be used.
             removeMessages(CMD_FORCE_REEVALUATION);
        }
    }

    // Being in the ValidatedState State indicates a Network is: