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

Commit 552fc09c authored by Jack Yu's avatar Jack Yu
Browse files

Fixed incorrect metered/unmetered APN in AP-assisted mode

From now all data traffic through IWLAN will be unmetered. Only
data through cellular will be checked for metered/unmetered.

Test: Unit tests
Bug: 132433959
Change-Id: I6947e9ba9a461484c25ca884048939724be7ce30
parent 8cf47e72
Loading
Loading
Loading
Loading
+14 −30
Original line number Diff line number Diff line
@@ -20,13 +20,11 @@ import android.content.Context;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.data.ApnSetting;
import android.text.TextUtils;
import android.telephony.data.ApnSetting.ApnType;
import android.util.Log;

import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.uicc.IccRecords;

import java.util.Arrays;
@@ -114,34 +112,29 @@ public class ApnSettingUtils {
    /**
     * Check if this APN type is metered.
     *
     * @param type the APN type
     * @param apnType the APN type
     * @param phone the phone object
     * @return {@code true} if the APN type is metered, {@code false} otherwise.
     */
    public static boolean isMeteredApnType(String type, Phone phone) {
        if (phone == null || TextUtils.isEmpty(type)) {
    public static boolean isMeteredApnType(@ApnType int apnType, Phone phone) {
        if (phone == null) {
            return true;
        }

        boolean isRoaming = phone.getServiceState().getDataRoaming();
        boolean isIwlan = phone.getServiceState().getRilDataRadioTechnology()
                == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
        int subId = phone.getSubId();

        String carrierConfig;
        // First check if the device is in IWLAN mode. If yes, use the IWLAN metered APN list. Then
        // check if the device is roaming. If yes, use the roaming metered APN list. Otherwise, use
        // the normal metered APN list.
        if (isIwlan) {
            carrierConfig = CarrierConfigManager.KEY_CARRIER_METERED_IWLAN_APN_TYPES_STRINGS;
        } else if (isRoaming) {
        // First check if the device is roaming. If yes, use the roaming metered APN list.
        // Otherwise use the normal metered APN list.
        if (isRoaming) {
            carrierConfig = CarrierConfigManager.KEY_CARRIER_METERED_ROAMING_APN_TYPES_STRINGS;
        } else {
            carrierConfig = CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS;
        }

        if (DBG) {
            Rlog.d(LOG_TAG, "isMeteredApnType: isRoaming=" + isRoaming + ", isIwlan=" + isIwlan);
            Rlog.d(LOG_TAG, "isMeteredApnType: isRoaming=" + isRoaming);
        }

        CarrierConfigManager configManager = (CarrierConfigManager)
@@ -169,16 +162,10 @@ public class ApnSettingUtils {
                    + Arrays.toString(meteredApnSet.toArray()));
        }

        // If all types of APN are metered, then this APN setting must be metered.
        if (meteredApnSet.contains(PhoneConstants.APN_TYPE_ALL)) {
            if (DBG) Rlog.d(LOG_TAG, "All APN types are metered.");
        if (meteredApnSet.contains(ApnSetting.getApnTypeString(apnType))) {
            if (DBG) Rlog.d(LOG_TAG, ApnSetting.getApnTypeString(apnType) + " is metered.");
            return true;
        }

        if (meteredApnSet.contains(type)) {
            if (DBG) Rlog.d(LOG_TAG, type + " is metered.");
            return true;
        } else if (type.equals(PhoneConstants.APN_TYPE_ALL)) {
        } else if (apnType == ApnSetting.TYPE_ALL) {
            // Assuming no configuration error, if at least one APN type is
            // metered, then this APN setting is metered.
            if (meteredApnSet.size() > 0) {
@@ -187,7 +174,7 @@ public class ApnSettingUtils {
            }
        }

        if (DBG) Rlog.d(LOG_TAG, type + " is not metered.");
        if (DBG) Rlog.d(LOG_TAG, ApnSetting.getApnTypeString(apnType) + " is not metered.");
        return false;
    }

@@ -203,12 +190,9 @@ public class ApnSettingUtils {
            return true;
        }

        String[] types = ApnSetting.getApnTypesStringFromBitmask(
                apn.getApnTypeBitmask()).split(",");

        for (String type : types) {
        for (int apnType : apn.getApnTypes()) {
            // If one of the APN type is metered, then this APN setting is metered.
            if (isMeteredApnType(type, phone)) {
            if (isMeteredApnType(apnType, phone)) {
                return true;
            }
        }
+2 −1
Original line number Diff line number Diff line
@@ -1149,7 +1149,8 @@ public class DataConnection extends StateMachine {
                mApnSetting.getApnTypeBitmask() & ~mDisabledApnTypeBitMask).split(",");
            for (String type : types) {
                if (!mRestrictedNetworkOverride && mUnmeteredUseOnly
                        && ApnSettingUtils.isMeteredApnType(type, mPhone)) {
                        && ApnSettingUtils.isMeteredApnType(
                                ApnSetting.getApnTypesBitmaskFromString(type), mPhone)) {
                    log("Dropped the metered " + type + " for the unmetered data call.");
                    continue;
                }
+30 −22
Original line number Diff line number Diff line
@@ -1250,8 +1250,8 @@ public class DcTracker extends Handler {
        boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
        boolean radioStateFromCarrier = mPhone.getServiceStateTracker().getPowerStateFromCarrier();
        // TODO: Remove this hack added by ag/641832.
        int radioTech = getDataRat();
        if (radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN) {
        int dataRat = getDataRat();
        if (dataRat == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN) {
            desiredPowerState = true;
            radioStateFromCarrier = true;
        }
@@ -1262,7 +1262,8 @@ public class DcTracker extends Handler {
                SubscriptionManager.getDefaultDataSubscriptionId());

        boolean isMeteredApnType = apnContext == null
                || ApnSettingUtils.isMeteredApnType(apnContext.getApnType(), mPhone);
                || ApnSettingUtils.isMeteredApnType(ApnSetting.getApnTypesBitmaskFromString(
                        apnContext.getApnType()) , mPhone);

        PhoneConstants.State phoneState = PhoneConstants.State.IDLE;
        // Note this is explicitly not using mPhone.getState.  See b/19090488.
@@ -1294,11 +1295,12 @@ public class DcTracker extends Handler {
            reasons.add(DataDisallowedReasonType.APN_NOT_CONNECTABLE);
        }

        // If RAT is IWLAN then don't allow default/IA PDP at all.
        // In legacy mode, if RAT is IWLAN then don't allow default/IA PDP at all.
        // Rest of APN types can be evaluated for remaining conditions.
        if ((apnContext != null && (apnContext.getApnType().equals(PhoneConstants.APN_TYPE_DEFAULT)
                || apnContext.getApnType().equals(PhoneConstants.APN_TYPE_IA)))
                && (radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN)) {
                && mPhone.getTransportManager().isInLegacyMode()
                && dataRat == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN) {
            reasons.add(DataDisallowedReasonType.ON_IWLAN);
        }

@@ -1355,11 +1357,17 @@ public class DcTracker extends Handler {

        // At this point, if data is not allowed, it must be because of the soft reasons. We
        // should start to check some special conditions that data will be allowed.

        // If the request APN type is unmetered and there are soft disallowed reasons (e.g. data
        // disabled, data roaming disabled) existing, we should allow the data because the user
        // won't be charged anyway.
        if (!isMeteredApnType && !reasons.allowed()) {
        if (!reasons.allowed()) {
            // If the device is on IWLAN, then all data should be unmetered. Check if the transport
            // is WLAN (for AP-assisted mode devices), or RAT equals IWLAN (for legacy mode devices)
            if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN
                    || (mPhone.getTransportManager().isInLegacyMode()
                    && dataRat == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN)) {
                reasons.add(DataAllowedReasonType.UNMETERED_APN);
            // Or if the data is on cellular, and the APN type is determined unmetered by the
            // configuration.
            } else if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN
                    && !isMeteredApnType) {
                reasons.add(DataAllowedReasonType.UNMETERED_APN);
            }

@@ -1370,9 +1378,9 @@ public class DcTracker extends Handler {
                    && !reasons.allowed()) {
                reasons.add(DataAllowedReasonType.RESTRICTED_REQUEST);
            }

        // If at this point, we still haven't built any disallowed reasons, we should allow data.
        if (reasons.allowed()) {
        } else {
            // If there is no disallowed reasons, then we should allow the data request with
            // normal reason.
            reasons.add(DataAllowedReasonType.NORMAL);
        }

+21 −191
Original line number Diff line number Diff line
@@ -350,21 +350,21 @@ public class ApnSettingTest extends TelephonyTest {
        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_IA | ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DEFAULT, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_MMS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_SUPL, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_CBS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DUN, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_HIPRI, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DEFAULT, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_MMS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_SUPL, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_CBS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DUN, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_HIPRI, mPhone));

        // Carrier config settings changes.
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_DEFAULT});

        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_MMS, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_MMS, mPhone));
    }

    @Test
@@ -400,49 +400,9 @@ public class ApnSettingTest extends TelephonyTest {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_ROAMING_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_FOTA});

        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_MMS, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_FOTA, mPhone));
    }

    @Test
    @SmallTest
    public void testIsIwlanMetered() throws Exception {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_IWLAN_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS});
        doReturn(false).when(mServiceState).getDataRoaming();
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(mServiceState)
                .getRilDataRadioTechnology();
        doReturn(1).when(mPhone).getSubId();

        assertTrue(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_DEFAULT), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_MMS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_SUPL | ApnSetting.TYPE_MMS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_DUN), mPhone));

        assertTrue(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_ALL), mPhone));

        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_SUPL | ApnSetting.TYPE_FOTA), mPhone));

        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_IA | ApnSetting.TYPE_CBS), mPhone));

        // Carrier config settings changes.
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_IWLAN_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_FOTA});

        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_MMS, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_MMS, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_FOTA, mPhone));
    }

    @Test
