summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2024-05-03 22:30:32 +0000
committer Mikhail Naganov <mnaganov@google.com> 2024-08-21 11:56:08 -0700
commit074801770af0e1724ddb269e6e23e4970ad38af4 (patch)
tree3b2aa69f31592dbc99a8f0a8ad407f4ac0759bd4
parent09e3851c0d8a7840079275358f484046ada3c68c (diff)
AudioService: do not mute music systematically in setBluetoothA2dpOn
Only mute music if an actual change in Bluetooth A2DP state happens when setBluetoothA2dpOn() is called. Bug: 334182057 Test: repro steps in bug. Change-Id: If2494dc9db1252cf1afb6ffcd600553b8140a191 Merged-In: If2494dc9db1252cf1afb6ffcd600553b8140a191
-rw-r--r--services/core/java/com/android/server/audio/AudioDeviceBroker.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index 5ed7c82012f3..d2c845dfcac8 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -274,8 +274,11 @@ public class AudioDeviceBroker {
}
/*package*/ void setBluetoothA2dpOn_Async(boolean on, String source) {
- mBluetoothA2dpEnabled.set(on);
- sendLMsgNoDelay(MSG_L_SET_FORCE_BT_A2DP_USE, SENDMSG_REPLACE, source);
+ boolean wasOn = mBluetoothA2dpEnabled.getAndSet(on);
+ // do not mute music if we do not anticipate a change in A2DP ON state
+ sendLMsgNoDelay(wasOn == on
+ ? MSG_L_SET_FORCE_BT_A2DP_USE_NO_MUTE : MSG_L_SET_FORCE_BT_A2DP_USE,
+ SENDMSG_REPLACE, source);
}
/**
@@ -1810,6 +1813,7 @@ public class AudioDeviceBroker {
onSetForceUse(msg.arg1, msg.arg2, false, (String) msg.obj);
break;
case MSG_L_SET_FORCE_BT_A2DP_USE:
+ case MSG_L_SET_FORCE_BT_A2DP_USE_NO_MUTE:
int forcedUsage = mBluetoothA2dpEnabled.get()
? AudioSystem.FORCE_NONE : AudioSystem.FORCE_NO_BT_A2DP;
onSetForceUse(AudioSystem.FOR_MEDIA, forcedUsage, true, (String) msg.obj);
@@ -2147,8 +2151,7 @@ public class AudioDeviceBroker {
private static final int MSG_I_UPDATE_LE_AUDIO_GROUP_ADDRESSES = 57;
private static final int MSG_L_SYNCHRONIZE_ADI_DEVICES_IN_INVENTORY = 58;
private static final int MSG_IL_UPDATED_ADI_DEVICE_STATE = 59;
-
-
+ private static final int MSG_L_SET_FORCE_BT_A2DP_USE_NO_MUTE = 60;
private static boolean isMessageHandledUnderWakelock(int msgId) {
switch(msgId) {