======================================================================
mReceiver = new RILReceiver()
RILReceiver对像的 run()中
InputStream is = mSocket.getInputStream();
LocalSocket
==============================================================================
==============================================================================
GsmSimCard.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
public void handleMessage(Message msg)
判断 msg.what
case EVENT_SIM_READY:
phone.mCM.getSimStatus(obtainMessage(EVENT_GET_SIM_STATUS_DONE));
case EVENT_SIM_LOCKED_OR_ABSENT:
phone.mCM.getSimStatus(obtainMessage(EVENT_GET_SIM_STATUS_DONE));
case EVENT_PINPUK_DONE:
// a PIN/PUK/PIN2/PUK2/Network Personalization
phone.mCM.getSimStatus(obtainMessage(EVENT_REPOLL_STATUS_DONE, ar.userObj));
GsmSimCard(GSMPhone phone)
phone.mCM.registerForSIMReady(this, EVENT_SIM_READY, null);
updateStateProperty();
GsmSimCard.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
ServiceStateTracker.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
SIMRecords.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
public abstract class BaseCommands implements CommandsInterface
BaseCommands 类实现了 CommandsInterface接口
public void registerForSIMReady(Handler h, int what, Object obj)
{
Registrant r = new Registrant (h, what, obj);
synchronized (mStateMonitor) {
mSIMReadyRegistrants.add(r)
if (mState.isSIMReady()) {
r.notifyRegistrant(new AsyncResult(null, null, null));
}
}
}
GsmSimCard(GSMPhone phone)
phone.mCM.registerForSIMReady(this, EVENT_SIM_READY, null);
static void pollSIMState (void *param)
switch(getSIMStatus()) {
case RIL_SIM_ABSENT:
case RIL_SIM_PIN:
case RIL_SIM_PUK:
case RIL_SIM_NETWORK_PERSONALIZATION:
default:
setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT);
return;
case RIL_SIM_NOT_READY:
RIL_requestTimedCallback (pollSIMState, NULL, &TIMEVAL_SIMPOLL);
return;
case RIL_SIM_READY:
setRadioState(RADIO_STATE_SIM_READY);
return;
}
//Reference-ril.c (hardware\ril\reference-ril)
static void setRadioState(RIL_RadioState newState)
如果RadioState 为 RADIO_STATE_SIM_READY 执行
onSIMReady();
如果RadioState 为 RADIO_STATE_SIM_NOT_READY 执行:
onRadioPowerOn();
======================================================================
获取sim卡状态流程:
getSIMStatus()
CommandsInterface.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
接口 public interface CommandsInterface 中有
void getSimStatus(Message result);
RIL.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
public final class RIL extends BaseCommands implements CommandsInterface
RIL 类实现了 CommandsInterface 接口
getSimStatus(Message result)
RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SIM_STATUS, result);
send(rr);
rild 程序流程
static void processCommandsCallback(int fd, short flags, void *param)
processCommandBuffer(p_record, recordlen);
status = p.readInt32(&request);
pRI->pCI = &(s_commands[request]);
pRI->pCI->dispatchFunction(p, pRI);
因为有 {RIL_REQUEST_GET_SIM_STATUS,dispatchVoid, responseInts},
所以执行的是 Ril.cpp (hardware\ril\libril) 文件中的函数:
static void dispatchVoid (Parcel& p, RequestInfo *pRI)
s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI);
//Reference-ril.c (hardware\ril\reference-ril):
case RIL_REQUEST_GET_SIM_STATUS:
getSIMStatus()
err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response);
return ret;
//Ril.cpp (hardware\ril\libril)
RIL_onRequestComplete(t, RIL_E_SUCCESS, &simStatus, sizeof(simStatus));
sendResponse(p);
sendResponseRaw(p.data(), p.dataSize());
blockingWrite(fd, data, dataSize);
==========================================================================================
pin码验证流程:
KeyguardViewManager.java (frameworks\policies\base\phone\com\android\internal\policy\impl
show()
mKeyguardView = mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this);
new LockPatternKeyguardView(context, updateMonitor,mLockPatternUtils, controller);
mUnlockScreen = createUnlockScreenFor(unlockMode);
createUnlockScreenFor(UnlockMode unlockMode)
如果 unlockMode == UnlockMode.SimPin
那么 new SimUnlockScreen(mContext,mUpdateMonitor,mKeyguardScreenCallback);
updateScreen(mMode);
由 SimUnlockScreen 类的
public void onClick(View v)
mOkButton 执行的是 checkPin()
new CheckSimPin(mPinText.getText().toString())
//PhoneInterfaceManager.java (packages\apps\phone\src\com\android\phone)
supplyPin(String pin)
return checkSimPin.checkPin(pin);
mSimCard.supplyPin(pin, callback);
//private final SimCard mSimCard;
//因为类 GsmSimCard 实现了 SimCard 接口所以实际执行的是:
//GsmSimCard.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)文件中的
public void supplyPin (String pin, Message onComplete)
phone.mCM.supplySimPin(pin,obtainMessage(EVENT_PINPUK_DONE, onComplete));
//RIL.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)
public void supplySimPin(String pin, Message result)
RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN, result);
send(rr); //通过socket 向 rild 发送 RIL_REQUEST_ENTER_SIM_PIN 请求
rild端处理流程:
static void processCommandsCallback(int fd, short flags, void *param)
processCommandBuffer(p_record, recordlen);
status = p.readInt32(&request);
pRI->pCI = &(s_commands[request]);
pRI->pCI->dispatchFunction(p, pRI);
因为有 {RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseVoid},
所以执行的是 Ril.cpp (hardware\ril\libril) 文件中的函数:
static void dispatchStrings (Parcel &p, RequestInfo *pRI)
s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI);
此处的 pRI->pCI->requestNumber 为 RIL_REQUEST_ENTER_SIM_PIN
//Reference-ril.c (hardware\ril\reference-ril)
static void onRequest (int request, void *data, size_t datalen, RIL_Token t)
case RIL_REQUEST_ENTER_SIM_PIN:
requestEnterSimPin(data, datalen, t);
err = at_send_command_singleline(cmd, "+CPIN:", &p_response);
err = at_send_command_full (command, SINGLELINE, responsePrefix,...);
err = at_send_command_full_nolock(command, type,responsePrefix,...);
err = writeline (command);
written = write (s_fd, s + cur, len - cur);//往串口写数据
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
===========================================================
开启sim卡的pin
EnableSimPinScreen.java
rild端处理流程:
static void processCommandsCallback(int fd, short flags, void *param)
processCommandBuffer(p_record, recordlen);
status = p.readInt32(&request);
pRI->pCI = &(s_commands[request]);
pRI->pCI->dispatchFunction(p, pRI);
因为有 {RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseVoid},
所以执行的是 Ril.cpp (hardware\ril\libril) 文件中的函数:
static void dispatchStrings (Parcel &p, RequestInfo *pRI)
s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI);
此处的 pRI->pCI->requestNumber 为 RIL_REQUEST_ENTER_SIM_PIN
==============================================================================
阅读(1223) | 评论(0) | 转发(0) |