2.3,通话状态的转换和更新
GsmCallTracker的handleMessage方法中对EVENT_POLL_CALLS_RESULT消息处理如下,
case EVENT_POLL_CALLS_RESULT:
ar = (AsyncResult)msg.obj;//获取查询结果
if (msg == mLastRelevantPoll) {
if (DBG_POLL) log("handle EVENT_POLL_CALL_RESULT: set needsPoll=F");
mNeedsPoll = false;
mLastRelevantPoll = null;
handlePollCalls((AsyncResult)msg.obj);
}
handlePollCalls方法主要是进行各种预处理以及通知。包括远程来电,远程接听电话,远程挂断电话,
1,远程来电的处理如下,
if (newRinging != null) {
mPhone.notifyNewRingingConnection(newRinging);
}
2,远程挂断的处理如下,
if (mDroppedDuringPoll.size() > 0) {
mCi.getLastCallFailCause(
obtainNoPollCompleteMessage(EVENT_GET_LAST_CALL_FAIL_CAUSE));
}
在RIJ.java中的在responseCallList方法中,会构造DriverCall对象,并且调用DriverCall对象的stateFromCLCC 方法
将rild守护进程上报来的通话状态转化为DriverCall对象的状态,
dc = new DriverCall();
dc.tate = DriverCall.stateFromCLCC(p.readInt());
DriverCall的stateFromCLCC方法如下,
public static State
stateFromCLCC(int state) throws ATParseEx {
switch(state) {
case 0: return State.ACTIVE;
case 1: return State.HOLDING;
case 2: return State.DIALING;
case 3: return State.ALERTING;
case 4: return State.INCOMING;
case 5: return State.WAITING;
default:
throw new ATParseEx("illegal call state " + state);
}
}
State 是DriverCall中的一个枚举,因此,modem测上报的rild守护进程通话状态和DriverCall对应如下,
rild守护进程 DriverCall. State
0 State.ACTIVE
1 State.HOLDING
2 State.DIALING
3 State.ALERTING
4 State.INCOMING
5 State.WAITING
handlePollCalls方法中还包含通话状态的转换和更新。
1,首先查询结果就包含当前的通话状态DriverCall对象,
dc = (DriverCall) polledCalls.get(curDC);
dc是DriverCall对象.
2,然后根据去电或者来电的情况分别更新状态,
如果是去电,就调用GsmConnection的update方法进行状态的转换,
mPendingMO.update(dc);
如果是来电,直接调用GsmConnection的构造方法进行转换,
mConnections[i] = new GsmConnection(mPhone, dc, this, i);
3,调用updatePhoneState方法更新状态流程,
updatePhoneState();
4,调用GSMPhone的notifyPreciseCallStateChanged方法更新状态,
mPhone.notifyPreciseCallStateChanged();