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

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

Snap for 10832001 from b70e9811 to udc-qpr1-release

Change-Id: I48fa4021d0b835639f8e7ab375a42c3754a0dfba
parents 3575f475 b70e9811
Loading
Loading
Loading
Loading
+29 −25
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class NetworkTypeController extends StateMachine {
    private int mLtePlusThresholdBandwidth;
    private int mNrAdvancedThresholdBandwidth;
    private boolean mIncludeLteForNrAdvancedThresholdBandwidth;
    private boolean mRatchetPccFieldsForSameAnchorNrCell;
    @NonNull private final Set<Integer> mAdditionalNrAdvancedBands = new HashSet<>();
    @NonNull private String mPrimaryTimerState;
    @NonNull private String mSecondaryTimerState;
@@ -300,6 +301,8 @@ public class NetworkTypeController extends StateMachine {
                CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT);
        mIncludeLteForNrAdvancedThresholdBandwidth = config.getBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL);
        mRatchetPccFieldsForSameAnchorNrCell = config.getBoolean(
                CarrierConfigManager.KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL);
        mEnableNrAdvancedWhileRoaming = config.getBoolean(
                CarrierConfigManager.KEY_ENABLE_NR_ADVANCED_WHILE_ROAMING_BOOL);
        mAdditionalNrAdvancedBands.clear();
