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

Commit 6311e6ae authored by Ling Ma's avatar Ling Ma
Browse files

Let new data stack support updateNRFrequency

DcTracker is no longer used in the new data stack.

Test: build
Bug: 220161774
Change-Id: I5f2f3829c47a11f8c9aac13a9db9a8f26866ed4a
parent 28a86c1b
Loading
Loading
Loading
Loading
+16 −9
Original line number Original line 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.DataNetwork;
import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
import com.android.internal.telephony.dataconnection.DataConnection;
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.dataconnection.TransportManager;
import com.android.internal.telephony.metrics.ServiceStateStats;
import com.android.internal.telephony.metrics.ServiceStateStats;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.metrics.TelephonyMetrics;
@@ -2097,16 +2096,23 @@ public class ServiceStateTracker extends Handler {
    private boolean updateNrFrequencyRangeFromPhysicalChannelConfigs(
    private boolean updateNrFrequencyRangeFromPhysicalChannelConfigs(
            List<PhysicalChannelConfig> physicalChannelConfigs, ServiceState ss) {
            List<PhysicalChannelConfig> physicalChannelConfigs, ServiceState ss) {
        int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN;
        int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN;

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


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


package com.android.internal.telephony.data;
package com.android.internal.telephony.data;



import android.annotation.CallbackExecutor;
import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
@@ -1624,6 +1625,23 @@ public class DataNetworkController extends Handler {
        return 0;
        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
     * 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
     * will not result in tearing down the network. The tear down request directly comes from
+19 −3
Original line number Original line Diff line number Diff line
@@ -2053,14 +2053,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<>();
        ArrayList<PhysicalChannelConfig> pc = new ArrayList<>();
        int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING;
        int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING;
        for (int bw : bandwidths) {
        for (int i = 0; i < bandwidths.length; i++) {
            pc.add(new PhysicalChannelConfig.Builder()
            pc.add(new PhysicalChannelConfig.Builder()
                    .setCellConnectionStatus(ssType)
                    .setCellConnectionStatus(ssType)
                    .setCellBandwidthDownlinkKhz(bw)
                    .setCellBandwidthDownlinkKhz(bandwidths[i])
                    .setContextIds(contextIDs != null ? contextIDs[i] : new int[0])
                    .setNetworkType(networkType)
                    .setNetworkType(networkType)
                    .setBand(1)
                    .setPhysicalCellId(pci)
                    .setPhysicalCellId(pci)
                    .build());
                    .build());


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


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

    private void sendRegStateUpdateForLteCellId(CellIdentityLte cellId) {
    private void sendRegStateUpdateForLteCellId(CellIdentityLte cellId) {
        LteVopsSupportInfo lteVopsSupportInfo =
        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
@@ -2195,6 +2202,15 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertTrue(Arrays.equals(new int[] {10000, 5000}, sst.mSS.getCellBandwidths()));
        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
    @Test
    public void testPhyChanBandwidthResetsOnOos() throws Exception {
    public void testPhyChanBandwidthResetsOnOos() throws Exception {
        testPhyChanBandwidthRatchetedOnPhyChanBandwidth();
        testPhyChanBandwidthRatchetedOnPhyChanBandwidth();