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

Commit 0852a954 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed that data retry didn't happen issue

When modem return -1 as the retry value in setup data call response,
we should interpret it correctly and retry the data connection.

bug: 27787361
Change-Id: I0a3e442f5125730dd9a196ce632120b44b880090
parent afcf7309
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -491,6 +491,11 @@ public class RetryManager {
            return NO_RETRY;
        }

        if (mModemSuggestedDelay == NO_RETRY) {
            log("Modem suggested not retrying.");
            return NO_RETRY;
        }

        if (mModemSuggestedDelay != NO_SUGGESTED_RETRY_DELAY &&
                mSameApnRetryCount < MAX_SAME_APN_RETRY) {
            // If the modem explicitly suggests a retry delay, we should use it, even in fail fast
+13 −1
Original line number Diff line number Diff line
@@ -1823,10 +1823,22 @@ public class DataConnection extends StateMachine {

        DataCallResponse response = (DataCallResponse) ar.result;

        if (response.suggestedRetryTime == RILConstants.MAX_INT) {
        /** According to ril.h
         * The value < 0 means no value is suggested
         * The value 0 means retry should be done ASAP.
         * The value of Integer.MAX_VALUE(0x7fffffff) means no retry.
         */

        // The value < 0 means no value is suggested
        if (response.suggestedRetryTime < 0) {
            if (DBG) log("No suggested retry delay.");
            return RetryManager.NO_SUGGESTED_RETRY_DELAY;
        }
        // The value of Integer.MAX_VALUE(0x7fffffff) means no retry.
        else if (response.suggestedRetryTime == Integer.MAX_VALUE) {
            if (DBG) log("Modem suggested not retrying.");
            return RetryManager.NO_RETRY;
        }

        // We need to cast it to long because the value returned from RIL is a 32-bit integer,
        // but the time values used in AlarmManager are all 64-bit long.
+1 −3
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.internal.telephony.dataconnection;
import android.content.Intent;
import android.telephony.Rlog;

import com.android.internal.telephony.RILConstants;

/**
 * A package visible class for supporting testing failing bringUp commands. This
 * saves the parameters from a action_fail_bringup intent. See
@@ -46,7 +44,7 @@ public class DcFailBringUp {

    // suggestedRetryTime with its --ei option name and default value
    static final String SUGGESTED_RETRY_TIME = "suggested_retry_time";
    static final int DEFAULT_SUGGESTED_RETRY_TIME = RILConstants.MAX_INT;
    static final int DEFAULT_SUGGESTED_RETRY_TIME = -1;
    int mSuggestedRetryTime;

    // Get the Extra Intent parameters
+3 −1
Original line number Diff line number Diff line
@@ -2239,6 +2239,8 @@ public class DcTracker extends Handler {

        // Use the exact timer instead of the inexact one to provide better user experience.
        // In some extreme cases, we saw the retry was delayed for few minutes.
        // Note that if the stated trigger time is in the past, the alarm will be triggered
        // immediately.
        mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + delay, alarmIntent);
    }
@@ -2898,7 +2900,7 @@ public class DcTracker extends Handler {
        long delay = apnContext.getDelayForNextApn(mFailFast);

        // Check if we need to retry or not.
        if (delay > 0) {
        if (delay >= 0) {
            if (DBG) log("onDataSetupCompleteError: Try next APN. delay = " + delay);
            apnContext.setState(DctConstants.State.SCANNING);
            // Wait a bit before trying the next APN, so that
+50 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.dataconnection;

import android.os.AsyncResult;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
@@ -24,6 +25,7 @@ import android.test.suitebuilder.annotation.SmallTest;

import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RetryManager;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.dataconnection.DataConnection.ConnectionParams;
import com.android.internal.telephony.dataconnection.DataConnection.DisconnectParams;
@@ -158,6 +160,14 @@ public class DataConnectionTest extends TelephonyTest {
        return (IState) method.invoke(mDc);
    }

    private long getSuggestedRetryDelay(AsyncResult ar) throws Exception {
        Class[] cArgs = new Class[1];
        cArgs[0] = AsyncResult.class;
        Method method = DataConnection.class.getDeclaredMethod("getSuggestedRetryDelay", cArgs);
        method.setAccessible(true);
        return (long) method.invoke(mDc, ar);
    }

    @Test
    @SmallTest
    public void testSanity() throws Exception {
@@ -197,4 +207,43 @@ public class DataConnectionTest extends TelephonyTest {

        assertEquals("DcInactiveState", getCurrentState().getName());
    }

    @Test
    @SmallTest
    public void testModemSuggestRetry() throws Exception {
        DataCallResponse response = new DataCallResponse();
        response.suggestedRetryTime = 0;
        AsyncResult ar = new AsyncResult(null, response, null);
        assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar));

        response.suggestedRetryTime = 1000;
        assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar));

        response.suggestedRetryTime = 9999;
        assertEquals(response.suggestedRetryTime, getSuggestedRetryDelay(ar));
    }

    @Test
    @SmallTest
    public void testModemNotSuggestRetry() throws Exception {
        DataCallResponse response = new DataCallResponse();
        response.suggestedRetryTime = -1;
        AsyncResult ar = new AsyncResult(null, response, null);
        assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar));

        response.suggestedRetryTime = -5;
        assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar));

        response.suggestedRetryTime = Integer.MIN_VALUE;
        assertEquals(RetryManager.NO_SUGGESTED_RETRY_DELAY, getSuggestedRetryDelay(ar));
    }

    @Test
    @SmallTest
    public void testModemSuggestNoRetry() throws Exception {
        DataCallResponse response = new DataCallResponse();
        response.suggestedRetryTime = Integer.MAX_VALUE;
        AsyncResult ar = new AsyncResult(null, response, null);
        assertEquals(RetryManager.NO_RETRY, getSuggestedRetryDelay(ar));
    }
}
 No newline at end of file
Loading