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

Commit 01d4efdb authored by SongFerngWang's avatar SongFerngWang
Browse files

Using user data to detect RRC state

Some carrier want to use user data(legacy behavior) to detect RRC state.

Bug: 191321871
Test: build pass and no phone crash.
atest NetworkTypeControllerTest  (pass)

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


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


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

    protected void log(String s) {
    protected void log(String s) {
        Rlog.d(TAG, "[" + mPhone.getPhoneId() + "] " + s);
        Rlog.d(TAG, "[" + mPhone.getPhoneId() + "] " + s);
    }
    }
+88 −0
Original line number Original line Diff line number Diff line
@@ -301,6 +301,27 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
        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
    @Test
    public void testTransitionToCurrentStateLteConnected() throws Exception {
    public void testTransitionToCurrentStateLteConnected() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
        assertEquals("DefaultState", getCurrentState().getName());
@@ -319,6 +340,7 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        broadcastCarrierConfigs();
        processAllMessages();
        processAllMessages();
        assertEquals("DefaultState", getCurrentState().getName());
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
@@ -330,6 +352,28 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
        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
    @Test
    public void testTransitionToCurrentStateNrConnected() throws Exception {
    public void testTransitionToCurrentStateNrConnected() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
        assertEquals("DefaultState", getCurrentState().getName());
@@ -564,6 +608,30 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
        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
    @Test
    public void testEventPhysicalChannelChangeFromLteToLteCaInLegacyState() throws Exception {
    public void testEventPhysicalChannelChangeFromLteToLteCaInLegacyState() throws Exception {
        testTransitionToCurrentStateLegacy();
        testTransitionToCurrentStateLegacy();
@@ -668,6 +736,26 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
        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
    @Test
    public void testEventPhysicalChannelConfigNotifChanged() throws Exception {
    public void testEventPhysicalChannelConfigNotifChanged() throws Exception {
        testTransitionToCurrentStateNrConnected();
        testTransitionToCurrentStateNrConnected();