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

Commit 789b8641 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Honor retry timer from setup data call response for emergency request" into main

parents 1c39854a 0e4eed8a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1405,6 +1405,17 @@ public class DataConfigManager extends Handler {
                com.android.internal.R.bool.allow_clear_initial_attach_data_profile);
    }

    /**
     * @return Indicating whether the retry timer from setup data call response for data throttling
     * should be honored for emergency network request. By default this is off, meaning emergency
     * network requests will ignore the previous retry timer passed in from setup data call
     * response.
     */
    public boolean shouldHonorRetryTimerForEmergencyNetworkRequest() {
        return mResources.getBoolean(
                com.android.internal.R.bool.config_honor_data_retry_timer_for_emergency_network);
    }

    /**
     * Log debug messages.
     * @param s debug messages
@@ -1448,6 +1459,8 @@ public class DataConfigManager extends Handler {
        pw.increaseIndent();
        mDataHandoverRetryRules.forEach(pw::println);
        pw.decreaseIndent();
        pw.println("shouldHonorRetryTimerForEmergencyNetworkRequest="
                + shouldHonorRetryTimerForEmergencyNetworkRequest());
        pw.println("mSetupDataCallAnomalyReport=" + mSetupDataCallAnomalyReportThreshold);
        pw.println("mNetworkUnwantedAnomalyReport=" + mNetworkUnwantedAnomalyReportThreshold);
        pw.println("mImsReleaseRequestAnomalyReport=" + mImsReleaseRequestAnomalyReportThreshold);
+19 −3
Original line number Diff line number Diff line
@@ -1517,11 +1517,27 @@ public class DataNetworkController extends Handler {

        // Bypass all checks for emergency network request.
        if (networkRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_EIMS)) {
            evaluation.addDataAllowedReason(DataAllowedReason.EMERGENCY_REQUEST);
            evaluation.setCandidateDataProfile(mDataProfileManager.getDataProfileForNetworkRequest(
            DataProfile emergencyProfile = mDataProfileManager.getDataProfileForNetworkRequest(
                    networkRequest, getDataNetworkType(transport),
                    mServiceState.isUsingNonTerrestrialNetwork(),
                    isEsimBootStrapProvisioningActivated(), true));
                    isEsimBootStrapProvisioningActivated(), true);

            // Check if the profile is being throttled.
            if (mDataConfigManager.shouldHonorRetryTimerForEmergencyNetworkRequest()
                    && emergencyProfile != null
                    && mDataRetryManager.isDataProfileThrottled(emergencyProfile, transport)) {
                evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_THROTTLED);
                log("Emergency network request is throttled by the previous setup data "
                            + "call response.");
                log(evaluation.toString());
                networkRequest.setEvaluation(evaluation);
                return evaluation;
            }

            evaluation.addDataAllowedReason(DataAllowedReason.EMERGENCY_REQUEST);
            if (emergencyProfile != null) {
                evaluation.setCandidateDataProfile(emergencyProfile);
            }
            networkRequest.setEvaluation(evaluation);
            log(evaluation.toString());
            return evaluation;
+80 −3
Original line number Diff line number Diff line
@@ -648,8 +648,26 @@ public class DataNetworkControllerTest extends TelephonyTest {
    private void serviceStateChanged(@NetworkType int networkType,
            @RegistrationState int dataRegState, @RegistrationState int voiceRegState,
            @RegistrationState int iwlanRegState, DataSpecificRegistrationInfo dsri) {
        boolean isEmergencyOnly = false;
        if (dataRegState == NetworkRegistrationInfo.REGISTRATION_STATE_DENIED) {
            isEmergencyOnly = true;
        }
        ServiceState ss = createSS(networkType, networkType, dataRegState, voiceRegState,
                iwlanRegState, dsri, isEmergencyOnly);

        doReturn(ss).when(mSST).getServiceState();
        doReturn(ss).when(mPhone).getServiceState();

        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
        processAllMessages();
    }

    private void serviceStateChanged(@NetworkType int networkType,
            @RegistrationState int dataRegState, @RegistrationState int voiceRegState,
            @RegistrationState int iwlanRegState, DataSpecificRegistrationInfo dsri,
            boolean isEmergencyOnly) {
        ServiceState ss = createSS(networkType, networkType, dataRegState, voiceRegState,
                iwlanRegState, dsri);
                iwlanRegState, dsri, isEmergencyOnly);

        doReturn(ss).when(mSST).getServiceState();
        doReturn(ss).when(mPhone).getServiceState();
@@ -661,7 +679,8 @@ public class DataNetworkControllerTest extends TelephonyTest {
    private ServiceState createSS(@NetworkType int dataNetworkType,
            @NetworkType int voiceNetworkType,
            @RegistrationState int dataRegState, @RegistrationState int voiceRegState,
            @RegistrationState int iwlanRegState, DataSpecificRegistrationInfo dsri) {
            @RegistrationState int iwlanRegState, DataSpecificRegistrationInfo dsri,
            boolean isEmergencyOnly) {
        if (dsri == null) {
            dsri = new DataSpecificRegistrationInfo.Builder(8)
                    .setNrAvailable(true)
@@ -682,6 +701,7 @@ public class DataNetworkControllerTest extends TelephonyTest {
                .setDataSpecificInfo(dsri)
                .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork)
                .setAvailableServices(mCarrierSupportedSatelliteServices)
                .setEmergencyOnly(isEmergencyOnly)
                .build());

        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
@@ -691,6 +711,7 @@ public class DataNetworkControllerTest extends TelephonyTest {
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork)
                .setAvailableServices(mCarrierSupportedSatelliteServices)
                .setEmergencyOnly(isEmergencyOnly)
                .build());

        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
@@ -698,6 +719,7 @@ public class DataNetworkControllerTest extends TelephonyTest {
                .setAccessNetworkTechnology(voiceNetworkType)
                .setRegistrationState(voiceRegState)
                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                .setEmergencyOnly(isEmergencyOnly)
                .build());

        ss.setDataRoamingFromRegistration(dataRegState
@@ -801,6 +823,12 @@ public class DataNetworkControllerTest extends TelephonyTest {
        mCarrierConfig.putIntArray(CarrierConfigManager
                        .KEY_CAPABILITIES_EXEMPT_FROM_SINGLE_DC_CHECK_INT_ARRAY,
                new int[]{NetworkCapabilities.NET_CAPABILITY_IMS});
        mCarrierConfig.putBooleanArray(
                CarrierConfigManager.KEY_DATA_STALL_RECOVERY_SHOULD_SKIP_BOOL_ARRAY,
                new boolean[] {false, false, true, false, false}
        );
        mCarrierConfig.putLongArray(CarrierConfigManager.KEY_DATA_STALL_RECOVERY_TIMERS_LONG_ARRAY,
                new long[] {180000, 180000, 180000, 180000});

        mCarrierConfig.putLongArray(CarrierConfigManager.KEY_DATA_STALL_RECOVERY_TIMERS_LONG_ARRAY,
                new long[] {100, 100, 100, 100});
@@ -811,6 +839,8 @@ public class DataNetworkControllerTest extends TelephonyTest {
        mContextFixture.putResource(com.android.internal.R.string.config_bandwidthEstimateSource,
                "bandwidth_estimator");

        mContextFixture.putBooleanResource(com.android.internal.R.bool
                .config_honor_data_retry_timer_for_emergency_network, true);
        mContextFixture.putIntResource(com.android.internal.R.integer
                        .config_delay_for_ims_dereg_millis, 3000);
        mContextFixture.putBooleanResource(com.android.internal.R.bool
@@ -2117,6 +2147,53 @@ public class DataNetworkControllerTest extends TelephonyTest {
        verifyConnectedNetworkHasDataProfile(mEmergencyDataProfile);
    }

    @Test
    public void testEmergencyRequestWithThrottling() throws Exception {
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, /* data */
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, /* voice */
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, /* iwlan */
                null, false);
        mDataNetworkControllerUT.getDataRetryManager()
                .registerCallback(mMockedDataRetryManagerCallback);

        setFailedSetupDataResponse(mMockedWwanDataServiceManager, DataFailCause.PROTOCOL_ERRORS,
                10000, false);
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_EIMS));
        processAllMessages();

        // There should be only one attempt, and no retry should happen because the second one
        // was throttled.
        verify(mMockedWwanDataServiceManager, times(1)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));

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

        Mockito.reset(mMockedWwanDataServiceManager);
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_DENIED, /* data */
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, /* voice */
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, /* iwlan */
                null, true);

        // No retry should happen because the second one was throttled.
        verify(mMockedWwanDataServiceManager, never()).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));
    }

    @Test
    public void testHandoverRuleFromString() {
        HandoverRule handoverRule = new HandoverRule("source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, "
@@ -4674,7 +4751,7 @@ public class DataNetworkControllerTest extends TelephonyTest {
                TelephonyManager.NETWORK_TYPE_1xRTT /* voice RAT */,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING ,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, null);
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, null, true);
        doReturn(ss).when(mSST).getServiceState();
        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
        mDataNetworkControllerUT.removeNetworkRequest(request);