IccCard.java --->SimCard.java ----> GsmPhone.java ------> PhoneInterfaceManager.java ------->SimUnlockScreen.java -------> LockPatternKeyguardView.java ------>KeyguardUpdateMonitor.java
KeyguardViewManager.java ------ > KeyguardViewMediator.java -------> PhoneWindowManager.java ------> WindowManagerService.java -------> ServerThread.java
KeyguardUpdateMonitor.java 現在有兩個IccCard.State , 分別代表G網和C網,如下:
private IccCard.State mSimState = IccCard.State.READY;
//jmhc ghd 2010.12.21 add{
private IccCard.State mSimStateGsm = IccCard.State.READY;
private String mPhoneType;
//jmhc ghd end }
通IccCard.java 發出的broadcast,分別設定 mSimState 和mSimStateGsm狀態, 現在的問題是KeyguardUpdateMonitor怎麼把這個兩種不同
的狀態,傳人SimUnlockScreen和LockScreen,並且在SimUnlockScreen和LockScreen中如何表示.
LockScreen 通過方法onSimStateChanged()得到sim卡的狀態,在單卡中SimUnlockScreen不需要知道sim卡的狀態,一旦SimUnlockScreen
被初始化,就確認為sim卡已鎖, 在雙卡中,SimUnlockScreen需要知道兩張卡的狀態,做一些處理。
LockScreen 中針對sim卡狀態分了許多種 如下:
/**
* Normal case (sim card present, it's not locked)
*/
Normal(true),
/**
* The sim card is 'network locked'.
*/
NetworkLocked(true),
/**
* The sim card is missing.
*/
SimMissing(false),
/**
* The sim card is missing, and this is the device isn't provisioned, so we don't let
* them get past the screen.
*/
SimMissingLocked(false),
/**
* The sim card is PUK locked, meaning they've entered the wrong sim unlock code too many
* times.
*/
SimPukLocked(false),
/**
* The sim card is locked.
*/
SimLocked(true);
現在,如果我要加入對另外一個卡狀態的表示,那麼兩個狀態結合在一起就更多了,簡單的處理是,在現有的各個狀態中,
對兩個卡分別做一個判斷,更新其狀態。
KeyguardUpdateMonitor.java 中增加變數
mCurrectPhoneType;
mGsmPhoneType;
mCdmaPhoneType;
接收IccCard.java 的broadcast ,並儲存狀態,其中,mCurrectPhoneType 存在的問題是,mCurrentPhone receive 這邊已經更新了許多狀態了,handleSimStateChange,就只能處理最後一種了; mGsmPhoneType 和mCdmaPhoneType 存在的問題是,當兩個卡都pin鎖以後,解鎖一個,連帶的會對另外一個狀態有所改變。
當我記錄這些想法的時候,另外一個想法又出現在我的腦海中,那就是從底層,控制兩個卡的狀態。以上兩種路走不同,也就是沒有走對路。
今天,實現了一個簡單的解決辦法
KeyguardUpdateMonitor.java 中方法handleSimStateChange()會接受IccCard.java 的broadcast。這裡區分是G網還是C網,是通過IccCard.java發broadcast 時把電話類型作為intent 參數,然後直接把intent 做為參數傳人handleSimStateChange(),再做判斷,這樣就省略了
上面的mCurrectPhoneType, mGsmPhoneType,mCdmaPhonetype 等參數。
機器啟動後,會查詢C卡,G卡的狀態,一旦有任意一張卡狀態為PIN鎖定,就會初始化SimUnlockScreen.java, 這樣 就有一個問題,SimUnlockScreen 已經初始化完了,另外一張卡的PIN鎖定狀態才設定成功,使得SimUnlockScreen.java狀態並不正確。解決這個問題的做法是,在KeyguardUpdateMonitor.java中再加一個broadcast, 在SimUnlockScreen.java加一個receiver, 這樣可以主動去修改SimUnlockScreen.java
的狀態
RIL
IccCardStatus
IccCardApplication
IccCard.java 在mHandler的方法handleMessage()中通過 mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE)); 調用Ril.java, Ril.java返回訊息自然也在mHanlder中,處理流程是getIccCardStatusDone(ar) ---->handleIccCardStatus((IccCardStatus) ar.result)---------->getIccCardState()
SIM 卡的部分AT
D/AT-GSM ( 1046): AT> ATE0Q0V1
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> ATE0Q0V1
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> ATS0=0
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CMEE=1
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CREG=2
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CGREG=1
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CCWA=1
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CMOD=0
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CSSN=0,1
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+COLP=0
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CSCS="HEX"
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CUSD=1
D/AT-GSM ( 1046): AT< +CME ERROR: 11
D/AT-GSM ( 1046): AT> AT+CGEREP=1,0
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CMGF=0
D/AT-GSM ( 1046): AT< OK
D/AT-GSM ( 1046): AT> AT+CPMS="SM","SM","SM"
D/AT-GSM ( 1046): AT< +CPMS: 0, 0, 0, 0, 0, 0
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> ATE0V1
2010-12-23 ��上��午07:05:52 com.ibm.icu4jni.util.Resources createTimeZoneNamesFor
INFO: Loaded time zone names for zh_CN in 597ms.
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT> AT+CFUN=0
[ 18.921508] [DPRTTY] BP mailbox is timeout.
[ 18.925811] GPIO-118 autorequested
D/AT-CDMA ( 788): AT< READY
D/AT-CDMA ( 788): AT< +CREG: 0,0,0
D/AT-CDMA ( 788): AT< ^SIMST: 255
I/RIL-CDMA( 788): onUnsolicited SIMST: ^SIMST: 255
E/RILC-CDMA( 788): unsupported unsolicited response code 1032
D/AT-CDMA ( 788): AT< ^SIMST: 1
I/RIL-CDMA( 788): onUnsolicited SIMST: ^SIMST: 1
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< O[ 18.976287] init: starting 'bootanim'
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT> ATE0V1
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT> ATS0=0
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT> AT+CMEE=2
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT> AT+CMGF=1
D/AT-CDMA ( 788): AT< OK
D/AT-CDMA ( 788): AT> AT+CTA=10
D/AT-CDMA ( 788): AT< OK
UIM --------------------lock
D/RILJ-CDMA( 907): [0243]> SET_FACILITY_LOCK
D/RIL-CDMA( 788): onRequest: SET_FACILITY_LOCK
D/AT-CDMA ( 788): AT> AT+CLCK="SC",1,"1234",7
D/AT-CDMA ( 788): AT< OK
D/RILJ-CDMA( 907): [0243]< SET_FACILITY_LOCK {}
D/CDMA ( 907): [IccCard] EVENT_CHANGE_FACILITY_LOCK_DONE: mIccPinLocked= true
UIM ---------------------unlock
D/RILJ-CDMA( 907): [0251]> SET_FACILITY_LOCK
D/RIL-CDMA( 788): onRequest: SET_FACILITY_LOCK
D/AT-CDMA ( 788): AT> AT+CLCK="SC",0,"1234",7
D/AT-CDMA ( 788): AT< OK
D/RILJ-CDMA( 907): [0251]< SET_FACILITY_LOCK {}
D/CDMA ( 907): [IccCard] EVENT_CHANGE_FACILITY_LOCK_DONE: mIccPinLocked= false
UIM -------------------enter
D/RILJ-CDMA( 907): [0021]> ENTER_SIM_PIN
D/RIL-CDMA( 788): onRequest: ENTER_SIM_PIN
D/AT-CDMA ( 788): AT> AT^CPIN="1234"
D/AT-CDMA ( 788): AT< OK
D/RIL-CDMA( 788): unlocking sim card simStatus=3, need sleep 10s for modem init sim card
SIM ------------------lock
D/RILJ-GSM( 907): [0318]> SET_FACILITY_LOCK
D/RIL-GSM ( 787): onRequest: SET_FACILITY_LOCK
D/RIL-GSM ( 787): RIL_REQUEST_SET_FACILITY_LOCK .........................
D/AT-GSM ( 787): AT> AT+CLCK="SC",1,"1234",7
D/AT-GSM ( 787): AT< OK
D/RILJ-GSM( 907): [0318]< SET_FACILITY_LOCK {}
D/GSM ( 907): [IccCard] EVENT_CHANGE_FACILITY_LOCK_DONE: mIccPinLocked= true
SIM ------------------unlock
D/RILJ-GSM( 907): [0319]> SET_FACILITY_LOCK
D/RIL-GSM ( 787): onRequest: SET_FACILITY_LOCK
D/RIL-GSM ( 787): RIL_REQUEST_SET_FACILITY_LOCK .........................
D/AT-GSM ( 787): AT> AT+CLCK="SC",0,"1234",7
D/AT-GSM ( 787): AT< OK
D/RILJ-GSM( 907): [0319]< SET_FACILITY_LOCK {}
D/GSM ( 907): [IccCard] EVENT_CHANGE_FACILITY_LOCK_DONE: mIccPinLocked= false
SIM ================================= enter
D/RILJ-GSM( 910): [0019]> ENTER_SIM_PIN
D/RIL-GSM ( 1063): onRequest: ENTER_SIM_PIN
D/AT-GSM ( 1063): AT> AT^CPIN=1234 --------------->>>>AT^CPIN="1234"
D/AT-GSM ( 1063): AT< +CME ERROR: 100
D/RILJ-GSM( 910): [0019]< ENTER_SIM_PIN error: com.android.internal.telephony.CommandException: PASSWORD_INCORRECT
D/RILJ-GSM( 910): [0020]> GET_SIM_STATUS
D/RIL-GSM ( 1063): onRequest: GET_SIM_STATUS
D/AT-GSM ( 1063): AT> AT+CPIN?
D/AT-GSM ( 1063): AT< +CPIN: SIM PIN
D/AT-GSM ( 1063): AT< OK
query
AT+CPIN?
puk right
D/RILJ ( 99): [0024]> ENTER_SIM_PUK
D/RILD ( 33): onRequest: ENTER_SIM_PUK
D/AT ( 33): AT> AT^CPIN="01153813","1234"
D/AT ( 33): AT< OK
puk error
/dev/dprtty0
/dev/ttyS0
^CPIN:<code>,[<times>],<puk_times>,<pin_times>,<puk2_times>,<pin2_times>
GET_PIN_PUK_LEFT_COUNTS CDMA
D/RIL-CDMA( 810): onRequest: GET_PIN_PUK_LEFT_COUNTS
D/AT-CDMA ( 810): AT> AT^CPIN?
D/RILJ-CDMA( 1116): [0026]< REGISTRATION_STATE {4, , , 0, -1, -1, -1, 0, -1, -1, 1, 0, -1, 0}
D/CDMA ( 1116): [CdmaServiceStateTracker] Set CDMA Roaming Indicator to: 1. mCdmaRoaming = false, isPrlLoaded = fa1
D/CDMA ( 1116): [CdmaServiceStateTracker] Poll ServiceState done: oldSS=[3 home null null null Unknown CSS not su]
D/AT-CDMA ( 810): AT< ^CPIN:SIM PIN,2,10,2,10,3
D/AT-CDMA ( 810): AT< OK
D/RIL-CDMA( 810): AT+CPIN? response[0]=3
D/RIL-CDMA( 810): AT+CPIN? response[1]=2
D/RIL-CDMA( 810): AT+CPIN? response[2]=10
D/RIL-CDMA( 810): AT+CPIN? response[3]=2
D/RIL-CDMA( 810): AT+CPIN? response[4]=10
D/RIL-CDMA( 810): AT+CPIN? response[5]=3
D/RILJ-CDMA( 1116): [0027]< RIL_REQUEST_GET_PIN_PUK_LEFT_COUNTS {3, 2, 10, 2, 10, 3}
D/AT-GSM ( 809): AT< OK
GET_PIN_PUK_LEFT_COUNTS GSM
>>>> at+epinc?
>>>> D/AT-GSM ( 809): AT< +EPINC: 0, 3, 10, 10
D/AT-GSM ( 809): AT< OK
logcat -s KeyguardUpdateMonitor &
logcat -s LockPatternKeyguardView &
logcat -b radio -s CDMA &
logcat -b radio -s GSM &
logcat -s SimUnlockScreen &
logcat -s KeyguardViewMediator &
logcat -s IccCard &
emulator -skin WVGA800 &
http://blog.csdn.net/ghd_214/article/details/6090120