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

Commit 0a8a3aaa authored by Sarah Chin's avatar Sarah Chin Committed by Automerger Merge Worker
Browse files

Fix NR advanced logic for NR NSA am: 13cbe364 am: edcc5d43

parents 527ac5f0 edcc5d43
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -1058,25 +1058,35 @@ public class NetworkTypeController extends StateMachine {
                mPhone.getServiceStateTracker().getPhysicalChannelConfigList();

        int anchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
        boolean anchorNrCellFound = false;
        int anchorLteCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
        int nrBandwidths = 0;
        Set<Integer> nrBands = new HashSet<>();
        if (physicalChannelConfigs != null) {
            for (PhysicalChannelConfig config : physicalChannelConfigs) {
                if (config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR) {
                    if (!anchorNrCellFound && config.getConnectionStatus()
                            == CellInfo.CONNECTION_PRIMARY_SERVING) {
                        // Make sure the anchor NR cell is the first one we find in the list
                    if (config.getConnectionStatus() == CellInfo.CONNECTION_PRIMARY_SERVING
                            && anchorNrCellId == PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
                        anchorNrCellId = config.getPhysicalCellId();
                        anchorNrCellFound = true;
                    }
                    nrBandwidths += config.getCellBandwidthDownlinkKhz();
                    nrBands.add(config.getBand());
                } else if (mIncludeLteForNrAdvancedThresholdBandwidth) {
                } else if (config.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE) {
                    if (config.getConnectionStatus() == CellInfo.CONNECTION_PRIMARY_SERVING
                            && anchorLteCellId == PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
                        anchorLteCellId = config.getPhysicalCellId();
                    }
                    if (mIncludeLteForNrAdvancedThresholdBandwidth) {
                        nrBandwidths += config.getCellBandwidthDownlinkKhz();
                    }
                }
            }
        }

        // Update anchor NR cell from anchor LTE cell for NR NSA
        if (anchorNrCellId == PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN
                && anchorLteCellId != PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN) {
            anchorNrCellId = anchorLteCellId;
        }

        boolean wasLastAnchorNrCellIdValid =
                mLastAnchorNrCellId != PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
+30 −0
Original line number Diff line number Diff line
@@ -402,6 +402,36 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        assertEquals("connected_mmwave", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateNrConnectedMmwaveWithAdditionalBandAndNoMmwaveNrNsa()
            throws Exception {
        assertEquals("DefaultState", getCurrentState().getName());
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(mServiceState).getNrFrequencyRange();
        mBundle.putIntArray(CarrierConfigManager.KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY,
                new int[]{41});
        PhysicalChannelConfig ltePhysicalChannelConfig = new PhysicalChannelConfig.Builder()
                .setPhysicalCellId(1)
                .setNetworkType(TelephonyManager.NETWORK_TYPE_LTE)
                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
                .build();
        PhysicalChannelConfig nrPhysicalChannelConfig = new PhysicalChannelConfig.Builder()
                .setPhysicalCellId(2)
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellConnectionStatus(CellInfo.CONNECTION_SECONDARY_SERVING)
                .setBand(41)
                .build();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(ltePhysicalChannelConfig);
        lastPhysicalChannelConfigList.add(nrPhysicalChannelConfig);
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        sendCarrierConfigChanged();

        mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */);
        processAllMessages();
        assertEquals("connected_mmwave", getCurrentState().getName());
    }

    @Test
    public void testTransitionToCurrentStateNrConnectedWithNoAdditionalBandAndNoMmwave()
            throws Exception {