PhoneApp.java

来源:互联网 发布:js字符串转date类型 编辑:程序博客网 时间:2024/05/23 17:14

Phone模块代码位于/packages/apps/Phone/src/com/android/phone/下,其中,PhoneApp.java, 和CallNotifier.java是常驻进程,前者负责与其它应用的交互,后者通过rail层,上报BP的命令。

 

PhoneApp继承于Application类,内部定义一个Handler处理外部消息,如EVENT_SIM_LOCKED(SIM卡锁),EVENT_WIRED_HEADSET_PLUG(耳机插入)等。

 


onCreate()构造像Phone, NotificationMgr, Ring, BluetoothHandsfree的对象,

// Initialize the telephony framework
PhoneFactory.makeDefaultPhones(this);

// Get the default phone
phone = PhoneFactory.getDefaultPhone();
这里factory一个phone出来,GSMPhone或者CDMAPhone,

 

sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null);
sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null);
sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
注册信号,新号到达时,进行相应处理

 

针对phone的三个状态,IDLE, RINGING, OFFHOOK, 对音频进行相应设置,

 

.......

 

针对新号的处理,出了上面提到的Handler,PhoneApp还设置了一个PhoneAppBroadcastReceiver与其进行配合运作。

原创粉丝点击