Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f061047 authored by Alice Kuo's avatar Alice Kuo
Browse files

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
parent 7de9fc5e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -214,6 +214,9 @@ cc_library_static {
    ],
    target: {
        android: {
            whole_static_libs: [
                "libPlatformProperties",
            ],
            srcs: ["src/btif_avrcp_audio_track.cc"],
            shared_libs: ["libaaudio"],
        },
+28 −1
Original line number Diff line number Diff line
@@ -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
}

/*******************************************************************************