Android Data Analyse(3)--APN & ApnSetting & ApnContext

APN定义: APN (access point name) 简单的可以理解为数据上网的接入点名称,是访问数据的必须要配置的参数。该参数的配置直接决定了访问数据的接入方式。参数:

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 + "'";
         
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值