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

Commit eeaf7fe4 authored by Nathan Harold's avatar Nathan Harold Committed by Gerrit Code Review
Browse files

Merge changes from topic "lteca-ratratcheter"

* changes:
  Fix RatRatcheter skipping the first Ratchet
  Migrate LTE_CA flag to NRI from DSRI
parents 26242849 99c3559a
Loading
Loading
Loading
Loading
+4 −22
Original line number Diff line number Diff line
@@ -228,9 +228,6 @@ public class CellularNetworkService extends NetworkService {
                        (android.hardware.radio.V1_0.VoiceRegStateResult) result;
                int regState = getRegStateFromHalRegState(voiceRegState.regState);
                int networkType = ServiceState.rilRadioTechnologyToNetworkType(voiceRegState.rat);
                if (networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) {
                    networkType = TelephonyManager.NETWORK_TYPE_LTE;
                }
                int reasonForDenial = voiceRegState.reasonForDenial;
                boolean emergencyOnly = isEmergencyOnly(voiceRegState.regState);
                boolean cssSupported = voiceRegState.cssSupported;
@@ -251,9 +248,6 @@ public class CellularNetworkService extends NetworkService {
                        (android.hardware.radio.V1_2.VoiceRegStateResult) result;
                int regState = getRegStateFromHalRegState(voiceRegState.regState);
                int networkType = ServiceState.rilRadioTechnologyToNetworkType(voiceRegState.rat);
                if (networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) {
                    networkType = TelephonyManager.NETWORK_TYPE_LTE;
                }
                int reasonForDenial = voiceRegState.reasonForDenial;
                boolean emergencyOnly = isEmergencyOnly(voiceRegState.regState);
                boolean cssSupported = voiceRegState.cssSupported;
@@ -281,7 +275,6 @@ public class CellularNetworkService extends NetworkService {
            int regState = NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN;
            int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
            int reasonForDenial = 0;
            boolean isUsingCarrierAggregation = false;
            boolean emergencyOnly = false;
            int maxDataCalls = 0;
            CellIdentity cellIdentity;
@@ -355,15 +348,10 @@ public class CellularNetworkService extends NetworkService {
            List<Integer> availableServices = getAvailableServices(
                    regState, domain, emergencyOnly);

            if (networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) {
                isUsingCarrierAggregation = true;
                networkType = TelephonyManager.NETWORK_TYPE_LTE;
            }

            return new NetworkRegistrationInfo(domain, transportType, regState, networkType,
                    reasonForDenial, emergencyOnly, availableServices, cellIdentity, rplmn,
                    maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable,
                    lteVopsSupportInfo, isUsingCarrierAggregation);
                    lteVopsSupportInfo);
        }

        private @NonNull NetworkRegistrationInfo getNetworkRegistrationInfo(
@@ -380,16 +368,10 @@ public class CellularNetworkService extends NetworkService {
            final String rplmn = regResult.registeredPlmn;
            final int reasonForDenial = regResult.reasonForDenial;

            // Network Type fixup for carrier aggregation
            int networkType = ServiceState.rilRadioTechnologyToNetworkType(regResult.rat);
            // In earlier versions of the HAL, LTE_CA was allowed to indicate that the device
            // is on CA; however, that has been superseded by the PHYSICAL_CHANNEL_CONFIG signal.
            // Because some vendors provide both NETWORK_TYPE_LTE_CA *and* PHYSICAL_CHANNEL_CONFIG,
            // this tweak is left for compatibility; however, the network type is no longer allowed
            // to be used to declare that carrier aggregation is in effect, because the other
            // signal provides a much richer information set, and we want to mitigate confusion in
            // how CA information is being provided.
            if (networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) {
                // In Radio HAL v1.5, NETWORK_TYPE_LTE_CA is ignored. Callers should use
                // PhysicalChannelConfig.
                networkType = TelephonyManager.NETWORK_TYPE_LTE;
            }

@@ -448,7 +430,7 @@ public class CellularNetworkService extends NetworkService {
                    return new NetworkRegistrationInfo(domain, transportType, regState, networkType,
                            reasonForDenial, isEmergencyOnly, availableServices, cellIdentity,
                            rplmn, MAX_DATA_CALLS, isDcNrRestricted, isNrAvailable, isEndcAvailable,
                            vopsInfo, false /* isUsingCarrierAggregation */);
                            vopsInfo);
            }
        }

+23 −45
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ public class RatRatcheter {
    private final SparseArray<SparseIntArray> mRatFamilyMap = new SparseArray<>();

    private final Phone mPhone;
    private boolean mVoiceRatchetEnabled = true;
    private boolean mDataRatchetEnabled = true;

    /**
     * Updates the ServiceState with a new set of cell bandwidths IFF the new bandwidth list has a
@@ -119,55 +117,35 @@ public class RatRatcheter {
        }
    }

    /** Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family. */
    public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS,
                        boolean locationChange) {
        // temporarily disable rat ratchet on location change.
        if (locationChange) {
            mVoiceRatchetEnabled = false;
            mDataRatchetEnabled = false;
            return;
        }

    /**
     * Ratchets RATs and cell bandwidths if oldSS and newSS have the same RAT family.
     *
     * Ensure that a device on the same cell reports the best-seen capability to the user.
     */
    public void ratchet(@NonNull ServiceState oldSS, @NonNull ServiceState newSS) {
        // Different rat family, don't need rat ratchet and update cell bandwidths.
        if (!isSameRatFamily(oldSS, newSS)) {
            Rlog.e(LOG_TAG, "Same cell cannot have different RAT Families. Likely bug.");
            return;
        }

        updateBandwidths(oldSS.getCellBandwidths(), newSS);
        final int[] domains = {
                NetworkRegistrationInfo.DOMAIN_CS, NetworkRegistrationInfo.DOMAIN_PS};
        for (int domain : domains) {
            NetworkRegistrationInfo oldNri = oldSS.getNetworkRegistrationInfo(
                    domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            NetworkRegistrationInfo newNri = newSS.getNetworkRegistrationInfo(
                    domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);

        boolean newUsingCA = oldSS.isUsingCarrierAggregation()
                || newSS.isUsingCarrierAggregation()
                || newSS.getCellBandwidths().length > 1;
        NetworkRegistrationInfo oldCsNri = oldSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        NetworkRegistrationInfo newCsNri = newSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (mVoiceRatchetEnabled) {
            int newPsNetworkType = ratchetRat(oldCsNri.getAccessNetworkTechnology(),
                    newCsNri.getAccessNetworkTechnology());
            newCsNri.setAccessNetworkTechnology(newPsNetworkType);
            newSS.addNetworkRegistrationInfo(newCsNri);
        } else if (oldCsNri.getAccessNetworkTechnology() != oldCsNri.getAccessNetworkTechnology()) {
            // resume rat ratchet on following rat change within the same location
            mVoiceRatchetEnabled = true;
            int newNetworkType = ratchetRat(oldNri.getAccessNetworkTechnology(),
                    newNri.getAccessNetworkTechnology());
            newNri.setAccessNetworkTechnology(newNetworkType);
            if (oldNri.isUsingCarrierAggregation()) newNri.setIsUsingCarrierAggregation(true);
            newSS.addNetworkRegistrationInfo(newNri);
        }

        NetworkRegistrationInfo oldPsNri = oldSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        NetworkRegistrationInfo newPsNri = newSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (mDataRatchetEnabled) {
            int newPsNetworkType = ratchetRat(oldPsNri.getAccessNetworkTechnology(),
                    newPsNri.getAccessNetworkTechnology());
            newPsNri.setAccessNetworkTechnology(newPsNetworkType);
            newSS.addNetworkRegistrationInfo(newPsNri);
        } else if (oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()) {
            // resume rat ratchet on following rat change within the same location
            mDataRatchetEnabled = true;
        }

        newSS.setIsUsingCarrierAggregation(newUsingCA);
        // Ratchet Cell Bandwidths
        updateBandwidths(oldSS.getCellBandwidths(), newSS);
    }

    private boolean isSameRatFamily(ServiceState ss1, ServiceState ss2) {
+11 −10
Original line number Diff line number Diff line
@@ -3251,10 +3251,8 @@ public class ServiceStateTracker extends Handler {
            int newRAT = newNrs != null ? newNrs.getAccessNetworkTechnology()
                    : TelephonyManager.NETWORK_TYPE_UNKNOWN;

            boolean isOldCA = oldNrs != null ? (oldNrs.getDataSpecificInfo() != null
                    ? oldNrs.getDataSpecificInfo().isUsingCarrierAggregation() : false) : false;
            boolean isNewCA = newNrs!= null ? (newNrs. getDataSpecificInfo() != null
                    ? newNrs. getDataSpecificInfo().isUsingCarrierAggregation() : false) : false;
            boolean isOldCA = oldNrs != null ? oldNrs.isUsingCarrierAggregation() : false;
            boolean isNewCA = newNrs != null ? newNrs.isUsingCarrierAggregation() : false;

            // If the carrier enable KEY_SHOW_CARRIER_DATA_ICON_PATTERN_STRING and the operator name
            // match this pattern, the data rat display LteAdvanced indicator.
@@ -3295,12 +3293,15 @@ public class ServiceStateTracker extends Handler {
        boolean hasLocationChanged = mCellIdentity == null
                ? primaryCellIdentity != null : !mCellIdentity.isSameCell(primaryCellIdentity);

        // ratchet the new tech up through its rat family but don't drop back down
        // until cell change or device is OOS
        boolean isDataInService = mNewSS.getDataRegistrationState()
                == ServiceState.STATE_IN_SERVICE;
        if (isDataInService) {
            mRatRatcheter.ratchet(mSS, mNewSS, hasLocationChanged);
        boolean isRegisteredOnWwan = false;
        for (NetworkRegistrationInfo nri : mNewSS.getNetworkRegistrationInfoListForTransportType(
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN)) {
            isRegisteredOnWwan |= nri.isRegistered();
        }

        // Ratchet if the device is in service on the same cell
        if (isRegisteredOnWwan && !hasLocationChanged) {
            mRatRatcheter.ratchet(mSS, mNewSS);
        }

        boolean hasRilVoiceRadioTechnologyChanged =
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ public class CellularNetworkServiceTest extends TelephonyTest {
                domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, voiceRegState,
                ServiceState.rilRadioTechnologyToNetworkType(voiceRadioTech), reasonForDenial,
                false, availableServices, null, "", maxDataCalls, false, false, false,
                lteVopsSupportInfo, false);
                lteVopsSupportInfo);

        try {
            verify(mCallback, timeout(1000).times(1)).onRequestNetworkRegistrationInfoComplete(
+3 −4
Original line number Diff line number Diff line
@@ -104,8 +104,7 @@ public class RatRatcheterTest extends TelephonyTest {
                false,  // isDcNrRestricted
                false,  // isNrAvailable
                false,  // isEndcAvailable
                lteVopsSupportInfo,  // lteVopsSupportInfo
                isUsingCarrierAggregation);  // isUsingCarrierAggregation
                lteVopsSupportInfo);  // lteVopsSupportInfo
    }

    private void setNetworkRegistrationInfo(ServiceState ss, int accessNetworkTechnology) {
@@ -141,7 +140,7 @@ public class RatRatcheterTest extends TelephonyTest {
        setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE);

        RatRatcheter ratRatcheter = new RatRatcheter(mPhone);
        ratRatcheter.ratchet(oldSS, newSS, false);
        ratRatcheter.ratchet(oldSS, newSS);

        assertTrue(newSS.isUsingCarrierAggregation());
    }
@@ -158,7 +157,7 @@ public class RatRatcheterTest extends TelephonyTest {
        setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE);

        RatRatcheter ratRatcheter = new RatRatcheter(mPhone);
        ratRatcheter.ratchet(oldSS, newSS, false);
        ratRatcheter.ratchet(oldSS, newSS);

        assertFalse(newSS.isUsingCarrierAggregation());
    }
Loading