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

Commit e1f8bab0 authored by Sarah Chin's avatar Sarah Chin Committed by Jack Yu
Browse files

Use NR configs for minimum NR advanced bandwidth threshold

Test: manual verify
Test: atest NetworkTypeControllerTest
Bug: 257135958
Bug: 260007418
Change-Id: I41eb1a08e9c04820e4ec188eb6dfd2c7f73ff591
parent 326cd5e1
Loading
Loading
Loading
Loading
+13 −6
Original line number Original line Diff line number Diff line
@@ -524,7 +524,8 @@ public class NetworkTypeController extends StateMachine {
        int value = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE;
        int value = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE;
        if ((getDataNetworkType() == TelephonyManager.NETWORK_TYPE_LTE_CA
        if ((getDataNetworkType() == TelephonyManager.NETWORK_TYPE_LTE_CA
                || mServiceState.isUsingCarrierAggregation())
                || mServiceState.isUsingCarrierAggregation())
                && getBandwidth() > mLtePlusThresholdBandwidth) {
                && IntStream.of(mServiceState.getCellBandwidths()).sum()
                > mLtePlusThresholdBandwidth) {
            value = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA;
            value = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA;
        }
        }
        if (isLteEnhancedAvailable()) {
        if (isLteEnhancedAvailable()) {
@@ -1286,9 +1287,19 @@ public class NetworkTypeController extends StateMachine {
            return false;
            return false;
        }
        }


        int bandwidths = 0;
        if (mPhone.getServiceStateTracker().getPhysicalChannelConfigList() != null) {
            bandwidths = mPhone.getServiceStateTracker().getPhysicalChannelConfigList()
                    .stream()
                    .filter(config -> 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
        // Check if meeting minimum bandwidth requirement. For most carriers, there is no minimum
        // bandwidth requirement and mNrAdvancedThresholdBandwidth is 0.
        // bandwidth requirement and mNrAdvancedThresholdBandwidth is 0.
        if (mNrAdvancedThresholdBandwidth > 0 && getBandwidth() < mNrAdvancedThresholdBandwidth) {
        if (mNrAdvancedThresholdBandwidth > 0 && bandwidths < mNrAdvancedThresholdBandwidth) {
            return false;
            return false;
        }
        }


@@ -1329,10 +1340,6 @@ public class NetworkTypeController extends StateMachine {
                ? DataCallResponse.LINK_STATUS_DORMANT : DataCallResponse.LINK_STATUS_ACTIVE;
                ? DataCallResponse.LINK_STATUS_DORMANT : DataCallResponse.LINK_STATUS_ACTIVE;
    }
    }


    private int getBandwidth() {
        return IntStream.of(mServiceState.getCellBandwidths()).sum();
    }

    private String getEventName(int event) {
    private String getEventName(int event) {
        try {
        try {
            return sEvents[event];
            return sEvents[event];
+7 −2
Original line number Original line Diff line number Diff line
@@ -1240,11 +1240,16 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange();
        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);
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        broadcastCarrierConfigs();
        broadcastCarrierConfigs();


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