From 3f061047f81e34c14859b603d8a0a213831bf170 Mon Sep 17 00:00:00 2001 From: Alice Kuo <aliceypkuo@google.com> Date: Tue, 10 Oct 2023 03:14:43 +0800 Subject: [PATCH] Update CoD LE audio bit based on the feature system properties From BAP, the device should set the LE audio bit 14 in CoD. It's hard to update the CoD per project setting. BT stack would check the feature enable system properties to update the CoD LE audio bit automatically. Bug: 263747231 Test: m com.android.btservices Change-Id: Ieb8c50babb87d7704e2c1e8e91a511063d6d9a66 --- system/btif/Android.bp | 3 +++ system/btif/src/btif_dm.cc | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/system/btif/Android.bp b/system/btif/Android.bp index 580cb8e230b..61441672d1e 100644 --- a/system/btif/Android.bp +++ b/system/btif/Android.bp @@ -214,6 +214,9 @@ cc_library_static { ], target: { android: { + whole_static_libs: [ + "libPlatformProperties", + ], srcs: ["src/btif_avrcp_audio_track.cc"], shared_libs: ["libaaudio"], }, diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc index 5f4b95e6f42..a04095db4b1 100644 --- a/system/btif/src/btif_dm.cc +++ b/system/btif/src/btif_dm.cc @@ -95,6 +95,10 @@ #include "stack_config.h" #include "types/raw_address.h" +#ifdef OS_ANDROID +#include <android/sysprop/BluetoothProperties.sysprop.h> +#endif + bool btif_get_device_type(const RawAddress& bda, int* p_device_type); using bluetooth::Uuid; @@ -2934,8 +2938,31 @@ void btif_dm_get_local_class_of_device(DEV_CLASS device_class) { LOG_ERROR("%s: COD malformed, fewer than three numbers", __func__); } - LOG_DEBUG("%s: Using class of device '0x%x, 0x%x, 0x%x'", __func__, + LOG_DEBUG("Using class of device '0x%x, 0x%x, 0x%x' from CoD system property", device_class[0], device_class[1], device_class[2]); + +#ifdef OS_ANDROID + // Per BAP 1.0.1, 8.2.3. Device discovery, the stack needs to set Class of + // Device (CoD) field Major Service Class bit 14 to 0b1 when Unicast Server, + // Unicast Client, Broadcast Source, Broadcast Sink, Scan Delegator, or + // Broadcast Assistant is supported on this device + if (android::sysprop::BluetoothProperties::isProfileBapUnicastClientEnabled() + .value_or(false) || + android::sysprop::BluetoothProperties:: + isProfileBapBroadcastAssistEnabled() + .value_or(false) || + android::sysprop::BluetoothProperties:: + isProfileBapBroadcastSourceEnabled() + .value_or(false)) { + device_class[1] |= 0x01 << 6; + } else { + device_class[1] &= ~(0x01 << 6); + } + LOG_DEBUG( + "Check LE audio enabled status, update class of device to '0x%x, 0x%x, " + "0x%x'", + device_class[0], device_class[1], device_class[2]); +#endif } /******************************************************************************* -- GitLab