Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +21 −4 Original line number Diff line number Diff line Loading @@ -1774,22 +1774,39 @@ import java.util.concurrent.atomic.AtomicBoolean; MESSAGES_MUTE_MUSIC.add(MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT_DISCONNECTION); MESSAGES_MUTE_MUSIC.add(MSG_L_LE_AUDIO_DEVICE_OUT_CONNECTION_CHANGE_EXT); MESSAGES_MUTE_MUSIC.add(MSG_IIL_SET_FORCE_BT_A2DP_USE); MESSAGES_MUTE_MUSIC.add(MSG_REPORT_NEW_ROUTES_A2DP); } private AtomicBoolean mMusicMuted = new AtomicBoolean(false); boolean messageMutesMusic(int message) { if (message == 0) { return false; } // Do not mute if we are disconnecting an A2DP device and music is playing // on a wired headset. if ((message == MSG_IL_SET_A2DP_SINK_CONNECTION_STATE_DISCONNECTED || message == MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT_DISCONNECTION) && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) && mDeviceInventory.DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.contains( mAudioService.getDevicesForStream(AudioSystem.STREAM_MUSIC))) { return false; } return true; } /** Mutes or unmutes music according to pending A2DP messages */ private void checkMessagesMuteMusic(int message) { boolean mute = message != 0; boolean mute = messageMutesMusic(message); if (!mute) { for (int msg : MESSAGES_MUTE_MUSIC) { if (mBrokerHandler.hasMessages(msg)) { if (messageMutesMusic(msg)) { mute = true; break; } } } } if (mute != mMusicMuted.getAndSet(mute)) { mAudioService.setMusicMute(mute); Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +1 −1 Original line number Diff line number Diff line Loading @@ -581,7 +581,7 @@ public class AudioDeviceInventory { mDeviceBroker.postObserveDevicesForAllStreams(); } private static final Set<Integer> DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET; /* package */ static final Set<Integer> DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET; static { DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET = new HashSet<>(); DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADSET); Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +21 −4 Original line number Diff line number Diff line Loading @@ -1774,22 +1774,39 @@ import java.util.concurrent.atomic.AtomicBoolean; MESSAGES_MUTE_MUSIC.add(MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT_DISCONNECTION); MESSAGES_MUTE_MUSIC.add(MSG_L_LE_AUDIO_DEVICE_OUT_CONNECTION_CHANGE_EXT); MESSAGES_MUTE_MUSIC.add(MSG_IIL_SET_FORCE_BT_A2DP_USE); MESSAGES_MUTE_MUSIC.add(MSG_REPORT_NEW_ROUTES_A2DP); } private AtomicBoolean mMusicMuted = new AtomicBoolean(false); boolean messageMutesMusic(int message) { if (message == 0) { return false; } // Do not mute if we are disconnecting an A2DP device and music is playing // on a wired headset. if ((message == MSG_IL_SET_A2DP_SINK_CONNECTION_STATE_DISCONNECTED || message == MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT_DISCONNECTION) && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) && mDeviceInventory.DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.contains( mAudioService.getDevicesForStream(AudioSystem.STREAM_MUSIC))) { return false; } return true; } /** Mutes or unmutes music according to pending A2DP messages */ private void checkMessagesMuteMusic(int message) { boolean mute = message != 0; boolean mute = messageMutesMusic(message); if (!mute) { for (int msg : MESSAGES_MUTE_MUSIC) { if (mBrokerHandler.hasMessages(msg)) { if (messageMutesMusic(msg)) { mute = true; break; } } } } if (mute != mMusicMuted.getAndSet(mute)) { mAudioService.setMusicMute(mute); Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +1 −1 Original line number Diff line number Diff line Loading @@ -581,7 +581,7 @@ public class AudioDeviceInventory { mDeviceBroker.postObserveDevicesForAllStreams(); } private static final Set<Integer> DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET; /* package */ static final Set<Integer> DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET; static { DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET = new HashSet<>(); DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.add(AudioSystem.DEVICE_OUT_WIRED_HEADSET); Loading