android CallCard.java/updateState(Phone phone)分析

來源:互聯網
上載者:User

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);
            }
        }
    }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.