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

Commit b6dbfb4e authored by Chiachang Wang's avatar Chiachang Wang
Browse files

Skip data stall check on unnecessary network

Except validation required networks, validation will be skipped.
Even there is signal comes from those networks, the validation
will not be proceeded and come back to ValidatedState. Thus, skip
the unnecessary state transition.

Bug: 144488209
Bug: 145275899
Test: atest NetworkStackTests NetworkStackNextTests
Change-Id: I6271cf812bc438882bfba94ca91673471814061c
parent 8e23204c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2253,6 +2253,10 @@ public class NetworkMonitor extends StateMachine {

    @VisibleForTesting
    protected boolean isDataStall() {
        if (!isValidationRequired()) {
            return false;
        }

        Boolean result = null;
        final StringJoiner msg = (DBG || VDBG_STALL) ? new StringJoiner(", ") : null;
        // Reevaluation will generate traffic. Thus, set a minimal reevaluation timer to limit the
+13 −0
Original line number Diff line number Diff line
@@ -814,6 +814,19 @@ public class NetworkMonitorTest {
        assertTrue(wrappedMonitor.isDataStall());
    }

    @Test
    public void testIsDataStall_SkipEvaluateOnValidationNotRequiredNetwork() {
        // Make DNS and TCP stall condition satisfied.
        setDataStallEvaluationType(DATA_STALL_EVALUATION_TYPE_DNS | DATA_STALL_EVALUATION_TYPE_TCP);
        when(mTstDependencies.isTcpInfoParsingSupported()).thenReturn(true);
        when(mTst.getLatestReceivedCount()).thenReturn(0);
        when(mTst.isDataStallSuspected()).thenReturn(true);
        final WrappedNetworkMonitor nm = makeMonitor(NO_INTERNET_CAPABILITIES);
        nm.setLastProbeTime(SystemClock.elapsedRealtime() - 1000);
        makeDnsTimeoutEvent(nm, DEFAULT_DNS_TIMEOUT_THRESHOLD);
        assertFalse(nm.isDataStall());
    }

    @Test
    public void testIsDataStall_EvaluationDnsWithDnsTimeThreshold() {
        // Test dns events happened in valid dns time threshold.