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

Commit 6fa85c57 authored by Sarah Chin's avatar Sarah Chin
Browse files

Add APN type XCAP

Add XCAP and update DataProfileInfo

Test: atest ApnSettingTest, DcTrackerTest
Bug: 73792201
Change-Id: I4bc7048cc98987a8aa3e132dbd43fa6aadb352b9
parent 7fd7f903
Loading
Loading
Loading
Loading
+87 −3
Original line number Diff line number Diff line
@@ -1482,6 +1482,43 @@ public class RIL extends BaseCommands implements CommandsInterface {
        return dpi;
    }

    /**
     * Convert to DataProfileInfo defined in radio/1.5/types.hal
     * @param dp Data profile
     * @return A converted data profile
     */
    private static android.hardware.radio.V1_5.DataProfileInfo convertToHalDataProfile15(
            DataProfile dp) {
        android.hardware.radio.V1_5.DataProfileInfo dpi =
                new android.hardware.radio.V1_5.DataProfileInfo();

        dpi.base.apn = dp.getApn();
        dpi.base.protocol = dp.getProtocolType();
        dpi.base.roamingProtocol = dp.getRoamingProtocolType();
        dpi.base.authType = dp.getAuthType();
        dpi.base.user = dp.getUserName();
        dpi.base.password = dp.getPassword();
        dpi.base.type = dp.getType();
        dpi.base.maxConnsTime = dp.getMaxConnectionsTime();
        dpi.base.maxConns = dp.getMaxConnections();
        dpi.base.waitTime = dp.getWaitTime();
        dpi.base.enabled = dp.isEnabled();
        dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmask();
        // Shift by 1 bit due to the discrepancy between
        // android.hardware.radio.V1_0.RadioAccessFamily and the bitmask version of
        // ServiceState.RIL_RADIO_TECHNOLOGY_XXXX.
        dpi.base.bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(
            dp.getBearerBitmask()) << 1;
        dpi.base.mtu = dp.getMtu();
        dpi.base.persistent = dp.isPersistent();
        dpi.base.preferred = dp.isPreferred();

        // profile id is only meaningful when it's persistent on the modem.
        dpi.base.profileId = (dpi.base.persistent) ? dp.getProfileId() : DataProfileId.INVALID;

        return dpi;
    }

    /**
     * Convert NV reset type into ResetNvType defined in types.hal.
     * @param resetType NV reset type.
@@ -1526,7 +1563,26 @@ public class RIL extends BaseCommands implements CommandsInterface {
            }

            try {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                    // IRadio V1.5
                    android.hardware.radio.V1_5.IRadio radioProxy15 =
                            (android.hardware.radio.V1_5.IRadio) radioProxy;

                    // Convert to HAL data profile
                    android.hardware.radio.V1_5.DataProfileInfo dpi =
                            convertToHalDataProfile15(dataProfile);

                    if (RILJ_LOGD) {
                        riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
                                + ",accessNetworkType="
                                + AccessNetworkType.toString(accessNetworkType) + ",isRoaming="
                                + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile
                                + ",addresses=" + addresses + ",dnses=" + dnses);
                    }

                    radioProxy15.setupDataCall_1_5(rr.mSerial, accessNetworkType, dpi, allowRoaming,
                            reason, addresses, dnses);
                } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
                    // IRadio V1.4
                    android.hardware.radio.V1_4.IRadio radioProxy14 =
                            (android.hardware.radio.V1_4.IRadio) radioProxy;
@@ -3596,7 +3652,13 @@ public class RIL extends BaseCommands implements CommandsInterface {
            }

            try {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                    // v1.5
                    android.hardware.radio.V1_5.IRadio radioProxy15 =
                            (android.hardware.radio.V1_5.IRadio) radioProxy;
                    radioProxy15.setInitialAttachApn_1_5(rr.mSerial,
                            convertToHalDataProfile15(dataProfile));
                } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
                    // v1.4
                    android.hardware.radio.V1_4.IRadio radioProxy14 =
                            (android.hardware.radio.V1_4.IRadio) radioProxy;
@@ -3999,7 +4061,29 @@ public class RIL extends BaseCommands implements CommandsInterface {

            RILRequest rr = null;
            try {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                    // V1.5
                    android.hardware.radio.V1_5.IRadio radioProxy15 =
                            (android.hardware.radio.V1_5.IRadio) radioProxy;

                    rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result,
                            mRILDefaultWorkSource);

                    ArrayList<android.hardware.radio.V1_5.DataProfileInfo> dpis = new ArrayList<>();
                    for (DataProfile dp : dps) {
                        dpis.add(convertToHalDataProfile15(dp));
                    }

                    if (RILJ_LOGD) {
                        riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
                                + " with data profiles : ");
                        for (DataProfile profile : dps) {
                            riljLog(profile.toString());
                        }
                    }

                    radioProxy15.setDataProfile_1_5(rr.mSerial, dpis);
                } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
                    // V1.4
                    android.hardware.radio.V1_4.IRadio radioProxy14 =
                            (android.hardware.radio.V1_4.IRadio) radioProxy;
+4 −0
Original line number Diff line number Diff line
@@ -591,6 +591,10 @@ public class ApnContext {
            if (apnType != ApnSetting.TYPE_NONE) error = true;
            apnType = ApnSetting.TYPE_MCX;
        }
        if (nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_XCAP)) {
            if (apnType != ApnSetting.TYPE_NONE) error = true;
            apnType = ApnSetting.TYPE_XCAP;
        }
        if (error) {
            // TODO: If this error condition is removed, the framework's handling of
            // NET_CAPABILITY_NOT_RESTRICTED will need to be updated so requests for
+4 −0
Original line number Diff line number Diff line
@@ -1279,6 +1279,10 @@ public class DataConnection extends StateMachine {
                        result.addCapability(NetworkCapabilities.NET_CAPABILITY_MCX);
                        break;
                    }
                    case PhoneConstants.APN_TYPE_XCAP: {
                        result.addCapability(NetworkCapabilities.NET_CAPABILITY_XCAP);
                        break;
                    }
                    default:
                }
            }
+6 −2
Original line number Diff line number Diff line
@@ -157,8 +157,9 @@ public class DcTracker extends Handler {
    private static final int NETWORK_TYPE_CBS = ConnectivityManager.TYPE_MOBILE_CBS;
    private static final int NETWORK_TYPE_IA = ConnectivityManager.TYPE_MOBILE_IA;
    private static final int NETWORK_TYPE_EMERGENCY = ConnectivityManager.TYPE_MOBILE_EMERGENCY;
    private static final int NETWORK_TYPE_MCX = 1001;  // far away from ConnectivityManager.TYPE_xxx
                                                       // constants as MCX isn't defined there.
    // far away from ConnectivityManager.TYPE_xxx constants as the APNs below aren't defined there.
    private static final int NETWORK_TYPE_MCX = 1001;
    private static final int NETWORK_TYPE_XCAP = 1002;

    @IntDef(value = {
            REQUEST_TYPE_NORMAL,
@@ -1064,6 +1065,9 @@ public class DcTracker extends Handler {
                case NETWORK_TYPE_MCX:
                    apnContext = addApnContext(PhoneConstants.APN_TYPE_MCX, networkConfig);
                    break;
                case NETWORK_TYPE_XCAP:
                    apnContext = addApnContext(PhoneConstants.APN_TYPE_XCAP, networkConfig);
                    break;
                default:
                    log("initApnContexts: skipping unknown type=" + networkConfig.type);
                    continue;
+13 −1
Original line number Diff line number Diff line
@@ -359,6 +359,7 @@ public class ApnSettingTest extends TelephonyTest {
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_HIPRI, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_XCAP, mPhone));

        // Carrier config settings changes.
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS,
@@ -404,6 +405,7 @@ public class ApnSettingTest extends TelephonyTest {
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_DEFAULT, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_MMS, mPhone));
        assertTrue(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_XCAP, mPhone));
    }

    @Test
@@ -434,6 +436,7 @@ public class ApnSettingTest extends TelephonyTest {
                createApnSetting(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_IMS), mPhone));

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

    @Test
@@ -472,6 +475,7 @@ public class ApnSettingTest extends TelephonyTest {
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_FOTA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_IA, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_HIPRI, mPhone));
        assertFalse(ApnSettingUtils.isMeteredApnType(ApnSetting.TYPE_XCAP, mPhone));
    }

    @Test
@@ -552,7 +556,7 @@ public class ApnSettingTest extends TelephonyTest {
                ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS | ApnSetting.TYPE_IA)
                .canHandleType(ApnSetting.TYPE_IA));

        // same for emergency and mcx
        // same for emergency, mcx, and xcap
        assertFalse(createApnSetting(ApnSetting.TYPE_ALL)
                .canHandleType(ApnSetting.TYPE_EMERGENCY));
        assertTrue(createApnSetting(
@@ -563,6 +567,11 @@ public class ApnSettingTest extends TelephonyTest {
        assertTrue(createApnSetting(
                ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS | ApnSetting.TYPE_MCX)
                .canHandleType(ApnSetting.TYPE_MCX));
        assertFalse(createApnSetting(ApnSetting.TYPE_ALL)
                .canHandleType(ApnSetting.TYPE_XCAP));
        assertTrue(createApnSetting(
                ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS | ApnSetting.TYPE_XCAP)
                .canHandleType(ApnSetting.TYPE_XCAP));

        // check carrier disabled
        assertFalse(createDisabledApnSetting(ApnSetting.TYPE_ALL)
@@ -578,6 +587,9 @@ public class ApnSettingTest extends TelephonyTest {
        assertFalse(createDisabledApnSetting(
                ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS | ApnSetting.TYPE_IA)
                .canHandleType(ApnSetting.TYPE_IA));
        assertFalse(createDisabledApnSetting(
                ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS | ApnSetting.TYPE_XCAP)
                .canHandleType(ApnSetting.TYPE_XCAP));
    }

    @Test
Loading