(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);
          ......
    }

你可能感兴趣的:(SIM卡开机流程分析)