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

Commit dd74d161 authored by Ling Ma's avatar Ling Ma
Browse files

Reset all data profiles upon resetting retry manager

Before this change, when a data profile is marked as permanent failed, only condition based evaluation could possibly resurrect this data profile. After this change, the data profile resurrect also after retry manager reset where retries and throttling entries are cleared.

Fix: 284108871
Test: internet browsing + phone call
Change-Id: I97a05085c336fa347f4e0466c026731a90a06b17
Merged-In: I97a05085c336fa347f4e0466c026731a90a06b17
parent 994930e9
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -993,6 +993,16 @@ public class DataProfileManager extends Handler {
                .build();
    }

    /**
     * Called by {@link DataRetryManager} to clear all permanent failures upon reset.
     */
    public void clearAllDataProfilePermanentFailures() {
        mAllDataProfiles.stream()
                .map(DataProfile::getApnSetting)
                .filter(Objects::nonNull)
                .forEach(apnSetting -> apnSetting.setPermanentFailed(false));
    }

    /**
     * Check if the provided data profile is still compatible with the current environment. Note
     * this method ignores APN id check and traffic descriptor check. A data profile with traffic
+3 −0
Original line number Diff line number Diff line
@@ -1304,6 +1304,9 @@ public class DataRetryManager extends Handler {
        logl("Remove all retry and throttling entries, reason=" + resetReasonToString(reason));
        removeMessages(EVENT_DATA_SETUP_RETRY);
        removeMessages(EVENT_DATA_HANDOVER_RETRY);

        mDataProfileManager.clearAllDataProfilePermanentFailures();

        mDataRetryEntries.stream()
                .filter(entry -> entry.getState() == DataRetryEntry.RETRY_STATE_NOT_RETRIED)
                .forEach(entry -> entry.setState(DataRetryEntry.RETRY_STATE_CANCELLED));
+16 −0
Original line number Diff line number Diff line
@@ -1462,4 +1462,20 @@ public class DataProfileManagerTest extends TelephonyTest {
        mSimInserted = simState == TelephonyManager.SIM_STATE_LOADED;
        mDataNetworkControllerCallback.onSimStateChanged(simState);
    }

    @Test
    public void testClearAllDataProfilePermanentFailures() {
        testPermanentFailureWithPreferredDataProfile();

        // Reset all data profiles
        mDataProfileManagerUT.clearAllDataProfilePermanentFailures();

        NetworkRequest request = new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build();

        // Verify the we can get the previously permanent failed data profile again.
        assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(
                new TelephonyNetworkRequest(request, mPhone),
                TelephonyManager.NETWORK_TYPE_LTE, false)).isNotNull();
    }
}
+6 −3
Original line number Diff line number Diff line
@@ -781,7 +781,7 @@ public class DataRetryManagerTest extends TelephonyTest {
    @Test
    public void testRilCrashedReset() {
        testDataSetupRetryNetworkSuggestedNeverRetry();
        Mockito.clearInvocations(mDataRetryManagerCallbackMock);
        Mockito.clearInvocations(mDataRetryManagerCallbackMock, mDataProfileManager);

        // RIL crashed and came back online.
        mDataRetryManagerUT.obtainMessage(8/*EVENT_RADIO_ON*/,
@@ -801,12 +801,13 @@ public class DataRetryManagerTest extends TelephonyTest {
        assertThat(throttleStatus.getThrottleExpiryTimeMillis()).isEqualTo(-1);
        assertThat(throttleStatus.getTransportType())
                .isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        verify(mDataProfileManager).clearAllDataProfilePermanentFailures();
    }

    @Test
    public void testModemCrashedReset() {
        testDataSetupRetryNetworkSuggestedNeverRetry();
        Mockito.clearInvocations(mDataRetryManagerCallbackMock);
        Mockito.clearInvocations(mDataRetryManagerCallbackMock, mDataProfileManager);

        // RIL crashed and came back online.
        mDataRetryManagerUT.obtainMessage(10 /*EVENT_TAC_CHANGED*/,
@@ -826,6 +827,7 @@ public class DataRetryManagerTest extends TelephonyTest {
        assertThat(throttleStatus.getThrottleExpiryTimeMillis()).isEqualTo(-1);
        assertThat(throttleStatus.getTransportType())
                .isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        verify(mDataProfileManager).clearAllDataProfilePermanentFailures();
    }

    @Test
@@ -833,7 +835,7 @@ public class DataRetryManagerTest extends TelephonyTest {
        doReturn(true).when(mDataConfigManager).shouldResetDataThrottlingWhenTacChanges();

        testDataSetupRetryNetworkSuggestedNeverRetry();
        Mockito.clearInvocations(mDataRetryManagerCallbackMock);
        Mockito.clearInvocations(mDataRetryManagerCallbackMock, mDataProfileManager);

        // RIL crashed and came back online.
        mDataRetryManagerUT.obtainMessage(9/*EVENT_MODEM_RESET*/,
@@ -853,5 +855,6 @@ public class DataRetryManagerTest extends TelephonyTest {
        assertThat(throttleStatus.getThrottleExpiryTimeMillis()).isEqualTo(-1);
        assertThat(throttleStatus.getTransportType())
                .isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        verify(mDataProfileManager).clearAllDataProfilePermanentFailures();
    }
}