當我看到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);