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

Commit 7b116462 authored by Pengquan Meng's avatar Pengquan Meng Committed by android-build-merger
Browse files

Merge "Implement 5G NR Non-Standalone" am: f14e4f56

am: 6fa20f23

Change-Id: Icfcaaea16ad52e8cc97547e9a2396435e16ab672
parents 079f4948 6fa20f23
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -276,7 +276,6 @@ public class CellularNetworkService extends NetworkService {
                        accessNetworkTechnology, reasonForDenial, emergencyOnly, availableServices,
                        cellIdentity, maxDataCalls, false /* isDcNrRestricted */,
                        false /* isNrAvailable */, false /* isEnDcAvailable */);

            } else if (result instanceof android.hardware.radio.V1_2.DataRegStateResult) {
                android.hardware.radio.V1_2.DataRegStateResult dataRegState =
                        (android.hardware.radio.V1_2.DataRegStateResult) result;
+117 −20
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.hardware.radio.V1_0.CellInfoType;
import android.net.NetworkCapabilities;
import android.os.AsyncResult;
import android.os.BaseBundle;
import android.os.Build;
@@ -50,6 +51,7 @@ import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
@@ -82,6 +84,8 @@ import android.util.TimestampedValue;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.cdma.EriInfo;
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.TelephonyMetrics;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
@@ -1439,9 +1443,16 @@ public class ServiceStateTracker extends Handler {
                    }
                    mPhone.notifyPhysicalChannelConfiguration(list);
                    mLastPhysicalChannelConfigList = list;

                    // only notify if bandwidths changed
                    if (RatRatcheter.updateBandwidths(getBandwidthsFromConfigs(list), mSS)) {
                    boolean hasChanged =
                            updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS);
                    hasChanged |= updateNrStatusFromPhysicalChannelConfigs(
                            list,
                            mSS.getNetworkRegistrationState(
                                    NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN));

                    // Notify NR frequency, NR connection status or bandwidths changed.
                    if (hasChanged
                            || RatRatcheter.updateBandwidths(getBandwidthsFromConfigs(list), mSS)) {
                        mPhone.notifyServiceStateChanged(mSS);
                    }
                }
