在搜索 Android 4.1 源代码后,我在其中一个私有类中找到了以下代码com.android.internal.telephony.IccCard
:
public State getState() {
if (mState == null) {
switch(mPhone.mCM.getRadioState()) {
/* This switch block must not return anything in
* State.isLocked() or State.ABSENT.
* If it does, handleSimStatus() may break
*/
case RADIO_OFF:
case RADIO_UNAVAILABLE:
case SIM_NOT_READY:
case RUIM_NOT_READY:
return State.UNKNOWN;
case SIM_LOCKED_OR_ABSENT:
case RUIM_LOCKED_OR_ABSENT:
//this should be transient-only
return State.UNKNOWN;
case SIM_READY:
case RUIM_READY:
case NV_READY:
return State.READY;
case NV_NOT_READY:
return State.ABSENT;
}
} else {
return mState;
}
Log.e(mLogTag, "IccCard.getState(): case should never be reached");
return State.UNKNOWN;
}
因此State.UNKNOWN
,只要无线电状态是RADIO_OFF或RADIO_UNAVAILABLE之一,就会返回。然后State.UNKNOWN
将SIM_STATE_UNKNOWN
通过方法转换为常量TelephonyManager.getSimState()
。
结论是:打开飞行模式时getSimState
会返回SIM_STATE_UNKNOWN
。