/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.telephony.data; import android.annotation.IntDef; import android.annotation.NonNull; import android.content.ContentValues; import android.database.Cursor; import android.hardware.radio.V1_0.ApnTypes; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.provider.Telephony; import android.provider.Telephony.Carriers; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; /** * An Access Point Name (APN) configuration for a carrier data connection. * *
The APN provides configuration to connect a cellular network device to an IP data network. A * carrier uses the name, type and other configuration in an {@code APNSetting} to decide which IP * address to assign, any security methods to apply, and how the device might be connected to * private networks. * *
Use {@link ApnSetting.Builder} to create new instances.
*/
public class ApnSetting implements Parcelable {
private static final String LOG_TAG = "ApnSetting";
private static final boolean VDBG = false;
private static final String V2_FORMAT_REGEX = "^\\[ApnSettingV2\\]\\s*";
private static final String V3_FORMAT_REGEX = "^\\[ApnSettingV3\\]\\s*";
private static final String V4_FORMAT_REGEX = "^\\[ApnSettingV4\\]\\s*";
private static final String V5_FORMAT_REGEX = "^\\[ApnSettingV5\\]\\s*";
/**
* Default value for mtu if it's not set. Moved from PhoneConstants.
* @hide
*/
public static final int UNSET_MTU = 0;
private static final int UNSPECIFIED_INT = -1;
private static final String UNSPECIFIED_STRING = "";
/**
* APN type for none. Should only be used for initialization.
* @hide
*/
public static final int TYPE_NONE = ApnTypes.NONE;
/**
* APN type for all APNs.
* @hide
*/
public static final int TYPE_ALL = ApnTypes.ALL;
/** APN type for default data traffic. */
public static final int TYPE_DEFAULT = ApnTypes.DEFAULT;
/** APN type for MMS traffic. */
public static final int TYPE_MMS = ApnTypes.MMS;
/** APN type for SUPL assisted GPS. */
public static final int TYPE_SUPL = ApnTypes.SUPL;
/** APN type for DUN traffic. */
public static final int TYPE_DUN = ApnTypes.DUN;
/** APN type for HiPri traffic. */
public static final int TYPE_HIPRI = ApnTypes.HIPRI;
/** APN type for accessing the carrier's FOTA portal, used for over the air updates. */
public static final int TYPE_FOTA = ApnTypes.FOTA;
/** APN type for IMS. */
public static final int TYPE_IMS = ApnTypes.IMS;
/** APN type for CBS. */
public static final int TYPE_CBS = ApnTypes.CBS;
/** APN type for IA Initial Attach APN. */
public static final int TYPE_IA = ApnTypes.IA;
/**
* APN type for Emergency PDN. This is not an IA apn, but is used
* for access to carrier services in an emergency call situation.
*/
public static final int TYPE_EMERGENCY = ApnTypes.EMERGENCY;
/** @hide */
@IntDef(flag = true, prefix = { "TYPE_" }, value = {
TYPE_DEFAULT,
TYPE_MMS,
TYPE_SUPL,
TYPE_DUN,
TYPE_HIPRI,
TYPE_FOTA,
TYPE_IMS,
TYPE_CBS,
TYPE_IA,
TYPE_EMERGENCY
})
@Retention(RetentionPolicy.SOURCE)
public @interface ApnType {}
// Possible values for authentication types.
/** No authentication type. */
public static final int AUTH_TYPE_NONE = 0;
/** Authentication type for PAP. */
public static final int AUTH_TYPE_PAP = 1;
/** Authentication type for CHAP. */
public static final int AUTH_TYPE_CHAP = 2;
/** Authentication type for PAP or CHAP. */
public static final int AUTH_TYPE_PAP_OR_CHAP = 3;
/** @hide */
@IntDef(prefix = { "AUTH_TYPE_" }, value = {
AUTH_TYPE_NONE,
AUTH_TYPE_PAP,
AUTH_TYPE_CHAP,
AUTH_TYPE_PAP_OR_CHAP,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AuthType {}
// Possible values for protocol.
/** Protocol type for IP. */
public static final int PROTOCOL_IP = 0;
/** Protocol type for IPV6. */
public static final int PROTOCOL_IPV6 = 1;
/** Protocol type for IPV4V6. */
public static final int PROTOCOL_IPV4V6 = 2;
/** Protocol type for PPP. */
public static final int PROTOCOL_PPP = 3;
/** @hide */
@IntDef(prefix = { "PROTOCOL_" }, value = {
PROTOCOL_IP,
PROTOCOL_IPV6,
PROTOCOL_IPV4V6,
PROTOCOL_PPP,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ProtocolType {}
// Possible values for MVNO type.
/** MVNO type for service provider name. */
public static final int MVNO_TYPE_SPN = 0;
/** MVNO type for IMSI. */
public static final int MVNO_TYPE_IMSI = 1;
/** MVNO type for group identifier level 1. */
public static final int MVNO_TYPE_GID = 2;
/** MVNO type for ICCID. */
public static final int MVNO_TYPE_ICCID = 3;
/** @hide */
@IntDef(prefix = { "MVNO_TYPE_" }, value = {
MVNO_TYPE_SPN,
MVNO_TYPE_IMSI,
MVNO_TYPE_GID,
MVNO_TYPE_ICCID,
})
@Retention(RetentionPolicy.SOURCE)
public @interface MvnoType {}
private static final Map Apn types are usage categories for an APN entry. One APN entry may support multiple
* APN types, eg, a single APN may service regular internet traffic ("default") as well as
* MMS-specific connections.
*
* The bitmask of APN types is calculated from APN types defined in {@link ApnSetting}.
*
* @see Builder#setApnTypeBitmask(int)
* @return a bitmask describing the types of the APN
*/
public @ApnType int getApnTypeBitmask() {
return mApnTypeBitmask;
}
/**
* Returns the unique database id for this entry.
*
* @return the unique database id
*/
public int getId() {
return mId;
}
/**
* Returns the numeric operator ID for the APN. Numeric operator ID is defined as
* {@link android.provider.Telephony.Carriers#MCC} +
* {@link android.provider.Telephony.Carriers#MNC}.
*
* @return the numeric operator ID
*/
public String getOperatorNumeric() {
return mOperatorNumeric;
}
/**
* Returns the protocol to use to connect to this APN.
*
* Protocol is one of the {@code PDP_type} values in TS 27.007 section 10.1.1.
*
* @see Builder#setProtocol(int)
* @return the protocol
*/
@ProtocolType
public int getProtocol() {
return mProtocol;
}
/**
* Returns the protocol to use to connect to this APN while the device is roaming.
*
* Roaming protocol is one of the {@code PDP_type} values in TS 27.007 section 10.1.1.
*
* @see Builder#setRoamingProtocol(int)
* @return the roaming protocol
*/
@ProtocolType
public int getRoamingProtocol() {
return mRoamingProtocol;
}
/**
* Returns the current status of APN.
*
* {@code true} : enabled APN.
* {@code false} : disabled APN.
*
* @return the current status
*/
public boolean isEnabled() {
return mCarrierEnabled;
}
/**
* Returns a bitmask describing the Radio Technologies(Network Types) which this APN may use.
*
* NetworkType bitmask is calculated from NETWORK_TYPE defined in {@link TelephonyManager}.
*
* Examples of Network Types include {@link TelephonyManager#NETWORK_TYPE_UNKNOWN},
* {@link TelephonyManager#NETWORK_TYPE_GPRS}, {@link TelephonyManager#NETWORK_TYPE_EDGE}.
*
* @return a bitmask describing the Radio Technologies(Network Types)
*/
public int getNetworkTypeBitmask() {
return mNetworkTypeBitmask;
}
/**
* Returns the MVNO match type for this APN.
*
* @see Builder#setMvnoType(int)
* @return the MVNO match type
*/
@MvnoType
public int getMvnoType() {
return mMvnoType;
}
private ApnSetting(Builder builder) {
this.mEntryName = builder.mEntryName;
this.mApnName = builder.mApnName;
this.mProxyAddress = builder.mProxyAddress;
this.mProxyPort = builder.mProxyPort;
this.mMmsc = builder.mMmsc;
this.mMmsProxyAddress = builder.mMmsProxyAddress;
this.mMmsProxyPort = builder.mMmsProxyPort;
this.mUser = builder.mUser;
this.mPassword = builder.mPassword;
this.mAuthType = builder.mAuthType;
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.mCarrierEnabled = builder.mCarrierEnabled;
this.mNetworkTypeBitmask = builder.mNetworkTypeBitmask;
this.mProfileId = builder.mProfileId;
this.mPersistent = builder.mModemCognitive;
this.mMaxConns = builder.mMaxConns;
this.mWaitTime = builder.mWaitTime;
this.mMaxConnsTime = builder.mMaxConnsTime;
this.mMvnoType = builder.mMvnoType;
this.mMvnoMatchData = builder.mMvnoMatchData;
this.mApnSetId = builder.mApnSetId;
}
/** @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) {
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)
.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_SET_SET);
}
/** @hide */
public static ApnSetting makeApnSetting(Cursor cursor) {
final int apnTypesBitmask = getApnTypesBitmaskFromString(
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE)));
int networkTypeBitmask = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.Carriers.NETWORK_TYPE_BITMASK));
if (networkTypeBitmask == 0) {
final int bearerBitmask = cursor.getInt(cursor.getColumnIndexOrThrow(
Telephony.Carriers.BEARER_BITMASK));
networkTypeBitmask =
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_COGNITIVE)) == 1,
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MAX_CONNS)),
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.WAIT_TIME)),
cursor.getInt(cursor.getColumnIndexOrThrow(
Telephony.Carriers.MAX_CONNS_TIME)),
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)));
}
/** @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);
}
/**
* 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:
* The example below shows how you might create a new {@code ApnSetting}:
*
* The {@link java.net.InetAddress} methods
* {@link java.net.InetAddress#getAllByName getAllByName()} require DNS for hostname
* resolution. To avoid this requirement when setting a hostname, call
* {@link java.net.InetAddress#getByAddress(java.lang.String, byte[])} with both the
* hostname and a dummy IP address. See {@link ApnSetting.Builder above} for an example.
*
* @param proxy the proxy address to set for the APN
* @deprecated use {@link #setProxyAddress(String)} instead.
*/
@Deprecated
public Builder setProxyAddress(InetAddress proxy) {
this.mProxyAddress = inetAddressToString(proxy);
return this;
}
/**
* Sets the proxy address of the APN.
*
* @param proxy the proxy address to set for the APN
*/
public Builder setProxyAddress(String proxy) {
this.mProxyAddress = proxy;
return this;
}
/**
* Sets the proxy port of the APN.
*
* @param port the proxy port to set for the APN
*/
public Builder setProxyPort(int port) {
this.mProxyPort = port;
return this;
}
/**
* Sets the MMSC Uri of the APN.
*
* @param mmsc the MMSC Uri to set for the APN
*/
public Builder setMmsc(Uri mmsc) {
this.mMmsc = mmsc;
return this;
}
/**
* Sets the address of an MMS proxy for the APN. The MMS proxy address can be an IP address
* or hostname. If {@code mmsProxy} contains both an IP address and hostname, this method
* ignores the IP address.
*
* The {@link java.net.InetAddress} methods
* {@link java.net.InetAddress#getByName getByName()} and
* {@link java.net.InetAddress#getAllByName getAllByName()} require DNS for hostname
* resolution. To avoid this requirement when setting a hostname, call
* {@link java.net.InetAddress#getByAddress(java.lang.String, byte[])} with both the
* hostname and a dummy IP address. See {@link ApnSetting.Builder above} for an example.
*
* @param mmsProxy the MMS proxy address to set for the APN
* @deprecated use {@link #setMmsProxyAddress(String)} instead.
*/
@Deprecated
public Builder setMmsProxyAddress(InetAddress mmsProxy) {
this.mMmsProxyAddress = inetAddressToString(mmsProxy);
return this;
}
/**
* Sets the MMS proxy address of the APN.
*
* @param mmsProxy the MMS proxy address to set for the APN
*/
public Builder setMmsProxyAddress(String mmsProxy) {
this.mMmsProxyAddress = mmsProxy;
return this;
}
/**
* Sets the MMS proxy port of the APN.
*
* @param mmsPort the MMS proxy port to set for the APN
*/
public Builder setMmsProxyPort(int mmsPort) {
this.mMmsProxyPort = mmsPort;
return this;
}
/**
* Sets the APN username of the APN.
*
* @param user the APN username to set for the APN
*/
public Builder setUser(String user) {
this.mUser = user;
return this;
}
/**
* Sets the APN password of the APN.
*
* @see android.provider.Telephony.Carriers#PASSWORD
* @param password the APN password to set for the APN
*/
public Builder setPassword(String password) {
this.mPassword = password;
return this;
}
/**
* Sets the authentication type of the APN.
*
* @param authType the authentication type to set for the APN
*/
public Builder setAuthType(@AuthType int authType) {
this.mAuthType = authType;
return this;
}
/**
* Sets the bitmask of APN types.
*
* Apn types are usage categories for an APN entry. One APN entry may support multiple
* APN types, eg, a single APN may service regular internet traffic ("default") as well as
* MMS-specific connections.
*
* The bitmask of APN types is calculated from APN types defined in {@link ApnSetting}.
*
* @param apnTypeBitmask a bitmask describing the types of the APN
*/
public Builder setApnTypeBitmask(@ApnType int apnTypeBitmask) {
this.mApnTypeBitmask = apnTypeBitmask;
return this;
}
/**
* Sets the numeric operator ID for the APN. Numeric operator ID is defined as
* {@link android.provider.Telephony.Carriers#MCC} +
* {@link android.provider.Telephony.Carriers#MNC}.
*
* @param operatorNumeric the numeric operator ID to set for this entry
*/
public Builder setOperatorNumeric(String operatorNumeric) {
this.mOperatorNumeric = operatorNumeric;
return this;
}
/**
* Sets the protocol to use to connect to this APN.
*
* Protocol is one of the {@code PDP_type} values in TS 27.007 section 10.1.1.
*
* @param protocol the protocol to set to use to connect to this APN
*/
public Builder setProtocol(@ProtocolType int protocol) {
this.mProtocol = protocol;
return this;
}
/**
* Sets the protocol to use to connect to this APN when the device is roaming.
*
* Roaming protocol is one of the {@code PDP_type} values in TS 27.007 section 10.1.1.
*
* @param roamingProtocol the protocol to set to use to connect to this APN when roaming
*/
public Builder setRoamingProtocol(@ProtocolType int roamingProtocol) {
this.mRoamingProtocol = roamingProtocol;
return this;
}
/**
* Sets the current status for this APN.
*
* @param carrierEnabled the current status to set for this APN
*/
public Builder setCarrierEnabled(boolean carrierEnabled) {
this.mCarrierEnabled = carrierEnabled;
return this;
}
/**
* Sets Radio Technology (Network Type) info for this APN.
*
* @param networkTypeBitmask the Radio Technology (Network Type) info
*/
public Builder setNetworkTypeBitmask(int networkTypeBitmask) {
this.mNetworkTypeBitmask = networkTypeBitmask;
return this;
}
/**
* Sets the MVNO match type for this APN.
*
* @param mvnoType the MVNO match type to set for this APN
*/
public Builder setMvnoType(@MvnoType int mvnoType) {
this.mMvnoType = mvnoType;
return this;
}
/**
* Builds {@link ApnSetting} from this builder.
*
* @return {@code null} if {@link #setApnName(String)} or {@link #setEntryName(String)}
* is empty, or {@link #setApnTypeBitmask(int)} doesn't contain a valid bit,
* {@link ApnSetting} built from this builder otherwise.
*/
public ApnSetting build() {
if ((mApnTypeBitmask & ApnTypes.ALL) == 0 || TextUtils.isEmpty(mApnName)
|| TextUtils.isEmpty(mEntryName)) {
return null;
}
return new ApnSetting(this);
}
/**
* Builds {@link ApnSetting} from this builder. This function doesn't check if
* {@link #setApnName(String)} or {@link #setEntryName(String)}, or
* {@link #setApnTypeBitmask(int)} is empty.
* @hide
*/
public ApnSetting buildWithoutCheck() {
return new ApnSetting(this);
}
}
}
*
*
*/
public static class Builder{
private String mEntryName;
private String mApnName;
private String mProxyAddress;
private int mProxyPort = UNSPECIFIED_INT;
private Uri mMmsc;
private String mMmsProxyAddress;
private int mMmsProxyPort = UNSPECIFIED_INT;
private String mUser;
private String mPassword;
private int mAuthType;
private int mApnTypeBitmask;
private int mId;
private String mOperatorNumeric;
private int mProtocol = UNSPECIFIED_INT;
private int mRoamingProtocol = UNSPECIFIED_INT;
private int mMtu;
private int mNetworkTypeBitmask;
private boolean mCarrierEnabled;
private int mProfileId;
private boolean mModemCognitive;
private int mMaxConns;
private int mWaitTime;
private int mMaxConnsTime;
private int mMvnoType = UNSPECIFIED_INT;
private String mMvnoMatchData;
private int mApnSetId;
/**
* Default constructor for Builder.
*/
public Builder() {}
/**
* Sets the unique database id for this entry.
*
* @param id the unique database id to set for this entry
*/
private Builder setId(int id) {
this.mId = id;
return this;
}
/**
* Set the MTU size of the mobile interface to which the APN connected.
*
* @param mtu the MTU size to set for the APN
* @hide
*/
public Builder setMtu(int mtu) {
this.mMtu = mtu;
return this;
}
/**
* Sets the profile id to which the APN saved in modem.
*
* @param profileId the profile id to set for the APN
* @hide
*/
public Builder setProfileId(int profileId) {
this.mProfileId = profileId;
return this;
}
/**
* Sets if the APN setting is to be set in modem.
*
* @param modemCognitive if the APN setting is to be set in modem
* @hide
*/
public Builder setModemCognitive(boolean modemCognitive) {
this.mModemCognitive = modemCognitive;
return this;
}
/**
* Sets the max connections of this APN.
*
* @param maxConns the max connections of this APN
* @hide
*/
public Builder setMaxConns(int maxConns) {
this.mMaxConns = maxConns;
return this;
}
/**
* Sets the wait time for retry of the APN.
*
* @param waitTime the wait time for retry of the APN
* @hide
*/
public Builder setWaitTime(int waitTime) {
this.mWaitTime = waitTime;
return this;
}
/**
* Sets the time to limit max connection for the APN.
*
* @param maxConnsTime the time to limit max connection for the APN
* @hide
*/
public Builder setMaxConnsTime(int maxConnsTime) {
this.mMaxConnsTime = maxConnsTime;
return this;
}
/**
* Sets the MVNO match data for the APN.
*
* @param mvnoMatchData the MVNO match data for the APN
* @hide
*/
public Builder setMvnoMatchData(String mvnoMatchData) {
this.mMvnoMatchData = mvnoMatchData;
return this;
}
/**
* Sets the APN set id for the APN.
*
* @param apnSetId the set id for the APN
* @hide
*/
public Builder setApnSetId(int apnSetId) {
this.mApnSetId = apnSetId;
return this;
}
/**
* Sets a human-readable name that describes the APN.
*
* @param entryName the entry name to set for the APN
*/
public Builder setEntryName(String entryName) {
this.mEntryName = entryName;
return this;
}
/**
* Sets the name of the APN.
*
* @param apnName the name to set for the APN
*/
public Builder setApnName(String apnName) {
this.mApnName = apnName;
return this;
}
/**
* Sets the address of an HTTP proxy for the APN. The proxy address can be an IP address or
* hostname. If {@code proxy} contains both an IP address and hostname, this method ignores
* the IP address.
*
*
* // Create an MMS proxy address with a hostname. A network might not be
* // available, so supply a dummy (0.0.0.0) IPv4 address to avoid DNS lookup.
* String host = "mms.example.com";
* byte[] ipAddress = new byte[4];
* InetAddress mmsProxy;
* try {
* mmsProxy = InetAddress.getByAddress(host, ipAddress);
* } catch (UnknownHostException e) {
* e.printStackTrace();
* return;
* }
*
* ApnSetting apn = new ApnSetting.Builder()
* .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS)
* .setApnName("apn.example.com")
* .setEntryName("Example Carrier APN")
* .setMmsc(Uri.parse("http://mms.example.com:8002"))
* .setMmsProxyAddress(mmsProxy)
* .setMmsProxyPort(8799)
* .build();
*