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

Commit 7dcb2b16 authored by Ling Ma's avatar Ling Ma
Browse files

Add secondary timer for advance band

Add a workaround carrier config nr_advanced_band_secondary_timer for previous advance band state, that overrides the existing secondary timer config.

Bug: 316425811
Test: voice call + data browsing
Change-Id: I794f9a92526593e6ce3e2d20413f9fc67c0a37c1
parent bdb00c5b
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ public class NetworkTypeController extends StateMachine {
    @NonNull private final Set<Integer> mAdditionalNrAdvancedBands = new HashSet<>();
    @NonNull private String mPrimaryTimerState;
    @NonNull private String mSecondaryTimerState;
    // TODO(b/316425811 remove the workaround)
    private int mNrAdvancedBandsSecondaryTimer;
    @NonNull private String mPreviousState;
    @LinkStatus private int mPhysicalLinkStatus;
    private boolean mIsPhysicalChannelConfig16Supported;
@@ -191,6 +193,8 @@ public class NetworkTypeController extends StateMachine {

    // Ratchet physical channel config fields to prevent 5G/5G+ flickering
    @NonNull private Set<Integer> mRatchetedNrBands = new HashSet<>();
    // TODO(b/316425811 remove the workaround)
    private boolean mLastShownNrDueToAdvancedBand = false;
    private int mRatchetedNrBandwidths = 0;
    private int mLastAnchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
    private boolean mDoesPccListIndicateIdle = false;
@@ -359,6 +363,8 @@ public class NetworkTypeController extends StateMachine {
                    mNrPhysicalLinkStatusChangedCallback);
            mNrPhysicalLinkStatusChangedCallback = null;
        }
        mNrAdvancedBandsSecondaryTimer = config.getInt(
                CarrierConfigManager.KEY_NR_ADVANCED_BANDS_SECONDARY_TIMER_SECONDS_INT);
        String nrIconConfiguration = config.getString(
                CarrierConfigManager.KEY_5G_ICON_CONFIGURATION_STRING);
        String overrideTimerRule = config.getString(
@@ -657,6 +663,7 @@ public class NetworkTypeController extends StateMachine {
                    mIsSecondaryTimerActive = false;
                    mSecondaryTimerState = "";
                    updateTimers();
                    mLastShownNrDueToAdvancedBand = false;
                    updateOverrideNetworkType();
                    break;
                case EVENT_RADIO_OFF_OR_UNAVAILABLE:
@@ -1137,7 +1144,11 @@ public class NetworkTypeController extends StateMachine {

        @Override
        public boolean processMessage(Message msg) {
            if (DBG) log("NrConnectedAdvancedState: process " + getEventName(msg.what));
            mLastShownNrDueToAdvancedBand = isAdditionalNrAdvancedBand(mRatchetedNrBands);
            if (DBG) {
                log("NrConnectedAdvancedState: process " + getEventName(msg.what)
                        + ", been using advanced band is " + mLastShownNrDueToAdvancedBand);
            }
            updateTimers();
            AsyncResult ar;
            switch (msg.what) {
@@ -1312,6 +1323,10 @@ public class NetworkTypeController extends StateMachine {
        }
        if (!mIsDeviceIdleMode && rule != null && rule.getSecondaryTimer(currentName) > 0) {
            int duration = rule.getSecondaryTimer(currentName);
            if (mLastShownNrDueToAdvancedBand && mNrAdvancedBandsSecondaryTimer > 0) {
                duration = mNrAdvancedBandsSecondaryTimer;
                if (DBG) log("secondary timer adjusted by nr_advanced_bands_secondary_timer_long");
            }
            if (DBG) log(duration + "s secondary timer started for state: " + currentName);
            mSecondaryTimerState = currentName;
            mPreviousState = currentName;
@@ -1416,6 +1431,8 @@ public class NetworkTypeController extends StateMachine {
        mIsSecondaryTimerActive = false;
        mPrimaryTimerState = "";
        mSecondaryTimerState = "";

        mLastShownNrDueToAdvancedBand = false;
    }

    private boolean isTimerActiveForRrcIdle() {
+83 −0
Original line number Diff line number Diff line
@@ -1412,6 +1412,89 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertFalse(mNetworkTypeController.areAnyTimersActive());
    }

    @Test
    public void testSecondaryTimerAdvanceBand() 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");
        mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING,
                "connected_mmwave,any,5");
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_BANDS_SECONDARY_TIMER_SECONDS_INT,
                20);
        sendCarrierConfigChanged();

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

        // lost the advance band, trigger 10 second connected_mmwave -> connected primary timer
        physicalChannelConfigs.clear();
        physicalChannelConfigs.add(new PhysicalChannelConfig.Builder()
                .setPhysicalCellId(1)
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
                .build());
        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */,
                new AsyncResult(null, physicalChannelConfigs, null));
        processAllMessages();

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

        // switch to connected_rrc_idle before primary timer expires
        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());

        // primary timer expires
        moveTimeForward(10 * 1000);
        processAllMessages();

        // should trigger 20(not 5) seconds connected_mmwave -> connected_rrc_idle secondary timer
        assertEquals("connected_rrc_idle", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED,
                mNetworkTypeController.getOverrideNetworkType());
        assertTrue(mNetworkTypeController.areAnyTimersActive());

        // 5 seconds passed during connected_mmwave -> connected_rrc_idle secondary timer
        moveTimeForward(5 * 1000);
        processAllMessages();
        assertEquals("connected_rrc_idle", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED,
                mNetworkTypeController.getOverrideNetworkType());
        assertTrue(mNetworkTypeController.areAnyTimersActive());

        // secondary timer expired
        moveTimeForward(15 * 1000);
        processAllMessages();

        assertEquals("connected_rrc_idle", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA,
                mNetworkTypeController.getOverrideNetworkType());
        assertFalse(mNetworkTypeController.areAnyTimersActive());
    }

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