由于类似平板、贩卖机、车载等产品定义上都没有听筒这种音频设备,因此会经常遇到这样一个需求:强制免提。
以下是修改diff,请参考。
如果只是APK修改的话,可以参考:
diff --git a/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java b/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java
index 78a92eb..b87ffbb 100644
--- a/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java
+++ b/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java
@@ -379,7 +379,12 @@ public class CallAudioManager extends CallsManagerListenerBase {
* @param route The new audio route to use. See {@link CallAudioState}.
*/
void setAudioRoute(int route) {
- Log.v(this, "setAudioRoute, route: %s", CallAudioState.audioRouteToString(route));
+ Log.v(this, "setAudioRoute,before Changed route: %s", CallAudioState.audioRouteToString(route));
+ if(CallAudioState.ROUTE_EARPIECE == route || CallAudioState.ROUTE_WIRED_OR_EARPIECE == route){
+ route = CallAudioState.ROUTE_SPEAKER;
+ }
+ Log.v(this, "setAudioRoute,after Changed route: %s", CallAudioState.audioRouteToString(route));
switch (route) {
case CallAudioState.ROUTE_BLUETOOTH:
mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
如果想一劳永逸的话,可以参考,以高通8953平台代码为例:
diff --git a/hardware/qcom/audio/configs/msm8953/audio_policy_configuration.xml b/hardware/qcom/audio/configs/msm8953/audio_policy_configuration.xml
old mode 100644
new mode 100755
index ea4b140..e016954
--- a/hardware/qcom/audio/configs/msm8953/audio_policy_configuration.xml
+++ b/hardware/qcom/audio/configs/msm8953/audio_policy_configuration.xml
@@ -49,7 +49,6 @@
<!-- Primary Audio HAL -->
<module name="primary" halVersion="2.0">
<attachedDevices>
- <item>Earpiece</item>
<item>Speaker</item>
<item>Telephony Tx</item>
<item>Built-In Mic</item>
@@ -171,10 +170,6 @@
<devicePorts>
<!-- Output devices declaration, i.e. Sink DEVICE PORT -->
- <devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink">
- <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
- samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
- </devicePort>
<devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER" address="">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
@@ -255,8 +250,6 @@
</devicePorts>
<!-- route declaration, i.e. list all available sources for a given sink -->
<routes>
- <route type="mix" sink="Earpiece"
- sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Speaker"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Wired Headset"