网上关于拨号流程的文章有很多,大多讲逻辑,本文从logcat输出的日志入手。分析通话流程,还原系统应用真实的调试场景。
adb logcat -b main -b radio -v time >> call.log
用如上adb命令将拨号至接通电话的日志输出。
1-01 08:02:07.458 V/OutgoingCallBroadcaster( 786): - Broadcasting intent: Intent { act=android.intent.action.NEW_OUTGOING_CALL flg=0x10000000 (has extras) }.
OutgoingCallBroadcaster类发出拨号请求。
01-01 08:02:07.467 D/CallController( 786): placeCall()... intent = Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxx (has extras) } 01-01 08:02:07.467 D/CallController( 786): extras = Bundle[{android.phone.extra.ACTUAL_NUMBER_TO_DIAL=01058928914, com.android.phone.extra.video=false, com.android.phone.extra.slot=1}]
PhoneGlobals.getInstance().callController.placeCall(intent);调用CallController类的placeCall方法。log也输出了信息。
01-01 08:02:07.467 D/PhoneUtils( 786): getInitialNumber(): Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxx (has extras) } 01-01 08:02:07.467 D/PhoneUtils( 786): ==> got EXTRA_ACTUAL_NUMBER_TO_DIAL; returning ‘01058928914‘ 01-01 08:02:07.467 D/CallController( 786): - action: android.intent.action.CALL 01-01 08:02:07.468 D/CallController( 786): - uri: tel:01058928914
01-01 08:02:07.482 D/CallController( 786): placeCallInternal()... intent = Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxx (has extras) }
CallController会调用placeCall() placeCallInternal() 并启动画面。
PhoneUtils辅助类会对号码进行许多判断(如是否是紧急号码等)
01-01 08:02:07.489 D/PhoneUtils( 786): placeCall ‘01058928914‘ GW:‘null‘
从CallController的placeCallInternal()函数调用PhoneUtils的placeCall()方法
01-01 08:02:07.503 D/CallManager( 786): dial(Handler (com.android.internal.telephony.gsm.GSMPhone) {42522050}, 01058928914)
PhoneUtils的placeCall()方法中走到了CallManager的dial方法,但此时号码并没有真正拨出。继续看log。
01-01 08:02:07.503 D/CallManager( 786): - Ringing: IDLE from Handler (com.android.internal.telephony.gsm.GSMPhone) {424b3d50} 01-01 08:02:07.503 D/CallManager( 786): Phone: Handler (com.android.internal.telephony.gsm.GSMPhone) {424b3d50}, name = GSM, state = IDLE 01-01 08:02:07.503 D/CallManager( 786): - Foreground: IDLE Background: IDLE Ringing: IDLE
从日志中也可以看出此时拨号的状态,三个GsmCall对象还都是IDLE的状态
01-01 08:02:07.504 D/GSM ( 786): GSMPhone(2) :[CC][GsmPhone][SIM2] dial:01058928914 01-01 08:02:07.504 D/GSM ( 786): newDial:01058928914
走到GSMPhone的dial() 方法,此时从应用层进入了framework层了。
01-01 08:02:07.532 D/RILJ ( 786): RIL(2) :[0643]> DIAL
RIL层 向下发出dial指令 > 指的是向下层发送命令
01-01 08:02:07.535 D/AT ( 559): AT> ATD01058928914;
发送AT命令给modem层 指示要拨出的号码
01-01 08:02:07.539 D/CallManager( 786): End dial(Handler (com.android.internal.telephony.gsm.GSMPhone) {42522050}, 01058928914)
拨号命令发送结束
01-01 08:02:07.540 D/CallManager( 786): Phone: Handler (com.android.internal.telephony.gsm.GSMPhone) {42522050}, name = GSM, state = OFFHOOK 01-01 08:02:07.540 D/CallManager( 786): - Foreground: DIALING Background: IDLE Ringing: IDLE
正在拨号。。。
01-01 08:02:07.560 D/PhoneGlobals( 786): displayCallScreen()...
01-01 08:02:07.562 D/AT ( 559): AT< OK
返回OK命令。
01-01 08:02:07.569 D/RILJ ( 786): RIL(2) :[0643]< DIAL
返回正在拨号的状态
从通话日志分析android 4.4.2 phone的拨号流程,布布扣,bubuko.com
时间: 2024-12-31 03:38:17