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

Commit 13cf841a authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Reset all data profiles upon resetting retry manager"

parents 994930e9 dd74d161
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();
    }
}