From b42ba0836ba29237e2e519fce730d28eda89bf46 Mon Sep 17 00:00:00 2001 From: Ɓukasz Rymanowski Date: Tue, 21 Dec 2021 14:49:11 +0000 Subject: AudioDeviceInventory: Fix for switching leaudio active/inactive When LeAudio device gets Inactive and Active again, it will not be choosen by the Audio Policy as an output device due to this code: https://cs.android.com/android/platform/superproject/+/master:frameworks/av/services/audiopolicy/enginedefault/src/Engine.cpp;l=347;drc=master;bpv=1;bpt=1?q=engine.cpp&ss=android%2Fplatform%2Fsuperproject This is because AUDIO_POLICY_FORCE_NO_BT_A2DP is set. This patch fixes it. Bug: 211079178 Test: play media on LE HS and switch between DUT and LE HS Change-Id: I806a63ef2eaa98736130383bfc0387e5187b1803 --- .../core/java/com/android/server/audio/AudioDeviceInventory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index 0a114b924063..fba8c05065f2 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -1088,6 +1088,12 @@ public class AudioDeviceInventory { private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int device, String eventSource) { if (device != AudioSystem.DEVICE_NONE) { + + /* Audio Policy sees Le Audio similar to A2DP. Let's make sure + * AUDIO_POLICY_FORCE_NO_BT_A2DP is not set + */ + mDeviceBroker.setBluetoothA2dpOnInt(true, false /*fromA2dp*/, eventSource); + AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_AVAILABLE, address, name, AudioSystem.AUDIO_FORMAT_DEFAULT); mConnectedDevices.put(DeviceInfo.makeDeviceListKey(device, address), -- cgit v1.2.3-59-g8ed1b