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

Commit 5e407e2e authored by Jack Yu's avatar Jack Yu
Browse files

Reset data throttling when TAC changes

Test: atest DataRetryManagerTest
Fix: 222323541
Change-Id: I898896f9bc36842e21ae35e29153b8c954d3d32f
parent 0e9736d7
Loading
Loading
Loading
Loading
+20 −5
Original line number Original line Diff line number Diff line
@@ -93,6 +93,9 @@ public class DataRetryManager extends Handler {
    /** Event for modem reset. */
    /** Event for modem reset. */
    private static final int EVENT_MODEM_RESET = 9;
    private static final int EVENT_MODEM_RESET = 9;


    /** Event for tracking area code change. */
    private static final int EVENT_TAC_CHANGED = 10;

    /** The maximum entries to preserve. */
    /** The maximum entries to preserve. */
    private static final int MAXIMUM_HISTORICAL_ENTRIES = 100;
    private static final int MAXIMUM_HISTORICAL_ENTRIES = 100;


@@ -102,26 +105,31 @@ public class DataRetryManager extends Handler {
                    RESET_REASON_RADIO_ON,
                    RESET_REASON_RADIO_ON,
                    RESET_REASON_MODEM_RESTART,
                    RESET_REASON_MODEM_RESTART,
                    RESET_REASON_DATA_SERVICE_BOUND,
                    RESET_REASON_DATA_SERVICE_BOUND,
                    RESET_REASON_DATA_CONFIG_CHANGED,
                    RESET_REASON_TAC_CHANGED,
            })
            })
    public @interface RetryResetReason {}
    public @interface RetryResetReason {}


    /** Reset due to data profiles changed. */
    /** Reset due to data profiles changed. */
    public static final int RESET_REASON_DATA_PROFILES_CHANGED = 1;
    private static final int RESET_REASON_DATA_PROFILES_CHANGED = 1;


    /** Reset due to radio on. This could happen after airplane mode off or RIL restarted. */
    /** Reset due to radio on. This could happen after airplane mode off or RIL restarted. */
    public static final int RESET_REASON_RADIO_ON = 2;
    private static final int RESET_REASON_RADIO_ON = 2;


    /** Reset due to modem restarted. */
    /** Reset due to modem restarted. */
    public static final int RESET_REASON_MODEM_RESTART = 3;
    private static final int RESET_REASON_MODEM_RESTART = 3;


    /**
    /**
     * Reset due to data service bound. This could happen when reboot or when data service crashed
     * Reset due to data service bound. This could happen when reboot or when data service crashed
     * and rebound.
     * and rebound.
     */
     */
    public static final int RESET_REASON_DATA_SERVICE_BOUND = 4;
    private static final int RESET_REASON_DATA_SERVICE_BOUND = 4;


    /** Reset due to data config changed. */
    /** Reset due to data config changed. */
    public static final int RESET_REASON_DATA_CONFIG_CHANGED = 5;
    private static final int RESET_REASON_DATA_CONFIG_CHANGED = 5;

    /** Reset due to tracking area code changed. */
    private static final int RESET_REASON_TAC_CHANGED = 6;


    /** The phone instance. */
    /** The phone instance. */
    private final @NonNull Phone mPhone;
    private final @NonNull Phone mPhone;
@@ -945,6 +953,8 @@ public class DataRetryManager extends Handler {
                });
                });
        mRil.registerForOn(this, EVENT_RADIO_ON, null);
        mRil.registerForOn(this, EVENT_RADIO_ON, null);
        mRil.registerForModemReset(this, EVENT_MODEM_RESET, null);
        mRil.registerForModemReset(this, EVENT_MODEM_RESET, null);

        mPhone.getServiceStateTracker().registerForAreaCodeChanged(this, EVENT_TAC_CHANGED, null);
    }
    }


    @Override
    @Override
@@ -976,6 +986,9 @@ public class DataRetryManager extends Handler {
            case EVENT_MODEM_RESET:
            case EVENT_MODEM_RESET:
                onReset(RESET_REASON_MODEM_RESTART);
                onReset(RESET_REASON_MODEM_RESTART);
                break;
                break;
            case EVENT_TAC_CHANGED:
                onReset(RESET_REASON_TAC_CHANGED);
                break;
            case EVENT_DATA_PROFILE_UNTHROTTLED:
            case EVENT_DATA_PROFILE_UNTHROTTLED:
                ar = (AsyncResult) msg.obj;
                ar = (AsyncResult) msg.obj;
                int transport = (int) ar.userObj;
                int transport = (int) ar.userObj;
@@ -1562,6 +1575,8 @@ public class DataRetryManager extends Handler {
                return "DATA_SERVICE_BOUND";
                return "DATA_SERVICE_BOUND";
            case RESET_REASON_DATA_CONFIG_CHANGED:
            case RESET_REASON_DATA_CONFIG_CHANGED:
                return "DATA_CONFIG_CHANGED";
                return "DATA_CONFIG_CHANGED";
            case RESET_REASON_TAC_CHANGED:
                return "TAC_CHANGED";
            default:
            default:
                return "UNKNOWN(" + reason + ")";
                return "UNKNOWN(" + reason + ")";
        }
        }
+25 −0
Original line number Original line Diff line number Diff line
@@ -654,6 +654,31 @@ public class DataRetryManagerTest extends TelephonyTest {
        testDataSetupRetryNetworkSuggestedNeverRetry();
        testDataSetupRetryNetworkSuggestedNeverRetry();
        Mockito.clearInvocations(mDataRetryManagerCallbackMock);
        Mockito.clearInvocations(mDataRetryManagerCallbackMock);


        // RIL crashed and came back online.
        mDataRetryManagerUT.obtainMessage(10 /*EVENT_TAC_CHANGED*/,
                new AsyncResult(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, mDataProfile3, null))
                .sendToTarget();
        processAllMessages();

        ArgumentCaptor<List<ThrottleStatus>> throttleStatusCaptor =
                ArgumentCaptor.forClass(List.class);
        verify(mDataRetryManagerCallbackMock).onThrottleStatusChanged(
                throttleStatusCaptor.capture());
        assertThat(throttleStatusCaptor.getValue()).hasSize(1);
        ThrottleStatus throttleStatus = throttleStatusCaptor.getValue().get(0);
        assertThat(throttleStatus.getApnType()).isEqualTo(ApnSetting.TYPE_IMS);
        assertThat(throttleStatus.getRetryType())
                .isEqualTo(ThrottleStatus.RETRY_TYPE_NEW_CONNECTION);
        assertThat(throttleStatus.getThrottleExpiryTimeMillis()).isEqualTo(-1);
        assertThat(throttleStatus.getTransportType())
                .isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
    }

    @Test
    public void testTacChangedReset() {
        testDataSetupRetryNetworkSuggestedNeverRetry();
        Mockito.clearInvocations(mDataRetryManagerCallbackMock);

        // RIL crashed and came back online.
        // RIL crashed and came back online.
        mDataRetryManagerUT.obtainMessage(9/*EVENT_MODEM_RESET*/,
        mDataRetryManagerUT.obtainMessage(9/*EVENT_MODEM_RESET*/,
                new AsyncResult(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, mDataProfile3, null))
                new AsyncResult(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, mDataProfile3, null))