在我的概念里,Telephony 是从 GsmcdmaPhone 这一对象开始往下算起,才算是 Telephony 层。实际上 Telephony 的概念,它还包括这三个部分,一直以为是 Call App 的模块:

  • /packages/services/Telephony ==> TeleService.apk
  • /packages/services/Telecomm ==> Telecomm.apk
  • /frameworks/base/telecomm ==> Telecomm FW

上面这三个部分,都算是 Telephony;在这个概念里, Call App UI 才算是上层 app 模块。

  • /packages/apps/Dialer/java/com/android/incallui ==> InCallUI

这篇文章,从框架上讲解一下这三个模块的关系,并整理一下来电的流程,熟悉他们的调用关系。
只谈框架流程,不聊具体细节。

架构

先上一张图,从大体上看他们的调用关系。
Android Telephony架构和流程_第1张图片
如上图所示,

  • TeleService <==> Telephony Framework PhoneBase;TeleService 和 framework 进行交互;
  • TelecommService/Telecomm FW <==> TeleService , TeleService 和 InCallUI 交互要经过 Telecomm 层;
  • InCallUI <==> TelecommService/Telecomm FW 交互;

这就是基本的架构,要清楚知道交互消息是如何传输的, 看起来是 Telecomm 起着中间桥梁的作用。

Telephony 主要的类

Android Telephony架构和流程_第2张图片
TeleService 中的 TelephonyConnection 监听来自 PhoneBase 的 call 状态变化,并通过 connectionService 相关的类(ConnectionServiceWrapper) 向 Telecomm 传递状态信息;
Telecomm 到 InCallUI 的过程,则是由 CallsManager 向 InCallController 传递,最后通过 InCallServiceImpl 向 InCallUI 传递。
中间各层 call 的转化,需要经过 Telecom FW.

Telephony 中主要的 Service

Android Telephony架构和流程_第3张图片

  1. 开机加载 TelecommServiceImpl(TelecommManager), 创建 CallsManager 和 InCallController;同时创建 PhoneAccount,监听来电信息;
  2. 来电,创建 TelephonyConnectionService, 创建 TelephonyConnection 监听 Call 状态变化;
  3. CallsManager 回调 InCallController, 告知 InCallService, 最终更新到 InCallUI.

来电流程图

Android Telephony架构和流程_第4张图片

  1. CallsManager and IncallController create by telecom service when system boot up;
  2. TelecomAccountResigistry create PstnIncomingCallNotifer, and it register Notification to PhoneBase,including event(EVENT_NEW_RINGING_CONNECTION);
  3. PstnIncomingCallNotifier receive incoming call event, it will let TelecomServiceImpl call addNewIncomingCall functio;
  4. CallsManager create Call instance, and set itself as Call.Listener.
  5. CallsManager give Call the ConnectionServiceWrapper reference, so Call can access ConnectionService.
  6. Call request ConnectionService to createConnection then callback to CreateConnectionResponse.
  7. When CreateConnectionResponse call back, Call will let its listeners(CallsManager) know it.
  8. When something is changed from ConnectionService, Wrapper will receive the event and then tell to Call or CallsManager.
  9. after create connection successfully, CallsManager will call onSuccessIncomingCall(), then addCall();
  10. InCallController as listener will call onCallAdded(), and then InCallService addCall and enter InCallUI logic.
    Android Telephony架构和流程_第5张图片
  11. TelephonyConnectionService get the orginalConnection(framework) first.
  12. Create GsmConnection/CdmaConnection depends on the phoneType.
  13. Each TelephonyConnection registerNotification to PhoneBase by themselves, listener to them.
  14. Some changed about PhoneBase, TelephonyConnection will receive and then broadcast to all listeners(ConnectionService).
  15. all the event will deliver by listener like: CallsManager ==> InCallController ==> InCallService ==> InCallUI;

更多相关文章

  1. Android 部分内容设置颜色、字体、超链接、图片
  2. (Android)处理图片成圆形
  3. Android P按键静音流程
  4. Android 架构篇----------Framework初识
  5. MixtureTextView 支持Android图文混排、文字环绕图片等效果
  6. MediaRecorder流程分析
  7. 穿针引线,帮你回忆, 汇总:Android系统启动流程 & 应用程序'进程'启

随机推荐

  1. Android(安卓)AIDL进程通信机制详解
  2. Android(安卓)TextView内容居中和控件居
  3. java.lang.RuntimeException: Unable to
  4. Android中有关Handler的使用(三)
  5. Android(安卓)8.0以上获取设备序列号解决
  6. Android(安卓)Bundle类
  7. Android(安卓)加快编译时间
  8. Android(安卓)自动化测试—robotium(五)Spi
  9. Android术语小全,推荐一下(改日在翻译).
  10. Android简易实战教程--第三十九话《简单