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

Commit eb08c410 authored by Sewook Seo's avatar Sewook Seo Committed by Automerger Merge Worker
Browse files

Merge "Improve HandoverRule check at roaming OOS" into udc-d1-dev am: 298da8c2 am: 0b0c1a8b

parents 7268f613 0b0c1a8b
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -664,6 +664,11 @@ public class DataNetwork extends StateMachine {
     */
    private @NetworkType int mLastKnownDataNetworkType;

    /**
     * The last known roaming state of this data network.
     */
    private boolean mLastKnownRoamingState;

    /** The reason that why setting up this data network is allowed. */
    private @NonNull DataAllowedReason mDataAllowedReason;

@@ -929,6 +934,7 @@ public class DataNetwork extends StateMachine {
        }
        mTransport = transport;
        mLastKnownDataNetworkType = getDataNetworkType();
        mLastKnownRoamingState = mPhone.getServiceState().getDataRoamingFromRegistration();
        mDataAllowedReason = dataAllowedReason;
        dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime());
        mAttachedNetworkRequestList.addAll(networkRequestList);
@@ -1142,6 +1148,15 @@ public class DataNetwork extends StateMachine {
                    if (networkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
                        mLastKnownDataNetworkType = networkType;
                    }
                    NetworkRegistrationInfo nri =
                            mPhone.getServiceState()
                                    .getNetworkRegistrationInfo(
                                            NetworkRegistrationInfo.DOMAIN_PS,
                                            AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                    if (nri != null && nri.isInService()) {
                        mLastKnownRoamingState = nri.getNetworkRegistrationState()
                                == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING;
                    }
                    updateSuspendState();
                    updateNetworkCapabilities();
                    break;
@@ -3398,6 +3413,13 @@ public class DataNetwork extends StateMachine {
        return mLastKnownDataNetworkType;
    }

    /**
     * @return The last known roaming state of this data network.
     */
    public boolean getLastKnownRoamingState() {
        return mLastKnownRoamingState;
    }

    /**
     * @return The PCO data received from the network.
     */
+14 −4
Original line number Diff line number Diff line
@@ -1996,21 +1996,31 @@ public class DataNetworkController extends Handler {
            }
            int sourceAccessNetwork = DataUtils.networkTypeToAccessNetworkType(
                    sourceNetworkType);

            NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo(
                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            boolean isWwanInService = false;
            if (nri != null && nri.isInService()) {
                isWwanInService = true;
            }
            // If WWAN is inService, use the real roaming state reported by modem instead of
            // using the overridden roaming state, otherwise get last known roaming state stored
            // in data network.
            boolean isRoaming = isWwanInService ? mServiceState.getDataRoamingFromRegistration()
                    : dataNetwork.getLastKnownRoamingState();
            int targetAccessNetwork = DataUtils.networkTypeToAccessNetworkType(
                    getDataNetworkType(DataUtils.getTargetTransport(dataNetwork.getTransport())));
            NetworkCapabilities capabilities = dataNetwork.getNetworkCapabilities();
            log("evaluateDataNetworkHandover: "
                    + "source=" + AccessNetworkType.toString(sourceAccessNetwork)
                    + ", target=" + AccessNetworkType.toString(targetAccessNetwork)
                    + ", roaming=" + isRoaming
                    + ", ServiceState=" + mServiceState
                    + ", capabilities=" + capabilities);

            // Matching the rules by the configured order. Bail out if find first matching rule.
            for (HandoverRule rule : handoverRules) {
                // Check if the rule is only for roaming and we are not roaming. Use the real
                // roaming state reported by modem instead of using the overridden roaming state.
                if (rule.isOnlyForRoaming && !mServiceState.getDataRoamingFromRegistration()) {
                // Check if the rule is only for roaming and we are not roaming.
                if (rule.isOnlyForRoaming && !isRoaming) {
                    // If the rule is for roaming only, and the device is not roaming, then bypass
                    // this rule.
                    continue;
+79 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.provider.Telephony;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.Annotation;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.NetCapability;
import android.telephony.Annotation.NetworkType;
@@ -4034,6 +4035,84 @@ public class DataNetworkControllerTest extends TelephonyTest {
                AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
    }

    @Test
    public void testHandoverDataNetworkRoamingOos() throws Exception {
        testSetupImsDataNetwork();
        // Configured handover is disallowed at Roaming.
        mCarrierConfig.putStringArray(
                CarrierConfigManager.KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY,
                new String[]{
                        "source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN|UNKNOWN, "
                                + "target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, roaming=true, "
                                + "type=disallowed, capabilities=IMS"
                });
        carrierConfigChanged();
        DataNetwork dataNetwork = getDataNetworks().get(0);
        //Enter ROAMING
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING);
        updateServiceStateForDatatNetwork(TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING, dataNetwork);
        //OOS
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING);
        updateServiceStateForDatatNetwork(TelephonyManager.NETWORK_TYPE_UNKNOWN,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING,
                dataNetwork);

        updateTransport(NetworkCapabilities.NET_CAPABILITY_IMS,
                AccessNetworkConstants.TRANSPORT_TYPE_WLAN);

        // Verify IMS network was torn down on source first.
        verify(mMockedWwanDataServiceManager).deactivateDataCall(anyInt(),
                eq(DataService.REQUEST_REASON_NORMAL), any(Message.class));

        // Verify that IWLAN is brought up again on IWLAN.
        verify(mMockedWlanDataServiceManager).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(),
                eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), any(), anyBoolean(),
                any(Message.class));

        DataNetwork dataNetworkIwlan = getDataNetworks().get(0);
        assertThat(dataNetworkIwlan.getTransport()).isEqualTo(
                AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
    }

    private void updateServiceStateForDatatNetwork(@Annotation.NetworkType int networkType,
            @NetworkRegistrationInfo.RegistrationState int regState, DataNetwork dataNetwork) {
        ServiceState ss = new ServiceState();
        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setAccessNetworkTechnology(networkType)
                .setRegistrationState(regState)
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .setDataSpecificInfo(null)
                .build());

        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .build());

        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setAccessNetworkTechnology(networkType)
                .setRegistrationState(regState)
                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                .build());
        ss.setDataRoamingFromRegistration(regState
                == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING);
        doReturn(ss).when(mSST).getServiceState();
        doReturn(ss).when(mPhone).getServiceState();

        if (dataNetwork != null) {
            dataNetwork.obtainMessage(9/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
            processAllMessages();
        }
    }

    @Test
    public void testHandoverDataNetworkSourceOosNoUnknownRule() throws Exception {
        testSetupImsDataNetwork();