当我看到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);
android中Connection.hangup()和Call.hangup()
最新推荐文章于 2021-05-25 17:40:55 发布