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

Commit 2d35175d authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

Merge "Using PHYSICAL_CHANNEL_CONFIG to detect RRC state" into sc-dev

parents 45bbb83e f0599178
Loading
Loading
Loading
Loading
+67 −7
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ public class NetworkTypeController extends StateMachine {
    private String mSecondaryTimerState;
    private String mPreviousState;
    private @PhysicalLinkState int mPhysicalLinkState;
    private boolean mIsPhysicalChannelConfig16Supported;

    /**
     * NetworkTypeController constructor.
@@ -190,9 +191,14 @@ public class NetworkTypeController extends StateMachine {
        mPhone.getServiceStateTracker().registerForDataRegStateOrRatChanged(
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getHandler(),
                EVENT_DATA_RAT_CHANGED, null);
        mIsPhysicalChannelConfig16Supported = mPhone.getContext().getSystemService(
                TelephonyManager.class).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        if (!mIsPhysicalChannelConfig16Supported) {
            mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .registerForPhysicalLinkStateChanged(getHandler(),
                            EVENT_PHYSICAL_LINK_STATE_CHANGED);
        }
        mPhone.getServiceStateTracker().registerForNrStateChanged(getHandler(),
                EVENT_NR_STATE_CHANGED, null);
        mPhone.getServiceStateTracker().registerForNrFrequencyChanged(getHandler(),
@@ -480,9 +486,13 @@ public class NetworkTypeController extends StateMachine {
                case EVENT_DATA_RAT_CHANGED:
                case EVENT_NR_STATE_CHANGED:
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    // ignored
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    }
                    break;
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
@@ -586,9 +596,19 @@ public class NetworkTypeController extends StateMachine {
                    mIsNrRestricted = isNrRestricted();
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    // ignored
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (!mIsPhysicalChannelConfig16Supported) {
                        // ignore
                        break;
                    }
                    mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    if (mIsTimerResetEnabledForLegacyStateRRCIdle && !isPhysicalLinkActive()) {
                        resetAllTimers();
                        updateOverrideNetworkType();
                    }
                    break;
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
@@ -649,9 +669,24 @@ public class NetworkTypeController extends StateMachine {
                    }
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                    // ignore
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (!mIsPhysicalChannelConfig16Supported) {
                        // ignore
                        break;
                    }
                    mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    if (isNrNotRestricted()) {
                        // NOT_RESTRICTED_RRC_IDLE -> NOT_RESTRICTED_RRC_CON
                        if (isPhysicalLinkActive()) {
                            transitionWithTimerTo(mLteConnectedState);
                        }
                    } else {
                        log("NR state changed. Sending EVENT_NR_STATE_CHANGED");
                        sendMessage(EVENT_NR_STATE_CHANGED);
                    }
                    break;
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
@@ -717,9 +752,24 @@ public class NetworkTypeController extends StateMachine {
                    }
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                    // ignore
                    break;
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (!mIsPhysicalChannelConfig16Supported) {
                        // ignore
                        break;
                    }
                    mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    if (isNrNotRestricted()) {
                        // NOT_RESTRICTED_RRC_CON -> NOT_RESTRICTED_RRC_IDLE
                        if (!isPhysicalLinkActive()) {
                            transitionWithTimerTo(mIdleState);
                        }
                    } else {
                        log("NR state changed. Sending EVENT_NR_STATE_CHANGED");
                        sendMessage(EVENT_NR_STATE_CHANGED);
                    }
                    break;
                case EVENT_PHYSICAL_LINK_STATE_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkState = (int) ar.result;
@@ -793,6 +843,9 @@ public class NetworkTypeController extends StateMachine {
                    break;
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED:
                    if (mIsPhysicalChannelConfig16Supported) {
                        mPhysicalLinkState = getPhysicalLinkStateFromPhysicalChannelConfig();
                    }
                    if (!isNrConnected()) {
                        log("NR state changed. Sending EVENT_NR_STATE_CHANGED");
                        sendMessage(EVENT_NR_STATE_CHANGED);
@@ -1064,6 +1117,13 @@ public class NetworkTypeController extends StateMachine {
        return mPhysicalLinkState == DcController.PHYSICAL_LINK_ACTIVE;
    }

    private int getPhysicalLinkStateFromPhysicalChannelConfig() {
        List<PhysicalChannelConfig> physicalChannelConfigList =
                mPhone.getServiceStateTracker().getPhysicalChannelConfigList();
        return (physicalChannelConfigList == null || physicalChannelConfigList.isEmpty())
                ? DcController.PHYSICAL_LINK_NOT_ACTIVE : DcController.PHYSICAL_LINK_ACTIVE;
    }

    private int getDataNetworkType() {
        NetworkRegistrationInfo nri =  mPhone.getServiceState().getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony;
import static android.telephony.TelephonyManager.CAPABILITY_ALLOWED_NETWORK_TYPES_USED;
import static android.telephony.TelephonyManager
        .CAPABILITY_NR_DUAL_CONNECTIVITY_CONFIGURATION_AVAILABLE;
import static android.telephony.TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED;
import static android.telephony.TelephonyManager.CAPABILITY_SECONDARY_LINK_BANDWIDTH_VISIBLE;
import static android.telephony.TelephonyManager.CAPABILITY_SLICING_CONFIG_SUPPORTED;
import static android.telephony.TelephonyManager.CAPABILITY_THERMAL_MITIGATION_DATA_THROTTLING;
@@ -310,6 +311,8 @@ public class RadioConfigResponse extends IRadioConfigResponse.Stub {
                Rlog.d(TAG, "CAPABILITY_THERMAL_MITIGATION_DATA_THROTTLING");
                caps.add(CAPABILITY_SLICING_CONFIG_SUPPORTED);
                Rlog.d(TAG, "CAPABILITY_SLICING_CONFIG_SUPPORTED");
                caps.add(CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
                Rlog.d(TAG, "CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED");
            }
        }
        return caps;
+97 −6
Original line number Diff line number Diff line
@@ -103,6 +103,8 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        doReturn(RadioAccessFamily.getRafFromNetworkType(
                TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA)).when(
                mPhone).getCachedAllowedNetworkTypesBitmask();
        doReturn(false).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        processAllMessages();
    }
@@ -274,6 +276,22 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateIdleSupportPhysicalChannelConfig1_6() throws Exception {
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        processAllMessages();
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
        setPhysicalLinkState(false);
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED);
        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
        processAllMessages();
        assertEquals("not_restricted_rrc_idle", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateLteConnected() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
@@ -286,6 +304,23 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateLteConnectedSupportPhysicalChannelConfig1_6()
            throws Exception {
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        processAllMessages();
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
        setPhysicalLinkState(true);
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED);
        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
        processAllMessages();
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateNrConnected() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
@@ -322,9 +357,9 @@ public class NetworkTypeControllerTest extends TelephonyTest {
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setBand(41)
                .build();
        List<PhysicalChannelConfig> mLastPhysicalChannelConfigList = new ArrayList<>();
        mLastPhysicalChannelConfigList.add(physicalChannelConfig);
        doReturn(mLastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(physicalChannelConfig);
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        broadcastCarrierConfigs();

        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
@@ -345,9 +380,9 @@ public class NetworkTypeControllerTest extends TelephonyTest {
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setBand(2)
                .build();
        List<PhysicalChannelConfig> mLastPhysicalChannelConfigList = new ArrayList<>();
        mLastPhysicalChannelConfigList.add(physicalChannelConfig);
        doReturn(mLastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(physicalChannelConfig);
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        broadcastCarrierConfigs();

        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
@@ -414,13 +449,52 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }

    @Test
    public void testNrPhysicalChannelChange1_6FromNrConnectedMmwaveToLteConnected()
            throws Exception {
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        processAllMessages();
        testTransitionToCurrentStateNrConnectedMmwave();
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState();
        setPhysicalLinkState(true);
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED);
        mNetworkTypeController.sendMessage(EVENT_NR_FREQUENCY_CHANGED);
        mNetworkTypeController.sendMessage(EVENT_NR_STATE_CHANGED);

        processAllMessages();

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

    @Test
    public void testEventPhysicalLinkStateChanged() throws Exception {
        testTransitionToCurrentStateLteConnected();
        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 testEventPhysicalLinkStateChangedSupportPhysicalChannelConfig1_6()
            throws Exception {
        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);
        mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController);
        processAllMessages();
        testTransitionToCurrentStateLteConnectedSupportPhysicalChannelConfig1_6();
        doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange();
        setPhysicalLinkState(false);
        mNetworkTypeController.sendMessage(EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED);

        processAllMessages();

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

@@ -842,4 +916,21 @@ public class NetworkTypeControllerTest extends TelephonyTest {
                mNetworkTypeController.getOverrideNetworkType());
        assertFalse(mNetworkTypeController.is5GHysteresisActive());
    }

    private void setPhysicalLinkState(Boolean state) {
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        // If PhysicalChannelConfigList is empty, PhysicalLinkState is DcController
        // .PHYSICAL_LINK_NOT_ACTIVE
        // If PhysicalChannelConfigList is not empty, PhysicalLinkState is DcController
        // .PHYSICAL_LINK_ACTIVE

        if (state) {
            PhysicalChannelConfig physicalChannelConfig = new PhysicalChannelConfig.Builder()
                    .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                    .setBand(41)
                    .build();
            lastPhysicalChannelConfigList.add(physicalChannelConfig);
        }
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
    }
}