From eb9419fb2da9582cfcb7a1685e72f76a4df777d3 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 4 Aug 2023 16:40:12 +0200 Subject: [PATCH] AudioDeviceInventory: fix LE Audio Broadcast device name. Make sure a non empty device name is provided for LE Audio broadcast devices as the this is needed for proper MediaRouter operation. The device name is not provided by th eBT stack for broadcast devices. Bug: 290701463 Test: make Change-Id: Ibe34660d589b18a1801cb51efd87822c33c822b0 --- .../com/android/server/audio/AudioDeviceInventory.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index 5a92cb4649502..13e3fc7852e91 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -2070,12 +2070,18 @@ public class AudioDeviceInventory { @GuardedBy("mDevicesLock") private void makeLeAudioDeviceAvailable( AudioDeviceBroker.BtDeviceInfo btInfo, int streamType, String eventSource) { - final String address = btInfo.mDevice.getAddress(); - final String name = BtHelper.getName(btInfo.mDevice); final int volumeIndex = btInfo.mVolume == -1 ? -1 : btInfo.mVolume * 10; final int device = btInfo.mAudioSystemDevice; if (device != AudioSystem.DEVICE_NONE) { + final String address = btInfo.mDevice.getAddress(); + String name = BtHelper.getName(btInfo.mDevice); + + // The BT Stack does not provide a name for LE Broadcast devices + if (device == AudioSystem.DEVICE_OUT_BLE_BROADCAST && name.equals("")) { + name = "Broadcast"; + } + /* Audio Policy sees Le Audio similar to A2DP. Let's make sure * AUDIO_POLICY_FORCE_NO_BT_A2DP is not set */