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

Commit abd36efd authored by Sarah Chin's avatar Sarah Chin Committed by Android (Google) Code Review
Browse files

Merge "Ratchet PCC bandwidths only if anchor cell is the same and ignore empty"

parents 8dd2f612 b6a79f5b
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -158,7 +158,6 @@ public class NetworkTypeController extends StateMachine {
    private boolean mIsTimerResetEnabledForLegacyStateRrcIdle;
    private int mLtePlusThresholdBandwidth;
    private int mNrAdvancedThresholdBandwidth;
    private boolean mIncludeLteForNrAdvancedThresholdBandwidth;
    private @NonNull int[] mAdditionalNrAdvancedBandsList;
    private @NonNull String mPrimaryTimerState;
    private @NonNull String mSecondaryTimerState;
@@ -282,8 +281,6 @@ public class NetworkTypeController extends StateMachine {
                CarrierConfigManager.KEY_LTE_PLUS_THRESHOLD_BANDWIDTH_KHZ_INT);
        mNrAdvancedThresholdBandwidth = config.getInt(
                CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT);
        mIncludeLteForNrAdvancedThresholdBandwidth = config.getBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL);
        mEnableNrAdvancedWhileRoaming = config.getBoolean(
                CarrierConfigManager.KEY_ENABLE_NR_ADVANCED_WHILE_ROAMING_BOOL);
        mAdditionalNrAdvancedBandsList = config.getIntArray(
@@ -1270,20 +1267,11 @@ public class NetworkTypeController extends StateMachine {
            return false;
        }

        int bandwidths = 0;
        if (mPhone.getServiceStateTracker().getPhysicalChannelConfigList() != null) {
            bandwidths = mPhone.getServiceStateTracker().getPhysicalChannelConfigList()
                    .stream()
                    .filter(config -> mIncludeLteForNrAdvancedThresholdBandwidth
                            || config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR)
                    .map(PhysicalChannelConfig::getCellBandwidthDownlinkKhz)
                    .mapToInt(Integer::intValue)
                    .sum();
        }

        // Check if meeting minimum bandwidth requirement. For most carriers, there is no minimum
        // bandwidth requirement and mNrAdvancedThresholdBandwidth is 0.
        if (mNrAdvancedThresholdBandwidth > 0 && bandwidths < mNrAdvancedThresholdBandwidth) {
        if (mNrAdvancedThresholdBandwidth > 0
                && IntStream.of(mPhone.getServiceState().getCellBandwidths()).sum()
                < mNrAdvancedThresholdBandwidth) {
            return false;
        }

+49 −4
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ public class ServiceStateTracker extends Handler {
    private long mLastCellInfoReqTime;
    private List<CellInfo> mLastCellInfoList = null;
    private List<PhysicalChannelConfig> mLastPhysicalChannelConfigList = null;
    private int mLastAnchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;

    private final Set<Integer> mRadioPowerOffReasons = new HashSet();

@@ -1637,8 +1638,20 @@ public class ServiceStateTracker extends Handler {
                if (ar.exception == null) {
                    List<PhysicalChannelConfig> list = (List<PhysicalChannelConfig>) ar.result;
                    if (VDBG) {
                        log("EVENT_PHYSICAL_CHANNEL_CONFIG: size=" + list.size() + " list="
                                + list);
                        log("EVENT_PHYSICAL_CHANNEL_CONFIG: list=" + list
                                + (list == null ? "" : ", list.size()=" + list.size()));
                    }
                    if ((list == null || list.isEmpty())
                            && mLastAnchorNrCellId != PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN
                            && mPhone.getContext().getSystemService(TelephonyManager.class)
                                    .isRadioInterfaceCapabilitySupported(TelephonyManager
                                            .CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED)
                            && !mCarrierConfig.getBoolean(CarrierConfigManager
                                    .KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL)
                            && mCarrierConfig.getBoolean(CarrierConfigManager
                                    .KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL)) {
                        log("Ignore empty PCC list when RRC idle.");
                        break;
                    }
                    mLastPhysicalChannelConfigList = list;
                    boolean hasChanged = false;
@@ -1650,8 +1663,40 @@ public class ServiceStateTracker extends Handler {
                        mNrFrequencyChangedRegistrants.notifyRegistrants();
                        hasChanged = true;
                    }
                    hasChanged |= RatRatcheter
                            .updateBandwidths(getBandwidthsFromConfigs(list), mSS);
                    int anchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
                    if (list != null) {
                        anchorNrCellId = list
                                .stream()
                                .filter(config -> config.getNetworkType()
                                        == TelephonyManager.NETWORK_TYPE_NR
                                        && config.getConnectionStatus()
                                        == PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING)
                                .map(PhysicalChannelConfig::getPhysicalCellId)
                                .findFirst()
                                .orElse(PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN);
                    }
                    boolean includeLte = mCarrierConfig.getBoolean(CarrierConfigManager
                            .KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL);
                    int[] bandwidths = new int[0];
                    if (list != null) {
                        bandwidths = list.stream()
                                .filter(config -> includeLte || config.getNetworkType()
                                        == TelephonyManager.NETWORK_TYPE_NR)
                                .map(PhysicalChannelConfig::getCellBandwidthDownlinkKhz)
                                .mapToInt(Integer::intValue)
                                .toArray();
                    }
                    if (anchorNrCellId == mLastAnchorNrCellId
                            && anchorNrCellId != PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
                        log("Ratchet bandwidths since anchor NR cell is the same.");
                        hasChanged |= RatRatcheter.updateBandwidths(bandwidths, mSS);
                    } else {
                        log("Do not ratchet bandwidths since anchor NR cell is different ("
                                + mLastAnchorNrCellId + "->" + anchorNrCellId + ").");
                        mLastAnchorNrCellId = anchorNrCellId;
                        hasChanged = !Arrays.equals(mSS.getCellBandwidths(), bandwidths);
                        mSS.setCellBandwidths(bandwidths);
                    }

                    mPhone.notifyPhysicalChannelConfig(list);
                    // Notify NR frequency, NR connection status or bandwidths changed.
+1 −34
Original line number Diff line number Diff line
@@ -555,7 +555,6 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("not_restricted_rrc_con", getCurrentState().getName());
    }


    @Test
    public void testUsingUserDataForRrcDetection_FromNrConnectedMmwaveToLteConnected()
            throws Exception {
@@ -1267,12 +1266,7 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellBandwidthDownlinkKhz(20001)
                .build());
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        doReturn(new int[] {20001}).when(mServiceState).getCellBandwidths();
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        broadcastCarrierConfigs();

@@ -1281,33 +1275,6 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("connected_mmwave", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateNrConnectedWithHighBandwidthIncludingLte()
            throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellBandwidthDownlinkKhz(20000)
                .build());
        lastPhysicalChannelConfigList.add(new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_LTE)
                .setCellBandwidthDownlinkKhz(10000)
                .build());
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        mBundle.putBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL,
                true);
        broadcastCarrierConfigs();

        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
        processAllMessages();
        assertEquals("connected_mmwave", getCurrentState().getName());
    }

    @Test
    public void testNrAdvancedDisabledWhileRoaming() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
+26 −7
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.telephony;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -251,6 +252,15 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                // UMTS < GPRS < EDGE
                new String[]{"3,1,2"});

        mBundle.putBoolean(CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL,
                false);

        mBundle.putBoolean(CarrierConfigManager.KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL,
                true);

        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
                TelephonyManager.CAPABILITY_PHYSICAL_CHANNEL_CONFIG_1_6_SUPPORTED);

        mSimulatedCommands.setVoiceRegState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
        mSimulatedCommands.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_HSPA);
        mSimulatedCommands.setDataRegState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
