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

Commit 1a126858 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "DNC set retry state FAILED if evaluation fails"

parents 3df47e18 4a60c149
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2079,7 +2079,10 @@ public class DataNetworkController extends Handler {
                        evaluation.getDataAllowedReason());
            } else {
                loge("onDataNetworkSetupRetry: Not able to find a suitable data profile to retry.");
                dataSetupRetryEntry.setState(DataRetryEntry.RETRY_STATE_FAILED);
            }
        } else {
            dataSetupRetryEntry.setState(DataRetryEntry.RETRY_STATE_FAILED);
        }
    }

+51 −0
Original line number Diff line number Diff line
@@ -1282,6 +1282,57 @@ public class DataNetworkControllerTest extends TelephonyTest {
                any(), any(), anyBoolean(), any(Message.class));
    }

    @Test
    public void testSetupDataNetworkRetryFailed() {
        mDataNetworkControllerUT.getDataRetryManager()
                .registerCallback(mMockedDataRetryManagerCallback);
        setFailedSetupDataResponse(mMockedWwanDataServiceManager, DataFailCause.CONGESTION,
                DataCallResponse.RETRY_DURATION_UNDEFINED);
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET));
        processAllMessages();

        verify(mMockedWwanDataServiceManager, times(1)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));

        // Process first retry
        moveTimeForward(2500);
        processAllMessages();
        verify(mMockedWwanDataServiceManager, times(2)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));
        ArgumentCaptor<DataRetryManager.DataSetupRetryEntry> retryEntry =
                ArgumentCaptor.forClass(DataRetryManager.DataSetupRetryEntry.class);
        verify(mMockedDataRetryManagerCallback, times(1))
                .onDataNetworkSetupRetry(retryEntry.capture());
        assertThat(retryEntry.getValue().getState()).isEqualTo(
                DataRetryManager.DataRetryEntry.RETRY_STATE_FAILED);

        // Cause data network setup failed due to RADIO_DISABLED_BY_CARRIER
        doReturn(false).when(mSST).getPowerStateFromCarrier();

        // Process second retry and ensure data network setup failed
        moveTimeForward(3000);
        processAllMessages();
        verify(mMockedWwanDataServiceManager, times(2)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));
        verify(mMockedDataRetryManagerCallback, times(2))
                .onDataNetworkSetupRetry(retryEntry.capture());
        assertThat(retryEntry.getValue().getState()).isEqualTo(
                DataRetryManager.DataRetryEntry.RETRY_STATE_FAILED);

        // Data network setup allowed again
        doReturn(true).when(mSST).getPowerStateFromCarrier();

        // Should not retry again after retry failure
        processAllFutureMessages();
        verify(mMockedWwanDataServiceManager, times(2)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));
    }

    @Test
    public void testSetupDataNetworkPermanentFailure() {
        setFailedSetupDataResponse(mMockedWwanDataServiceManager, DataFailCause.PROTOCOL_ERRORS,