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

Commit 277e6260 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Reset all data profiles upon resetting retry manager" am: 13cf841a...

Merge "Reset all data profiles upon resetting retry manager" am: 13cf841a am: 5a4860f2 am: 0cf40378 am: 3bfef6f9 am: 6ae852f2

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2606497



Change-Id: I94b24dcdd0ce1620dd4835e4ffec88174fc1e340
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 85e9b0fa 6ae852f2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1006,6 +1006,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
@@ -1357,6 +1357,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
@@ -1533,4 +1533,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
@@ -850,7 +850,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*/,
@@ -870,12 +870,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*/,
@@ -895,6 +896,7 @@ public class DataRetryManagerTest extends TelephonyTest {
        assertThat(throttleStatus.getThrottleExpiryTimeMillis()).isEqualTo(-1);
        assertThat(throttleStatus.getTransportType())
                .isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        verify(mDataProfileManager).clearAllDataProfilePermanentFailures();
    }

    @Test
@@ -902,7 +904,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*/,
@@ -922,5 +924,6 @@ public class DataRetryManagerTest extends TelephonyTest {
        assertThat(throttleStatus.getThrottleExpiryTimeMillis()).isEqualTo(-1);
        assertThat(throttleStatus.getTransportType())
                .isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        verify(mDataProfileManager).clearAllDataProfilePermanentFailures();
    }
}