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

Commit f4c94f56 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Let new data stack support updateNRFrequency" am: 83f543d6 am: 083626b4

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2035023

Change-Id: I61eb3af5e53f34a373989090eb61cead628f0595
parents 20b6383f 083626b4
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;
@@ -2084,16 +2083,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(
@@ -2104,6 +2110,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;
@@ -1545,6 +1546,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();