(M)SIM卡开机流程分析之RIL类分析

本文深入探讨了SIM卡开机流程中的关键类RIL.java,包括RIL类的创建过程,如WakeLock的使用、HandlerThread与RILSender、RILReceiver的启动,特别是RILReceiver如何建立通信连接并处理RIL消息。同时,文章提到了RILRequest类的作用及其在处理底层ril消息中的角色,并概述了数据请求的方法流程。
摘要由CSDN通过智能技术生成

今天,来简单看一下SIM卡开机流程中的另一个重要的类,RIL.java

首先,进入RIL.java文件中

/**
 * RIL implementation of the CommandsInterface.
 *
 * {@hide}
 */
// Leo,需要注意这个地方,继承自BaseCommands,实现了CommandsInterface的接口
public final class RIL extends BaseCommands implements CommandsInterface {
    ......
}
注意,这个类是继承自BaseCommands,并实现了CommandsInterface接口

再来看看,PhoneFactory.java文件中的makeDefaultPhone方法中对于RIL类的创建

for (int i = 0; i < numPhones; i++) {
     // reads the system properties and makes commandsinterface
     // Get preferred network type.
     networkModes[i] = RILConstants.PREFERRED_NETWORK_MODE;

     Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkModes[i]));
     // Leo,为每一个卡槽新建一个RIL对象
     // RIL是实现了CommandsInterface的接口,因此这个地方的名称为sCommandsInterfaces
     sCommandsInterfaces[i] = new RIL(context, networkModes[i], cdmaSubscription, i);
}
// Leo,获取Settings.Global.CDMA_SUBSCRIPTION_MODE的值
int cdmaSubscription = CdmaSubscriptionSourceManager.getDefault(context);
CdmaSubscriptionSourceManager.java

/**
     * Gets the default CDMA subscription source
     *
     * @return Default CDMA subscription source from Settings DB if present.
     */
    public static int getDefault(Context context) {
        // Get the default value from the Settings
        int subscriptionSource = Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.CDMA_SUBSCRIPTION_MODE, PREFERRED_CDMA_SUBSCRIPTION);
        Rlog.d(LOG_TAG, "subscriptionSource from settings: " + subscriptionSource);
        return subscriptionSource;
    }
networkModes[i]参数,从上面可以看到,是直接赋值的,cdmaSubscription参数,从上文中看值为指定的值,暂不追究,i参数是之的第几张卡槽,接下来,看看RIL的构造函数

// Leo, RIL的构造方法
// 第四个参数是第instanceId个卡槽
// 第二个参数是第instanceId个卡槽的PreferredNetworkMode值
// 第三个参数cdmaSubscription,是Settings.Global.CDMA_SUBSCRIPTION_MODE的值
public RIL(Context context, int preferredNetworkType, int cdmaSubscription, Integer instanceId) {
    super(context);
    ......
    
    mContext = context;
    mCdmaSubscription  = cdmaSubscription;
    mPreferredNetworkType = preferredNetworkType;
    mPhoneType = RILConstants.NO_PHONE;
    mInstanceId = instanceId;

    PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
    // Leo, 这个WakeLock是干嘛用的?
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, RILJ_LOG_TAG);
    mWakeLock.setReferenceCounted(false);
    mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT, DEFAULT_WAKE_LOCK_TIMEOUT);
    mWakeL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值