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

Commit f2b3db5f authored by Jack Yu's avatar Jack Yu
Browse files

Fixed crash in data retry manager

Fixed a corner case that APN list got reset
before modem suggested a retry timer.

Fix: 158526917
Test: FrameworksTelephonyTests
Change-Id: I278155872dde12ef2ac8c838cb4dca8bfb063340
parent 4f4d7c5c
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -498,9 +498,10 @@ public class RetryManager {

        // If the modem had suggested a retry delay, we should retry the current APN again
        // (up to MAX_SAME_APN_RETRY times) instead of getting the next APN setting from
        // our own list.
        if (mModemSuggestedDelay != NO_SUGGESTED_RETRY_DELAY &&
                mSameApnRetryCount < MAX_SAME_APN_RETRY) {
        // our own list. If the APN waiting list has been reset before a setup data responses
        // arrive (i.e. mCurrentApnIndex=-1), then ignore the modem suggested retry.
        if (mCurrentApnIndex != -1 && mModemSuggestedDelay != NO_SUGGESTED_RETRY_DELAY
                && mSameApnRetryCount < MAX_SAME_APN_RETRY) {
            mSameApnRetryCount++;
            return mWaitingApns.get(mCurrentApnIndex);
        }
@@ -665,6 +666,10 @@ public class RetryManager {
     * @param delay The delay in milliseconds
     */
    public void setModemSuggestedDelay(long delay) {
        if (mCurrentApnIndex == -1) {
            log("Waiting APN list has been reset. Ignore the value from modem.");
            return;
        }
        mModemSuggestedDelay = delay;
    }

+27 −0
Original line number Diff line number Diff line
@@ -1026,4 +1026,31 @@ public class RetryManagerTest extends TelephonyTest {
        delay = rm.getDelayForNextApn(false);
        assertEquals(4000, delay);
    }

    /**
     * Test the scenario where reset happens before modem suggests retry.
     */
    @Test
    @SmallTest
    public void testRetryManagerResetBeforeModemSuggestedRetry() throws Exception {

        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS,
                new String[]{"others:1000,4000,7000,9000"});

        ArrayList<ApnSetting> waitingApns = new ArrayList<ApnSetting>();
        ApnSetting myApn1 = ApnSetting.makeApnSetting(mApn1);
        ApnSetting myApn2 = ApnSetting.makeApnSetting(mApn2);
        waitingApns.add(myApn1);
        waitingApns.add(myApn2);

        RetryManager rm = new RetryManager(mPhone, "mms");
        rm.setWaitingApns(waitingApns);

        rm.setModemSuggestedDelay(10);

        ApnSetting nextApn = rm.getNextApnSetting();
        assertTrue(nextApn.equals(mApn1));
        long delay = rm.getDelayForNextApn(false);
        assertEquals(20000, delay);
    }
}