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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章