@@ -565,9 +568,9 @@ public class NetworkTypeController extends StateMachine {
                    quit();
                    break;
                case EVENT_INITIALIZE:
                    // The reason that we do it here is because some of the works below requires
                    // other modules (e.g. DataNetworkController, ServiceStateTracker), which is not
                    // created yet when NetworkTypeController is created.
                    // The reason that we do it here is that the work below requires other modules
                    // (e.g. DataNetworkController, ServiceStateTracker), which are not created
                    // when NetworkTypeController is created.
                    registerForAllEvents();
                    parseCarrierConfigs();
                    break;
@@ -1056,6 +1059,13 @@ public class NetworkTypeController extends StateMachine {
    private void updatePhysicalChannelConfigs() {
        List<PhysicalChannelConfig> physicalChannelConfigs =
                mPhone.getServiceStateTracker().getPhysicalChannelConfigList();
        boolean isPccListEmpty = physicalChannelConfigs == null || physicalChannelConfigs.isEmpty();
        if (isPccListEmpty && isUsingPhysicalChannelConfigForRrcDetection()) {
            log("Physical channel configs updated: not updating PCC fields for empty PCC list "
                    + "indicating RRC idle.");
            mPhysicalChannelConfigs = physicalChannelConfigs;
            return;
        }

        int anchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
        int anchorLteCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
@@ -1088,34 +1098,25 @@ public class NetworkTypeController extends StateMachine {
            anchorNrCellId = anchorLteCellId;
        }

        boolean wasLastAnchorNrCellIdValid =
                mLastAnchorNrCellId != PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
        if ((physicalChannelConfigs == null || physicalChannelConfigs.isEmpty())
                && wasLastAnchorNrCellIdValid && isUsingPhysicalChannelConfigForRrcDetection()) {
            log("Keep same anchor NR cell and PCC fields for empty PCC list indicating RRC idle.");
            // Set to mLastAnchorNrCellId since it will be UNKNOWN if the PCC list is empty
            anchorNrCellId = mLastAnchorNrCellId;
        }
        if (mLastAnchorNrCellId == anchorNrCellId && wasLastAnchorNrCellIdValid) {
            log("Ratchet physical channel config fields since anchor NR cell is the same.");
            mRatchetedNrBandwidths = Math.max(mRatchetedNrBandwidths, nrBandwidths);
            mRatchetedNrBands.addAll(nrBands);
        } else {
        if (anchorNrCellId == PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
                if (wasLastAnchorNrCellIdValid) {
                    // Only log when the previous anchor NR cell was valid to prevent log spam
                    log("Clearing physical channel config fields without an anchor NR cell, "
            if (!isPccListEmpty) {
                log("Ignoring physical channel config fields without an anchor NR cell, "
                        + "either due to LTE-only configs or an unspecified cell ID.");
            }
            mRatchetedNrBandwidths = 0;
            mRatchetedNrBands.clear();
        } else if (anchorNrCellId == mLastAnchorNrCellId && mRatchetPccFieldsForSameAnchorNrCell) {
            log("Ratchet physical channel config fields since anchor NR cell is the same.");
            mRatchetedNrBandwidths = Math.max(mRatchetedNrBandwidths, nrBandwidths);
            mRatchetedNrBands.addAll(nrBands);
        } else {
                log("Not ratcheting physical channel config fields since anchor NR cell changed "
            if (mRatchetPccFieldsForSameAnchorNrCell) {
                log("Not ratcheting physical channel config fields since anchor NR cell changed: "
                        + mLastAnchorNrCellId + " -> " + anchorNrCellId);
            }
            mRatchetedNrBandwidths = nrBandwidths;
            mRatchetedNrBands = nrBands;
        }
        }

        mLastAnchorNrCellId = anchorNrCellId;
        mPhysicalChannelConfigs = physicalChannelConfigs;
@@ -1351,7 +1352,7 @@ public class NetworkTypeController extends StateMachine {
        // Check PCO requirement. For carriers using PCO to indicate whether the data connection is
        // NR advanced capable, mNrAdvancedCapablePcoId should be configured to non-zero.
        if (mNrAdvancedCapablePcoId > 0 && !mIsNrAdvancedAllowedByPco) {
            if (DBG) log("isNrAdvanced: false because PCO ID " + mNrAdvancedCapablePcoId + " <= 0");
            if (DBG) log("isNrAdvanced: not allowed by PCO for PCO ID " + mNrAdvancedCapablePcoId);
            return false;
        }

@@ -1460,6 +1461,9 @@ public class NetworkTypeController extends StateMachine {
                + mIsTimerResetEnabledForLegacyStateRrcIdle);
        pw.println("mLtePlusThresholdBandwidth=" + mLtePlusThresholdBandwidth);
        pw.println("mNrAdvancedThresholdBandwidth=" + mNrAdvancedThresholdBandwidth);
        pw.println("mIncludeLteForNrAdvancedThresholdBandwidth="
                + mIncludeLteForNrAdvancedThresholdBandwidth);
        pw.println("mRatchetPccFieldsForSameAnchorNrCell=" + mRatchetPccFieldsForSameAnchorNrCell);
        pw.println("mRatchetedNrBandwidths=" + mRatchetedNrBandwidths);
        pw.println("mAdditionalNrAdvancedBandsList=" + mAdditionalNrAdvancedBands);
        pw.println("mRatchetedNrBands=" + mRatchetedNrBands);
+97 −0
Original line number Diff line number Diff line
@@ -571,6 +571,8 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
                new int[]{41, 77});
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        mBundle.putBoolean(CarrierConfigManager.KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL,
                true);
        sendCarrierConfigChanged();

        // Primary serving NR PCC with cell ID = 1, band = none, bandwidth = 200000
@@ -631,6 +633,101 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("connected_mmwave", getCurrentState().getName());
    }

    @Test
    public void testEventPhysicalChannelConfigChangedWithoutRatcheting() throws Exception {
        testTransitionToCurrentStateNrConnected();
        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
                new int[]{41, 77});
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        sendCarrierConfigChanged();

        // Primary serving NR PCC with cell ID = 1, band = none, bandwidth = 200000
        PhysicalChannelConfig pcc1 = new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setPhysicalCellId(1)
                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
                .setCellBandwidthDownlinkKhz(19999)
                .build();
        // Secondary serving NR PCC with cell ID = 2, band = 41, bandwidth = 10000
        PhysicalChannelConfig pcc2 = new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setPhysicalCellId(2)
                .setCellConnectionStatus(CellInfo.CONNECTION_SECONDARY_SERVING)
                .setCellBandwidthDownlinkKhz(10000)
                .setBand(41)
                .build();

        List<PhysicalChannelConfig> physicalChannelConfigs = new ArrayList<>();
        physicalChannelConfigs.add(pcc1);
        physicalChannelConfigs.add(pcc2);
        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();

        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
        processAllMessages();
        assertEquals("connected_mmwave", getCurrentState().getName());

        // bands and bandwidths should stay ratcheted even if an empty PCC list is sent
        doReturn(new ArrayList<>()).when(mSST).getPhysicalChannelConfigList();
        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
        processAllMessages();
        assertEquals("connected_mmwave", getCurrentState().getName());

        // bands and bandwidths should change if PCC list changes
        physicalChannelConfigs.remove(pcc2);
        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
        processAllMessages();
        assertEquals("connected", getCurrentState().getName());
    }

    @Test
    public void testEventPhysicalChannelConfigChangedUsingUserDataForRrc() throws Exception {
        testTransitionToCurrentStateNrConnected();
        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
                new int[]{41, 77});
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        mBundle.putBoolean(CarrierConfigManager.KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL,
                true);
        sendCarrierConfigChanged();

        // Primary serving NR PCC with cell ID = 1, band = none, bandwidth = 200000
        PhysicalChannelConfig pcc1 = new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setPhysicalCellId(1)
                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
                .setCellBandwidthDownlinkKhz(19999)
                .build();
        // Secondary serving NR PCC with cell ID = 2, band = 41, bandwidth = 10000
        PhysicalChannelConfig pcc2 = new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setPhysicalCellId(2)
                .setCellConnectionStatus(CellInfo.CONNECTION_SECONDARY_SERVING)
                .setCellBandwidthDownlinkKhz(10000)
                .setBand(41)
                .build();

        List<PhysicalChannelConfig> physicalChannelConfigs = new ArrayList<>();
        physicalChannelConfigs.add(pcc1);
        physicalChannelConfigs.add(pcc2);
        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();

        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
        processAllMessages();
        assertEquals("connected_mmwave", getCurrentState().getName());

        // bands and bandwidths should not stay the same even if an empty PCC list is sent
        doReturn(new ArrayList<>()).when(mSST).getPhysicalChannelConfigList();
        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
        processAllMessages();
        assertEquals("connected", getCurrentState().getName());

        // bands and bandwidths should change if PCC list changes
        doReturn(physicalChannelConfigs).when(mSST).getPhysicalChannelConfigList();
        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */);
        processAllMessages();
        assertEquals("connected_mmwave", getCurrentState().getName());
    }

    @Test
    public void testNrPhysicalChannelChangeFromNrConnectedMmwaveToLteConnected() throws Exception {
        testTransitionToCurrentStateNrConnectedMmwave();