@@ -2237,16 +2247,20 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    }

    @Test
    public void testPhyChanBandwidthRatchetedOnPhyChanBandwidth() throws Exception {
    public void testPhyChanBandwidthRatchetedOnPhyChanBandwidth() {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL,
                true);

        // LTE Cell with bandwidth = 10000
        CellIdentityLte cellIdentity10 =
                new CellIdentityLte(1, 1, 1, 1, new int[] {1, 2}, 10000, "1", "1", "test",
                        "tst", Collections.emptyList(), null);

        sendRegStateUpdateForLteCellId(cellIdentity10);
        assertTrue(Arrays.equals(new int[] {10000}, sst.mSS.getCellBandwidths()));
        assertArrayEquals(new int[]{10000}, sst.mSS.getCellBandwidths());
        sendPhyChanConfigChange(new int[] {10000, 5000}, TelephonyManager.NETWORK_TYPE_LTE, 1);
        assertTrue(Arrays.equals(new int[] {10000, 5000}, sst.mSS.getCellBandwidths()));
        assertArrayEquals(new int[]{10000, 5000}, sst.mSS.getCellBandwidths());
    }

    @Test
@@ -2258,7 +2272,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    }

    @Test
    public void testPhyChanBandwidthResetsOnOos() throws Exception {
    public void testPhyChanBandwidthResetsOnOos() {
        testPhyChanBandwidthRatchetedOnPhyChanBandwidth();
        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
@@ -2288,11 +2302,16 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    public void testPhyChanBandwidthForNr() {
        // NR Cell with bandwidth = 10000
        CellIdentityNr nrCi = new CellIdentityNr(
                0, 0, 0, new int[] {}, "", "", 5, "", "", Collections.emptyList());
                0, 0, 0, new int[]{10000}, "", "", 5, "", "", Collections.emptyList());

        sendPhyChanConfigChange(new int[] {10000, 5000}, TelephonyManager.NETWORK_TYPE_NR, 0);
        sendRegStateUpdateForNrCellId(nrCi);
        assertTrue(Arrays.equals(new int[] {10000, 5000}, sst.mSS.getCellBandwidths()));
        // should ratchet for NR
        sendPhyChanConfigChange(new int[] {10000, 5000}, TelephonyManager.NETWORK_TYPE_NR, 0);
        assertArrayEquals(new int[]{10000, 5000}, sst.mSS.getCellBandwidths());

        // should not ratchet for LTE
        sendPhyChanConfigChange(new int[] {100}, TelephonyManager.NETWORK_TYPE_LTE, 0);
        assertArrayEquals(new int[]{}, sst.mSS.getCellBandwidths());
    }

    /**