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

Commit 2915d400 authored by Sewook Seo's avatar Sewook Seo
Browse files

Improve HandoverRule check at roaming OOS

Even though the actual PDN is established at roaming area, if DUT moves
in OOS area, handover rules for roaming condition are not referred and
unwanted handover operation can occur.
To prevent this, Store last roaming state in datanetwork when DUT is
inService, and use it for handover rule check at OOS.

Bug: 284932261
Test: atest FrameworksTelephonyTests, DeviceTest: b/284932261#comment29
Change-Id: I32a81cf95e09ef7464b695828db264f1a393da7a
parent 4fbe54b7
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
@@ -1977,21 +1977,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;
@@ -3972,6 +3973,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();