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

Commit 2de82f19 authored by Jack Yu's avatar Jack Yu
Browse files

Data profile refactoring

Data profile should use the public defined types
instead of the internal defined data types.

1. Using integer instead of string for protocol type.
2. Using TelephonyManager.NetworkTypeBitMask instead of
   the internal ServiceState.RIL_RADIO_TECHNOLOGY_XXX
   in data profile.

Test: Telephony sanity tests
Bug: 73659459

Change-Id: Ib025f353a199f2d1e7acb9c5e630ce871450323b
parent 9521fc46
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -1333,8 +1333,8 @@ public class RIL extends BaseCommands implements CommandsInterface {

        dpi.profileId = dp.getProfileId();
        dpi.apn = dp.getApn();
        dpi.protocol = dp.getProtocol();
        dpi.roamingProtocol = dp.getRoamingProtocol();
        dpi.protocol = ApnSetting.getProtocolStringFromInt(dp.getProtocol());
        dpi.roamingProtocol = ApnSetting.getProtocolStringFromInt(dp.getRoamingProtocol());
        dpi.authType = dp.getAuthType();
        dpi.user = dp.getUserName();
        dpi.password = dp.getPassword();
@@ -1344,7 +1344,11 @@ public class RIL extends BaseCommands implements CommandsInterface {
        dpi.waitTime = dp.getWaitTime();
        dpi.enabled = dp.isEnabled();
        dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmap();
        dpi.bearerBitmap = dp.getBearerBitmap();
        // 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.bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(
                dp.getBearerBitmap()) << 1;
        dpi.mtu = dp.getMtu();
        dpi.mvnoType = MvnoType.NONE;
        dpi.mvnoMatchData = "";
@@ -1363,8 +1367,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
                new android.hardware.radio.V1_4.DataProfileInfo();

        dpi.apn = dp.getApn();
        dpi.protocol = ApnSetting.getProtocolIntFromString(dp.getProtocol());
        dpi.roamingProtocol = ApnSetting.getProtocolIntFromString(dp.getRoamingProtocol());
        dpi.protocol = dp.getProtocol();
        dpi.roamingProtocol = dp.getRoamingProtocol();
        dpi.authType = dp.getAuthType();
        dpi.user = dp.getUserName();
        dpi.password = dp.getPassword();
@@ -1374,7 +1378,11 @@ public class RIL extends BaseCommands implements CommandsInterface {
        dpi.waitTime = dp.getWaitTime();
        dpi.enabled = dp.isEnabled();
        dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmap();
        dpi.bearerBitmap = dp.getBearerBitmap();
        // 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.bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(
                dp.getBearerBitmap()) << 1;
        dpi.mtu = dp.getMtu();
        dpi.persistent = dp.isPersistent();
        dpi.preferred = dp.isPreferred();
@@ -5669,7 +5677,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
        if (dcResult == null) return null;

        int status, suggestedRetryTime, cid, active, mtu;
        String type, ifname;
        String ifname;
        int protocolType;
        String[] addresses = null;
        String[] dnses = null;
        String[] gateways = null;
@@ -5681,7 +5690,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
            suggestedRetryTime = result.suggestedRetryTime;
            cid = result.cid;
            active = result.active;
            type = result.type;
            protocolType = ApnSetting.getProtocolIntFromString(result.type);
            ifname = result.ifname;
            if (!TextUtils.isEmpty(result.addresses)) {
                addresses = result.addresses.split("\\s+");
@@ -5701,7 +5710,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
            suggestedRetryTime = result.suggestedRetryTime;
            cid = result.cid;
            active = result.active;
            type = ApnSetting.getProtocolStringFromInt(result.type);
            protocolType = result.type;
            ifname = result.ifname;
            addresses = result.addresses.stream().toArray(String[]::new);
            dnses = result.dnses.stream().toArray(String[]::new);
@@ -5768,8 +5777,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
            }
        }

        return new DataCallResponse(status, suggestedRetryTime, cid, active, type, ifname, laList,
                dnsList, gatewayList, pcscfs, mtu);
        return new DataCallResponse(status, suggestedRetryTime, cid, active, protocolType, ifname,
                laList, dnsList, gatewayList, pcscfs, mtu);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -543,7 +543,7 @@ public class DataConnection extends StateMachine {
        if (mDcTesterFailBringUpAll.getDcFailBringUp().mCounter  > 0) {
            DataCallResponse response = new DataCallResponse(
                    mDcTesterFailBringUpAll.getDcFailBringUp().mFailCause,
                    mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime, 0, 0, "", "",
                    mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime, 0, 0, 0, "",
                    null, null, null, null, PhoneConstants.UNSET_MTU);

            Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
+7 −9
Original line number Diff line number Diff line
@@ -3271,7 +3271,7 @@ public class DcTracker extends Handler {
                    if (DBG) {
                        log("buildWaitingApns: networkTypeBitmask:"
                                + apn.getNetworkTypeBitmask()
                                + "do not include radioTech:" + radioTech);
                                + " does not include radioTech:" + radioTech);
                    }
                }
            } else if (DBG) {
@@ -4678,23 +4678,21 @@ public class DcTracker extends Handler {
                                                boolean isPreferred) {
        int profileType;

        int bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask(
                apn.getNetworkTypeBitmask());
        int networkTypeBitmask = apn.getNetworkTypeBitmask();

        if (bearerBitmap == 0) {
        if (networkTypeBitmask == 0) {
            profileType = DataProfile.TYPE_COMMON;
        } else if (ServiceState.bearerBitmapHasCdma(bearerBitmap)) {
        } else if (ServiceState.bearerBitmapHasCdma(networkTypeBitmask)) {
            profileType = DataProfile.TYPE_3GPP2;
        } else {
            profileType = DataProfile.TYPE_3GPP;
        }

        return new DataProfile(profileId, apn.getApnName(),
                ApnSetting.getProtocolStringFromInt(apn.getProtocol()), apn.getAuthType(),
        return new DataProfile(profileId, apn.getApnName(), apn.getProtocol(), apn.getAuthType(),
                apn.getUser(), apn.getPassword(), profileType, apn.getMaxConnsTime(),
                apn.getMaxConns(),  apn.getWaitTime(), apn.isEnabled(), apn.getApnTypeBitmask(),
                ApnSetting.getProtocolStringFromInt(apn.getRoamingProtocol()), bearerBitmap,
                apn.getMtu(), apn.isPersistent(), isPreferred);
                apn.getRoamingProtocol(), networkTypeBitmask, apn.getMtu(), apn.isPersistent(),
                isPreferred);
    }

    private void onDataServiceBindingChanged(boolean bound) {
+6 −10
Original line number Diff line number Diff line
@@ -1124,7 +1124,7 @@ public class TelephonyMetrics {
     * @param protocol Data connection protocol
     */
    public void writeSetupDataCall(int phoneId, int radioTechnology, int profileId, String apn,
                                   String protocol) {
                                   int protocol) {

        RilSetupDataCall setupDataCall = new RilSetupDataCall();
        setupDataCall.rat = radioTechnology;
@@ -1132,9 +1132,8 @@ public class TelephonyMetrics {
        if (apn != null) {
            setupDataCall.apn = apn;
        }
        if (protocol != null) {
            setupDataCall.type = toPdpType(protocol);
        }

        setupDataCall.type = protocol + 1;

        addTelephonyEvent(new TelephonyEventBuilder(phoneId).setSetupDataCall(
                setupDataCall).build());
@@ -1186,9 +1185,8 @@ public class TelephonyMetrics {
            if (!TextUtils.isEmpty(dcsList.get(i).getIfname())) {
                dataCalls[i].iframe = dcsList.get(i).getIfname();
            }
            if (!TextUtils.isEmpty(dcsList.get(i).getType())) {
                dataCalls[i].type = toPdpType(dcsList.get(i).getType());
            }

            dataCalls[i].type = dcsList.get(i).getProtocolType() + 1;
        }

        addTelephonyEvent(new TelephonyEventBuilder(phoneId).setDataCalls(dataCalls).build());
@@ -1435,9 +1433,7 @@ public class TelephonyMetrics {
            setupDataCallResponse.suggestedRetryTimeMillis = response.getSuggestedRetryTime();

            dataCall.cid = response.getCallId();
            if (!TextUtils.isEmpty(response.getType())) {
                dataCall.type = toPdpType(response.getType());
            }
            dataCall.type = response.getProtocolType() + 1;

            if (!TextUtils.isEmpty(response.getIfname())) {
                dataCall.iframe = response.getIfname();
+5 −7
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ public class RILTest extends TelephonyTest {

    private static final int PROFILE_ID = 0;
    private static final String APN = "apn";
    private static final String PROTOCOL = "IPV6";
    private static final int PROTOCOL = ApnSetting.PROTOCOL_IPV6;
    private static final int AUTH_TYPE = 0;
    private static final String USER_NAME = "username";
    private static final String PASSWORD = "password";
@@ -239,11 +239,9 @@ public class RILTest extends TelephonyTest {
    private static final int WAIT_TIME = 10;
    private static final boolean APN_ENABLED = true;
    private static final int SUPPORTED_APNT_YPES_BITMAP = 123456;
    private static final String ROAMING_PROTOCOL = "IPV6";
    private static final int ROAMING_PROTOCOL = ApnSetting.PROTOCOL_IPV6;
    private static final int BEARER_BITMAP = 123123;
    private static final int MTU = 1234;
    private static final String MVNO_TYPE = "";
    private static final String MVNO_MATCH_DATA = "";
    private static final boolean PERSISTENT = true;

    private class RILTestHandler extends HandlerThread {
@@ -1605,7 +1603,7 @@ public class RILTest extends TelephonyTest {
        result10.pcscf = "fd00:976a:c206:20::6   fd00:976a:c206:20::9    fd00:976a:c202:1d::9";
        result10.mtu = 1500;

        DataCallResponse response = new DataCallResponse(0, -1, 0, 2, "IPV4V6",
        DataCallResponse response = new DataCallResponse(0, -1, 0, 2, ApnSetting.PROTOCOL_IPV4V6,
                "ifname",
                Arrays.asList(new LinkAddress(NetworkUtils.numericToInetAddress("10.0.2.15"), 32),
                        new LinkAddress("2607:fb90:a620:651d:eabe:f8da:c107:44be/64")),
@@ -1800,7 +1798,7 @@ public class RILTest extends TelephonyTest {
        DataProfileInfo dpi = dpiCaptor.getValue();
        assertEquals(PROFILE_ID, dpi.profileId);
        assertEquals(APN, dpi.apn);
        assertEquals(PROTOCOL, dpi.protocol);
        assertEquals(PROTOCOL, ApnSetting.getProtocolIntFromString(dpi.protocol));
        assertEquals(AUTH_TYPE, dpi.authType);
        assertEquals(USER_NAME, dpi.user);
        assertEquals(PASSWORD, dpi.password);
@@ -1810,7 +1808,7 @@ public class RILTest extends TelephonyTest {
        assertEquals(WAIT_TIME, dpi.waitTime);
        assertEquals(APN_ENABLED, dpi.enabled);
        assertEquals(SUPPORTED_APNT_YPES_BITMAP, dpi.supportedApnTypesBitmap);
        assertEquals(ROAMING_PROTOCOL, dpi.protocol);
        assertEquals(ROAMING_PROTOCOL, ApnSetting.getProtocolIntFromString(dpi.protocol));
        assertEquals(BEARER_BITMAP, dpi.bearerBitmap);
        assertEquals(MTU, dpi.mtu);
    }
Loading