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

Commit 80750855 authored by Diaesh Antony's avatar Diaesh Antony Committed by Jack Yu
Browse files

[DSRM] Fix for failing to perform data stall recovery soon after


       skipping data recovery action under poor network signal.

Symptom: If a data stall recovery is skipped under poor
         network signal strength for the very first time.
	 Then in the next iteration, data stall recovery is
	 skipped due to mIsValidNetwork flag remains false always.

Solution: Refactor the existing conditions for data stall recovery.

Bug: 249687945
Test: Manual test passed.

Signed-off-by: default avatarDiaesh Antony <diaeshantony@google.com>
Merged-In: I16abe882dfc965b7f48b37d79e5e678efbc490b0
Change-Id: I16abe882dfc965b7f48b37d79e5e678efbc490b0
parent c787c82a
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -151,6 +151,8 @@ public class DataStallRecoveryManager extends Handler {
    private @ElapsedRealtimeLong long mTimeLastRecoveryStartMs;
    /** Whether current network is good or not */
    private boolean mIsValidNetwork;
    /** Whether data stall recovery is triggered or not */
    private boolean mRecoveryTriggered = false;
    /** Whether data stall happened or not. */
    private boolean mDataStalled;
    /** Whether the result of last action(RADIO_RESTART) reported. */
@@ -352,6 +354,7 @@ public class DataStallRecoveryManager extends Handler {
     */
    private void reset() {
        mIsValidNetwork = true;
        mRecoveryTriggered = false;
        mIsAttemptedAllSteps = false;
        mRadioStateChangedDuringDataStall = false;
        mIsAirPlaneModeEnableDuringDataStall = false;
@@ -373,17 +376,14 @@ public class DataStallRecoveryManager extends Handler {
        setNetworkValidationState(isValid);
        if (isValid) {
            reset();
        } else {
            if (mIsValidNetwork || isRecoveryAlreadyStarted()) {
        } else if (isRecoveryNeeded(true)) {
            // Set the network as invalid, because recovery is needed
            mIsValidNetwork = false;
                if (isRecoveryNeeded(true)) {
            log("trigger data stall recovery");
            mTimeLastRecoveryStartMs = SystemClock.elapsedRealtime();
            sendMessage(obtainMessage(EVENT_DO_RECOVERY));
        }
    }
        }
    }

    /** Reset the action to initial step. */
    private void resetAction() {
@@ -455,7 +455,7 @@ public class DataStallRecoveryManager extends Handler {
     * @return {@code true} if recovery already started, {@code false} recovery not started.
     */
    private boolean isRecoveryAlreadyStarted() {
        return getRecoveryAction() != RECOVERY_ACTION_GET_DATA_CALL_LIST;
        return getRecoveryAction() != RECOVERY_ACTION_GET_DATA_CALL_LIST || mRecoveryTriggered;
    }

    /**
@@ -542,6 +542,12 @@ public class DataStallRecoveryManager extends Handler {
    private boolean isRecoveryNeeded(boolean isNeedToCheckTimer) {
        logv("enter: isRecoveryNeeded()");

        // Skip if network is invalid and recovery was not started yet
        if (!mIsValidNetwork && !isRecoveryAlreadyStarted()) {
            logl("skip when network still remains invalid and recovery was not started yet");
            return false;
        }

        // Skip recovery if we have already attempted all steps.
        if (mIsAttemptedAllSteps) {
            logl("skip retrying continue recovery action");
@@ -577,7 +583,6 @@ public class DataStallRecoveryManager extends Handler {
            logl("skip data stall recovery as data not connected");
            return false;
        }

        return true;
    }

@@ -652,6 +657,7 @@ public class DataStallRecoveryManager extends Handler {
    private void doRecovery() {
        @RecoveryAction final int recoveryAction = getRecoveryAction();
        final int signalStrength = mPhone.getSignalStrength().getLevel();
        mRecoveryTriggered = true;

        // DSRM used sendMessageDelayed to process the next event EVENT_DO_RECOVERY, so it need
        // to check the condition if DSRM need to process the recovery action.