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

Commit 1b80434b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed incorrect RAT set in PS WWAN registration info" into qt-dev

parents 524ca379 feefb2d7
Loading
Loading
Loading
Loading
+48 −29
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */
package com.android.internal.telephony;
package com.android.internal.telephony;


import android.annotation.NonNull;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
@@ -26,6 +27,7 @@ import android.telephony.CarrierConfigManager;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.Rlog;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager.NetworkType;
import android.util.SparseArray;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.SparseIntArray;


@@ -86,23 +88,32 @@ public class RatRatcheter {
        resetRatFamilyMap();
        resetRatFamilyMap();
    }
    }


    private int ratchetRat(int oldRat, int newRat) {
    private @NetworkType int ratchetRat(@NetworkType int oldNetworkType,
                                        @NetworkType int newNetworkType) {
        int oldRat = ServiceState.networkTypeToRilRadioTechnology(oldNetworkType);
        int newRat = ServiceState.networkTypeToRilRadioTechnology(newNetworkType);
        synchronized (mRatFamilyMap) {
        synchronized (mRatFamilyMap) {
            final SparseIntArray oldFamily = mRatFamilyMap.get(oldRat);
            final SparseIntArray oldFamily = mRatFamilyMap.get(oldRat);
            if (oldFamily == null) return newRat;
            if (oldFamily == null) {
                return newNetworkType;
            }


            final SparseIntArray newFamily = mRatFamilyMap.get(newRat);
            final SparseIntArray newFamily = mRatFamilyMap.get(newRat);
            if (newFamily != oldFamily) return newRat;
            if (newFamily != oldFamily) {
                return newNetworkType;
            }


            // now go with the higher of the two
            // now go with the higher of the two
            final int oldRatRank = newFamily.get(oldRat, -1);
            final int oldRatRank = newFamily.get(oldRat, -1);
            final int newRatRank = newFamily.get(newRat, -1);
            final int newRatRank = newFamily.get(newRat, -1);
            return (oldRatRank > newRatRank ? oldRat : newRat);
            return ServiceState.rilRadioTechnologyToNetworkType(
                    oldRatRank > newRatRank ? oldRat : newRat);
        }
        }
    }
    }


    /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */
    /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */
    public void ratchet(ServiceState oldSS, ServiceState newSS, boolean locationChange) {
    public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS,
                        boolean locationChange) {
        if (!locationChange && isSameRatFamily(oldSS, newSS)) {
        if (!locationChange && isSameRatFamily(oldSS, newSS)) {
            updateBandwidths(oldSS.getCellBandwidths(), newSS);
            updateBandwidths(oldSS.getCellBandwidths(), newSS);
        }
        }
@@ -116,32 +127,30 @@ public class RatRatcheter {
        boolean newUsingCA = oldSS.isUsingCarrierAggregation()
        boolean newUsingCA = oldSS.isUsingCarrierAggregation()
                || newSS.isUsingCarrierAggregation()
                || newSS.isUsingCarrierAggregation()
                || newSS.getCellBandwidths().length > 1;
                || newSS.getCellBandwidths().length > 1;
        if (mVoiceRatchetEnabled) {
        NetworkRegistrationInfo oldCsNri = oldSS.getNetworkRegistrationInfo(
            int newVoiceRat = ratchetRat(oldSS.getRilVoiceRadioTechnology(),
                    newSS.getRilVoiceRadioTechnology());
            NetworkRegistrationInfo nri = newSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            if (nri != null) {
        NetworkRegistrationInfo newCsNri = newSS.getNetworkRegistrationInfo(
                nri.setAccessNetworkTechnology(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                        ServiceState.rilRadioTechnologyToNetworkType(newVoiceRat));
        if (mVoiceRatchetEnabled) {
                newSS.addNetworkRegistrationInfo(nri);
            int newPsNetworkType = ratchetRat(oldCsNri.getAccessNetworkTechnology(),
            }
                    newCsNri.getAccessNetworkTechnology());
        } else if (oldSS.getRilVoiceRadioTechnology() != newSS.getRilVoiceRadioTechnology()) {
            newCsNri.setAccessNetworkTechnology(newPsNetworkType);
            newSS.addNetworkRegistrationInfo(newCsNri);
        } else if (oldCsNri.getAccessNetworkTechnology() != oldCsNri.getAccessNetworkTechnology()) {
            // resume rat ratchet on following rat change within the same location
            // resume rat ratchet on following rat change within the same location
            mVoiceRatchetEnabled = true;
            mVoiceRatchetEnabled = true;
        }
        }


        if (mDataRatchetEnabled) {
        NetworkRegistrationInfo oldPsNri = oldSS.getNetworkRegistrationInfo(
            int newDataRat = ratchetRat(oldSS.getRilDataRadioTechnology(),
                    newSS.getRilDataRadioTechnology());
            NetworkRegistrationInfo nri = newSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            if (nri != null) {
        NetworkRegistrationInfo newPsNri = newSS.getNetworkRegistrationInfo(
                nri.setAccessNetworkTechnology(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                        ServiceState.rilRadioTechnologyToNetworkType(newDataRat));
        if (mDataRatchetEnabled) {
                newSS.addNetworkRegistrationInfo(nri);
            int newPsNetworkType = ratchetRat(oldPsNri.getAccessNetworkTechnology(),
            }
                    newPsNri.getAccessNetworkTechnology());
        } else if (oldSS.getRilDataRadioTechnology() != newSS.getRilDataRadioTechnology()) {
            newPsNri.setAccessNetworkTechnology(newPsNetworkType);
            newSS.addNetworkRegistrationInfo(newPsNri);
        } else if (oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()) {
            // resume rat ratchet on following rat change within the same location
            // resume rat ratchet on following rat change within the same location
            mDataRatchetEnabled = true;
            mDataRatchetEnabled = true;
        }
        }
@@ -153,10 +162,20 @@ public class RatRatcheter {
        synchronized (mRatFamilyMap) {
        synchronized (mRatFamilyMap) {
            // Either the two technologies are the same or their families must be non-null
            // Either the two technologies are the same or their families must be non-null
            // and the same.
            // and the same.
            if (ss1.getRilDataRadioTechnology() == ss2.getRilDataRadioTechnology()) return true;
            int dataRat1 = ServiceState.networkTypeToRilRadioTechnology(
            if (mRatFamilyMap.get(ss1.getRilDataRadioTechnology()) == null) return false;
                    ss1.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
            return mRatFamilyMap.get(ss1.getRilDataRadioTechnology())
                            AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    == mRatFamilyMap.get(ss2.getRilDataRadioTechnology());
                            .getAccessNetworkTechnology());
            int dataRat2 = ServiceState.networkTypeToRilRadioTechnology(
                    ss2.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                            AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                            .getAccessNetworkTechnology());

            if (dataRat1 == dataRat2) return true;
            if (mRatFamilyMap.get(dataRat1) == null) {
                return false;
            }
            return mRatFamilyMap.get(dataRat1) == mRatFamilyMap.get(dataRat2);
        }
        }
    }
    }