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

Commit e225a9b8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11464157 from 9e935a83 to 24Q2-release

Change-Id: I15d5b3afe5e60c6f71640c672e56673006186135
parents 0b559fb4 9e935a83
Loading
Loading
Loading
Loading
+26 −5
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class NetworkTypeController extends StateMachine {
    private boolean mIsPrimaryTimerActive;
    private boolean mIsSecondaryTimerActive;
    private boolean mIsTimerResetEnabledForLegacyStateRrcIdle;
    private boolean mIsTimerResetEnabledOnPlmnChanges;
    private int mLtePlusThresholdBandwidth;
    private int mNrAdvancedThresholdBandwidth;
    private boolean mIncludeLteForNrAdvancedThresholdBandwidth;
@@ -172,6 +173,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 +194,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;
@@ -304,6 +309,8 @@ public class NetworkTypeController extends StateMachine {
                CarrierConfigManager.KEY_SHOW_CARRIER_DATA_ICON_PATTERN_STRING);
        mIsTimerResetEnabledForLegacyStateRrcIdle = config.getBoolean(
                CarrierConfigManager.KEY_NR_TIMERS_RESET_IF_NON_ENDC_AND_RRC_IDLE_BOOL);
        mIsTimerResetEnabledOnPlmnChanges = config.getBoolean(
                CarrierConfigManager.KEY_NR_TIMERS_RESET_ON_PLMN_CHANGE_BOOL);
        mLtePlusThresholdBandwidth = config.getInt(
                CarrierConfigManager.KEY_LTE_PLUS_THRESHOLD_BANDWIDTH_KHZ_INT);
        mNrAdvancedThresholdBandwidth = config.getInt(
@@ -359,6 +366,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(
@@ -656,6 +665,7 @@ public class NetworkTypeController extends StateMachine {
                    mIsSecondaryTimerActive = false;
                    mSecondaryTimerState = "";
                    updateTimers();
                    mLastShownNrDueToAdvancedBand = false;
                    updateOverrideNetworkType();
                    break;
                case EVENT_RADIO_OFF_OR_UNAVAILABLE:
@@ -1136,7 +1146,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) {
@@ -1206,12 +1220,13 @@ public class NetworkTypeController extends StateMachine {

    /** On service state changed. */
    private void onServiceStateChanged() {
        ServiceState newSS = mPhone.getServiceStateTracker().getServiceState();
        if (!TextUtils.equals(mServiceState.getOperatorAlpha(), newSS.getOperatorAlpha())) {
            log("PLMN changed, reset any timers");
        ServiceState ss = mPhone.getServiceStateTracker().getServiceState();
        if (mIsTimerResetEnabledOnPlmnChanges
                && !TextUtils.equals(mServiceState.getOperatorNumeric(), ss.getOperatorNumeric())) {
            log("Reset any timers due to nr_timers_reset_on_plmn_change_bool");
            resetAllTimers();
        }
        mServiceState = newSS;
        mServiceState = ss;
        if (DBG) log("ServiceState updated: " + mServiceState);
    }

@@ -1321,6 +1336,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;
@@ -1425,6 +1444,8 @@ public class NetworkTypeController extends StateMachine {
        mIsSecondaryTimerActive = false;
        mPrimaryTimerState = "";
        mSecondaryTimerState = "";

        mLastShownNrDueToAdvancedBand = false;
    }

    private boolean isTimerActiveForRrcIdle() {
+86 −1
Original line number Diff line number Diff line
@@ -1429,6 +1429,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();
@@ -1779,6 +1862,8 @@ public class NetworkTypeControllerTest extends TelephonyTest {
    @Test
    public void testNrTimerResetWhenPlmnChanged() throws Exception {
        testTransitionToCurrentStateNrConnectedMmwave();
        mBundle.putBoolean(CarrierConfigManager.KEY_NR_TIMERS_RESET_ON_PLMN_CHANGE_BOOL,
                true);
        mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING,
                "connected_mmwave,any,10;connected,any,10;not_restricted_rrc_con,any,10");
        mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING,
@@ -1798,7 +1883,7 @@ public class NetworkTypeControllerTest extends TelephonyTest {

        // PLMN changed, should cancel any active timers
        ServiceState newSS = mock(ServiceState.class);
        doReturn("different plmn").when(newSS).getOperatorAlpha();
        doReturn("different plmn").when(newSS).getOperatorNumeric();
        doReturn(newSS).when(mSST).getServiceState();
        mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */);
        processAllMessages();
+0 −18
Original line number Diff line number Diff line
@@ -246,24 +246,6 @@ public class DomainSelectionControllerTest extends TelephonyTest {
        verify(mMockContext, times(1)).bindService(any(), any(), anyInt());
    }

    /**
     * Ensure that calling unbind stops automatic rebind from occurring.
     */
    @SmallTest
    @Test
    public void testUnbindCauseAutoBindCancelAfterBinderDied() throws RemoteException {
        ServiceConnection conn = bindAndConnectService();

        conn.onBindingDied(null /*null*/);
        mTestController.unbind();

        long delay = mTestController.getBindDelay();
        waitForHandlerActionDelayed(mHandler, delay, 2 * delay);

        // Unbind should stop the autobind from occurring.
        verify(mMockContext, times(1)).bindService(any(), any(), anyInt());
    }

    private void bindAndNullServiceError() {
        ServiceConnection connection = bindService(mTestComponentName);
        connection.onNullBinding(mTestComponentName);