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

Commit e1064628 authored by Sarah Chin's avatar Sarah Chin Committed by Automerger Merge Worker
Browse files

Merge "Disable RatRatcheter feature for rats not in the same rat family" into...

Merge "Disable RatRatcheter feature for rats not in the same rat family" into rvc-dev am: 703b426b am: debb1dc0

Change-Id: Ia337db387a5d2d8bf8eb49ac9083255a1765bc3f
parents bbbcca79 debb1dc0
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -122,9 +122,6 @@ 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) {
        if (!locationChange && isSameRatFamily(oldSS, newSS)) {
            updateBandwidths(oldSS.getCellBandwidths(), newSS);
        }
        // temporarily disable rat ratchet on location change.
        if (locationChange) {
            mVoiceRatchetEnabled = false;
@@ -132,6 +129,13 @@ public class RatRatcheter {
            return;
        }

        // Different rat family, don't need rat ratchet and update cell bandwidths.
        if (!isSameRatFamily(oldSS, newSS)) {
            return;
        }

        updateBandwidths(oldSS.getCellBandwidths(), newSS);

        boolean newUsingCA = oldSS.isUsingCarrierAggregation()
                || newSS.isUsingCarrierAggregation()
                || newSS.getCellBandwidths().length > 1;
@@ -179,6 +183,20 @@ public class RatRatcheter {
                            AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                            .getAccessNetworkTechnology());

            // The api getAccessNetworkTechnology@NetworkRegistrationInfo always returns LTE though
            // data rat is LTE CA. Because it uses mIsUsingCarrierAggregation to indicate whether
            // it is LTE CA or not. However, we need its actual data rat to check if they are the
            // same family. So convert it to LTE CA.
            if (dataRat1 == ServiceState.RIL_RADIO_TECHNOLOGY_LTE
                    && ss1.isUsingCarrierAggregation()) {
                dataRat1 = ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA;
            }

            if (dataRat2 == ServiceState.RIL_RADIO_TECHNOLOGY_LTE
                    && ss2.isUsingCarrierAggregation()) {
                dataRat2 = ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA;
            }

            if (dataRat1 == dataRat2) return true;
            if (mRatFamilyMap.get(dataRat1) == null) {
                return false;
+96 −2
Original line number Diff line number Diff line
@@ -18,23 +18,37 @@ package com.android.internal.telephony;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import android.os.PersistableBundle;
import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
import android.telephony.LteVopsSupportInfo;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;

/** Tests for RatRatcheter. */
public class RatRatcheterTest {
public class RatRatcheterTest extends TelephonyTest {

    private ServiceState mServiceState;
    private PersistableBundle mBundle;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
        mServiceState = new ServiceState();
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @Test
    public void testUpdateBandwidthsSuccess() {
        int[] bandwidths = new int[] {1400, 5000};
@@ -68,4 +82,84 @@ public class RatRatcheterTest {
        assertFalse(updated);
        assertTrue(Arrays.equals(mServiceState.getCellBandwidths(), originalBandwidths));
    }

    private NetworkRegistrationInfo createNetworkRegistrationInfo(
            int domain, int accessNetworkTechnology, boolean isUsingCarrierAggregation) {

        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_SUPPORTED,
                        LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED);

        return new NetworkRegistrationInfo(
                domain,  // domain
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN,  // transportType
                0,  // registrationState
                accessNetworkTechnology,  // accessNetworkTechnology
                0,  // rejectCause
                false,  // emergencyOnly
                null,  // availableServices
                null,  // cellIdentity
                null,  // rplmn
                0,  // maxDataCalls
                false,  // isDcNrRestricted
                false,  // isNrAvailable
                false,  // isEndcAvailable
                lteVopsSupportInfo,  // lteVopsSupportInfo
                isUsingCarrierAggregation);  // isUsingCarrierAggregation
    }

    private void setNetworkRegistrationInfo(ServiceState ss, int accessNetworkTechnology) {

        NetworkRegistrationInfo nri1;
        NetworkRegistrationInfo nri2;

        boolean isUsingCarrierAggregation = false;

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

        nri1 = createNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                accessNetworkTechnology, isUsingCarrierAggregation);
        nri2 = createNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_CS,
                accessNetworkTechnology, isUsingCarrierAggregation);

        ss.addNetworkRegistrationInfo(nri1);
        ss.addNetworkRegistrationInfo(nri2);
    }

    @Test
    public void testRatchetIsFamily() {
        ServiceState oldSS = new ServiceState();
        ServiceState newSS = new ServiceState();

        mBundle = mContextFixture.getCarrierConfigBundle();
        mBundle.putStringArray(CarrierConfigManager.KEY_RATCHET_RAT_FAMILIES,
                new String[]{"14,19"});

        setNetworkRegistrationInfo(oldSS, TelephonyManager.NETWORK_TYPE_LTE_CA);
        setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE);

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

        assertTrue(newSS.isUsingCarrierAggregation());
    }

    @Test
    public void testRatchetIsNotFamily() {
        ServiceState oldSS = new ServiceState();
        ServiceState newSS = new ServiceState();

        mBundle = mContextFixture.getCarrierConfigBundle();
        mBundle.putStringArray(CarrierConfigManager.KEY_RATCHET_RAT_FAMILIES, new String[]{});

        setNetworkRegistrationInfo(oldSS, TelephonyManager.NETWORK_TYPE_LTE_CA);
        setNetworkRegistrationInfo(newSS, TelephonyManager.NETWORK_TYPE_LTE);

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

        assertFalse(newSS.isUsingCarrierAggregation());
    }
}