CallCard.java----->void updateState(Phone phone)----->根據當點電話的狀態選擇執行下列更新函數,1,updateRingCall(phone)/ 2,updateForegroundCall(phone)/ 3, updateNoCallphone()
1,
updateRingCall(phone)----->a, displayMainCallStatus(phone, ringingCall) && b, displayOnholdingCallStatus(phone, bgCall) && c, displayOngoingCallStatus(phone, fgoingCall)
a, displayMainCallStatus(phone ringingCall)----->{假如無來電,返回, 確定是否橫屏狀態,藍芽狀態, 如果當前電話已經接通,根據橫屏狀態和藍芽狀態拿到當前CallCard背景圖片資>源,即callCardBackgroundResid, 更新時鐘資訊,就是打電話的時候螢幕下方計時的時鐘, 而如果是保持狀態,掛斷狀態(DISCONNECTED),撥打等待(DIALING)狀態,警告狀態(ALERTING),來電狀態(INCOMING),等待狀態(WAITING),也拿到對應的callCardBackgroundResid, 取消計時,空閑狀態下,什麼也不做 }, 設定好callCardBackgroundResid(就是裝頭像的那個背景)後,然後進入updat
eCallCardTitleWidgets(Phone phone, Call call), 設定一些widget, getTitleForCallCard(call), 給目前狀態找一個條題目,比如“撥號中”“來電”“當前通話”等等, {如果當前是的Call是啟用的也就是接通的,根據藍芽狀態給當前通話找一個表徵圖,設定文字顏色,如果是掛斷狀態,也配置好表徵圖和字串顯示在螢幕上,然後根據掛斷與否,顯示時鐘},到這裡為止,顯示的都是背景阿,文字什>麼的, 當前通話人的資訊,比如頭像名字還沒找出來,接寫來就幹這個了, 如果當前是會議通話,更新會議介面,否則尋找個人資訊,如相片,電話號碼,名字等,顯示在介面上不詳細解釋.
b,c 不詳細解釋
2,
updateForgroundCall(phone), 如果當前電話空閑,且有新串連,則displayMainCallStatus(), 然後執行1裡面的動作
3,
updateNoCallPhone, 也是執行,1裡面的三個更新函數,只不過,不同狀態下,參數不一樣,比如電話在完全空閑狀態下,沒有新來電,也沒有掛起的電話,也沒有去電,則參數,ringCall, bgCall, ongoingCall 都為null.
原始碼如下:
void updateState(Phone phone) {
if (DBG) log("updateState(" + phone + ")...");
// Update some internal state based on the current state of the phone.
// TODO: This code, and updateForegroundCall() / updateRingingCall(),
// can probably still be simplified some more.
Phone.State state = phone.getState(); // IDLE, RINGING, or OFFHOOK
if (state == Phone.State.RINGING) {
// A phone call is ringing *or* call waiting
// (ie. another call may also be active as well.)
updateRingingCall(phone);
} else if (state == Phone.State.OFFHOOK) {
// The phone is off hook. At least one call exists that is
// dialing, active, or holding, and no calls are ringing or waiting.
updateForegroundCall(phone);
} else {
// The phone state is IDLE!
//
// The most common reason for this is if a call just
// ended: the phone will be idle, but we *will* still
// have a call in the DISCONNECTED state:
Call fgCall = phone.getForegroundCall();
Call bgCall = phone.getBackgroundCall();
if ((fgCall.getState() == Call.State.DISCONNECTED)
|| (bgCall.getState() == Call.State.DISCONNECTED)) {
// In this case, we want the main CallCard to display
// the "Call ended" state. The normal "foreground call"
// code path handles that.
updateForegroundCall(phone);
} else {
updateNoCall(phone);
}
}
}