电话管理是Android 系统支持的重要的业务之一,提供接听电话,收发短信、电话薄、网络事件监听、读取用户信息等功能。
电话管理是
Android
系统支持的重要的业务之一,提供接听电话,收发短信、电话薄、网络事件监听、读取用户信息等功能。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
从下到上可以分为四层:硬件驱动层
、RIL daemon层、
Telephony
框架实现层、
PHONE应用层,下层为上层提供服务,每层之间采用不同的通讯方式交互。
RIL daemon
层实现为单独的一个开机启动的进程(
rild命令),通过
AT命令硬件驱动层交互,
Telephony
JAVA框架实现层包括一个
RIL抽象层,
RIL
抽象层中通过一个本地
socket与
RIL daemon层(
rild
)交互,
PHONE
应用层通过
BINDER机制与
Telephony框架交互。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
本文主要分析框架层相关的主要类的结构。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
一
Telephony框架
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
Telephony框架系统类图如下图:
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
Telephony框架层为应用层和框架层的其它服务提供
Telephony
服务,提供了如下几个服务:
PhoneInterfaceManager
服务,是ITelephony接口的桩实现,IccSmsInterfaceManager
短消息服务,是
Isms接口的桩实现;IccPhoneBookInterfaceManager电话本服务,是IIccPhoneBook接口的桩实现;
PhoneSubInfo提供用户信息读取服务,是IPhoneSubInfo接口的桩实现;TelephonyRegistry
提供应用层的消息登记服务,是ITelephonyRegistry接口的桩实现。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
应用程序通过以下几个客户端对象使用Telephony框架提供的服务。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
应用程序可以在SmsManager单例对象(通过SmsManager类的
getDefault函数返回
SmsManager单例对象)中访问IccSmsInterfaceManager服务,用来收发短信。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
通过IccProvider一个内容提供对象提供对IccPhoneBookInterfaceManager
服务的访问,读取和管理电话本。 < p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
通过TelephonyManager对象提供对PhoneSubInfo、PhoneInterfaceManager
、
TelephonyRegistry服务的访问,TelephonyManager对象通过getSubscriberInfo函数获得PhoneSubInfo
服务的远程访问代理对象。通过getITelephony函数获得PhoneInterfaceManager
的远程访问代理对象。提供一个对象全局sRegistry(指向TelephonyRegistry
服务的远程访问代理对象)访问TelephonyRegistry服务。< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
TelephonyManager通过这三个接口函数提供对外的
TelephonyAPI,因此应用程序可以通过
TelephonyManager
对象提供的
TelephonyAPI访问这些服务,使用
Telephony框架层提供的接口功能。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
TelephonyManager对象本身通过
Context对象调用
getSystemService(Context.TELEPHONY_SERVICE)
函数返回,
TelephonyManager对象是一个单例对象。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
PhoneInterfaceManager服务在默认电话应用的
PhoneApp对象中采用单例模式进行初始化(
PhoneApp
对象本身也是单例对象),和
PhoneApp对象公用一个进程,
PhoneInterfaceManager
为框架层的其它服务提供
Telephony API
服务,并通过
TelephonyManager对象(通过
getITelephony函数获得
ITelephony
接口)为其它应用提供服务。
PhoneInterfaceManager通过
PhoneApp、
CallManager
、
Phone对象实现相应功能。
CallManager是一个单例对象,
CallManager
对象提供
CALL控制以及登记通知等功能。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
Phone对象是整个
Telephony服务的核心,主要的
Telephony
服务(IccSmsInterfaceManager、IccPhoneBookInterfaceManager、PhoneSubInfo
)及数据连接功能都通过具体的Phone对象提供,具体的Phone对象包括CDMAPhone
、
CDMALTEPhone、GSMPhone及SipPhone。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
PhoneBase抽象类是这些具体
Phone对象的共同的基类,本身一个
Handler
类,用来提供Phone
接口的基实现,PhoneBase通过CommandsInterface接口与RIL daemon
层交互,实现短消息提交、数据连接控制、ICC 信息读取等Telephony
基类功能。PhoneBase包含SMSDispatcher、DataConnectionTracker
、
IccFileHandler、IccRecords、IccCard等几个抽象类成员,并通过这些抽象类成员提供某一方面功能的基类实现。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
SMSDispatcher 、
DataConnectionTracker
、
IccFileHandler
、
IccRecords抽象类也是派生自
Handler类,因此都能够向
RIL
发送命令,接收和处理
RIL发来的事件和命令应答。
PhoneBase包括一个
PhoneNotifier
接口,
Phone对象本身及内部对象可以通过
PhoneNotifier接口向应用发送
Telephony事件通知。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
CDMAPhone、
GSMPhone、
CDMALTEPhone三个具体的
Phone
对象在默认的
PhoneApp应用中调用
PhoneFactory的
makeDefaultPhone
函数根据不同的网络模式进行单例实例化,并封装进一个统一的
PhoneProxy代理对象中。
< table width="721" cellspacing="0" cellpadding="0" border="1" style="margin: 0px auto; border: 1px solid rgb(192, 192, 192); border-collapse: collapse; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
int phoneType = getPhoneType(networkMode);
if (phoneType == Phone.PHONE_TYPE_GSM) {
sProxyPhone = new PhoneProxy(new GSMPhone(context,
sCommandsInterface, sPhoneNotifier));
} else if (phoneType == Phone.PHONE_TYPE_CDMA) {
switch (BaseCommands.getLteOnCdmaModeStatic()) {
case Phone.LTE_ON_CDMA_TRUE:
sProxyPhone = new PhoneProxy(new CDMALTEPhone(context,
sCommandsInterface, sPhoneNotifier));
break;
case Phone.LTE_ON_CDMA_FALSE:
default:
sProxyPhone = new PhoneProxy(new CDMAPhone(context,
sCommandsInterface, sPhoneNotifier));
break;
}
}
|
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
PhoneProxy内部的对象成员
mActivePhone指向代理的实际
Phone
对象。
PhoneProxy
代理对象实现了
Phone接口,使应用能够使用统一的
PhoneProxy对象控制操作具体类型的
Phone
对象,而不用关心它们之间的差异(代理模式的采用),应用程序通过
PhoneFactory的
getDefaultPhone
函数返回统一的
PhoneProxy代理对象来访问不同的
Phone对象。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
因为Telephony框架层支持不同的网络类型的Telephony实现(
CDMA、GSM
),因此Telephony框架层普遍使用代理模式来对应用提供统一的服务接口。如PhoneProxy
代理对象内部还封装了IccSmsInterfaceManager、IccPhoneBookInterfaceManager、PhoneSubInfo
三个服务的代理对象,通过代理对象提供对这三个服务的操作控制。
< table width="744" cellspacing="0" cellpadding="0" border="1" style="margin: 0px auto; border: 1px solid rgb(192, 192, 192); border-collapse: collapse; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
public PhoneProxy(Phone phone) {
mActivePhone = phone;
mIccSmsInterfaceManagerProxy = new IccSmsInterfaceManagerProxy(
phone.getIccSmsInterfaceManager());
mIccPhoneBookInterfaceManagerProxy = new IccPhoneBookInterfaceManagerProxy(
phone.getIccPhoneBookInterfaceManager());
mPhoneSubInfoProxy = new PhoneSubInfoProxy(phone.getPhoneSubInfo());
mCommandsInterface = ((PhoneBase)mActivePhone).mCM;
}
|
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
另外CommandsInterface接口的具体实现对象RIL及PhoneNotifier
接口的具体实现对象
DefaultPhoneNotifier也是在PhoneFactory的makeDefaultPhone中进行单例实例化。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
CDMAPhone、
GSMPhone对象直接派生自
PhoneBase
,提供
Phone
接口的具体实现,
GSMPhone是
GSM电话的
JAVA
框架层实现,
CDMAPhone
是
CDMA电话的
JAVA框架层实现。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
CDMAPhone、
GSMPhone对象实例化时除实例化基对象
PhoneBase
内部抽象对象(
SMSDispatcher
、
DataConnectionTracker、
IccFileHandler、
IccRecords
、
IccCard)的具体类外,还实例化用于具体电话对象的
Telephony服务(
IccSmsInterfaceManager、
IccPhoneBookInterfaceManager、
PhoneSubInfo三个服务或者服务的派生类)。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
二
GSMPhone
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
如下是GSMPhone对象的相关类图。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
SMSDispatcher 、
DataConnectionTracker
、
IccFileHandler
、
IccRecords、
IccCard等抽象类对应
GSMPhone
对象中的派生类分别为
GsmSMSDispatcher(提供
GSM模式的短消息发送和接收提交功能)、
GsmDataConnectionTracker
(提供
GSM模式的数据连接管理功能)、
SIMFileHandler(提供
SIM File处理)、
SIMRecords
(提供
SIM信息记录功能)、
SimCard(提供
SIM CARD功能);
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
IccSmsInterfaceManager、
IccPhoneBookInterfaceManager、
PhoneSubInfo
服务在
GSMPhone
对象中实现的具体的服务类为
SimSmsInterfaceManager、
SimPhoneBookInterfaceManager
及
PhoneSubInfo;这些对象和服务都在
CDMAPhone对象实例化进行实例化。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
另外GSMPhone对象在实例化时还实例化GsmCallTracker(提供GSM
模式的CALL
管理)、GsmServiceStateTracker(提供GSM模式的服务状态管理)、CatService
对象(提供STK服务)。
< table width="732" cellspacing="0" cellpadding="0" border="1" style="margin: 0px auto; border: 1px solid rgb(192, 192, 192); border-collapse: collapse; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
mCT = new GsmCallTracker(this);
mSST = new GsmServiceStateTracker (this);
mSMS = new GsmSMSDispatcher(this, mSmsStorageMonitor, mSmsUsageMonitor);
mIccFileHandler = new SIMFileHandler(this);
mIccRecords = new SIMRecords(this);
mDataConnectionTracker = new GsmDataConnectionTracker (this);
mIccCard = new SimCard(this);
if (!unitTestMode) {
mSimPhoneBookIntManager = new SimPhoneBookInterfaceManager(this);
mSimSmsIntManager = new SimSmsInterfaceManager(this, mSMS);
mSubInfo = new PhoneSubInfo(this);
}
mStkService = CatService.getInstance(mCM, mIccRecords, mContext, mIccFileHandler, mIccCard);
|
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GSMCallTracker是
Android的通话管理层,
GsmCallTracker
派生自
Handler
的虚拟类
CallTracker;
GsmServiceStateTracker派生自
Handler
的虚拟类
ServiceStateTracker。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GsmCallTracker、
GsmServiceStateTracker对象分别提供
Call
状态
(
共有
IDLE, ACTIVE, HOLDING, DIALING, ALERTING, INCOMING, WAITING, DISCONNECTED, DISCONNECTING九种状态
)及
ServiceState
(共有
STATE_IN_SERVICE、
STATE_OUT_OF_SERVICE、
STATE_EMERGENCY_ONLY
、
STATE_POWER_OFF四种状态)的跟踪和管理,能够提供向
RIL层发送请求,接收和处理
RIL
层发来的命令响应事件及其它主动通知事件,如振铃等
CALL相关事件及
Service状态事件。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GsmCallTracker对象中还提供有三个
GsmCall对象(派生自抽象类
Call
):
ringingCall
(用来管理处于
INCOMING和
WAITING状态的通话)、
foregroundCall
(用来管理处于
DAILING、
ALERTING、
ACTIVE
状态的通话)、
backgroundCall
(用来管理
HOLD的通话)。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
每个
GsmCall可以同时有几路
connection
,因此
GsmCall
对象内部包含一个
Connection类型的
ArrayList对象,用来维护每个
CALL
拥有的
connection,一个
Call最大允许有
5个
connections。< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
另外
GSMCallTracker还包含一个
GsmConnection
类型(派生自抽象类
Connection)的数组对象
Connections,用来维护所有的现行的通话的列表,
GSMCallTracker
对象最大可维护
7路通话。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GsmConnection对象中有个成员变量:
GsmCall parent,这个成员变量是用来表示该
connection
是属于哪个
Call的,一个
Call可以有多个
Connection,但一个
Connection
只能属于一个
Call。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GsmServiceStateTracker对象中除了包括
ServiceState状态信息外,还包括
SignalStrength
信号强度等信息。< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GsmServiceStateTracker对象还维护
GSM CELL位置信息
,
因此包含两个
GsmCellLocation
对象成员
cellLoc(当前位置
) , newCellLoc( 新位置
)。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
GsmCallTracker、
GsmServiceStateTracker维护的状态和位置信息都通过
RIL
从
RIL daemon
获得,因此两个对象都包括一个指向
RIL的
CommandsInterface对象。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
CatService对象实现STK服务,
也是一个Handler对象,并实现AppInterface
接口。CatService
对象能够与RIL和STK应用交互:可以实现向RIL发送
Envelop
命令,以及从RIL接收STK
事件,解析事件流(包括Proactive Command)
,从STK应用接收命令执行结果编码后发给RIL。CatService
对象采用一个RilMessageDecoder状态机解析RIL发来的STK事件流。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
三
CDMAPhone
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
如下是CDMAPhone对象的相关类图。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
SMSDispatcher 、
DataConnectionTracker
、
IccFileHandler
、
IccRecords、
IccCard等抽象类对应的
CDMAPhone
对象中的派生类为
CdmaSMSDispatcher、
CdmaDataConnectionTracker、
RuimFileHandler
、
RuimRecords
、
RuimCard;
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
IccSmsInterfaceManager、
IccPhoneBookInterfaceManager、
PhoneSubInfo
服务在
CDMAPhone
对象中实现的派生类服务为
RuimSmsInterfaceManager、
RuimPhoneBookInterfaceManager
及
PhoneSubInfo;这些对象和服务都在
CDMAPhone对象实例化进行实例化。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
另外CDMAPhone对象在实例化时还实例化CdmaCallTracker、
CdmaServiceStateTracker、
CatService对象。以及一个EriManager对象用来加载ERI文件及管理CDMA漫游信息。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< table width="732" cellspacing="0" cellpadding="0" border="1" style="margin: 0px auto; border: 1px solid rgb(192, 192, 192); border-collapse: collapse; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
boolean unitTestMode) {
super(notifier, context, ci, unitTestMode);
initSstIcc();
init(context, notifier);
}
protected void initSstIcc() {
mSST = new CdmaServiceStateTracker(this);
mIccRecords = new RuimRecords(this);
mIccCard = new RuimCard(this, LOG_TAG, DBG);
mIccFileHandler = new RuimFileHandler(this);
}
protected void init(Context context, PhoneNotifier notifier) {
mCM.setPhoneType(Phone.PHONE_TYPE_CDMA);
mCT = new CdmaCallTracker(this);
mSMS = new CdmaSMSDispatcher(this, mSmsStorageMonitor, mSmsUsageMonitor);
mDataConnectionTracker = new CdmaDataConnectionTracker (this);
mRuimPhoneBookInterfaceManager = new RuimPhoneBookInterfaceManager(this);
mRuimSmsInterfaceManager = new RuimSmsInterfaceManager(this, mSMS);
mSubInfo = new PhoneSubInfo(this);
mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML);
mCcatService = CatService.getInstance(mCM, mIccRecords, mContext,
mIccFileHandler, mIccCard);
|
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
CdmaCallTracker提供
CDMA电话的通话管理功能,提供
CDMA Call
事件的处理,
CdmaCallTracker
派生自
Handler的虚拟类
CallTracker,用来管理
CALL
通话。和
GsmCallTracker相同,
CdmaCallTracker对象中也提供有三个
CdmaCall
类型的
Call
对象:
ringingCall、
foregroundCall、
backgroundCall。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
每个CdmaCall也包含一个Connection类型的ArrayList
对象,用来维护每个CALL
拥有的connection,但一个CdmaCall最大只允许有1
个
connection。同样CdmaCallTracker也包含一个CdmaConnection类型的数组对象Connections
,用来维护所有的现行的通话的列表,但Cdma最大也只允许1路现行通话。
< p style="line-height: 19px; margin: 5px auto; text-indent: 0px; color: rgb(75, 75, 75); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
CdmaServiceStateTracker派生自
Handler的虚拟类
ServiceStateTracker
,提供
CdmaService
状态的管理。
CdmaServiceStateTracker对象也维护
CELL
位置信息
,
因此和
GsmServiceStateTracker相同包含两个
CdmaCellLocation对象成员
cellLoc(
记录
CELL当前位置
) , newCellLoc(记录
CELL
新的位置
),用来记录
CELL位置信息。
网友评论 已有 0 条评论,查看更多评论»