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

Commit c025f01a authored by Ling Ma's avatar Ling Ma
Browse files

Prevent advance <-> idle pingpong

If we moved advance -> idle, it means physical link status is inactive(be it determined by PCC or notified from DNC). Then, unless physical link changed to active again, any attempts to move back to advance should be ignored.

Fix: 350390372
Test: b/350390372#comment47
Flag: EXEMPT bugfix
Change-Id: I5a01d2ef19911a2c74201aea9a725466b8478083
parent 6171d7ff
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1024,7 +1024,10 @@ public class NetworkTypeController extends StateMachine {
                    if (rat == TelephonyManager.NETWORK_TYPE_NR
                            || (isLte(rat) && isNrConnected())) {
                        if (isNrAdvanced()) {
                            transitionTo(mNrConnectedAdvancedState);
                            // Move into idle state because mPhysicalLinkStatus indicated idle,
                            // ignored any advance reason because unless mPhysicalLinkStatus changed
                            // again, shouldn't move back to advance.
                            log("Ignore NR advanced from cached PCC/RatchetedNrBands while idle");
                        } else if (isPhysicalLinkActive()) {
                            transitionWithTimerTo(mNrConnectedState);
                        } else {
+46 −0
Original line number Diff line number Diff line
@@ -1506,6 +1506,52 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertFalse(mNetworkTypeController.areAnyTimersActive());
    }

    @Test
    public void testTransitionToNrIdle() throws Exception {
        doReturn(true).when(mFeatureFlags).supportNrSaRrcIdle();
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
        ArrayList<PhysicalChannelConfig> physicalChannelConfigs = new ArrayList<>();
        // use advanced band
        physicalChannelConfigs.add(new PhysicalChannelConfig.Builder()
                .setPhysicalCellId(1)
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
                .setBand(41)
                .build());
        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
                new int[]{41});
        mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING,
                "connected_mmwave,any,10");
        sendCarrierConfigChanged();

        assertEquals("connected_mmwave", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED,
                mNetworkTypeController.getOverrideNetworkType());

        // empty PCC, switch to connected_rrc_idle,
        // isNrAdvanced is still true(due to either advance band OR frequency)
        physicalChannelConfigs.clear();
        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */,
                new AsyncResult(null, physicalChannelConfigs, null));
        processAllMessages();

        assertEquals("connected_rrc_idle", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED,
                mNetworkTypeController.getOverrideNetworkType());
        assertTrue(mNetworkTypeController.areAnyTimersActive());

        // Received an event update, verify should stay in idle because physical link didn't change,
        // otherwise there is a loop between advance state and idle state.
        mNetworkTypeController.sendMessage(0 /* EVENT_UPDATE */);
        processAllMessages();

        assertEquals("connected_rrc_idle", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED,
                mNetworkTypeController.getOverrideNetworkType());
    }

    @Test
    public void testSecondaryTimerAdvanceBand() throws Exception {
        doReturn(true).when(mFeatureFlags).supportNrSaRrcIdle();