Android Phone模块
电话管理是Android 系统支持的重要的业务之一,提供接听电话,收发短信、电话薄、网络事件监听、读取用户信息等功能。
从下到上可以分为四层:硬件驱动层、RIL daemon层、Telephony框架实现层、 PHONE应用层,下层为上层提供服务,每层之间采用不同的通讯方式交互。RIL daemon层实现为单独的一个开机启动的进程(rild命令),通过AT命令硬件驱动层交互,Telephony JAVA框架实现层包括一个RIL抽象层,RIL抽象层中通过一个本地socket与RIL daemon层(rild)交互,Phone应用层通过Binder机制与Telephony框架交互。
一 Telephony框架
Telephony框架系统类图如下图:
Telephony框架层为应用层和框架层的其它服务提供Telephony服务,提供了如下几个服务:PhoneInterfaceManager服务,是ITelephony接口的实现,IccSmsInterfaceManager短消息服务,是Isms接口的实现;IccPhoneBookInterfaceManager电话本服务,PhoneBook接口的实现;PhoneSubInfo提供用户信息读取服务,是IPhoneSubInfo接口的实现;TelephonyRegistry提供应用层的消息登记服务,是ITelephonyRegistry接口的实现。
应用程序通过以下几个客户端对象使用Telephony框架提供的服务。
应用程序可以在SmsManager单例对象(通过SmsManager类的getDefault函数返回SmsManager单例对象)SmsInterfaceManager服务,用来收发短信。
PhoneBookInterfaceManager服务的访问,读取和管理电话本。
通过TelephonyManager对象提供对PhoneSubInfo、PhoneInterfaceManager、TelephonyRegistry服务的访问,TelephonyManager对象通过getSubscriberInfo函数获得PhoneSubInfo服务的远程访问代理对象。通过getITelephony函数获得PhoneInterfaceManager的远程访问代理对象。提供一个对象全局sRegistry(指向TelephonyRegistry服务的远程访问代理对象)访问TelephonyRegistry服务。
TelephonyManager通过这三个接口函数提供对外的TelephonyAPI,因此应用程序可以通过 TelephonyManager对象提供的TelephonyAPI访问这些服务,使用Telephony框架层提供的接口功能。
TelephonyManager对象本身通过Context对象调用getSystemService()函数返回,TelephonyManager对象是一个单例对象。
PhoneInterfaceManager服务在默认电话应用的PhoneApp对象中采用单例模式进行初始化(PhoneApp对象本身也是单例对象),和PhoneApp对象公用一个进程,PhoneInterfaceManager为框架层的其它服务提供Telephony API 服务,并通过TelephonyManager对象(通过getITelephony函数获得ITelephony接口)为其它应用提供服务。PhoneInterfaceManager通过PhoneApp、CallManager、Phone对象实现相应功能。CallManager是一个单例对象,CallManager对象提供CALL控制以及登记通知等功能。
Phone对象是整个Telephony服务的核心,主要的Telephony服务(IccSmsInterfaceManager、IccPhoneBookInterfaceManager、PhoneSubInfo)及数据连接功能都通过具体的Phone对象提供,具体的Phone对象包括CDMAPhone、CDMALTEPhone、GSMPhone及SipPhone。
PhoneBase抽象类是这些具体Phone对象的共同的基类,本身一个Handler类,用来提供Phone接口的基实现,mandsInterface接口与RIL daemon层交互,实现短消息提交、数据连接控制、ICC 信息读取
AndroidPhone模块基本介绍 来自淘豆网www.taodocs.com转载请标明出处.