Android Telephony 分析[PART I]
来源:互联网 发布:ubuntu记事本 编辑:程序博客网 时间:2024/06/11 04:03
11年下半年一直在做RIL的移植,主要解决第三方库的一些bug,使之能更好的工作在公司的PAD上。但是后来发现远远不够,有好多问题出现在Framework层。比方说我们想让PAD支持热插拔,尽管底层做好了,但上层还会出现很多问题,如PIN/PUK解锁功能,用户把解锁PIN/PUK的界面打开但同时他把卡拔掉了,此时是无法解锁的,系统该如何响应此时的情况,我们该怎么做,这都是需要了解Telephony Framework之后才知道如何实现的。
于是研究了一番Telephony的Java框架,刚开始接触时感觉挺复杂很混乱,现在理清了关系,所以希望能帮到那些还在纠结中的同志。
我想大致以网络连接为例分析Android Telephony Framework层,关于ril及其移植的文章有很多所以就不赘述了。
以下部分内容引自前段时期我关于Telephony的总结做的PPT,参考了不少前辈的文章,用英文写的,懒得再译回来了,凑合着看吧(当时为了翻译成英文还煞费苦心- -!),需要PPT原件可以在此 http://wenku.baidu.com/view/bfe5361afad6195f312ba61c.html 下载,重要的和难理解的地方会做些解释,文章较长,一篇日志不让保存所以共分为四部分。
先来个整体结构图,有个大致印象,看完本文回头再看应该会有更深的理解。
![[原创]Android Telephony 分析[PART I] - 〇〇柒 - 朝阳光出发](http://img3.ph.126.net/ktr7cGJQ7dxnFxqg5agDmw==/2278821411466358493.jpg)
1.Telephony Framework
Telephony framework contains a set of telephony API for applications. There are twocategaries of JAVApacakges in telephony framework:
1.The internal telephony packages -
com.android.internal.telephony.*,
source code:frameworks/base/telephony/java/com/android/internal/telephony
2.The open telephony packages -
android.telephony.*.
source code:frameworks/base/telephony/java/android/telephony
The internal packages are used for Android default telephony application -Phone.apk, and the open packages are for any 3rd party telephony applications.
![[原创]Android Telephony 分析[PART I] - 〇〇柒 - 朝阳光出发](http://img5.ph.126.net/MfYXoj62ytXZq62iKkSBqQ==/2566770312641813425.jpg)
Internal Telephony Packages:
frameworks/base/telephony/java/com/android/internal/telephony
The public interface Phone is used to control the phone. The abstract classPhoneBase implements this interface. And the classGSMPhone extends this abstract class.
Phone.java
44 public interface Phone{326 String getPhoneName();332 int getPhoneType();1118 void setPreferredNetworkType(int networkType, Message response);1125 void getPreferredNetworkType(Message response); ...
The default telephony application could usemakeDefaultPhones() andgetDefaultPhone() in the classPhoneFactory to obtain the unique instance of Phone. The code below shows how this be done.
packages/apps/Phone/src/com/android/phone/PhoneApp.java
410 public void onCreate() { ...425 if (phone == null) {426 // Initialize the telephonyframework427 PhoneFactory.makeDefaultPhones(this);428429 // Get the default phone430 phone = PhoneFactory.getDefaultPhone();
PhoneFactory.java
56 public static void makeDefaultPhone(Context context) { ...130 sCommandsInterface = new RIL(context, networkMode, cdmaSubscription); 132 int phoneType = getPhoneType(networkMode); if (phoneType == Phone.PHONE_TYPE_GSM) {135 sProxyPhone = new PhoneProxy(new GSMPhone(context, sCommandsInterface, sPhoneNotifier));137 } else if (phoneType == Phone.PHONE_TYPE_CDMA) {
Let’s suppose the current network mode is in GSM/GPRS, so the default telephony application could obtain aPhoneProxy to aGSMPhone, and use its API to achieve telephony functionalities.ProxyPhone is also extended fromPhone. It is used to abstract the specific instance of a specific network mode.
PhoneProxy.java
57 public PhoneProxy(Phone phone) {
58 mActivePhone = phone;
...
66 mCommandsInterface = ((PhoneBase)mActivePhone).mCM;
67 mCommandsInterface.registerForRadioTechnologyChanged(
68 this, EVENT_RADIO_TECHNOLOGY_CHANGED, null);
69 }
...
549 public void getPreferredNetworkType(Message response) {
550 mActivePhone.getPreferredNetworkType(response);
551 }
The class PhoneBase has a membermCM of the typeCommandsInterface. And this is assigned in the constructor ofGSMPhone.
GSMPhone.java
130 GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier,
boolean unitTestMode) {
131 super(notifier, context, ci, unitTestMode);
...
PhoneBase.java
114 public CommandsInterface mCM;
...
203 protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci,
204 boolean unitTestMode) {
207 mLooper = Looper.myLooper();
...
757 public void getPreferredNetworkType(Message response) {
758 mCM.getPreferredNetworkType(response);
759 }
- Android Telephony 分析[PART I]
- Android Telephony 分析[PART IV]
- Android Telephony 分析【全】
- Android Telephony 框架分析
- Android 6.0 telephony 状态分析
- Android Telephony启动过程源码分析
- 学着分析android framework telephony
- Android Telephony分析(一) ---- Phone详解
- Android Telephony分析(二) ---- RegistrantList详解
- Android Telephony分析(三) ---- RILJ详解
- Android Telephony分析(四) ---- TelephonyManager详解
- Android Telephony分析(五) ---- TelephonyRegistry详解
- Android Telephony分析(一) ---- Phone详解
- Android Telephony分析(二) ---- RegistrantList详解
- Android Telephony分析(三) ---- RILJ详解
- Android Telephony分析(四) ---- TelephonyManager详解
- Android Telephony分析(五) ---- TelephonyRegistry详解
- Android Telephony分析(一) ---- Phone详解
- PHP SESSION Name 引用SESSION ID(SESSION NAME与SESSION ID的关系) Discuz! 用户(自动)登录原理
- 2020年互联网如何赚钱:设备碎片化并不怕
- The Target of Cocoa application
- MiniGUI1.6.10交叉编译配置以及开发板移植-Ubunbu11.10
- 希捷原装移动硬盘拆壳
- Android Telephony 分析[PART I]
- OLED技术泄密 技术争夺战全面打响
- iPhone开发进阶--利用ModalViewController切换View
- QT中的元对象系统(一):QVariant的简单说明
- Android MMS模块数据存取
- paip.AJAX回调函数不起作用的解决
- Defining Classes and Objects
- Python 判斷目前的 DLL or EXE 是32bit 還是 64bit
- QT中的元对象系统(二):创建自定义的QT类型