android phone application 通知missed call的过程

 

 
phone app怎么判断missed call的  
 
正序:
phone disconnect (对方打来,没来得及接听,对方挂断,成为missed call),过程:
 
RIL --> ... ->  --msg3-->
GsmCallTracker -->
GsmConnect.onDisconnect/onRemoteDisconnect -->  
GsmPhone.onDisconnect ---msg2--->
CallManager.handleMsg ---msg1--->
PhoneApp的CallNotifier.handleMsg --> 
CallNotifier.onDisconnect,判断cause为missed call  -->
NotificationManager显示
 
倒序和解释:
 
phone app中CallNotifier.java负责监听状态,并更新UI。
它注册了onDisconnect方法.还有很多事件,比如connect,这里只以disconnect为例
注册是通过internal api com.android.internal.telephony.CallManager
registerfordisconnect做到
callmanager很好用,能注册接听,挂断,注册事件等,但是hide
 
当phone disconnect时,可能是对方挂断或者己方挂断,call manager会把disconnect msg1发给phone app,
msg里有个Connection对象(telephony internal api),
Connection里面有disconnectCause域,在missed call情况下,值为MISSED_CALL。
callnotifier.java会调用NotificationManager.java的方法通知miss call到手机通知栏
 
call-manager通过registerPhone(Phone phone),registerForPhoneStates,并把自己作为handler,
得到phone state消息后,例如disconnect,再通过msg2告诉phone app:
mDisconnectRegistrants.notifyRegistrants((AsyncResult) msg.obj);
 
 
而registerPhone(Phone phone)是phone app调用的,   其中的phone对象是phone app在onCreate时创建的
   428            PhoneFactory.makeDefaultPhones(this);
   429
   430             // Get the default phone
   431             phone = PhoneFactory.getDefaultPhone();
   432
   433             mCM = CallManager.getInstance();
   434             mCM.registerPhone(phone);
PhoneFactory.makeDefaultPhones(this);
 
RIL msg3 略
 
 
不错的参考文章:
 
http://hi.baidu.com/weiyousheng/blog/item/a7255ef4e2438c7dddc4748c.html
http://www.360doc.com/content/11/0222/11/474846_95043329.shtml
http://newfaction.net/2011/03/15/android-2-2-ril-java-part-of-the-code-profile.html
http://www.cnblogs.com/Tiger-Dog/articles/2056273.html  
http://www.meegozu.com/thread-391-1-1.html
 
 
android 1.1的telephony相关文章,很老,结构已经发展了,但仍可以借鉴
http://www.kandroid.org/online-pdk/guide/telephony.html 
http://www.linuxjournal.com/magazine/java-api-androids-telephony-stack
http://www.netmite.com/android/mydroid/development/pdk/docs/telephony.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章