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

Commit ccb767c8 authored by Willy Hu's avatar Willy Hu
Browse files

[DSRM] Fix the metrics wrong duration

- add back start time when data stall happen first time
- add the unit test for this case, ensure the start time not zero.

Bug: 260166714
Test: Manual test passed. See the correct time in log.
Change-Id: Ia33e05eadc2e96a1b2b78c488af4efcb9811065e
parent 52182a1a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -158,7 +158,8 @@ public class DataStallRecoveryManager extends Handler {
    /** Whether the result of last action(RADIO_RESTART) reported. */
    private boolean mLastActionReported;
    /** The real time for data stall start. */
    private @ElapsedRealtimeLong long mDataStallStartMs;
    @VisibleForTesting
    public @ElapsedRealtimeLong long mDataStallStartMs;
    /** Last data stall recovery action. */
    private @RecoveryAction int mLastAction;
    /** Last radio power state. */
@@ -607,6 +608,8 @@ public class DataStallRecoveryManager extends Handler {
            isLogNeeded = true;
            mDataStalled = true;
            isFirstDataStall = true;
            mDataStallStartMs = SystemClock.elapsedRealtime();
            logl("data stall: start time = " + DataUtils.elapsedTimeToString(mDataStallStartMs));
        } else if (!mLastActionReported) {
            // When the first validation status appears, enter this block.
            isLogNeeded = true;
+19 −0
Original line number Diff line number Diff line
@@ -350,4 +350,23 @@ public class DataStallRecoveryManagerTest extends TelephonyTest {
            assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(0);
        }
    }

    @Test
    public void testStartTimeNotZero() throws Exception {
        sendOnInternetDataNetworkCallback(false);
        doReturn(mSignalStrength).when(mPhone).getSignalStrength();
        doReturn(PhoneConstants.State.IDLE).when(mPhone).getState();

        logd("Sending validation failed callback");
        sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
        processAllFutureMessages();

        for (int i = 0; i < 2; i++) {
            sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
            logd("Sending validation failed callback");
            processAllMessages();
            moveTimeForward(101);
        }
        assertThat(mDataStallRecoveryManager.mDataStallStartMs != 0).isTrue();
    }
}