Merge "Refactored DataProfile and ApnSetting"
diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java
index be1502a..1ef04be 100644
--- a/telephony/java/android/telephony/data/ApnSetting.java
+++ b/telephony/java/android/telephony/data/ApnSetting.java
@@ -147,7 +147,12 @@
}
// Possible values for authentication types.
- /** No authentication type. */
+ /**
+ * Authentication type is unknown.
+ * @hide
+ */
+ public static final int AUTH_TYPE_UNKNOWN = -1;
+ /** Authentication is not required. */
public static final int AUTH_TYPE_NONE = 0;
/** Authentication type for PAP. */
public static final int AUTH_TYPE_PAP = 1;
@@ -357,6 +362,7 @@
/** @hide */
@IntDef(prefix = { "AUTH_TYPE_" }, value = {
+ AUTH_TYPE_UNKNOWN,
AUTH_TYPE_NONE,
AUTH_TYPE_PAP,
AUTH_TYPE_CHAP,
@@ -498,7 +504,8 @@
private final String mOperatorNumeric;
private final int mProtocol;
private final int mRoamingProtocol;
- private final int mMtu;
+ private final int mMtuV4;
+ private final int mMtuV6;
private final boolean mCarrierEnabled;
@@ -522,13 +529,25 @@
private final int mSkip464Xlat;
/**
- * Returns the MTU size of the mobile interface to which the APN connected.
+ * Returns the MTU size of the IPv4 mobile interface to which the APN connected. Note this value
+ * is used only if MTU size is not provided in {@link DataCallResponse}.
*
* @return the MTU size of the APN
* @hide
*/
- public int getMtu() {
- return mMtu;
+ public int getMtuV4() {
+ return mMtuV4;
+ }
+
+ /**
+ * Returns the MTU size of the IPv6 mobile interface to which the APN connected. Note this value
+ * is used only if MTU size is not provided in {@link DataCallResponse}.
+ *
+ * @return the MTU size of the APN
+ * @hide
+ */
+ public int getMtuV6() {
+ return mMtuV6;
}
/**
@@ -879,13 +898,18 @@
this.mMmsProxyPort = builder.mMmsProxyPort;
this.mUser = builder.mUser;
this.mPassword = builder.mPassword;
- this.mAuthType = builder.mAuthType;
+ this.mAuthType = (builder.mAuthType != AUTH_TYPE_UNKNOWN)
+ ? builder.mAuthType
+ : TextUtils.isEmpty(builder.mUser)
+ ? AUTH_TYPE_NONE
+ : AUTH_TYPE_PAP_OR_CHAP;
this.mApnTypeBitmask = builder.mApnTypeBitmask;
this.mId = builder.mId;
this.mOperatorNumeric = builder.mOperatorNumeric;
this.mProtocol = builder.mProtocol;
this.mRoamingProtocol = builder.mRoamingProtocol;
- this.mMtu = builder.mMtu;
+ this.mMtuV4 = builder.mMtuV4;
+ this.mMtuV6 = builder.mMtuV6;
this.mCarrierEnabled = builder.mCarrierEnabled;
this.mNetworkTypeBitmask = builder.mNetworkTypeBitmask;
this.mProfileId = builder.mProfileId;
@@ -903,66 +927,6 @@
/**
* @hide
*/
- public static ApnSetting makeApnSetting(int id, String operatorNumeric, String entryName,
- String apnName, String proxyAddress, int proxyPort, Uri mmsc,
- String mmsProxyAddress, int mmsProxyPort, String user, String password,
- int authType, int mApnTypeBitmask, int protocol, int roamingProtocol,
- boolean carrierEnabled, int networkTypeBitmask, int profileId,
- boolean modemCognitive, int maxConns, int waitTime, int maxConnsTime, int mtu,
- int mvnoType, String mvnoMatchData, int apnSetId, int carrierId, int skip464xlat) {
- return new Builder()
- .setId(id)
- .setOperatorNumeric(operatorNumeric)
- .setEntryName(entryName)
- .setApnName(apnName)
- .setProxyAddress(proxyAddress)
- .setProxyPort(proxyPort)
- .setMmsc(mmsc)
- .setMmsProxyAddress(mmsProxyAddress)
- .setMmsProxyPort(mmsProxyPort)
- .setUser(user)
- .setPassword(password)
- .setAuthType(authType)
- .setApnTypeBitmask(mApnTypeBitmask)
- .setProtocol(protocol)
- .setRoamingProtocol(roamingProtocol)
- .setCarrierEnabled(carrierEnabled)
- .setNetworkTypeBitmask(networkTypeBitmask)
- .setProfileId(profileId)
- .setModemCognitive(modemCognitive)
- .setMaxConns(maxConns)
- .setWaitTime(waitTime)
- .setMaxConnsTime(maxConnsTime)
- .setMtu(mtu)
- .setMvnoType(mvnoType)
- .setMvnoMatchData(mvnoMatchData)
- .setApnSetId(apnSetId)
- .setCarrierId(carrierId)
- .setSkip464Xlat(skip464xlat)
- .buildWithoutCheck();
- }
-
- /**
- * @hide
- */
- public static ApnSetting makeApnSetting(int id, String operatorNumeric, String entryName,
- String apnName, String proxyAddress, int proxyPort, Uri mmsc,
- String mmsProxyAddress, int mmsProxyPort, String user, String password,
- int authType, int mApnTypeBitmask, int protocol, int roamingProtocol,
- boolean carrierEnabled, int networkTypeBitmask, int profileId, boolean modemCognitive,
- int maxConns, int waitTime, int maxConnsTime, int mtu, int mvnoType,
- String mvnoMatchData) {
- return makeApnSetting(id, operatorNumeric, entryName, apnName, proxyAddress, proxyPort,
- mmsc, mmsProxyAddress, mmsProxyPort, user, password, authType, mApnTypeBitmask,
- protocol, roamingProtocol, carrierEnabled, networkTypeBitmask, profileId,
- modemCognitive, maxConns, waitTime, maxConnsTime, mtu, mvnoType, mvnoMatchData,
- Carriers.NO_APN_SET_ID, TelephonyManager.UNKNOWN_CARRIER_ID,
- Carriers.SKIP_464XLAT_DEFAULT);
- }
-
- /**
- * @hide
- */
public static ApnSetting makeApnSetting(Cursor cursor) {
final int apnTypesBitmask = getApnTypesBitmaskFromString(
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE)));
@@ -975,272 +939,99 @@
ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask);
}
- return makeApnSetting(
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)),
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)),
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NAME)),
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)),
- cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY)),
- portFromString(cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.PORT))),
- UriFromString(cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSC))),
- cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY)),
- portFromString(cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPORT))),
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)),
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)),
- apnTypesBitmask,
- getProtocolIntFromString(
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL))),
- getProtocolIntFromString(
- cursor.getString(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.ROAMING_PROTOCOL))),
- cursor.getInt(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.CARRIER_ENABLED)) == 1,
- networkTypeBitmask,
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROFILE_ID)),
- cursor.getInt(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.MODEM_PERSIST)) == 1,
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MAX_CONNECTIONS)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.WAIT_TIME_RETRY)),
- cursor.getInt(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.TIME_LIMIT_FOR_MAX_CONNECTIONS)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MTU)),
- getMvnoTypeIntFromString(
- cursor.getString(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.MVNO_TYPE))),
- cursor.getString(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.MVNO_MATCH_DATA)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN_SET_ID)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.CARRIER_ID)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Carriers.SKIP_464XLAT)));
+ return new Builder()
+ .setId(cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)))
+ .setOperatorNumeric(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)))
+ .setEntryName(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.NAME)))
+ .setApnName(cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)))
+ .setProxyAddress(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY)))
+ .setProxyPort(portFromString(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.PORT))))
+ .setMmsc(UriFromString(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSC))))
+ .setMmsProxyAddress(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY)))
+ .setMmsProxyPort(portFromString(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPORT))))
+ .setUser(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)))
+ .setPassword(cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)))
+ .setAuthType(cursor.getInt(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)))
+ .setApnTypeBitmask(apnTypesBitmask)
+ .setProtocol(getProtocolIntFromString(
+ cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL))))
+ .setRoamingProtocol(getProtocolIntFromString(
+ cursor.getString(cursor.getColumnIndexOrThrow(
+ Telephony.Carriers.ROAMING_PROTOCOL))))
+ .setCarrierEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
+ Telephony.Carriers.CARRIER_ENABLED)) == 1)
+ .setNetworkTypeBitmask(networkTypeBitmask)
+ .setProfileId(cursor.getInt(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.PROFILE_ID)))
+ .setModemCognitive(cursor.getInt(cursor.getColumnIndexOrThrow(
+ Telephony.Carriers.MODEM_PERSIST)) == 1)
+ .setMaxConns(cursor.getInt(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.MAX_CONNECTIONS)))
+ .setWaitTime(cursor.getInt(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.WAIT_TIME_RETRY)))
+ .setMaxConnsTime(cursor.getInt(cursor.getColumnIndexOrThrow(
+ Telephony.Carriers.TIME_LIMIT_FOR_MAX_CONNECTIONS)))
+ .setMtuV4(cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MTU)))
+ .setMtuV6(UNSET_MTU) // TODO: Add corresponding support in telephony provider
+ .setMvnoType(getMvnoTypeIntFromString(
+ cursor.getString(cursor.getColumnIndexOrThrow(
+ Telephony.Carriers.MVNO_TYPE))))
+ .setMvnoMatchData(cursor.getString(cursor.getColumnIndexOrThrow(
+ Telephony.Carriers.MVNO_MATCH_DATA)))
+ .setApnSetId(cursor.getInt(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.APN_SET_ID)))
+ .setCarrierId(cursor.getInt(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.CARRIER_ID)))
+ .setSkip464Xlat(cursor.getInt(cursor.getColumnIndexOrThrow(Carriers.SKIP_464XLAT)))
+ .buildWithoutCheck();
}
/**
* @hide
*/
public static ApnSetting makeApnSetting(ApnSetting apn) {
- return makeApnSetting(apn.mId, apn.mOperatorNumeric, apn.mEntryName, apn.mApnName,
- apn.mProxyAddress, apn.mProxyPort, apn.mMmsc, apn.mMmsProxyAddress,
- apn.mMmsProxyPort, apn.mUser, apn.mPassword, apn.mAuthType, apn.mApnTypeBitmask,
- apn.mProtocol, apn.mRoamingProtocol, apn.mCarrierEnabled, apn.mNetworkTypeBitmask,
- apn.mProfileId, apn.mPersistent, apn.mMaxConns, apn.mWaitTime,
- apn.mMaxConnsTime, apn.mMtu, apn.mMvnoType, apn.mMvnoMatchData, apn.mApnSetId,
- apn.mCarrierId, apn.mSkip464Xlat);
- }
-
- /**
- * Creates an ApnSetting object from a string.
- *
- * @param data the string to read.
- *
- * The string must be in one of two formats (newlines added for clarity,
- * spaces are optional):
- *
- * v1 format:
- * <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...],
- *
- * v2 format:
- * [ApnSettingV2] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
- *
- * v3 format:
- * [ApnSettingV3] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
- * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
- * <mvnoType>, <mvnoMatchData>
- *
- * v4 format:
- * [ApnSettingV4] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
- * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
- * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask>
- *
- * v5 format:
- * [ApnSettingV5] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
- * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
- * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask>, <apnSetId>
- *
- * v6 format:
- * [ApnSettingV6] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
- * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
- * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask>, <apnSetId>, <carrierId>
- *
- * v7 format:
- * [ApnSettingV7] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
- * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
- * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
- * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
- * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask>, <apnSetId>, <carrierId>, <skip464xlat>
- *
- * Note that the strings generated by {@link #toString()} do not contain the username
- * and password and thus cannot be read by this method.
- *
- * This method may return {@code null} if the input string is invalid.
- *
- * @hide
- */
- public static ApnSetting fromString(String data) {
- if (data == null) return null;
-
- int version;
- // matches() operates on the whole string, so append .* to the regex.
- if (data.matches(V7_FORMAT_REGEX + ".*")) {
- version = 7;
- data = data.replaceFirst(V7_FORMAT_REGEX, "");
- } else if (data.matches(V6_FORMAT_REGEX + ".*")) {
- version = 6;
- data = data.replaceFirst(V6_FORMAT_REGEX, "");
- } else if (data.matches(V5_FORMAT_REGEX + ".*")) {
- version = 5;
- data = data.replaceFirst(V5_FORMAT_REGEX, "");
- } else if (data.matches(V4_FORMAT_REGEX + ".*")) {
- version = 4;
- data = data.replaceFirst(V4_FORMAT_REGEX, "");
- } else if (data.matches(V3_FORMAT_REGEX + ".*")) {
- version = 3;
- data = data.replaceFirst(V3_FORMAT_REGEX, "");
- } else if (data.matches(V2_FORMAT_REGEX + ".*")) {
- version = 2;
- data = data.replaceFirst(V2_FORMAT_REGEX, "");
- } else {
- version = 1;
- }
-
- String[] a = data.split("\\s*,\\s*", -1);
- if (a.length < 14) {
- return null;
- }
-
- int authType;
- try {
- authType = Integer.parseInt(a[12]);
- } catch (NumberFormatException e) {
- authType = 0;
- }
-
- String[] typeArray;
- String protocol, roamingProtocol;
- boolean carrierEnabled;
- int bearerBitmask = 0;
- int networkTypeBitmask = 0;
- int profileId = 0;
- boolean modemCognitive = false;
- int maxConns = 0;
- int waitTime = 0;
- int maxConnsTime = 0;
- int mtu = UNSET_MTU;
- String mvnoType = "";
- String mvnoMatchData = "";
- int apnSetId = Carriers.NO_APN_SET_ID;
- int carrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
- int skip464xlat = Carriers.SKIP_464XLAT_DEFAULT;
- if (version == 1) {
- typeArray = new String[a.length - 13];
- System.arraycopy(a, 13, typeArray, 0, a.length - 13);
- protocol = PROTOCOL_INT_MAP.get(PROTOCOL_IP);
- roamingProtocol = PROTOCOL_INT_MAP.get(PROTOCOL_IP);
- carrierEnabled = true;
- } else {
- if (a.length < 18) {
- return null;
- }
- typeArray = a[13].split("\\s*\\|\\s*");
- protocol = a[14];
- roamingProtocol = a[15];
- carrierEnabled = Boolean.parseBoolean(a[16]);
-
- bearerBitmask = ServiceState.getBitmaskFromString(a[17]);
-
- if (a.length > 22) {
- modemCognitive = Boolean.parseBoolean(a[19]);
- try {
- profileId = Integer.parseInt(a[18]);
- maxConns = Integer.parseInt(a[20]);
- waitTime = Integer.parseInt(a[21]);
- maxConnsTime = Integer.parseInt(a[22]);
- } catch (NumberFormatException e) {
- }
- }
- if (a.length > 23) {
- try {
- mtu = Integer.parseInt(a[23]);
- } catch (NumberFormatException e) {
- }
- }
- if (a.length > 25) {
- mvnoType = a[24];
- mvnoMatchData = a[25];
- }
- if (a.length > 26) {
- networkTypeBitmask = ServiceState.getBitmaskFromString(a[26]);
- }
- if (a.length > 27) {
- apnSetId = Integer.parseInt(a[27]);
- }
- if (a.length > 28) {
- carrierId = Integer.parseInt(a[28]);
- }
- if (a.length > 29) {
- try {
- skip464xlat = Integer.parseInt(a[29]);
- } catch (NumberFormatException e) {
- }
- }
- }
-
- // If both bearerBitmask and networkTypeBitmask were specified, bearerBitmask would be
- // ignored.
- if (networkTypeBitmask == 0) {
- networkTypeBitmask =
- ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask);
- }
- return makeApnSetting(-1, a[10] + a[11], a[0], a[1], a[2],
- portFromString(a[3]), UriFromString(a[7]), a[8],
- portFromString(a[9]), a[4], a[5], authType,
- getApnTypesBitmaskFromString(TextUtils.join(",", typeArray)),
- getProtocolIntFromString(protocol), getProtocolIntFromString(roamingProtocol),
- carrierEnabled, networkTypeBitmask, profileId, modemCognitive, maxConns, waitTime,
- maxConnsTime, mtu, getMvnoTypeIntFromString(mvnoType), mvnoMatchData, apnSetId,
- carrierId, skip464xlat);
- }
-
- /**
- * Creates an array of ApnSetting objects from a string.
- *
- * @param data the string to read.
- *
- * Builds on top of the same format used by fromString, but allows for multiple entries
- * separated by ";".
- *
- * @hide
- */
- public static List<ApnSetting> arrayFromString(String data) {
- List<ApnSetting> retVal = new ArrayList<ApnSetting>();
- if (TextUtils.isEmpty(data)) {
- return retVal;
- }
- String[] apnStrings = data.split("\\s*;\\s*");
- for (String apnString : apnStrings) {
- ApnSetting apn = fromString(apnString);
- if (apn != null) {
- retVal.add(apn);
- }
- }
- return retVal;
+ return new Builder()
+ .setId(apn.mId)
+ .setOperatorNumeric(apn.mOperatorNumeric)
+ .setEntryName(apn.mEntryName)
+ .setApnName(apn.mApnName)
+ .setProxyAddress(apn.mProxyAddress)
+ .setProxyPort(apn.mProxyPort)
+ .setMmsc(apn.mMmsc)
+ .setMmsProxyAddress(apn.mMmsProxyAddress)
+ .setMmsProxyPort(apn.mMmsProxyPort)
+ .setUser(apn.mUser)
+ .setPassword(apn.mPassword)
+ .setAuthType(apn.mAuthType)
+ .setApnTypeBitmask(apn.mApnTypeBitmask)
+ .setProtocol(apn.mProtocol)
+ .setRoamingProtocol(apn.mRoamingProtocol)
+ .setCarrierEnabled(apn.mCarrierEnabled)
+ .setNetworkTypeBitmask(apn.mNetworkTypeBitmask)
+ .setProfileId(apn.mProfileId)
+ .setModemCognitive(apn.mPersistent)
+ .setMaxConns(apn.mMaxConns)
+ .setWaitTime(apn.mWaitTime)
+ .setMaxConnsTime(apn.mMaxConnsTime)
+ .setMtuV4(apn.mMtuV4)
+ .setMtuV6(apn.mMtuV6)
+ .setMvnoType(apn.mMvnoType)
+ .setMvnoMatchData(apn.mMvnoMatchData)
+ .setApnSetId(apn.mApnSetId)
+ .setCarrierId(apn.mCarrierId)
+ .setSkip464Xlat(apn.mSkip464Xlat)
+ .buildWithoutCheck();
}
/**
@@ -1251,7 +1042,7 @@
*/
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("[ApnSettingV7] ")
+ sb.append("[ApnSetting] ")
.append(mEntryName)
.append(", ").append(mId)
.append(", ").append(mOperatorNumeric)
@@ -1272,7 +1063,8 @@
sb.append(", ").append(mMaxConns);
sb.append(", ").append(mWaitTime);
sb.append(", ").append(mMaxConnsTime);
- sb.append(", ").append(mMtu);
+ sb.append(", ").append(mMtuV4);
+ sb.append(", ").append(mMtuV6);
sb.append(", ").append(MVNO_TYPE_INT_MAP.get(mMvnoType));
sb.append(", ").append(mMvnoMatchData);
sb.append(", ").append(mPermanentFailed);
@@ -1343,9 +1135,9 @@
public int hashCode() {
return Objects.hash(mApnName, mProxyAddress, mProxyPort, mMmsc, mMmsProxyAddress,
mMmsProxyPort, mUser, mPassword, mAuthType, mApnTypeBitmask, mId, mOperatorNumeric,
- mProtocol, mRoamingProtocol, mMtu, mCarrierEnabled, mNetworkTypeBitmask, mProfileId,
- mPersistent, mMaxConns, mWaitTime, mMaxConnsTime, mMvnoType, mMvnoMatchData,
- mApnSetId, mCarrierId, mSkip464Xlat);
+ mProtocol, mRoamingProtocol, mMtuV4, mMtuV6, mCarrierEnabled, mNetworkTypeBitmask,
+ mProfileId, mPersistent, mMaxConns, mWaitTime, mMaxConnsTime, mMvnoType,
+ mMvnoMatchData, mApnSetId, mCarrierId, mSkip464Xlat);
}
@Override
@@ -1357,33 +1149,34 @@
ApnSetting other = (ApnSetting) o;
return mEntryName.equals(other.mEntryName)
- && Objects.equals(mId, other.mId)
- && Objects.equals(mOperatorNumeric, other.mOperatorNumeric)
- && Objects.equals(mApnName, other.mApnName)
- && Objects.equals(mProxyAddress, other.mProxyAddress)
- && Objects.equals(mMmsc, other.mMmsc)
- && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress)
- && Objects.equals(mMmsProxyPort, other.mMmsProxyPort)
- && Objects.equals(mProxyPort, other.mProxyPort)
- && Objects.equals(mUser, other.mUser)
- && Objects.equals(mPassword, other.mPassword)
- && Objects.equals(mAuthType, other.mAuthType)
- && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask)
- && Objects.equals(mProtocol, other.mProtocol)
- && Objects.equals(mRoamingProtocol, other.mRoamingProtocol)
- && Objects.equals(mCarrierEnabled, other.mCarrierEnabled)
- && Objects.equals(mProfileId, other.mProfileId)
- && Objects.equals(mPersistent, other.mPersistent)
- && Objects.equals(mMaxConns, other.mMaxConns)
- && Objects.equals(mWaitTime, other.mWaitTime)
- && Objects.equals(mMaxConnsTime, other.mMaxConnsTime)
- && Objects.equals(mMtu, other.mMtu)
- && Objects.equals(mMvnoType, other.mMvnoType)
- && Objects.equals(mMvnoMatchData, other.mMvnoMatchData)
- && Objects.equals(mNetworkTypeBitmask, other.mNetworkTypeBitmask)
- && Objects.equals(mApnSetId, other.mApnSetId)
- && Objects.equals(mCarrierId, other.mCarrierId)
- && Objects.equals(mSkip464Xlat, other.mSkip464Xlat);
+ && Objects.equals(mId, other.mId)
+ && Objects.equals(mOperatorNumeric, other.mOperatorNumeric)
+ && Objects.equals(mApnName, other.mApnName)
+ && Objects.equals(mProxyAddress, other.mProxyAddress)
+ && Objects.equals(mMmsc, other.mMmsc)
+ && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress)
+ && Objects.equals(mMmsProxyPort, other.mMmsProxyPort)
+ && Objects.equals(mProxyPort, other.mProxyPort)
+ && Objects.equals(mUser, other.mUser)
+ && Objects.equals(mPassword, other.mPassword)
+ && Objects.equals(mAuthType, other.mAuthType)
+ && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask)
+ && Objects.equals(mProtocol, other.mProtocol)
+ && Objects.equals(mRoamingProtocol, other.mRoamingProtocol)
+ && Objects.equals(mCarrierEnabled, other.mCarrierEnabled)
+ && Objects.equals(mProfileId, other.mProfileId)
+ && Objects.equals(mPersistent, other.mPersistent)
+ && Objects.equals(mMaxConns, other.mMaxConns)
+ && Objects.equals(mWaitTime, other.mWaitTime)
+ && Objects.equals(mMaxConnsTime, other.mMaxConnsTime)
+ && Objects.equals(mMtuV4, other.mMtuV4)
+ && Objects.equals(mMtuV6, other.mMtuV6)
+ && Objects.equals(mMvnoType, other.mMvnoType)
+ && Objects.equals(mMvnoMatchData, other.mMvnoMatchData)
+ && Objects.equals(mNetworkTypeBitmask, other.mNetworkTypeBitmask)
+ && Objects.equals(mApnSetId, other.mApnSetId)
+ && Objects.equals(mCarrierId, other.mCarrierId)
+ && Objects.equals(mSkip464Xlat, other.mSkip464Xlat);
}
/**
@@ -1406,31 +1199,32 @@
ApnSetting other = (ApnSetting) o;
return mEntryName.equals(other.mEntryName)
- && Objects.equals(mOperatorNumeric, other.mOperatorNumeric)
- && Objects.equals(mApnName, other.mApnName)
- && Objects.equals(mProxyAddress, other.mProxyAddress)
- && Objects.equals(mMmsc, other.mMmsc)
- && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress)
- && Objects.equals(mMmsProxyPort, other.mMmsProxyPort)
- && Objects.equals(mProxyPort, other.mProxyPort)
- && Objects.equals(mUser, other.mUser)
- && Objects.equals(mPassword, other.mPassword)
- && Objects.equals(mAuthType, other.mAuthType)
- && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask)
- && (isDataRoaming || Objects.equals(mProtocol, other.mProtocol))
- && (!isDataRoaming || Objects.equals(mRoamingProtocol, other.mRoamingProtocol))
- && Objects.equals(mCarrierEnabled, other.mCarrierEnabled)
- && Objects.equals(mProfileId, other.mProfileId)
- && Objects.equals(mPersistent, other.mPersistent)
- && Objects.equals(mMaxConns, other.mMaxConns)
- && Objects.equals(mWaitTime, other.mWaitTime)
- && Objects.equals(mMaxConnsTime, other.mMaxConnsTime)
- && Objects.equals(mMtu, other.mMtu)
- && Objects.equals(mMvnoType, other.mMvnoType)
- && Objects.equals(mMvnoMatchData, other.mMvnoMatchData)
- && Objects.equals(mApnSetId, other.mApnSetId)
- && Objects.equals(mCarrierId, other.mCarrierId)
- && Objects.equals(mSkip464Xlat, other.mSkip464Xlat);
+ && Objects.equals(mOperatorNumeric, other.mOperatorNumeric)
+ && Objects.equals(mApnName, other.mApnName)
+ && Objects.equals(mProxyAddress, other.mProxyAddress)
+ && Objects.equals(mMmsc, other.mMmsc)
+ && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress)
+ && Objects.equals(mMmsProxyPort, other.mMmsProxyPort)
+ && Objects.equals(mProxyPort, other.mProxyPort)
+ && Objects.equals(mUser, other.mUser)
+ && Objects.equals(mPassword, other.mPassword)
+ && Objects.equals(mAuthType, other.mAuthType)
+ && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask)
+ && (isDataRoaming || Objects.equals(mProtocol, other.mProtocol))
+ && (!isDataRoaming || Objects.equals(mRoamingProtocol, other.mRoamingProtocol))
+ && Objects.equals(mCarrierEnabled, other.mCarrierEnabled)
+ && Objects.equals(mProfileId, other.mProfileId)
+ && Objects.equals(mPersistent, other.mPersistent)
+ && Objects.equals(mMaxConns, other.mMaxConns)
+ && Objects.equals(mWaitTime, other.mWaitTime)
+ && Objects.equals(mMaxConnsTime, other.mMaxConnsTime)
+ && Objects.equals(mMtuV4, other.mMtuV4)
+ && Objects.equals(mMtuV6, other.mMtuV6)
+ && Objects.equals(mMvnoType, other.mMvnoType)
+ && Objects.equals(mMvnoMatchData, other.mMvnoMatchData)
+ && Objects.equals(mApnSetId, other.mApnSetId)
+ && Objects.equals(mCarrierId, other.mCarrierId)
+ && Objects.equals(mSkip464Xlat, other.mSkip464Xlat);
}
/**
@@ -1732,7 +1526,7 @@
dest.writeString(mApnName);
dest.writeString(mProxyAddress);
dest.writeInt(mProxyPort);
- dest.writeValue(mMmsc);
+ dest.writeParcelable(mMmsc, flags);
dest.writeString(mMmsProxyAddress);
dest.writeInt(mMmsProxyPort);
dest.writeString(mUser);
@@ -1742,40 +1536,53 @@
dest.writeInt(mProtocol);
dest.writeInt(mRoamingProtocol);
dest.writeBoolean(mCarrierEnabled);
- dest.writeInt(mMvnoType);
dest.writeInt(mNetworkTypeBitmask);
+ dest.writeInt(mProfileId);
+ dest.writeBoolean(mPersistent);
+ dest.writeInt(mMaxConns);
+ dest.writeInt(mWaitTime);
+ dest.writeInt(mMaxConnsTime);
+ dest.writeInt(mMtuV4);
+ dest.writeInt(mMtuV6);
+ dest.writeInt(mMvnoType);
+ dest.writeString(mMvnoMatchData);
dest.writeInt(mApnSetId);
dest.writeInt(mCarrierId);
dest.writeInt(mSkip464Xlat);
}
private static ApnSetting readFromParcel(Parcel in) {
- final int id = in.readInt();
- final String operatorNumeric = in.readString();
- final String entryName = in.readString();
- final String apnName = in.readString();
- final String proxy = in.readString();
- final int port = in.readInt();
- final Uri mmsc = (Uri) in.readValue(Uri.class.getClassLoader());
- final String mmsProxy = in.readString();
- final int mmsPort = in.readInt();
- final String user = in.readString();
- final String password = in.readString();
- final int authType = in.readInt();
- final int apnTypesBitmask = in.readInt();
- final int protocol = in.readInt();
- final int roamingProtocol = in.readInt();
- final boolean carrierEnabled = in.readBoolean();
- final int mvnoType = in.readInt();
- final int networkTypeBitmask = in.readInt();
- final int apnSetId = in.readInt();
- final int carrierId = in.readInt();
- final int skip464xlat = in.readInt();
-
- return makeApnSetting(id, operatorNumeric, entryName, apnName,
- proxy, port, mmsc, mmsProxy, mmsPort, user, password, authType, apnTypesBitmask,
- protocol, roamingProtocol, carrierEnabled, networkTypeBitmask, 0, false,
- 0, 0, 0, 0, mvnoType, null, apnSetId, carrierId, skip464xlat);
+ return new Builder()
+ .setId(in.readInt())
+ .setOperatorNumeric(in.readString())
+ .setEntryName(in.readString())
+ .setApnName(in.readString())
+ .setProxyAddress(in.readString())
+ .setProxyPort(in.readInt())
+ .setMmsc(in.readParcelable(Uri.class.getClassLoader()))
+ .setMmsProxyAddress(in.readString())
+ .setMmsProxyPort(in.readInt())
+ .setUser(in.readString())
+ .setPassword(in.readString())
+ .setAuthType(in.readInt())
+ .setApnTypeBitmask(in.readInt())
+ .setProtocol(in.readInt())
+ .setRoamingProtocol(in.readInt())
+ .setCarrierEnabled(in.readBoolean())
+ .setNetworkTypeBitmask(in.readInt())
+ .setProfileId(in.readInt())
+ .setModemCognitive(in.readBoolean())
+ .setMaxConns(in.readInt())
+ .setWaitTime(in.readInt())
+ .setMaxConnsTime(in.readInt())
+ .setMtuV4(in.readInt())
+ .setMtuV6(in.readInt())
+ .setMvnoType(in.readInt())
+ .setMvnoMatchData(in.readString())
+ .setApnSetId(in.readInt())
+ .setCarrierId(in.readInt())
+ .setSkip464Xlat(in.readInt())
+ .buildWithoutCheck();
}
public static final @android.annotation.NonNull Parcelable.Creator<ApnSetting> CREATOR =
@@ -1834,13 +1641,14 @@
private int mMmsProxyPort = UNSPECIFIED_INT;
private String mUser;
private String mPassword;
- private int mAuthType;
+ private int mAuthType = AUTH_TYPE_UNKNOWN;
private int mApnTypeBitmask;
private int mId;
private String mOperatorNumeric;
private int mProtocol = UNSPECIFIED_INT;
private int mRoamingProtocol = UNSPECIFIED_INT;
- private int mMtu;
+ private int mMtuV4;
+ private int mMtuV6;
private int mNetworkTypeBitmask;
private boolean mCarrierEnabled;
private int mProfileId;
@@ -1863,20 +1671,34 @@
* Sets the unique database id for this entry.
*
* @param id the unique database id to set for this entry
+ * @hide
*/
- private Builder setId(int id) {
+ public Builder setId(int id) {
this.mId = id;
return this;
}
/**
- * Set the MTU size of the mobile interface to which the APN connected.
+ * Set the MTU size of the IPv4 mobile interface to which the APN connected. Note this value
+ * is used only if MTU size is not provided in {@link DataCallResponse}.
*
- * @param mtu the MTU size to set for the APN
+ * @param mtuV4 the MTU size to set for the APN
* @hide
*/
- public Builder setMtu(int mtu) {
- this.mMtu = mtu;
+ public Builder setMtuV4(int mtuV4) {
+ this.mMtuV4 = mtuV4;
+ return this;
+ }
+
+ /**
+ * Set the MTU size of the IPv6 mobile interface to which the APN connected. Note this value
+ * is used only if MTU size is not provided in {@link DataCallResponse}.
+ *
+ * @param mtuV6 the MTU size to set for the APN
+ * @hide
+ */
+ public Builder setMtuV6(int mtuV6) {
+ this.mMtuV6 = mtuV6;
return this;
}
@@ -2237,7 +2059,8 @@
| TYPE_FOTA | TYPE_IMS | TYPE_CBS | TYPE_IA | TYPE_EMERGENCY | TYPE_MCX
| TYPE_XCAP | TYPE_VSIM | TYPE_BIP | TYPE_ENTERPRISE)) == 0
|| TextUtils.isEmpty(mApnName) || TextUtils.isEmpty(mEntryName)) {
- return null;
+ throw new IllegalArgumentException("mApName=" + mApnName + ", mEntryName="
+ + mEntryName + ", mApnTypeBitmask=" + mApnTypeBitmask);
}
return new ApnSetting(this);
}
diff --git a/telephony/java/android/telephony/data/DataProfile.java b/telephony/java/android/telephony/data/DataProfile.java
index f2a1249..93903d2 100644
--- a/telephony/java/android/telephony/data/DataProfile.java
+++ b/telephony/java/android/telephony/data/DataProfile.java
@@ -25,13 +25,11 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.Annotation.ApnType;
+import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager.NetworkTypeBitMask;
import android.telephony.data.ApnSetting.AuthType;
import android.text.TextUtils;
-import com.android.internal.telephony.RILConstants;
-import com.android.internal.telephony.util.TelephonyUtils;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -62,152 +60,141 @@
/** 3GPP2 type data profile */
public static final int TYPE_3GPP2 = 2;
- private final int mProfileId;
+ private final @Type int mType;
- private final String mApn;
+ private final @Nullable ApnSetting mApnSetting;
- @ProtocolType
- private final int mProtocolType;
-
- @AuthType
- private final int mAuthType;
-
- private final String mUserName;
-
- private final String mPassword;
-
- @Type
- private final int mType;
-
- private final int mMaxConnectionsTime;
-
- private final int mMaxConnections;
-
- private final int mWaitTime;
-
- private final boolean mEnabled;
-
- @ApnType
- private final int mSupportedApnTypesBitmask;
-
- @ProtocolType
- private final int mRoamingProtocolType;
-
- @NetworkTypeBitMask
- private final int mBearerBitmask;
-
- private final int mMtuV4;
-
- private final int mMtuV6;
-
- private final boolean mPersistent;
+ private final @Nullable TrafficDescriptor mTrafficDescriptor;
private final boolean mPreferred;
- /** @hide */
- private DataProfile(int profileId, String apn, @ProtocolType int protocolType, int authType,
- String userName, String password, int type, int maxConnectionsTime,
- int maxConnections, int waitTime, boolean enabled,
- @ApnType int supportedApnTypesBitmask, @ProtocolType int roamingProtocolType,
- @NetworkTypeBitMask int bearerBitmask, int mtuV4, int mtuV6, boolean persistent,
- boolean preferred) {
- this.mProfileId = profileId;
- this.mApn = apn;
- this.mProtocolType = protocolType;
- if (authType == -1) {
- authType = TextUtils.isEmpty(userName) ? RILConstants.SETUP_DATA_AUTH_NONE
- : RILConstants.SETUP_DATA_AUTH_PAP_CHAP;
+ private DataProfile(@NonNull Builder builder) {
+ mApnSetting = builder.mApnSetting;
+ mTrafficDescriptor = builder.mTrafficDescriptor;
+ mPreferred = builder.mPreferred;
+
+ if (builder.mType != -1) {
+ mType = builder.mType;
+ } else if (mApnSetting != null) {
+ int networkTypes = mApnSetting.getNetworkTypeBitmask();
+
+ if (networkTypes == 0) {
+ mType = DataProfile.TYPE_COMMON;
+ } else if ((networkTypes & TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP2)
+ == networkTypes) {
+ mType = DataProfile.TYPE_3GPP2;
+ } else if ((networkTypes & TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP)
+ == networkTypes) {
+ mType = DataProfile.TYPE_3GPP;
+ } else {
+ mType = DataProfile.TYPE_COMMON;
+ }
+ } else {
+ mType = DataProfile.TYPE_COMMON;
}
- this.mAuthType = authType;
- this.mUserName = userName;
- this.mPassword = password;
- this.mType = type;
- this.mMaxConnectionsTime = maxConnectionsTime;
- this.mMaxConnections = maxConnections;
- this.mWaitTime = waitTime;
- this.mEnabled = enabled;
- this.mSupportedApnTypesBitmask = supportedApnTypesBitmask;
- this.mRoamingProtocolType = roamingProtocolType;
- this.mBearerBitmask = bearerBitmask;
- this.mMtuV4 = mtuV4;
- this.mMtuV6 = mtuV6;
- this.mPersistent = persistent;
- this.mPreferred = preferred;
}
private DataProfile(Parcel source) {
- mProfileId = source.readInt();
- mApn = source.readString();
- mProtocolType = source.readInt();
- mAuthType = source.readInt();
- mUserName = source.readString();
- mPassword = source.readString();
mType = source.readInt();
- mMaxConnectionsTime = source.readInt();
- mMaxConnections = source.readInt();
- mWaitTime = source.readInt();
- mEnabled = source.readBoolean();
- mSupportedApnTypesBitmask = source.readInt();
- mRoamingProtocolType = source.readInt();
- mBearerBitmask = source.readInt();
- mMtuV4 = source.readInt();
- mMtuV6 = source.readInt();
- mPersistent = source.readBoolean();
+ mApnSetting = source.readParcelable(ApnSetting.class.getClassLoader());
+ mTrafficDescriptor = source.readParcelable(TrafficDescriptor.class.getClassLoader());
mPreferred = source.readBoolean();
}
/**
* @return Id of the data profile.
*/
- public int getProfileId() { return mProfileId; }
+ public int getProfileId() {
+ if (mApnSetting != null) {
+ return mApnSetting.getProfileId();
+ }
+ return 0;
+ }
/**
* @return The APN (Access Point Name) to establish data connection. This is a string
* specifically defined by the carrier.
*/
@NonNull
- public String getApn() { return mApn; }
+ public String getApn() {
+ if (mApnSetting != null) {
+ return TextUtils.emptyIfNull(mApnSetting.getApnName());
+ }
+ return "";
+ }
/**
* @return The connection protocol defined in 3GPP TS 27.007 section 10.1.1.
*/
- public @ProtocolType int getProtocolType() { return mProtocolType; }
+ public @ProtocolType int getProtocolType() {
+ if (mApnSetting != null) {
+ return mApnSetting.getProtocol();
+ }
+ return ApnSetting.PROTOCOL_IP;
+ }
/**
* @return The authentication protocol used for this PDP context.
*/
- public @AuthType int getAuthType() { return mAuthType; }
+ public @AuthType int getAuthType() {
+ if (mApnSetting != null) {
+ return mApnSetting.getAuthType();
+ }
+ return ApnSetting.AUTH_TYPE_NONE;
+ }
/**
* @return The username for APN. Can be null.
*/
@Nullable
- public String getUserName() { return mUserName; }
+ public String getUserName() {
+ if (mApnSetting != null) {
+ return mApnSetting.getUser();
+ }
+ return null;
+ }
/**
* @return The password for APN. Can be null.
*/
@Nullable
- public String getPassword() { return mPassword; }
+ public String getPassword() {
+ if (mApnSetting != null) {
+ return mApnSetting.getPassword();
+ }
+ return null;
+ }
/**
* @return The profile type.
*/
- public @Type int getType() { return mType; }
+ public @Type int getType() {
+ return mType;
+ }
/**
* @return The period in seconds to limit the maximum connections.
*
* @hide
*/
- public int getMaxConnectionsTime() { return mMaxConnectionsTime; }
+ public int getMaxConnectionsTime() {
+ if (mApnSetting != null) {
+ return mApnSetting.getMaxConnsTime();
+ }
+ return 0;
+ }
/**
* @return The maximum connections allowed.
*
* @hide
*/
- public int getMaxConnections() { return mMaxConnections; }
+ public int getMaxConnections() {
+ if (mApnSetting != null) {
+ return mApnSetting.getMaxConns();
+ }
+ return 0;
+ }
/**
* @return The required wait time in seconds after a successful UE initiated disconnect of a
@@ -216,57 +203,117 @@
*
* @hide
*/
- public int getWaitTime() { return mWaitTime; }
+ public int getWaitTime() {
+ if (mApnSetting != null) {
+ return mApnSetting.getWaitTime();
+ }
+ return 0;
+ }
/**
* @return True if the profile is enabled.
*/
- public boolean isEnabled() { return mEnabled; }
+ public boolean isEnabled() {
+ if (mApnSetting != null) {
+ return mApnSetting.isEnabled();
+ }
+ return false;
+ }
/**
* @return The supported APN types bitmask.
*/
- public @ApnType int getSupportedApnTypesBitmask() { return mSupportedApnTypesBitmask; }
+ public @ApnType int getSupportedApnTypesBitmask() {
+ if (mApnSetting != null) {
+ return mApnSetting.getApnTypeBitmask();
+ }
+ return ApnSetting.TYPE_NONE;
+ }
/**
* @return The connection protocol on roaming network defined in 3GPP TS 27.007 section 10.1.1.
*/
- public @ProtocolType int getRoamingProtocolType() { return mRoamingProtocolType; }
+ public @ProtocolType int getRoamingProtocolType() {
+ if (mApnSetting != null) {
+ return mApnSetting.getRoamingProtocol();
+ }
+ return ApnSetting.PROTOCOL_IP;
+ }
/**
* @return The bearer bitmask indicating the applicable networks for this data profile.
*/
- public @NetworkTypeBitMask int getBearerBitmask() { return mBearerBitmask; }
+ public @NetworkTypeBitMask int getBearerBitmask() {
+ if (mApnSetting != null) {
+ return mApnSetting.getNetworkTypeBitmask();
+ }
+ return (int) TelephonyManager.NETWORK_TYPE_BITMASK_UNKNOWN;
+ }
/**
* @return The maximum transmission unit (MTU) size in bytes.
* @deprecated use {@link #getMtuV4} or {@link #getMtuV6} instead.
*/
@Deprecated
- public int getMtu() { return mMtuV4; }
+ public int getMtu() {
+ return getMtuV4();
+ }
/**
* This replaces the deprecated method getMtu.
* @return The maximum transmission unit (MTU) size in bytes, for IPv4.
*/
- public int getMtuV4() { return mMtuV4; }
+ public int getMtuV4() {
+ if (mApnSetting != null) {
+ return mApnSetting.getMtuV4();
+ }
+ return 0;
+ }
/**
* @return The maximum transmission unit (MTU) size in bytes, for IPv6.
*/
- public int getMtuV6() { return mMtuV6; }
+ public int getMtuV6() {
+ if (mApnSetting != null) {
+ return mApnSetting.getMtuV6();
+ }
+ return 0;
+ }
/**
* @return {@code true} if modem must persist this data profile.
*/
- public boolean isPersistent() { return mPersistent; }
+ public boolean isPersistent() {
+ if (mApnSetting != null) {
+ return mApnSetting.isPersistent();
+ }
+ return false;
+ }
/**
* @return {@code true} if this data profile was used to bring up the last default
* (i.e internet) data connection successfully, or the one chosen by the user in Settings'
* APN editor. For one carrier there can be only one profiled preferred.
*/
- public boolean isPreferred() { return mPreferred; }
+ public boolean isPreferred() {
+ return mPreferred;
+ }
+
+ /**
+ * @return The APN setting
+ * @hide TODO: Remove before T is released.
+ */
+ public @Nullable ApnSetting getApnSetting() {
+ return mApnSetting;
+ }
+
+ /**
+ * @return The traffic descriptor
+ * @hide TODO: Remove before T is released.
+ */
+ public @Nullable TrafficDescriptor getTrafficDescriptor() {
+ return mTrafficDescriptor;
+ }
@Override
public int describeContents() {
@@ -276,34 +323,15 @@
@NonNull
@Override
public String toString() {
- return "DataProfile=" + mProfileId + "/" + mProtocolType + "/" + mAuthType
- + "/" + (TelephonyUtils.IS_USER ? "***/***/***" :
- (mApn + "/" + mUserName + "/" + mPassword)) + "/" + mType + "/"
- + mMaxConnectionsTime + "/" + mMaxConnections + "/"
- + mWaitTime + "/" + mEnabled + "/" + mSupportedApnTypesBitmask + "/"
- + mRoamingProtocolType + "/" + mBearerBitmask + "/" + mMtuV4 + "/" + mMtuV6 + "/"
- + mPersistent + "/" + mPreferred;
+ return "DataProfile=" + mApnSetting + ", " + mTrafficDescriptor + ", preferred="
+ + mPreferred;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mProfileId);
- dest.writeString(mApn);
- dest.writeInt(mProtocolType);
- dest.writeInt(mAuthType);
- dest.writeString(mUserName);
- dest.writeString(mPassword);
dest.writeInt(mType);
- dest.writeInt(mMaxConnectionsTime);
- dest.writeInt(mMaxConnections);
- dest.writeInt(mWaitTime);
- dest.writeBoolean(mEnabled);
- dest.writeInt(mSupportedApnTypesBitmask);
- dest.writeInt(mRoamingProtocolType);
- dest.writeInt(mBearerBitmask);
- dest.writeInt(mMtuV4);
- dest.writeInt(mMtuV6);
- dest.writeBoolean(mPersistent);
+ dest.writeParcelable(mApnSetting, flags);
+ dest.writeParcelable(mTrafficDescriptor, flags);
dest.writeBoolean(mPreferred);
}
@@ -321,36 +349,18 @@
};
@Override
- public boolean equals(@Nullable Object o) {
+ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DataProfile that = (DataProfile) o;
- return mProfileId == that.mProfileId
- && mProtocolType == that.mProtocolType
- && mAuthType == that.mAuthType
- && mType == that.mType
- && mMaxConnectionsTime == that.mMaxConnectionsTime
- && mMaxConnections == that.mMaxConnections
- && mWaitTime == that.mWaitTime
- && mEnabled == that.mEnabled
- && mSupportedApnTypesBitmask == that.mSupportedApnTypesBitmask
- && mRoamingProtocolType == that.mRoamingProtocolType
- && mBearerBitmask == that.mBearerBitmask
- && mMtuV4 == that.mMtuV4
- && mMtuV6 == that.mMtuV6
- && mPersistent == that.mPersistent
- && mPreferred == that.mPreferred
- && Objects.equals(mApn, that.mApn)
- && Objects.equals(mUserName, that.mUserName)
- && Objects.equals(mPassword, that.mPassword);
+ return mType == that.mType
+ && Objects.equals(mApnSetting, that.mApnSetting)
+ && Objects.equals(mTrafficDescriptor, that.mTrafficDescriptor);
}
@Override
public int hashCode() {
- return Objects.hash(mProfileId, mApn, mProtocolType, mAuthType, mUserName, mPassword, mType,
- mMaxConnectionsTime, mMaxConnections, mWaitTime, mEnabled,
- mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtuV4, mMtuV6,
- mPersistent, mPreferred);
+ return Objects.hash(mType, mApnSetting, mTrafficDescriptor);
}
/**
@@ -383,13 +393,7 @@
private String mPassword;
@Type
- private int mType;
-
- private int mMaxConnectionsTime;
-
- private int mMaxConnections;
-
- private int mWaitTime;
+ private int mType = -1;
private boolean mEnabled;
@@ -410,6 +414,10 @@
private boolean mPreferred;
+ private ApnSetting mApnSetting;
+
+ private TrafficDescriptor mTrafficDescriptor;
+
/**
* Default constructor for Builder.
*/
@@ -496,48 +504,6 @@
}
/**
- * Set the period in seconds to limit the maximum connections.
- *
- * @param maxConnectionsTime The profile type
- * @return The same instance of the builder.
- *
- * @hide
- */
- public @NonNull Builder setMaxConnectionsTime(int maxConnectionsTime) {
- mMaxConnectionsTime = maxConnectionsTime;
- return this;
- }
-
- /**
- * Set the maximum connections allowed.
- *
- * @param maxConnections The maximum connections allowed.
- * @return The same instance of the builder.
- *
- * @hide
- */
- public @NonNull Builder setMaxConnections(int maxConnections) {
- mMaxConnections = maxConnections;
- return this;
- }
-
- /**
- * Set the period in seconds to limit the maximum connections.
- *
- * @param waitTime The required wait time in seconds after a successful UE initiated
- * disconnect of a given PDN connection before the device can send a new PDN connection
- * request for that given PDN.
- *
- * @return The same instance of the builder.
- *
- * @hide
- */
- public @NonNull Builder setWaitTime(int waitTime) {
- mWaitTime = waitTime;
- return this;
- }
-
- /**
* Enable the data profile
*
* @param isEnabled {@code true} to enable the data profile, otherwise disable.
@@ -587,8 +553,9 @@
*
* @param mtu The maximum transmission unit (MTU) size in bytes.
* @return The same instance of the builder.
- * @deprecated use {@link #setMtuV4} or {@link #setMtuV6} instead.
+ * @deprecated use {@link #setApnSetting(ApnSetting)} instead.
*/
+ @Deprecated
public @NonNull Builder setMtu(int mtu) {
mMtuV4 = mMtuV6 = mtu;
return this;
@@ -631,7 +598,7 @@
}
/**
- * Set data profile as persistent/non-persistent
+ * Set data profile as persistent/non-persistent.
*
* @param isPersistent {@code true} if this data profile was used to bring up the last
* default (i.e internet) data connection successfully.
@@ -643,15 +610,63 @@
}
/**
+ * Set APN setting.
+ *
+ * @param apnSetting APN setting
+ * @return The same instance of the builder
+ *
+ * @hide // TODO: Remove before T is released.
+ */
+ public @NonNull Builder setApnSetting(@NonNull ApnSetting apnSetting) {
+ mApnSetting = apnSetting;
+ return this;
+ }
+
+ /**
+ * Set traffic descriptor.
+ *
+ * @param trafficDescriptor Traffic descriptor
+ * @return The same instance of the builder
+ *
+ * @hide // TODO: Remove before T is released.
+ */
+ public @NonNull Builder setTrafficDescriptor(@NonNull TrafficDescriptor trafficDescriptor) {
+ mTrafficDescriptor = trafficDescriptor;
+ return this;
+ }
+
+ /**
* Build the DataProfile object
*
* @return The data profile object
*/
public @NonNull DataProfile build() {
- return new DataProfile(mProfileId, mApn, mProtocolType, mAuthType, mUserName, mPassword,
- mType, mMaxConnectionsTime, mMaxConnections, mWaitTime, mEnabled,
- mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtuV4, mMtuV6,
- mPersistent, mPreferred);
+ if (mApnSetting == null && mApn != null) {
+ // This is for backwards compatibility.
+ mApnSetting = new ApnSetting.Builder()
+ .setEntryName(mApn)
+ .setApnName(mApn)
+ .setApnTypeBitmask(mSupportedApnTypesBitmask)
+ .setAuthType(mAuthType)
+ .setCarrierEnabled(mEnabled)
+ .setModemCognitive(mPersistent)
+ .setMtuV4(mMtuV4)
+ .setMtuV6(mMtuV6)
+ .setNetworkTypeBitmask(mBearerBitmask)
+ .setProfileId(mProfileId)
+ .setPassword(mPassword)
+ .setProtocol(mProtocolType)
+ .setRoamingProtocol(mRoamingProtocolType)
+ .setUser(mUserName)
+ .build();
+ }
+
+ if (mApnSetting == null && mTrafficDescriptor == null) {
+ throw new IllegalArgumentException("APN setting and traffic descriptor can't be "
+ + "both null.");
+ }
+
+ return new DataProfile(this);
}
}
}