From 32029978f8d99213df86ce7bab6b7a3d20aa589e Mon Sep 17 00:00:00 2001 From: Patty Huang Date: Wed, 6 Jul 2022 00:12:03 +0800 Subject: [PATCH] Add function for getting supported audio format for LE Audio Broadcast * Update function getHwOffloadFormatsSupportedForBluetoothMedia(), when the input device is AUDIO_DEVICE_OUT_BLE_HEADSET return the supported audio format for LE Audio unicast device * Update function getHwOffloadFormatsSupportedForBluetoothMedia() for getting the supported format of LE Audio broadcast Bug: 242472419 Test: atest AudioManagerTest Merged-In: I16de155597178fc8fdcb249e8625b8f78b334286 Change-Id: I16de155597178fc8fdcb249e8625b8f78b334286 --- core/api/module-lib-current.txt | 1 + media/java/android/media/AudioManager.java | 43 ++++++++++++++++------ media/java/android/media/AudioSystem.java | 7 ++-- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt index 3a94198c545b..5c6c2b195731 100644 --- a/core/api/module-lib-current.txt +++ b/core/api/module-lib-current.txt @@ -157,6 +157,7 @@ package android.media { method public void adjustSuggestedStreamVolumeForUid(int, int, int, @NonNull String, int, int, int); method @NonNull public java.util.List getHwOffloadFormatsSupportedForA2dp(); method @NonNull public java.util.List getHwOffloadFormatsSupportedForLeAudio(); + method @NonNull public java.util.List getHwOffloadFormatsSupportedForLeBroadcast(); method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void handleBluetoothActiveDeviceChanged(@Nullable android.bluetooth.BluetoothDevice, @Nullable android.bluetooth.BluetoothDevice, @NonNull android.media.BluetoothProfileConnectionInfo); method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void setA2dpSuspended(boolean); method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void setBluetoothHeadsetProperties(@NonNull String, boolean, boolean); diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 85911a37684d..16b7a009d90c 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -6963,22 +6963,13 @@ public class AudioManager { return codecConfigList; } - /** - * Returns a list of audio formats that corresponds to encoding formats - * supported on offload path for Le audio playback. - * - * @return a list of {@link BluetoothLeAudioCodecConfig} objects containing encoding formats - * supported for offload Le Audio playback - * @hide - */ - @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) - @NonNull - public List getHwOffloadFormatsSupportedForLeAudio() { + private List getHwOffloadFormatsSupportedForLeAudio( + @AudioSystem.BtOffloadDeviceType int deviceType) { ArrayList formatsList = new ArrayList<>(); ArrayList leAudioCodecConfigList = new ArrayList<>(); int status = AudioSystem.getHwOffloadFormatsSupportedForBluetoothMedia( - AudioSystem.DEVICE_OUT_BLE_HEADSET, formatsList); + deviceType, formatsList); if (status != AudioManager.SUCCESS) { Log.e(TAG, "getHwOffloadEncodingFormatsSupportedForLeAudio failed:" + status); return leAudioCodecConfigList; @@ -6995,6 +6986,34 @@ public class AudioManager { return leAudioCodecConfigList; } + /** + * Returns a list of audio formats that corresponds to encoding formats + * supported on offload path for Le audio playback. + * + * @return a list of {@link BluetoothLeAudioCodecConfig} objects containing encoding formats + * supported for offload Le Audio playback + * @hide + */ + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + @NonNull + public List getHwOffloadFormatsSupportedForLeAudio() { + return getHwOffloadFormatsSupportedForLeAudio(AudioSystem.DEVICE_OUT_BLE_HEADSET); + } + + /** + * Returns a list of audio formats that corresponds to encoding formats + * supported on offload path for Le Broadcast playback. + * + * @return a list of {@link BluetoothLeAudioCodecConfig} objects containing encoding formats + * supported for offload Le Broadcast playback + * @hide + */ + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + @NonNull + public List getHwOffloadFormatsSupportedForLeBroadcast() { + return getHwOffloadFormatsSupportedForLeAudio(AudioSystem.DEVICE_OUT_BLE_BROADCAST); + } + // Since we need to calculate the changes since THE LAST NOTIFICATION, and not since the // (unpredictable) last time updateAudioPortCache() was called by someone, keep a list // of the ports that exist at the time of the last notification. diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 474ccc939a4c..22033c6d8401 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -275,10 +275,11 @@ public class AudioSystem /** @hide */ @IntDef(flag = false, prefix = "DEVICE_", value = { DEVICE_OUT_BLUETOOTH_A2DP, - DEVICE_OUT_BLE_HEADSET} + DEVICE_OUT_BLE_HEADSET, + DEVICE_OUT_BLE_BROADCAST} ) @Retention(RetentionPolicy.SOURCE) - public @interface DeviceType {} + public @interface BtOffloadDeviceType {} /** * @hide @@ -1972,7 +1973,7 @@ public class AudioSystem * Returns a list of audio formats (codec) supported on the A2DP and LE audio offload path. */ public static native int getHwOffloadFormatsSupportedForBluetoothMedia( - @DeviceType int deviceType, ArrayList formatList); + @BtOffloadDeviceType int deviceType, ArrayList formatList); /** @hide */ public static native int setSurroundFormatEnabled(int audioFormat, boolean enabled);