当前位置: 首页 > news >正文

Android12 呼出电话呼叫中挂断后铃声继续响一下的处理


项目中遇到一个问题,测试同事测试电话时发现,呼出电话时,被呼叫电话非彩铃模式,本端设备播放“嗡~嗡~”正常呼叫音,未拨通时挂断电话,挂断后,在铃声未播放完成时会继续播放铃声,提出要优化为直接挂断,禁止有余音。最后搞定,我们总结下~

一捕获log:

呼出电话,然后挂断,记住响玲时间点,然后挂断。导出log。

二分析

  1. 设备有自定义手柄,该逻辑是需要根据手柄抬起/放下切换音频 通道,刚开始方案时声音从手柄切换到外放延迟3s,然后再切换音频通道。这样体验是可以的。但是连接蓝牙手柄时音频通道切换是走原生切换逻辑,说明该问题点不在音频通道切换这里。
  2. 分析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)


http://www.mrgr.cn/news/1643.html

相关文章:

  • 第132天:内网安全-横向移动Exchange服务有账户CVE漏洞无账户口令爆破
  • SpringCloud之服务提供与调用
  • AXI DMA IP的DRE对性能产生的影响
  • “软件定义汽车”时代,腾讯找到了怎样的身位?
  • 数字化转型底座-盘古信息IMS OS,可支撑构建MES/WMS/QCS/IoT等工业软件
  • UART通信实现与验证(RS485)
  • Python Web 应用和数据处理任务库之Redis Queue (RQ) 使用详解
  • Kafka面试题
  • Yolov10网络详解与实战(附数据集)
  • 【JavaScript】[]和{} 的转换
  • 自助酒店管理系统设计与实现
  • stm32—串口
  • 4.4、配置交换机vlan
  • 三节点 DMHS 级联同步搭建
  • EasyExcel基本使用
  • 分布式缓存———数据一致性问题
  • Playbook剧本案例实战
  • 【CUDA】【PyTorch】安装 PyTorch 与 CUDA 11.1 的详细步骤
  • 八股之数据库
  • PDF转图片 JAVA