@@ -1813,6 +1824,78 @@ public class ServiceStateTracker extends Handler {
        return cdmaRoaming && !isSameOperatorNameFromSimAndSS(s);
    }

    private boolean isNrStatusChanged(
            NetworkRegistrationState oldRegState, NetworkRegistrationState newRegState) {
        if (oldRegState == null || newRegState == null) {
            return oldRegState != newRegState;
        }

        return oldRegState.getNrStatus() != newRegState.getNrStatus();
    }

    private boolean updateNrFrequencyRangeFromPhysicalChannelConfigs(
            List<PhysicalChannelConfig> physicalChannelConfigs, ServiceState ss) {
        int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN;

        if (physicalChannelConfigs != null) {
            DcTracker dcTracker = mPhone.getDcTracker(TransportType.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 (dc != null && dc.getNetworkCapabilities().hasCapability(
                                NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
                            newFrequencyRange = ServiceState.getBetterNRFrequencyRange(
                                    newFrequencyRange, config.getFrequencyRange());
                            break;
                        }
                    }
                }
            }
        }

        boolean hasChanged = newFrequencyRange != ss.getNrFrequencyRange();
        ss.setNrFrequencyRange(newFrequencyRange);
        return hasChanged;
    }

    private boolean updateNrStatusFromPhysicalChannelConfigs(
            List<PhysicalChannelConfig> configs, NetworkRegistrationState regState) {

        if (regState == null || configs == null) return false;

        boolean hasNrSecondaryServingCell = false;
        for (PhysicalChannelConfig config : configs) {
            if (isNrPhysicalChannelConfig(config) && config.getConnectionStatus()
                    == PhysicalChannelConfig.CONNECTION_SECONDARY_SERVING) {
                hasNrSecondaryServingCell = true;
                break;
            }
        }

        int newNrStatus = regState.getNrStatus();
        if (hasNrSecondaryServingCell) {
            if (regState.getNrStatus() == NetworkRegistrationState.NR_STATUS_NOT_RESTRICTED) {
                newNrStatus = NetworkRegistrationState.NR_STATUS_CONNECTED;
            }
        } else {
            if (regState.getNrStatus() == NetworkRegistrationState.NR_STATUS_CONNECTED) {
                newNrStatus = NetworkRegistrationState.NR_STATUS_NOT_RESTRICTED;
            }
        }

        boolean hasChanged = newNrStatus != regState.getNrStatus();
        regState.setNrStatus(newNrStatus);
        return hasChanged;
    }

    private boolean isNrPhysicalChannelConfig(PhysicalChannelConfig config) {
        return config.getRat() == TelephonyManager.NETWORK_TYPE_NR;
    }

    void handlePollStateResultMessage(int what, AsyncResult ar) {
        int ints[];
        switch (what) {
@@ -1905,14 +1988,17 @@ public class ServiceStateTracker extends Handler {
                        networkRegState.getAccessNetworkTechnology());
                mNewSS.setDataRegState(serviceState);
                mNewSS.setRilDataRadioTechnology(newDataRat);
                mNewSS.addNetworkRegistrationState(networkRegState);

                // When we receive OOS reset the PhyChanConfig list so that non-return-to-idle
                // implementers of PhyChanConfig unsol will not carry forward a CA report
                // (2 or more cells) to a new cell if they camp for emergency service only.
                if (serviceState == ServiceState.STATE_OUT_OF_SERVICE) {
                    mLastPhysicalChannelConfigList = null;
                    updateNrFrequencyRangeFromPhysicalChannelConfigs(null, mNewSS);
                }
                updateNrStatusFromPhysicalChannelConfigs(
                        mLastPhysicalChannelConfigList, networkRegState);
                mNewSS.addNetworkRegistrationState(networkRegState);
                setPhyCellInfoFromCellIdentity(mNewSS, networkRegState.getCellIdentity());

                if (mPhone.isPhoneTypeGsm()) {
@@ -2851,6 +2937,15 @@ public class ServiceStateTracker extends Handler {
        boolean hasVoiceRegStateChanged =
                mSS.getVoiceRegState() != mNewSS.getVoiceRegState();

        boolean hasNrFrequencyRangeChanged =
                mSS.getNrFrequencyRange() != mNewSS.getNrFrequencyRange();

        boolean hasNrStatusChanged = isNrStatusChanged(
                mSS.getNetworkRegistrationState(
                        NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN),
                mNewSS.getNetworkRegistrationState(
                        NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN));

        // TODO: loosen this restriction to exempt fields that are provided through system
        // information; otherwise, we will get false positives when things like the operator
        // alphas are provided later - that's better than missing location changes, but
@@ -2930,7 +3025,9 @@ public class ServiceStateTracker extends Handler {
                    + " has4gHandoff = " + has4gHandoff
                    + " hasMultiApnSupport = " + hasMultiApnSupport
                    + " hasLostMultiApnSupport = " + hasLostMultiApnSupport
                    + " hasCssIndicatorChanged=" + hasCssIndicatorChanged);
                    + " hasCssIndicatorChanged = " + hasCssIndicatorChanged
                    + " hasNrFrequencyRangeChanged = " + hasNrFrequencyRangeChanged
                    + " hasNrStatusChanged = " + hasNrStatusChanged);
        }

        // Add an event log when connection state changes
+4 −1
Original line number Diff line number Diff line
@@ -982,7 +982,10 @@ public class DataConnection extends StateMachine {
        return true;
    }

    NetworkCapabilities getNetworkCapabilities() {
    /**
     * @return the {@link NetworkCapabilities} of this data connection.
     */
    public NetworkCapabilities getNetworkCapabilities() {
        NetworkCapabilities result = new NetworkCapabilities();
        result.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);

+7 −0
Original line number Diff line number Diff line
@@ -1764,6 +1764,13 @@ public class DcTracker extends Handler {
        return matches.size() > 0;
    }

    /**
     * @return the {@link DataConnection} with the given context id {@code cid}.
     */
    public DataConnection getDataConnectionByContextId(int cid) {
        return mDcc.getActiveDcByCid(cid);
    }

    /**
     * Determine if DUN connection is special and we need to teardown on start/stop
     */