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

Commit a3555fa5 authored by Sarah Kim's avatar Sarah Kim Committed by Android Build Coastguard Worker
Browse files

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

This reverts commit b6a79f5b.

Reason for revert: b/286594668
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:542f8e399ce10bd6d34c724b00f6f1a5b8f5daae)
Merged-In: I67d9a186cd67e495cc64f60cc0fdf838335ceeeb
Change-Id: I67d9a186cd67e495cc64f60cc0fdf838335ceeeb
parent 6ccd6680
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ 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;
@@ -290,6 +291,8 @@ 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(
@@ -1281,11 +1284,20 @@ 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
                && IntStream.of(mPhone.getServiceState().getCellBandwidths()).sum()
                < mNrAdvancedThresholdBandwidth) {
        if (mNrAdvancedThresholdBandwidth > 0 && bandwidths < mNrAdvancedThresholdBandwidth) {
            return false;
        }

+2 −47
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ 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();

@@ -1661,18 +1660,6 @@ public class ServiceStateTracker extends Handler {
                        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;
                    if (updateNrStateFromPhysicalChannelConfigs(list, mSS)) {
@@ -1683,40 +1670,8 @@ public class ServiceStateTracker extends Handler {
                        mNrFrequencyChangedRegistrants.notifyRegistrants();
                        hasChanged = true;
                    }
                    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);
                    }
                    hasChanged |= RatRatcheter
                            .updateBandwidths(getBandwidthsFromConfigs(list), mSS);

                    mPhone.notifyPhysicalChannelConfig(list);
                    // Notify NR frequency, NR connection status or bandwidths changed.
+33 −1
Original line number Diff line number Diff line
@@ -1274,7 +1274,12 @@ 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();
        doReturn(new int[] {20001}).when(mServiceState).getCellBandwidths();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellBandwidthDownlinkKhz(20001)
                .build());
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        sendCarrierConfigChanged();

@@ -1283,6 +1288,33 @@ 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);
        sendCarrierConfigChanged();

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

    @Test
    public void testNrAdvancedDisabledWhileRoaming() throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
+3 −21
Original line number Diff line number Diff line
@@ -278,15 +278,6 @@ 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);
@@ -2282,10 +2273,6 @@ public class ServiceStateTrackerTest extends TelephonyTest {

    @Test
    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",
@@ -2372,16 +2359,11 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    public void testPhyChanBandwidthForNr() {
        // NR Cell with bandwidth = 10000
        CellIdentityNr nrCi = new CellIdentityNr(
                0, 0, 0, new int[]{10000}, "", "", 5, "", "", Collections.emptyList());
                0, 0, 0, new int[] {}, "", "", 5, "", "", Collections.emptyList());

        sendRegStateUpdateForNrCellId(nrCi);
        // should ratchet for NR
        sendPhyChanConfigChange(new int[] {10000, 5000}, TelephonyManager.NETWORK_TYPE_NR, 0);
        sendRegStateUpdateForNrCellId(nrCi);
        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());
    }

    /**