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

Commit b6bfd8c0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[DSRM] Fix the index ArrayIndexOutOfBoundsException" into tm-dev

parents 414454f7 996d4624
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -337,6 +337,20 @@ public class DataStallRecoveryManager extends Handler {
        }
    }

    /**
     * Called when internet validation status passed. We will initialize all parameters.
     */
    private void reset() {
        mIsValidNetwork = true;
        mIsAttemptedAllSteps = false;
        mRadioStateChangedDuringDataStall = false;
        mMobileDataChangedToEnabledDuringDataStall = false;
        cancelNetworkCheckTimer();
        mTimeLastRecoveryStartMs = 0;
        mLastAction = RECOVERY_ACTION_GET_DATA_CALL_LIST;
        mRecovryAction = RECOVERY_ACTION_GET_DATA_CALL_LIST;
    }

    /**
     * Called when internet validation status changed.
     *
@@ -347,10 +361,7 @@ public class DataStallRecoveryManager extends Handler {
        final boolean isValid = status == NetworkAgent.VALIDATION_STATUS_VALID;
        setNetworkValidationState(isValid);
        if (isValid) {
            mIsValidNetwork = true;
            cancelNetworkCheckTimer();
            resetAction();
            mIsAttemptedAllSteps = false;
            reset();
        } else {
            mIsValidNetwork = false;
            if (isRecoveryNeeded(true)) {
@@ -518,7 +529,7 @@ public class DataStallRecoveryManager extends Handler {
        logv("enter: isRecoveryNeeded()");

        // Skip recovery if we have already attempted all steps.
        if (mIsAttemptedAllSteps && mLastAction == RECOVERY_ACTION_RESET_MODEM) {
        if (mIsAttemptedAllSteps) {
            logl("skip retrying continue recovery action");
            return false;
        }
+44 −0
Original line number Diff line number Diff line
@@ -250,6 +250,50 @@ public class DataStallRecoveryManagerTest extends TelephonyTest {
        }
    }

    @Test
    public void testDoRecoveryWhenMeetDataStallAgain() throws Exception {
        sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_VALID);
        mDataStallRecoveryManager.setRecoveryAction(0);
        doReturn(PhoneConstants.State.IDLE).when(mPhone).getState();
        doReturn(3).when(mSignalStrength).getLevel();
        doReturn(mSignalStrength).when(mPhone).getSignalStrength();
        logd("Sending validation failed callback");

        assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(0);
        sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
        processAllMessages();
        moveTimeForward(101);
        assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(1);

        sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
        processAllMessages();
        moveTimeForward(101);
        assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(3);

        sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
        processAllMessages();
        moveTimeForward(101);
        assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(4);

        // Handle multiple VALIDATION_STATUS_NOT_VALID and make sure we don't attempt recovery
        for (int i = 0; i < 4; i++) {
            sendValidationStatusCallback(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
            logd("Sending validation failed callback");
            processAllMessages();
            moveTimeForward(101);
            assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(0);
        }

        moveTimeForward(101);
        assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(0);

        mDataStallRecoveryManager.sendMessageDelayed(
                mDataStallRecoveryManager.obtainMessage(0), 1000);
        processAllMessages();
        processAllMessages();
        assertThat(mDataStallRecoveryManager.getRecoveryAction()).isEqualTo(0);
    }

    @Test
    public void testDoNotDoRecoveryWhenDataNoService() throws Exception {
        mDataStallRecoveryManager.setRecoveryAction(1);