Android U 网页代码:/ - OpenGrok cross reference for / (aospxref.com)
字段参数介绍
实体对象 ApnSetting
ApnSetting.java - OpenGrok cross reference for /frameworks/base/telephony/java/android/telephony/data/ApnSetting.java (aospxref.com)
An Access Point Name (APN) configuration for a carrier data connection.
一个运营商数据连接的接入点名称(APN)配置。
界面Projection
ApnEditor.java - OpenGrok cross reference for /packages/apps/Settings/src/com/android/settings/network/apn/ApnEditor.java (aospxref.com)
客制化开发举例:sourceType字段标记APN来源(预置、服务器下发或用户添加 )
源码实现:ApnEditor.java - OpenGrok cross reference for /packages/apps/Settings/src/com/android/settings/network/apn/ApnEditor.java (aospxref.com)
private static final int SOURCE_TYPE_INDEX = 26;//自定义新增数据库字段索引号// the source type for apn
public static final int SOURCE_TYPE_DEFAULT = 0; // the default configured by apns-config.xml
public static final int SOURCE_TYPE_USER_EDIT = 1; // from user editingprivate int mSourceType = SOURCE_TYPE_DEFAULT;//初始化默认为预置类型/*** Standard projection for the interesting columns of a normal note.*/
private static final String[] sProjection = new String[] {Telephony.Carriers._ID, // 0Telephony.Carriers.NAME, // 1Telephony.Carriers.APN, // 2Telephony.Carriers.PROXY, // 3Telephony.Carriers.PORT, // 4Telephony.Carriers.USER, // 5Telephony.Carriers.SERVER, // 6Telephony.Carriers.PASSWORD, // 7Telephony.Carriers.MMSC, // 8Telephony.Carriers.MCC, // 9Telephony.Carriers.MNC, // 10Telephony.Carriers.NUMERIC, // 11Telephony.Carriers.MMSPROXY, // 12Telephony.Carriers.MMSPORT, // 13Telephony.Carriers.AUTH_TYPE, // 14Telephony.Carriers.TYPE, // 15Telephony.Carriers.PROTOCOL, // 16Telephony.Carriers.CARRIER_ENABLED, // 17Telephony.Carriers.BEARER, // 18Telephony.Carriers.BEARER_BITMASK, // 19Telephony.Carriers.ROAMING_PROTOCOL, // 20Telephony.Carriers.MVNO_TYPE, // 21Telephony.Carriers.MVNO_MATCH_DATA, // 22Telephony.Carriers.EDITED_STATUS, // 23Telephony.Carriers.USER_EDITABLE, // 24Telephony.Carriers.CARRIER_ID, // 25SOURCE_TYPE //自定义新增字段,MTK inner suppport
};void fillUI(boolean firstTime) {//从数据库更新APN来源类型mSourceType = mApnData.getInteger(SOURCE_TYPE_INDEX);
}
telephony.db字段
开机Android TelephonyProvider会将apns-conf.xml APN配置信息 load到数据库telephony.db名为carrier的表中,可以用SQLite工具可视化。
手机存储目录:data/user_de/0/com.android.providers.telephony,在子文件夹databases
RecNo | FieldName | SQLType | DefaultValue | 备注 |
1 | _id | INTEGER | ||
2 | name | TEXT | '' | 必须 |
3 | numeric | TEXT | '' | =mcc+mnc |
4 | mcc | TEXT | '' | 必须 |
5 | mnc | TEXT | '' | 必须 |
6 | class | TEXT | '' | 运营商需求 |
7 | apn_source | INTEGER | -1 | |
8 | modify_apn_name_id | INTEGER | -1 | |
9 | carrier_id | INTEGER | -1 | |
10 | apn | TEXT | '' | 必须 |
11 | user | TEXT | '' | |
12 | server | TEXT | '' | |
13 | password | TEXT | '' | |
14 | proxy | TEXT | '' | |
15 | port | TEXT | '' | |
16 | mmsproxy | TEXT | '' | |
17 | mmsport | TEXT | '' | |
18 | mmsc | TEXT | '' | |
19 | authtype | INTEGER | -1 | |
20 | type | TEXT | '' | |
21 | current | INTEGER | ||
22 | sourcetype | INTEGER | 0 | |
23 | protocol | TEXT | IP | |
24 | roaming_protocol | TEXT | IP | |
25 | carrier_enabled | BOOLEAN | 1 | |
26 | bearer | INTEGER | 0 | |
27 | bearer_bitmask | INTEGER | 0 | |
28 | network_type_bitmask | INTEGER | 0 | |
29 | lingering_network_type_bitmask | INTEGER | 0 | |
30 | mvno_type | TEXT | '' | |
31 | mvno_match_data | TEXT | '' | |
32 | sub_id | INTEGER | -1 | 指明归属的卡,来源subscription |
33 | profile_id | INTEGER | 0 | |
34 | modem_cognitive | BOOLEAN | 0 | |
35 | max_conns | INTEGER | 0 | |
36 | wait_time | INTEGER | 0 | |
37 | max_conns_time | INTEGER | 0 | |
38 | mtu | INTEGER | 0 | |
39 | mtu_v4 | INTEGER | 0 | |
40 | mtu_v6 | INTEGER | 0 | |
41 | edited | INTEGER | 0 | |
42 | user_visible | BOOLEAN | 1 | |
43 | user_editable | BOOLEAN | 1 | |
44 | owned_by | INTEGER | 1 | APN归属者,0或1,基本都是1. |
45 | apn_set_id | INTEGER | 0 | APN类型集合的id,功能基本都没用到 |
46 | skip_464xlat | INTEGER | -1 | 464xLAT上层有个开关会设置下去给MD,默认是开的。 参考NetworkAgentConfig.java 介绍: Set to skip 464xlat. This means the device will treat the network as IPv6-only and will not attempt to detect a NAT64 via RFC 7050 DNS lookups. |
47 | always_on | INTEGER | 0 |
相关默认值
在MMS模块有定义proxy port默认值是80(在APN没有配置的情况下),代码实现如下:
ApnSettings.java - OpenGrok cross reference for /packages/services/Mms/src/com/android/mms/service/ApnSettings.java (aospxref.com)
private static ApnSettings getApnSettingsFromCursor(Cursor cursor, String requestId)throws ApnException {// Default proxy port to 80int proxyPort = 80;//...if (!TextUtils.isEmpty(proxyAddress)) {proxyAddress = Inet4AddressUtils.trimAddressZeros(proxyAddress);final String portString =trimWithNullCheck(cursor.getString(COLUMN_MMSPORT));if (!TextUtils.isEmpty(portString)) {try {proxyPort = Integer.parseInt(portString);} catch (NumberFormatException e) {LogUtil.e(requestId, "Invalid port " + portString + ", use 80");}}}return new ApnSettings(mmscUrl, proxyAddress, proxyPort, getDebugText(cursor));
}