本文主要是介绍Android12 呼出电话呼叫中挂断后铃声继续响一下的处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
项目中遇到一个问题,测试同事测试电话时发现,呼出电话时,被呼叫电话非彩铃模式,本端设备播放“嗡~嗡~”正常呼叫音,未拨通时挂断电话,挂断后,在铃声未播放完成时会继续播放铃声,提出要优化为直接挂断,禁止有余音。最后搞定,我们总结下~
一捕获log:
呼出电话,然后挂断,记住响玲时间点,然后挂断。导出log。
二分析
- 设备有自定义手柄,该逻辑是需要根据手柄抬起/放下切换音频 通道,刚开始方案时声音从手柄切换到外放延迟3s,然后再切换音频通道。这样体验是可以的。但是连接蓝牙手柄时音频通道切换是走原生切换逻辑,说明该问题点不在音频通道切换这里。
- 分析log 根据导出来的log我们看下日志
【outcallringingdeley0808_095957\ap\000-0808_095935】 S064D87 08-08 09:59:56.406 1147 6829 I Telecom : CallsManager: setCallState DIALING -> DIALING, call: [Call id=TC@8//播放回铃音 R06560B 08-08 09:59:58.474 1357 1357 I ImsPhoneCall: maybeChangeRingbackState: state=ALERTING R06560C 08-08 09:59:58.474 1357 1357 I ImsPhoneCall: isLocalTone: audioDirection=0, playRingback=true S06562F 08-08 09:59:58.503 1147 1539 I Telecom : RingbackPlayer: Playing the ringback tone for [Call id=TC@8, state=DIALING, tpac=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, cmgr=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, handle=tel:*********78, vidst=A, childs(0), has_parent(false), cap=[ sup_hld mut VTlrx VTltx VTlbi], prop=[ HD]].: CSW.SRR(cap)@Ds0//挂掉电话,停止播放 M065BEF 08-08 10:00:07.488 6832 6832 I Dialer : InCallFragment.onClick - end call button clicked S065C4A 08-08 10:00:07.531 1147 2776 I Telecom : TelecomUtils: isSupportByCarrierConfig key:carrier_feature_play_rbk_bool value:false: ICA.dC(cad)@Dwg S065C52 08-08 10:00:07.532 1147 2776 I Telecom : RingbackPlayer: Stopping the ringback tone for [Call id=TC@8, state=DISCONNECTING, tpac=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, cmgr=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, handle=tel:*********78, vidst=A, childs(0), has_parent(false), cap=[ sup_hld mut VTlrx VTltx VTlbi], prop=[ HD]].: ICA.dC(cad)@Dwg//又播放回铃音?(state=DISCONNECTING不应该进入播放回铃音) S065C79 08-08 10:00:07.546 1147 2776 I Telecom : RingbackPlayer: Playing the ringback tone for [Call id=TC@8, state=DISCONNECTING, tpac=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, cmgr=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, handle=tel:*********78, vidst=A, childs(0), has_parent(false), cap=[ sup_hld mut VTlrx VTltx VTlbi], prop=[ HD]].: ICA.dC(cad)@Dwg//再停止播放 R066012 08-08 10:00:08.307 1357 1357 I ImsPhoneCall: maybeChangeRingbackState: state=DISCONNECTED R066013 08-08 10:00:08.307 1357 1357 I ImsPhoneCall: maybeChangeRingbackState: stop ringback M066030 08-08 10:00:08.337 1357 1357 V Telephony: MSG_RINGBACK_TONE S0660AD 08-08 10:00:08.397 1147 1214 I Telecom : RingbackPlayer: Stopping the ringback tone for [Call id=TC@8, state=DISCONNECTED, tpac=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, cmgr=ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, handle=tel:*********78, vidst=A, childs(0), has_parent(false), cap=[ sup_hld mut VTlrx VTltx VTlbi], prop=[ HD]].: CSW.sDc(cap)@DxQ S06605A 08-08 10:00:08.365 1147 1214 I Telecom : CallsManager: setCallState DISCONNECTING -> DISCONNECTED, call: [Call id=TC@8, state=DISCONNECTING (20240813T07:20:08)
三修改方案
diff --git a/src/com/android/server/telecom/CallAudioManager.java b/src/com/android/server/telecom/CallAudioManager.java
index d4a3afd00..c2ec064be 100644
--- a/src/com/android/server/telecom/CallAudioManager.java
+++ b/src/com/android/server/telecom/CallAudioManager.java
@@ -108,10 +108,18 @@ public class CallAudioManager extends CallsManagerListenerBase {@Overridepublic void onCallStateChanged(Call call, int oldState, int newState) {
+ printLog("onCallStateChanged: oldState:" + oldState +",newState:" +newState);if (shouldIgnoreCallForAudio(call)) {// No audio management for calls in a conference, or external calls.return;}
+
+ if (oldState == newState) {
+ // State did not change, so no need to do anything.
+ printLog("oldState == newState,return:");
+
+ return;
+ }Log.d(LOG_TAG, "Call state changed for TC@%s: %s -> %s", call.getId(),CallState.toString(oldState), CallState.toString(newState));@@ -124,15 +132,19 @@ public class CallAudioManager extends CallsManagerListenerBase {updateForegroundCall();if (shouldPlayDisconnectTone(oldState, newState)) {
+ printLog("onCallStateChanged: shouldPlayDisconnectTone(oldState, newState):" +shouldPlayDisconnectTone(oldState, newState));
+playToneForDisconnectedCall(call);}
参考文章
Android 通话流程相关分析
Android打电话流程
安卓10拨号流程详细总结
android N 拨打电话流程(MO)
这篇关于Android12 呼出电话呼叫中挂断后铃声继续响一下的处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!