Android 源码开发系列 (四) Android 4.2中与SIM/USIM 管理流程
Android在经过几次更新后,在与卡相关的管理出现的重大的改变。谨以些文,给自己做下学习该块的笔记。既然作为开源的,我们第一步当然是从代码入手,分析该处的关系。
Uicc的架构图如下:

从图中可以看出,UiccController是用来控制所有与卡相关的操作,通过UiccController,我们可以访问IccRecords(SIM卡相关), CatService(STK相关),IccFileHandle(读取SIM卡文件)。
与前面几个版相比,变化最大的就是IccCard.java这个文件,在4.2以前的版本中,该IccCard是一个类,而在4.2中,它却是一个接口,代码如下:
public PhoneProxy(PhoneBase phone) { mActivePhone = phone; mResetModemOnRadioTechnologyChange = SystemProperties.getBoolean( TelephonyProperties.PROPERTY_RESET_ON_RADIO_TECH_CHANGE, false); mIccSmsInterfaceManagerProxy = new IccSmsInterfaceManagerProxy( phone.getIccSmsInterfaceManager()); mIccPhoneBookInterfaceManagerProxy = new IccPhoneBookInterfaceManagerProxy( phone.getIccPhoneBookInterfaceManager()); mPhoneSubInfoProxy = new PhoneSubInfoProxy(phone.getPhoneSubInfo()); mCommandsInterface = ((PhoneBase)mActivePhone).mCM; mCommandsInterface.registerForRilConnected(this, EVENT_RIL_CONNECTED, null); mCommandsInterface.registerForOn(this, EVENT_RADIO_ON, null); mCommandsInterface.registerForVoiceRadioTechChanged( this, EVENT_VOICE_RADIO_TECH_CHANGED, null); mIccCardProxy = new IccCardProxy(phone.getContext(), mCommandsInterface); if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) { // For the purpose of IccCardProxy we only care about the technology family mIccCardProxy.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS); } else if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { mIccCardProxy.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT); } }至于细节东东,只有去看代码了,在创建GSMPHONE的时候做了好多的事。需要自己去体会。由于一直从事GSMPHONE ,好像还没有遇到CDMA的实例。