Android Data Analyse(3)--APN & ApnSetting & ApnContext
最新推荐文章于 2023-11-22 16:41:42 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
APN
定义:
APN (access point name) 简单的可以理解为数据上网的接入点名称,是访问数据的必须要配置的参数。该参数的配置直接决定了访问数据的接入方式。
参数:
<apn carrier="中国移动 (China Mobile) WAP"
mcc="460"
mnc="00"
apn="cmwap"
proxy="10.0.0.172"
port="80"
type="default,supl"
/>
名称 | 说明 |
---|---|
carrier | 该APN的名称(在手机上可以看到) |
mccmnc | 手机的mccmnc |
apn | 接入点 |
proxy | 代理 |
port | 端口 |
type | 该条apn可以入网的类型 |
配置:
apn 由google定义了一套可供各运营商使用的默认配置,其默认存放位置在device/sample/etc/apns-full-conf.xml里。编译后会copy到system/etc/apns-conf.xml.针对不同的运营商需求,可以在apns-full-conf.xml里更改。
在手机中,apn存在于telephony.db中。具体位置为:content://telephony/carriers
加载:
在device 检测到simcard load完成后,经过一系列的调用:
protected void onRecordsLoadedOrSubIdChanged() {
...
createAllApnList();//从数据库中获取所有符合标准的apn
setInitialAttachApn();//设置初始accach的apn
...
}
/**
* Based on the sim operator numeric, create a list for all possible
* Data Connections and setup the preferredApn.
*/
protected void createAllApnList() {
mMvnoMatched = false;//虚拟运营商相关的,尚未遇到过
mAllApnSettings = new ArrayList<ApnSetting>();
IccRecords r = mIccRecords.get();
String operator = mPhone.getOperatorNumeric();
if (operator != null) {
String selection = "numeric = '" + operator + "'";
02-06
401
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
评论
![](https://csdnimg.cn/release/blogv2/dist/pc/img/closeBt.png)
![](https://csdnimg.cn/release/blogv2/dist/pc/img/closeBt.png)
![](https://csdnimg.cn/release/blogv2/dist/pc/img/commentArrowLeftWhite.png)
![](https://csdnimg.cn/release/blogv2/dist/pc/img/iconPark.png)
查看更多评论
![](https://csdnimg.cn/release/blogv2/dist/pc/img/commentArrowDownWhite.png)
添加红包
![](https://csdnimg.cn/release/blogv2/dist/pc/img/guideRedReward02.png)
![](https://csdnimg.cn/release/blogv2/dist/pc/img/guideRedReward03.png)