APN(Access Point Name)是通过手机上网必须配置的一个参数,用来决定手机通过哪种接入方式来访问网络。只要我们的手机插上sim卡之后就可以在手机的设置中查看当前sim卡内置的默认apn参数,一般的安卓智能机都可以在sim卡设置中找到“接入点名称(APN)”并可以查看和新增apn。
在MTK平台APN配置路径为:device/mediatek/common/apns-conf.xml
在MTK平台SPN配置路径为:device/mediatek/common/spn-conf.xml
spn调用路径为:framework/opt/telephony/src/java/com/android/internal/telephony/uicc/SpnOverride.jav
<apn carrier="" mcc="" mnc="" apn="" user="" password=""
proxy="" port="" type="" authtype="" />
其中carrier、apn、mcc、mnc几个字段是一个完整的apn一定要有的,proxy和port两个字段一般情况下上网的apn都会有这两个字段,而其他的字段都是非必须的。
字段名称 | 描述 |
name | APN配置名称 |
numeric | 运营商编号 |
apn | APN接入点,如移动的有:cmwap和cmnet |
proxy | 代理服务器地址 |
Port | 端口号 |
mmsproxy | 彩信代理服务器地址 |
mmsport | 彩信代理服务器端口号 |
Mmsc | 彩信接入服务器地址 |
Type | APN接入类型 |
在启动Android手机或者启动android虚拟设备后,所有的APN配置信息都会保存在telephony.db的SQLite数据库表名为carriers的表中。我们可以将此数据库文件pull到本地,然后可以查看carriers表的结构和其中的APN配置信息数据,命令如下:
adb pull /data/data/com.android.providers.telephony/databases/telephony.db D:/telephony.db
"CREATE TABLE " +CARRIERS_TABLE +
"(_id INTEGER PRIMARY KEY," +"name TEXT," +"numeric TEXT," +
"mcc TEXT,"+ "mnc TEXT," + "apn TEXT," + "user TEXT," +
"serverTEXT," + "password TEXT," + "proxy TEXT," +
"port TEXT," + "mmsproxyTEXT," + "mmsport TEXT," +
"mmscTEXT," + "authtype INTEGER," + "type TEXT," +
"current INTEGER," +"protocol TEXT," + "roaming_protocol TEXT," +
"carrier_enabledBOOLEAN," + "bearer INTEGER," +
"mvno_typeTEXT," + "mvno_match_data TEXT," +
"preferredBOOLEAN DEFAULT 0," + "read_only BOOLEAN DEFAULT 0," +
"ppp_numberTEXT," + "localized_name TEXT," + "v_mccmnc TEXT);"
虽然字段众多但是我们从用途上可以把apn分为发送彩信和上网两种,其中上网的apn又分为wap和net。