前面有说过,SIM卡的开机流程是从PhoneFactory.java文件中的makeDefaultPhone方法开始的,SIM的displayName也是从这部分开始的,接下来记录一下自己的研究成果
public static void makeDefaultPhone(Context context) {
synchronized (sLockProxyPhones) {
if (!sMadeDefaults) {
......
// Instantiate UiccController so that all other classes can just
// call getInstance()
// Leo,这个方法是开机后SIM卡启动过程中,较为重要的一个方法,需要注意
// Leo,获取UiccController的对象
mUiccController = UiccController.make(context, sCommandsInterfaces);
for (int i = 0; i < numPhones; i++) {
PhoneBase phone = null;
// Leo,根据Preferred Network Mode,获得SIM卡的PhoneType,从而确认Phone的类型,是GSMPhone还是CDMALTEPhone类型
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);
// Leo,Phone代理, 注意这个PhoneProxy是继承自Handler
sProxyPhones[i] = new PhoneProxy(phone);
}
......
Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater ");
sSubInfoRecordUpdater = new SubscriptionInfoUpdater(context,
sProxyPhones, sCommandsInterfaces);
......
}
}
}
在此方法中,主要是做了如下几件事
1. 使用UiccController类的make方法,创建UiccController对象
2. 创建PhoneProxy代理类对象
3. new一个SubscriptionInfoUpdater对象
从此前的分析中,我们知道,UiccController类的make方法,主要是创建了UiccController对象,那么我们来具体看看代码
// Leo,单例模式,而且make方法只能够调用一次,否则抛出异常
public static UiccController make(Context c, CommandsInterface[] ci) {
synchronized (mLock) {
if (mInstance != null) {
throw new RuntimeException("MSimUiccController.make() should only be called once");
}
mInstance = new UiccController(c, ci);
return (UiccController)mInstance;
}
}
// Leo,第二个参数是RIL集合
private UiccController(Context c, CommandsInterface []ci) {
if (DBG) log("Creating UiccController");
mContext = c;
mCis = ci;
for (int i = 0; i < mCis.length; i++) {
Integer index = new Integer(i);