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

Commit 723facc2 authored by sinikang's avatar sinikang Committed by Robert Greenwalt
Browse files

Add OTADM feature for Verizon requirement.

- GsmDataConnectionTracker.java
  <in function createApnList>
  : modify parameter type for new ApnSetting.
    (carrierEnabled has changed to boolean from integer,
     BEARER has changed to integer from string).
  <in function createAllApnList>
  : modify telephony db query statement using carrierEnabled. (carrier_enabled: 1 enable apn, 0: disabled apn)
  <in function buildWaitingApns>
  : modify apn management code when current RAT (radio access technology) is LTE or EHRPD.
    add internal function named needToCheckApnBearer to check current RAT is LTE or EHRPD.
- ApnSetting.java
  : add two member variable (carrierEnabled: apn enable/disable , bearer : Radio Access Technology)
- Telephony.java
  : add two static string CARRIER_ENABLED & BEARER.
- ApnSettingTest.java
  : add two assertEquals in function assertApnSettingEqual.
    add CARRIER_ENABLED & BEARER parameters.

bug: 4991683
Change-Id: I9450c220009c3093b1e09e8ac9cd0faa0a975067
parent 96cbcbfe
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1798,6 +1798,20 @@ public final class Telephony {
        public static final String ROAMING_PROTOCOL = "roaming_protocol";

        public static final String CURRENT = "current";

        /**
          * Current status of APN
          * true : enabled APN, false : disabled APN.
          */
        public static final String CARRIER_ENABLED = "carrier_enabled";

        /**
          * Radio Access Technology info
          * To check what values can hold, refer to ServiceState.java.
          * This should be spread to other technologies,
          * but currently only used for LTE(14) and EHRPD(13).
          */
        public static final String BEARER = "bearer";
    }

    public static final class Intents {
+2 −3
Original line number Diff line number Diff line
@@ -17,10 +17,9 @@
*/
-->

<!-- use empty string to specify no proxy or port -->

<!-- If you edit this version, also edit the version in the partner-supplied
    apns-conf.xml configuration file -->
<apns version="6">
<apns version="7">

</apns>
+31 −5
Original line number Diff line number Diff line
@@ -38,12 +38,24 @@ public class ApnSetting {
    public final String numeric;
    public final String protocol;
    public final String roamingProtocol;
    /**
      * Current status of APN
      * true : enabled APN, false : disabled APN.
      */
    public final boolean carrierEnabled;
    /**
      * Radio Access Technology info
      * To check what values can hold, refer to ServiceState.java.
      * This should be spread to other technologies,
      * but currently only used for LTE(14) and EHRPD(13).
      */
    public final int bearer;

    public ApnSetting(int id, String numeric, String carrier, String apn,
            String proxy, String port,
            String mmsc, String mmsProxy, String mmsPort,
            String user, String password, int authType, String[] types,
            String protocol, String roamingProtocol) {
            String protocol, String roamingProtocol, boolean carrierEnabled, int bearer) {
        this.id = id;
        this.numeric = numeric;
        this.carrier = carrier;
@@ -59,6 +71,8 @@ public class ApnSetting {
        this.types = types;
        this.protocol = protocol;
        this.roamingProtocol = roamingProtocol;
        this.carrierEnabled = carrierEnabled;
        this.bearer = bearer;
    }

    /**
@@ -76,8 +90,8 @@ public class ApnSetting {
     *
     * v2 format:
     *   [ApnSettingV2] <carrier>, <apn>, <proxy>, <port>, <mmsc>, <mmsproxy>,
     *   <mmsport>, <user>, <password, <authtype>, <mcc>, <mnc>,
     *   <type>[| <type>...], <protocol>, <roaming_protocol>
     *   <mmsport>, <user>, <password>, <authtype>, <mcc>, <mnc>,
     *   <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearer>
     *
     * Note that the strings generated by toString() do not contain the username
     * and password and thus cannot be read by this method.
@@ -110,22 +124,32 @@ public class ApnSetting {

        String[] typeArray;
        String protocol, roamingProtocol;
        boolean carrierEnabled;
        int bearer;
        if (version == 1) {
            typeArray = new String[a.length - 13];
            System.arraycopy(a, 13, typeArray, 0, a.length - 13);
            protocol = RILConstants.SETUP_DATA_PROTOCOL_IP;
            roamingProtocol = RILConstants.SETUP_DATA_PROTOCOL_IP;
            carrierEnabled = true;
            bearer = 0;
        } else {
            if (a.length < 16) {
            if (a.length < 18) {
                return null;
            }
            typeArray = a[13].split("\\s*\\|\\s*");
            protocol = a[14];
            roamingProtocol = a[15];
            try {
                carrierEnabled = Boolean.parseBoolean(a[16]);
            } catch (Exception e) {
                carrierEnabled = true;
            }
            bearer = Integer.parseInt(a[17]);
        }

        return new ApnSetting(-1,a[10]+a[11],a[0],a[1],a[2],a[3],a[7],a[8],
                a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol);
                a[9],a[4],a[5],authType,typeArray,protocol,roamingProtocol,carrierEnabled,bearer);
    }

    public String toString() {
@@ -149,6 +173,8 @@ public class ApnSetting {
        }
        sb.append(", ").append(protocol);
        sb.append(", ").append(roamingProtocol);
        sb.append(", ").append(carrierEnabled);
        sb.append(", ").append(bearer);
        return sb.toString();
    }

+1 −1
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
            apnId = mDefaultApnId;
        }
        mActiveApn = new ApnSetting(apnId, "", "", "", "", "", "", "", "", "",
                                    "", 0, types, "IP", "IP");
                                    "", 0, types, "IP", "IP", true, 0);
        if (DBG) log("call conn.bringUp mActiveApn=" + mActiveApn);

        Message msg = obtainMessage();
+35 −5
Original line number Diff line number Diff line
@@ -890,7 +890,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                        types,
                        cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)),
                        cursor.getString(cursor.getColumnIndexOrThrow(
                                Telephony.Carriers.ROAMING_PROTOCOL)));
                                Telephony.Carriers.ROAMING_PROTOCOL)),
                        cursor.getInt(cursor.getColumnIndexOrThrow(
                                Telephony.Carriers.CARRIER_ENABLED)) == 1,
                        cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)));
                result.add(apn);
            } while (cursor.moveToNext());
        }
@@ -1985,6 +1988,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        String operator = mPhone.mIccRecords.getOperatorNumeric();
        if (operator != null) {
            String selection = "numeric = '" + operator + "'";
            // query only enabled apn.
            // carrier_enabled : 1 means enabled apn, 0 disabled apn.
            selection += " and carrier_enabled = 1";
            if (DBG) log("createAllApnList: selection=" + selection);

            Cursor cursor = mPhone.getContext().getContentResolver().query(
@@ -2071,6 +2077,18 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }
    }

    /**
     * Check current radio access technology is LTE or EHRPD.
     *
     * @param integer value of radio access technology
     * @return true when current radio access technology is LTE or EHRPD
     * @	   false when current radio access technology is not LTE or EHRPD
     */
    private boolean needToCheckApnBearer(int radioTech) {
        return (radioTech == ServiceState.RADIO_TECHNOLOGY_LTE ||
                radioTech == ServiceState.RADIO_TECHNOLOGY_EHRPD);
    }

    /**
     * Build a list of APNs to be used to create PDP's.
     *
@@ -2091,6 +2109,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }

        String operator = mPhone.mIccRecords.getOperatorNumeric();
        int radioTech = mPhone.getServiceState().getRadioTechnology();
        boolean needToCheckApnBearer = needToCheckApnBearer(radioTech);

        if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
            if (canSetPreferApn && mPreferredApn != null) {
                if (DBG) {
@@ -2098,6 +2119,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                        + mPreferredApn.numeric + ":" + mPreferredApn);
                }
                if (mPreferredApn.numeric.equals(operator)) {
                    if (!needToCheckApnBearer || mPreferredApn.bearer == radioTech) {
                        apnList.add(mPreferredApn);
                        if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
                        return apnList;
@@ -2106,14 +2128,22 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                        setPreferredApn(-1);
                        mPreferredApn = null;
                    }
                } else {
                    if (DBG) log("buildWaitingApns: no preferred APN");
                    setPreferredApn(-1);
                    mPreferredApn = null;
                }
            }
        }
        if (mAllApns != null) {
            for (ApnSetting apn : mAllApns) {
                if (apn.canHandleType(requestedApnType)) {
                    if (!needToCheckApnBearer || apn.bearer == radioTech) {
                        if (DBG) log("apn info : " +apn.toString());
                        apnList.add(apn);
                    }
                }
            }
        } else {
            loge("mAllApns is empty!");
        }
Loading