Android N拨打电话的流程

编程入门 行业动态 更新时间:2024-10-26 09:27:14

1. 从Dialer工程开始,DialtactsActivity中打开DialpadFragment界面,在DialpadFragment中实现OnClickListener的onClick()方法,根据点击事件如果是拨号按钮(R.id.dialpad_floating_action_button)则调用handleDialButtonPressed()方法,开启拨号流程。
2. handleDialButtonPressed方法中首先判断所拨打的号码是否为空号,是否为禁止拨打的号码,如果都不是则继续调用DialerUtils中的startActivityWithErrorToast()方法将拨号的请求继续往下传递,通过ContactsCommon中的TeleManagerCompat类传递到telem(TeleService)中的TeleManager中。
3 .在TeleManager中调用placeCall()方法,通过该方法远程调用ITeleService.aidl的方式调用TeleServiceImpl(进入Tele工程)中的placeCall()方法(ITeleService的实现类为TeleServiceImpl中的ITeleService.Stub mBinderImpl)。
4. placeCall()方法中通过工厂模式生成UserCallIntentProcessor对象,通过调用UserCallIntentProcessor中的processIntent()方法向PrimaryCallReceiver发送请求通话的广播(processIntent()—>processOutgoingCallIntent()–>sendBroadcastToReceiver())。
5. 在PrimaryCallReceiver的回调方法中获取TeleSystem实例,然后通过再获取CallIntentProcessor实例,调用CallIntentProcessor中的processIntent()方法。
6. processIntent()方法中对unKnownCall和outgoingcall进行判断,分别处理:

if (isUnknownCall) {processUnknownCallIntent(mCallsManager, intent);} else {processOutgoingCallIntent(mContext, mCallsManager, intent);}

processOutgoingCallIntent方法处理拨打正常号码的流程。
7. processOutgoingCallIntent()方法中通过CallsManagerstartOutgoingCall()方法获取Call实例(startOutgoingCal()l方法中同时对手机是单卡双卡进行判断):

// Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returnsCall call = callsManager.startOutgoingCall(handle, phoneAountHandle, clientExtras, initiatingUser);

如果call不为空,new一个NewOutgoingCallIntentBroadcaster对象,然后调用processIntent()方法。
8. processIntent()方法中对所拨打的号码进行处理。如果不是紧急拨号或者语音拨号,则继续调用broadcastIntent()方法,发生action为ACTION_NEW_OUTGOING_CALL的有序广播到NewOutgoingCallBroadcastIntentReceiver
9. NewOutgoingCallBroadcastIntentReceiver中回调到CallsManager中的placeOutgoingCall()方法,该方法中继续调用Call中的startCreateConnection()方法开始建立通话连接。
10. startCreateConnection()方法中生成CreateConnectionProcessor对象,然后调用process()方法。
11. process()方法中调用自身的attemptNextPhoneAount()方法,此方法中通过ConnectionServiceWrapper实例调用createConnection()方法,createConnection()方法中通过IConnectionService.aidl远程调用ConnectionService中的IConnectionService的实现类中的createConnection()方法,通过handler继续传递MSG_CREATE_CONNECTION消息。在handler的处理消息的方法中调用ConnectionService的createConnection()方法(注意和IConnectionService的实现类中的createConnection()区分,此时有进入telem工程。)。
12. 判断建立的连接是否为outgoingConnection:

Connection connection = isUnknown ? onCreateUnknownConnection(callManagerAount, request): isIning ? onCreateIningConnection(callManagerAount, request): onCreateOutgoingConnection(callManagerAount, request);

在onCreateOutgoingConnection()方法中处理外拨电话的流程。
13. onCreateOutgoingConnection()方法中调用placeOutgoingConnection()方法,获取GsmCdmaPhone的对象,通过dial()方法获取连接。
14. 获取mCT,创建RIL对象,通过RILSender发送消息,通过RILReceiver接收处理消息。
15. 如果通过成功则在CallsManager中的onSuessfulOutgoingCall()方法中调用setCallState()方法生成通话记录(setCallState()–>CallsManagerListener.onCallStateChanged()–>CallLogManager.onCallStateChanged()–>logCall()–>logCallAsync()–>LogCallAsyncTask)。

更多推荐

拨打电话,流程,Android

本文发布于:2023-05-25 12:19:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/300576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:拨打电话   流程   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!