@@ -503,54 +463,14 @@ public class ApnSettingTest extends TelephonyTest {

        assertFalse(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_IMS), mPhone));

        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_SUPL, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_CBS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_MMS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DUN, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_HIPRI, mPhone));
    }

    @Test
    @SmallTest
    public void testIsIwlanMeteredAnother() throws Exception {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_IWLAN_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_SUPL, PhoneConstants.APN_TYPE_CBS});
        doReturn(true).when(mServiceState).getDataRoaming();
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(mServiceState)
                .getRilDataRadioTechnology();
        doReturn(2).when(mPhone).getSubId();

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_SUPL | ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_SUPL), mPhone));

        assertTrue(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_FOTA | ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_SUPL | ApnSetting.TYPE_IA), mPhone));

        assertTrue(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_ALL), mPhone));

        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_IMS), mPhone));

        assertFalse(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_IMS), mPhone));

        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_SUPL, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_CBS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_MMS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_DUN, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(PhoneConstants.APN_TYPE_HIPRI, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_SUPL, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_CBS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_MMS, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DUN, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_HIPRI, mPhone));
    }

    @Test
@@ -594,96 +514,6 @@ public class ApnSettingTest extends TelephonyTest {
                createApnSetting(ApnSetting.TYPE_ALL), mPhone));
    }

    @Test
    @SmallTest
    public void testIsIwlanMeteredNothingCharged() throws Exception {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_IWLAN_APN_TYPES_STRINGS,
                new String[]{});
        doReturn(true).when(mServiceState).getDataRoaming();
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(mServiceState)
                .getRilDataRadioTechnology();
        doReturn(3).when(mPhone).getSubId();

        assertFalse(ApnSettingUtils.isMetered(createApnSetting(ApnSetting.TYPE_IMS), mPhone));

        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_IMS | ApnSetting.TYPE_MMS), mPhone));

        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_FOTA), mPhone));

        assertFalse(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_ALL), mPhone));
    }

    @Test
    @SmallTest
    public void testIsMeteredNothingFree() throws Exception {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_ALL});

        doReturn(false).when(mServiceState).getDataRoaming();
        doReturn(4).when(mPhone).getSubId();

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_ALL), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_FOTA | ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_IA | ApnSetting.TYPE_DUN), mPhone));
    }

    @Test
    @SmallTest
    public void testIsRoamingMeteredNothingFree() throws Exception {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_ROAMING_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_ALL});

        doReturn(true).when(mServiceState).getDataRoaming();
        doReturn(4).when(mPhone).getSubId();

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_ALL), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_FOTA | ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_IA | ApnSetting.TYPE_DUN), mPhone));
    }

    @Test
    @SmallTest
    public void testIsIwlanMeteredNothingFree() throws Exception {
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_IWLAN_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_ALL});

        doReturn(false).when(mServiceState).getDataRoaming();
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(mServiceState)
                .getRilDataRadioTechnology();
        doReturn(4).when(mPhone).getSubId();

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_ALL), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_FOTA | ApnSetting.TYPE_CBS), mPhone));

        assertTrue(ApnSettingUtils.isMetered(
                createApnSetting(ApnSetting.TYPE_IA | ApnSetting.TYPE_DUN), mPhone));
    }

    @Test
    @SmallTest
    public void testCanHandleType() throws Exception {
+1 −0
Original line number Diff line number Diff line
@@ -1212,6 +1212,7 @@ public class DcTrackerTest extends TelephonyTest {
    @Test
    @SmallTest
    public void testTrySetupDefaultOnIWLAN() throws Exception {
        doReturn(true).when(mTransportManager).isInLegacyMode();
        initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL});
        mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder()
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)