android 6.0 查看服务,android 6.0 ConnectionService

分析Connection的创建

MO的时候,CallIntentProcessor(packages/services/Telecomm/src/com/android/server/telecom/CallIntentProcessor.java)收到去电请求后,会调用CallsManager的startOutgoingCall生成一个Call对象,在其中会走前一篇(绑定InCallService)的逻辑,然后继续往下走,最终到CallsManager.placeOutgoingCall函数,里面通过call.startCreateConnection来创建Connection。最后走到ConnectionServiceWrapper.createConnection()从此走上ConnectionService相关之路。

首先是通过ConnectionServiceWrapper来获得ConnectionService(frameworks/base/telecomm/java/android/telecom/ConnectionService.java),也就是在ConnectionServiceWrapper中通过bindService来和ConnectionService相连。事件上TelephonyConnectionService(packages/services/Telephony/src/com/android/services/telephony/TelephonyConnectionService.java)继承ConnectionService,最后连的是TelephonyConnectionService。

并且,和InCallService类似,连接成功后,设置IConnectionServiceAdapter.Stub的一个adapter到ConnectionService,以完成双向调用。

mServiceInterface.addConnectionServiceAdapter(adapter)

最后存在了ConnectionServiceAdapter(frameworks/base/telecomm/java/android/telecom/ConnectionServiceAdapter.java)对象中。

创建connection之前,把ConnectionServiceWrapper对象设置到Call对象中,这样,当有相关操作的时候(比如answer),会调用ConnectionServiceWrapper对象,最终会调用ConnectionService来传到framework下面去。

if (mResponse != null && attempt != null) {

Log.i(this, "Trying attempt %s", attempt);

PhoneAccountHandle phoneAccount = attempt.connectionManagerPhoneAccount;

ConnectionServiceWrapper service =

mRepository.getService(

phoneAccount.getComponentName(),

phoneAccount.getUserHandle());

if (service == null) {

Log.i(this, "Found no connection service for attempt %s", attempt);

attemptNextPhoneAccount();

} else {

mCall.setConnectionManagerPhoneAccount(attempt.connectionManagerPhoneAccount);

mCall.setTargetPhoneAccount(attempt.targetPhoneAccount);

mCall.setConnectionService(service);

setTimeoutIfNeeded(service, attempt);

service.createConnection(mCall, new Response(service));

}

}

走了一圈,最后到了ConnectionService.createConnection,里面根据是MO/MT调用了onCreateOutgoingConnection/onCreateInComingConnection,这里我们看onCreateOutgoingConnection,在这个里面创建最终的connection,并调用phone.dial()拨号,把命令发到RIL。

com.android.internal.telephony.Connection originalConnection;

try {

if (isAddParticipant) {

phone.addParticipant(number);

return;

} else {

originalConnection = phone.dial(number, null, request.getVideoState(), bundle);

}

} catch (CallStateException e) {

然后把dial生成的connection和service包里面的connection相关联。

connection.setOriginalConnection(originalConnection);

这样,当底层有电话状态变化的时候,会传到connection中,然后再传到call,最后到UI。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值