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

Commit f714035f authored by Sarah Kim's avatar Sarah Kim Committed by Automerger Merge Worker
Browse files

Merge changes I67d9a186,I12e1a8e0 into udc-dev am: 03001d6c am: c58a573b

parents 82c397bf c58a573b
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;
        }

+6 −49
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();

@@ -1667,18 +1666,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)) {
@@ -1689,34 +1676,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);
                    }
                    int[] bandwidths = new int[0];
                    if (list != null) {
                        bandwidths = getBandwidthsFromLastPhysicalChannelConfigs();
                    }
                    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
                                + "). New bandwidths are " + Arrays.toString(bandwidths));
                        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.
@@ -1796,12 +1757,8 @@ public class ServiceStateTracker extends Handler {
        return simAbsent;
    }

    private int[] getBandwidthsFromLastPhysicalChannelConfigs() {
        boolean includeLte = mCarrierConfig.getBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL);
        return mLastPhysicalChannelConfigList.stream()
                .filter(config -> includeLte
                        || config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR)
    private static int[] getBandwidthsFromConfigs(List<PhysicalChannelConfig> list) {
        return list.stream()
                .map(PhysicalChannelConfig::getCellBandwidthDownlinkKhz)
                .mapToInt(Integer::intValue)
                .toArray();
@@ -2561,7 +2518,7 @@ public class ServiceStateTracker extends Handler {
            // Prioritize the PhysicalChannelConfig list because we might already be in carrier
            // aggregation by the time poll state is performed.
            if (primaryPcc != null) {
                bandwidths = getBandwidthsFromLastPhysicalChannelConfigs();
                bandwidths = getBandwidthsFromConfigs(mLastPhysicalChannelConfigList);
                for (int bw : bandwidths) {
                    if (!isValidLteBandwidthKhz(bw)) {
                        loge("Invalid LTE Bandwidth in RegistrationState, " + bw);
@@ -2597,7 +2554,7 @@ public class ServiceStateTracker extends Handler {
            // Prioritize the PhysicalChannelConfig list because we might already be in carrier
            // aggregation by the time poll state is performed.
            if (primaryPcc != null) {
                bandwidths = getBandwidthsFromLastPhysicalChannelConfigs();
                bandwidths = getBandwidthsFromConfigs(mLastPhysicalChannelConfigList);
                for (int bw : bandwidths) {
                    if (!isValidNrBandwidthKhz(bw)) {
                        loge("Invalid NR Bandwidth in RegistrationState, " + bw);
+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 −23
Original line number Diff line number Diff line
@@ -279,15 +279,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);
@@ -375,9 +366,6 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                    15, /* SIGNAL_STRENGTH_GOOD */
                    30  /* SIGNAL_STRENGTH_GREAT */
                });
        mBundle.putBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL,
                true);

        sendCarrierConfigUpdate(PHONE_ID);
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
@@ -2402,21 +2390,13 @@ public class ServiceStateTrackerTest extends TelephonyTest {

    @Test
    public void testPhyChanBandwidthForNr() {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_INCLUDE_LTE_FOR_NR_ADVANCED_THRESHOLD_BANDWIDTH_BOOL,
                false);
        // 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());
    }

    /**