SIM卡 --- IccCardProxy
Posted Achillisjack
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SIM卡 --- IccCardProxy相关的知识,希望对你有一定的参考价值。
6.2 IccCardProxy
在phone进程初始化过程中, PhoneProxy的构造方法中会构造IccCardProxy对象,
mIccCardProxy = new IccCardProxy(mContext, mCommandsInterface, mActivePhone.getPhoneId());
IccCardProxy的构造方法注册SIM卡状态变化的代码如下,
mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
UiccController的registerForIccChanged方法如下,
synchronized (mLock)
Registrant r = new Registrant (h, what, obj);
mIccChangedRegistrants.add(r);
//Notify registrant right after registering, so that it will get the latest ICC status,
//otherwise which may not happen until there is an actual change in ICC status.
r.notifyRegistrant();
现在的问题是关键是什么时候调用?在UiccController的获取SIM卡状态完成之后,也就是onGetIccCardStatusDone方法中,
mIccChangedRegistrants.notifyRegistrants(new AsyncResult(null, index, null));
IccCardProxy的handleMessage方法对EVENT_ICC_CHANGED消息处理如下,
case EVENT_ICC_CHANGED:
if (mInitialized)
updateIccAvailability();
break;
updateIccAvailability方法调用流程图如下,
updateIccAvailability方法主要逻辑如下,
1,根据不同条件进行判断,注册
registerUiccCardEvents();
2,调用updateExternalState方法将SIM卡的状态通过广播的形式发送出去,
updateExternalState();
updateExternalState方法根据SIM卡的不同状态,调用setExternalState方法进行处理,例如,
READY状态处理如下,
setExternalState(State.READY);
setExternalState方法如下,
setExternalState(newState, false);
setExternalState方法如下,
if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(getIccStateIntentString(mExternalState)))
broadcastInternalIccStateChangedIntent(getIccStateIntentString(mExternalState),
getIccStateReason(mExternalState));
else
broadcastIccStateChangedIntent(getIccStateIntentString(mExternalState),
getIccStateReason(mExternalState));
broadcastInternalIccStateChangedIntent和 broadcastIccStateChangedIntent都是发送广播,那有什么区别呢?
在使用场景上 broadcastInternalIccStateChangedIntent主要用在
INTENT_VALUE_ICC_LOCKED和INTENT_VALUE_ICC_LOADED 状态,其他状态使用 broadcastIccStateChangedIntent,主要包括 READY、IMSI、LOADED。
IccCardConstants.java中一共定义了十几种SIM卡状态,部分如下,
public static final String INTENT_VALUE_ICC_READY = "READY";
public static final String INTENT_VALUE_ICC_IMSI = "IMSI";
public static final String INTENT_VALUE_ICC_LOADED = "LOADED";
•••
以上是关于SIM卡 --- IccCardProxy的主要内容,如果未能解决你的问题,请参考以下文章