diff --git a/system/btif/Android.bp b/system/btif/Android.bp index 580cb8e230b5f2100c7f93ff56124a7a1f92faa1..61441672d1e699063d63e139d86382630a20e6fb 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 5f4b95e6f428a0b0ea6c43fe3794c931526e655b..a04095db4b13f7dd2ed1dd8d1c987c47904a0c72 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 } /*******************************************************************************