(M)SIM卡开机流程分析之默认APN设置

本文深入探讨SIM卡开机过程,聚焦于默认APN的设置步骤。从PhoneFactory.java的makeDefaultPhone方法出发,揭示了初始化过程中如何配置网络连接的关键细节。
摘要由CSDN通过智能技术生成
近日,一直在研究,默认APN的设置
当我们从代码和手机中看到,默认APN的显示是从content://telephony/carriers/preferapn的数据中查询到的,而这个是通过shared preference来保存的,当手机第一次插卡开机后,我们将preferapn.xml文件导出来后,我们发现其中已经写有值了,但是从TelephonyProvider.Java文件中,我们却没有发现任何写入的地方,那么这个默认APN究竟是如何写入和设定的呢?
结合LOG查看了插卡开机流程多日后,终于找到了其写入的位置,仅以此篇记录近期的成果。

首先,SIM卡的开机流程中,我们知道,是从PhoneFactory.java文件的makeDefaultPhone方法中开始的,而在其中,我们可以看到如下段

for (int i = 0; i < numPhones; i++) {  
        PhoneBase phone = null;  
        int phoneType = TelephonyManager.getPhoneType(networkModes[i]);  
        if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {  
            phone = new GSMPhone(context,  
                    sCommandsInterfaces[i], sPhoneNotifier, i);  
        } else if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {  
            phone = new CDMALTEPhone(context,  
                    sCommandsInterfaces[i], sPhoneNotifier, i);  
        }  
        Rlog.i(LOG_TAG, "Creating Phone with type = " + phoneType + " sub = " + i);  
      
        sProxyPhones[i] = new PhoneProxy(phone);  
    }
创建Phone对象,今天我们就以GSMPhone对象来分析这个默认APN的流程

public  
    GSMPhone(Context context, CommandsInterface ci, PhoneNotifier notifier, int phoneId) {  
        this(context, ci, notifier, false, phoneId);  
}
public  
    GSMPhone(Context context, CommandsInterface ci,  
            PhoneNotifier notifier, boolean unitTestMode, int phoneId) {  
        super("GSM", notifier, context, ci, unitTestMode, phoneId);  
      
        if (ci instanceof SimulatedRadioControl) {  
            mSimulatedRadioControl = (SimulatedRadioControl) ci;  
        }  
      
        mCi.setPhoneType(PhoneConstants.PHONE_TYPE_GSM);  
        mCT = new GsmCallTracker(this);  
      
        mSST = new GsmServiceStateTracker(this);  
        mDcTracker = new DcTracker(this);  
      
        if (!unitTestMode) {  
            mSimPhoneBookIntManager = new SimPhoneBookInterfaceManager(this);  
            mSubInfo = new PhoneSubInfo(this);  
        }  
      
        mCi.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);  
        mCi.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);  
        mCi.registerForOn(this, EVENT_RADIO_ON, null);  
        mCi.setOnUSSD(this, EVENT_USSD, null);  
        mCi.setOnSuppServiceNotification(this, EVENT_SSN, null);  
        mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null);  
        mCi.setOnSs(this, EVENT_SS, null);  
        setProperties();  
      
        log("GSMPhone: constructor: sub = " + mPhoneId);  
      
        setProperties();  
}
其中,有创建DcTracker对象,查看这个类的构造方法

//***** Constructor  
    public DcTracker(PhoneBase p) {  
        super(p);  
        ......  
        update();  
        ......  
}
首先,先调用了其父类的构造方法

/**  
     * Default constructor  
     */  
    protected DcTrackerBase(PhoneBase phone) {  
      
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值