(M)SIM卡开机流程分析之主线分析

首先,PhoneFactory.java中通过方法makeDefaultPhone方法创建Phone对象,以及其他的对象,看一下PhoneFactory.makeDefaultPhone方法:

    /**
     * FIXME replace this with some other way of making these
     * instances
     */
    public static void makeDefaultPhone(Context context) {
        ......
        // use UNIX domain socket to
        // prevent subsequent initialization
        // 创建Socket,和Telephony进行通信
        new LocalServerSocket("com.android.internal.telephony");
        ......
        
        /* In case of multi SIM mode two instances of PhoneProxy, RIL are created,
           where as in single SIM mode only instance. isMultiSimEnabled() function checks
           whether it is single SIM or multi SIM mode */
        // 取得手机最大支持的SIM卡数量
        int numPhones = TelephonyManager.getDefault().getPhoneCount();
        // 网络模式,Preferred Network Mode
        int[] networkModes = new int[numPhones];
        // Phone代理
        sProxyPhones = new PhoneProxy[numPhones];
        // 创建RIL
        sCommandsInterfaces = new RIL[numPhones];

        for (int i = 0; i < numPhones; i++) {
            // reads the system properties and makes commandsinterface
            // Get preferred network type.
            // 默认的Preferred Network Mode
            networkModes[i] = RILConstants.PREFERRED_NETWORK_MODE;
            Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkModes[i]));
            // 初始化RIL,后续会经常遇到这个,需要注意
            sCommandsInterfaces[i] = new RIL(context, networkModes[i], cdmaSubscription, i);
         }
         Rlog.i(LOG_TAG, "Creating SubscriptionController");
         SubscriptionController.init(context, sCommandsInterfaces);

         // Instantiate UiccController so that all other classes can just
         // call getInstance()
         // 创建UiccController对象,注意单例模式,注意传入的参数为RIL数组
         mUiccController = UiccController.make(context, sCommandsInterfaces);

         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);
             }
             
             // 创建Phone代理
             sProxyPhones[i] = new PhoneProxy(phone);
          }
          mProxyController = ProxyController.getInstance(context, sProxyPhones, mUiccController, sCommandsInterfaces);
          ......
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值