二次撥号計時, 就是在撥打電話給對方,對方電話接通後, 發送個line control 消息給自己, phone 接收到消息, 對電話撥通時間重置的一個動作。
二次撥号計時,在phoneApp 最主要的一個實作就是監聽 lineControl 消息。 需要用到的函數在
PhoneProxy.java (frameworks\base\telephony\java\com\android\internal\telephony)中有個函數:
public void registerForLineControlInfo(Handler h, int what, Object obj) {
mActivePhone.registerForLineControlInfo( h, what, obj);
}
是以我的做法是在Phone中IncallScreen.java 中注冊一個監聽
// only for cdma ElapsedTime reset
mCM.getPhoneInCall().registerForLineControlInfo(mHandler, PHONE_LINE_CONTROL_INFO, null);
在handle 中處理這個事件 。
case PHONE_LINE_CONTROL_INFO:
log("................PHONE_LINE_CONTROL_INFO");
resetLineControlInfo((AsyncResult) msg.obj);
break;
函數的具體實作為:
private void resetLineControlInfo(AsyncResult r) {
// Extract the LineControl String from the message
CdmaLineControlInfoRec lineControlInfoRec = (CdmaLineControlInfoRec)(r.result);
if (lineControlInfoRec != null) {
byte polarityIncluded = lineControlInfoRec.lineCtrlPolarityIncluded;
if (DBG) log("resetLineControlInfo: polarityIncluded=" + polarityIncluded);
if (polarityIncluded ==1){
mCallCard.resetElapsedTime();
}
}
}
其中, mCallCard.resetElapsedTime() , 就是在callcard.java 中實作對計時的reset 。 進而實作二次計時。
附:
二次撥号跟蹤流程(高通7627A平台):
1,Qcril_cm.c (vendor\qcom\proprietary\qcril\qcril_fusion) 中的
void qcril_cm_process_cdma_info_recs
(
qcril_instance_id_e_type instance_id,
qcril_modem_id_e_type modem_id
)
函數。 把所有infoRecs 消息都歸類成 RIL_UNSOL_CDMA_INFO_REC 。 并上傳報告給Ril側。
2, 在RIL.java (frameworks\base\telephony\java\com\android\internal\telephony) 中, 函數processUnsolicited處理 RIL_UNSOL_CDMA_INFO_REC 消息。
case RIL_UNSOL_CDMA_INFO_REC:
ArrayList<CdmaInformationRecords> listInfoRecs;
try {
listInfoRecs = (ArrayList<CdmaInformationRecords>)ret;
} catch (ClassCastException e) {
Log.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e);
break;
}
for (CdmaInformationRecords rec : listInfoRecs) {
if (RILJ_LOGD) unsljLogRet(response, rec);
notifyRegistrantsCdmaInfoRec(rec);
}
break;
其中 notifyRegistrantsCdmaInfoRec 函數中, 有判斷是否是 linecontrol消息。
private void
notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) {
int response = RIL_UNSOL_CDMA_INFO_REC;
。。。。。。。。。。。。。。。。。。。。。。。。。。
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec) {
Log.e(LOG_TAG, ".................................infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec");
if (mLineControlInfoRegistrants != null) {
if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
mLineControlInfoRegistrants.notifyRegistrants(
new AsyncResult (null, infoRec.record, null));
}
} else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53ClirInfoRec) {
。。。。。。。。。。。。。。。。。。。。。。。。。。。
}
如果是 linecontrol 消息, 那就會對所有注冊 linecontrol 監聽消息的對象發送一個通知。比如上面的phoneApp。