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

Commit a69d2466 authored by Ling Ma's avatar Ling Ma Committed by Android (Google) Code Review
Browse files

Merge "Let new data stack support updateNRFrequency" into tm-dev

parents ed09a3db 6311e6ae
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ import com.android.internal.telephony.cdnr.CarrierDisplayNameResolver;
import com.android.internal.telephony.data.DataNetwork;
import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
import com.android.internal.telephony.dataconnection.DataConnection;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.dataconnection.TransportManager;
import com.android.internal.telephony.metrics.ServiceStateStats;
import com.android.internal.telephony.metrics.TelephonyMetrics;
@@ -2097,16 +2096,23 @@ public class ServiceStateTracker extends Handler {
    private boolean updateNrFrequencyRangeFromPhysicalChannelConfigs(
            List<PhysicalChannelConfig> physicalChannelConfigs, ServiceState ss) {
        int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN;

        if (physicalChannelConfigs != null) {
            DcTracker dcTracker = mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            for (PhysicalChannelConfig config : physicalChannelConfigs) {
                if (isNrPhysicalChannelConfig(config)) {
                    // Update the frequency range of the NR parameters if there is an internet data
                    // connection associate to this NR physical channel channel config.
                    int[] contextIds = config.getContextIds();
                    for (int cid : contextIds) {
                        DataConnection dc = dcTracker.getDataConnectionByContextId(cid);
                        if (mPhone.isUsingNewDataStack()) {
                            if (mPhone.getDataNetworkController().isInternetNetwork(cid)) {
                                newFrequencyRange = ServiceState.getBetterNRFrequencyRange(
                                        newFrequencyRange, config.getFrequencyRange());
                                break;
                            }
                        } else {
                            DataConnection dc = mPhone.getDcTracker(
                                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                                    .getDataConnectionByContextId(cid);
                            if (dc != null && dc.getNetworkCapabilities().hasCapability(
                                    NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
                                newFrequencyRange = ServiceState.getBetterNRFrequencyRange(
@@ -2117,6 +2123,7 @@ public class ServiceStateTracker extends Handler {
                    }
                }
            }
        }

        boolean hasChanged = newFrequencyRange != ss.getNrFrequencyRange();
        ss.setNrFrequencyRange(newFrequencyRange);
+18 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.data;


import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -1624,6 +1625,23 @@ public class DataNetworkController extends Handler {
        return 0;
    }

    /**
     * Check whether a dataNetwork is actively capable of internet connection
     * @param cid dataNetwork unique identifier
     * @return true if the dataNetwork is connected and capable of internet connection
     */
    public boolean isInternetNetwork(int cid) {
        for (DataNetwork dataNetwork : mDataNetworkList) {
            if (dataNetwork.getId() == cid
                    && dataNetwork.isConnected()
                    && dataNetwork.getNetworkCapabilities()
                    .hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
                return true;
            }
        }
        return false;
    }

    /**
     * Remove a network request, which is originated from the apps. Note that remove a network
     * will not result in tearing down the network. The tear down request directly comes from
+19 −3
Original line number Diff line number Diff line
@@ -2054,14 +2054,17 @@ public class ServiceStateTrackerTest extends TelephonyTest {

    }

    private void sendPhyChanConfigChange(int[] bandwidths, int networkType, int pci) {
    private void sendPhyChanConfigChange(int[] bandwidths, int networkType, int pci,
            int[][] contextIDs) {
        ArrayList<PhysicalChannelConfig> pc = new ArrayList<>();
        int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING;
        for (int bw : bandwidths) {
        for (int i = 0; i < bandwidths.length; i++) {
            pc.add(new PhysicalChannelConfig.Builder()
                    .setCellConnectionStatus(ssType)
                    .setCellBandwidthDownlinkKhz(bw)
                    .setCellBandwidthDownlinkKhz(bandwidths[i])
                    .setContextIds(contextIDs != null ? contextIDs[i] : new int[0])
                    .setNetworkType(networkType)
                    .setBand(1)
                    .setPhysicalCellId(pci)
                    .build());

@@ -2073,6 +2076,10 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
    }

    private void sendPhyChanConfigChange(int[] bandwidths, int networkType, int pci) {
        sendPhyChanConfigChange(bandwidths, networkType, pci, null);
    }

    private void sendRegStateUpdateForLteCellId(CellIdentityLte cellId) {
        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
@@ -2196,6 +2203,15 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertTrue(Arrays.equals(new int[] {10000, 5000}, sst.mSS.getCellBandwidths()));
    }

    @Test
    public void testUpdateNrFrequencyRangeFromPhysicalChannelConfigs() {
        doReturn(true).when(mPhone).isUsingNewDataStack();
        when(mPhone.getDataNetworkController().isInternetNetwork(eq(3))).thenReturn(true);
        sendPhyChanConfigChange(new int[] {1000, 500}, TelephonyManager.NETWORK_TYPE_NR, 1,
                new int[][]{{0, 1}, {2, 3}});
        assertEquals(ServiceState.FREQUENCY_RANGE_MID, sst.mSS.getNrFrequencyRange());
    }

    @Test
    public void testPhyChanBandwidthResetsOnOos() throws Exception {
        testPhyChanBandwidthRatchetedOnPhyChanBandwidth();