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

Commit b2fd6207 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Using user data to detect RRC state" into sc-dev am: 03f48c2b

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

Change-Id: I7865b7ea0e580850a7dcdcb0dde425f4f71f41d6
parents 7c179b8f 03f48c2b
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ public class NetworkTypeController extends StateMachine {
    private boolean mIsPhysicalChannelConfig16Supported;
    private Boolean mIsNrAdvancedAllowedByPco = false;
    private int mNrAdvancedCapablePcoId = 0;
    private boolean mIsUsingUserDataForRrcDetection = false;

    /**
     * NetworkTypeController constructor.
@@ -279,6 +280,13 @@ public class NetworkTypeController extends StateMachine {
                        CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY);
                mNrAdvancedCapablePcoId = b.getInt(
                        CarrierConfigManager.KEY_NR_ADVANCED_CAPABLE_PCO_ID_INT);
                mIsUsingUserDataForRrcDetection = b.getBoolean(
                        CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL);
                if (mIsPhysicalChannelConfig16Supported && mIsUsingUserDataForRrcDetection) {
                    mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                            .registerForPhysicalLinkStateChanged(getHandler(),
                                    EVENT_PHYSICAL_LINK_STATE_CHANGED);
                }
            }
        }
        createTimerRules(nrIconConfiguration, overrideTimerRule, overrideSecondaryTimerRule);
@@ -503,7 +511,7 @@ public class NetworkTypeController extends StateMachine {
                    // ignored
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                    if (isUsingPhysicalChannelConfigForRrcDetection()) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    }
                    break;
@@ -608,7 +616,7 @@ public class NetworkTypeController extends StateMachine {
                    // ignored
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                    if (isUsingPhysicalChannelConfigForRrcDetection()) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                        if (mIsTimerResetEnabledForLegacyStateRRCIdle && !isPhysicalLinkActive()) {
                            resetAllTimers();
@@ -680,7 +688,7 @@ public class NetworkTypeController extends StateMachine {
                    // ignore
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                    if (isUsingPhysicalChannelConfigForRrcDetection()) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                        if (isNrNotRestricted()) {
                            // NOT_RESTRICTED_RRC_IDLE -> NOT_RESTRICTED_RRC_CON
@@ -764,7 +772,7 @@ public class NetworkTypeController extends StateMachine {
                    // ignore
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                    if (isUsingPhysicalChannelConfigForRrcDetection()) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                        if (isNrNotRestricted()) {
                            // NOT_RESTRICTED_RRC_CON -> NOT_RESTRICTED_RRC_IDLE
@@ -856,7 +864,7 @@ public class NetworkTypeController extends StateMachine {
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                    if (isUsingPhysicalChannelConfigForRrcDetection()) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    }
                    updateNrAdvancedState();
@@ -1188,6 +1196,10 @@ public class NetworkTypeController extends StateMachine {
        }
    }

    private boolean isUsingPhysicalChannelConfigForRrcDetection() {
        return mIsPhysicalChannelConfig16Supported && !mIsUsingUserDataForRrcDetection;
    }

    protected void log(String s) {
        Rlog.d(TAG, "[" + mPhone.getPhoneId() + "] " + s);
    }
+88 −0
Original line number Diff line number Diff line
@@ -301,6 +301,27 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateIdle_usingUserDataForRrcDetection() throws Exception {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL, true);
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        broadcastCarrierConfigs();
        processAllMessages();
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED,
                new AsyncResult(null, DcController.PHYSICAL_LINK_NOT_ACTIVE, null));
        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);

        processAllMessages();

        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateLteConnected() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
@@ -319,6 +340,7 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        broadcastCarrierConfigs();
        processAllMessages();
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
@@ -330,6 +352,28 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateLteConnected_usingUserDataForRrcDetection()
            throws Exception {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL, true);
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        broadcastCarrierConfigs();
        processAllMessages();
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED,
                new AsyncResult(null, DcController.PHYSICAL_LINK_ACTIVE, null));
        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);

        processAllMessages();

        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateNrConnected() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
@@ -564,6 +608,30 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }


    @Test
    public void testUsingUserDataForRrcDetection_FromNrConnectedMmwaveToLteConnected()
            throws Exception {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL, true);
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        broadcastCarrierConfigs();
        processAllMessages();
        testTransitionToCurrentStateNrConnectedMmwave();
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED,
                new AsyncResult(null, DcController.PHYSICAL_LINK_ACTIVE, null));
        mNetworkTypeController.sendMessage(EVENT_NR_FREQUENCY_CHANGED);
        mNetworkTypeController.sendMessage(EVENT_NR_STATE_CHANGED);

        processAllMessages();

        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }

    @Test
    public void testEventPhysicalChannelChangeFromLteToLteCaInLegacyState() throws Exception {
        testTransitionToCurrentStateLegacy();
@@ -668,6 +736,26 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
    }

    @Test
    public void testEventPhysicalLinkStateChanged_UsingUserDataForRrcDetection()
            throws Exception {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL, true);
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        broadcastCarrierConfigs();
        processAllMessages();
        testTransitionToCurrentStateLteConnected_usingUserDataForRrcDetection();
        doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange();
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED,
                new AsyncResult(null, DcController.PHYSICAL_LINK_NOT_ACTIVE, null));

        processAllMessages();

        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
    }

    @Test
    public void testEventPhysicalChannelConfigNotifChanged() throws Exception {
        testTransitionToCurrentStateNrConnected();