android中Connection.hangup()和Call.hangup()

來源:互聯網
上載者:User

當我看到PhoneUtil的這麼多hangup()的時候,頭都有點暈了,還是來詳細捋一遍吧。
-------GsmConnectio.java---------
public void hangup() throws CallStateException
{
    if (!disconnected) {
       owner.hangup(this);      //owner是GsmCallTracker對象
    } else {
       throw new CallStateException ("disconnected");
    }
}  
--------GsmCall-------------------
public void hangup() throws CallStateException
{
    owner.hangup(this);        //owner是GsmCallTracker對象
}
由此可見,hangup()由GsmCallTracker進行了多態化,最後還是得由CommandInterface的對象cm.hangupConnection()進行掛斷操作。CommandInterface本來是一個介面類,通過RIL implement之後,再>上溯為一個CommandInterface對象,RIL對象都在PhoneFactory裡面得到建立。
在PhoneFactory.java裡面,new PhoneProxy(new GSMPhone(context, sCommandsInterface, sPhoneNotifier));  PhoneProxy是CDMAPhone和GSMPhone的代理,參數context實際就是個PhoneApp對象,通
過PhoneFactory.makeDefaltPhones(this)講自己傳給PhoneFactory, sCommandsInterface就是那個由RIL對象上溯而來的對象,sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
在RIL.java裡面
public void hangupConnection (int gsmIndex, Message result) {
   if (RILJ_LOGD) riljLog("hangupConnection: gsmIndex=" + gsmIndex);
   RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP, result);
   if (RILJ_LOGD)
        riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " + gsmIndex);
   rr.mp.writeInt(1);
   rr.mp.writeInt(gsmIndex);
   send(rr);
}

RIL裡面的RILSender收到發送訊息之後,最終是要把掛斷請求通過Socket發送出去的
s.getOutputStream().write(dataLength);
s.getOutputStream().write(data);

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.