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

Commit 49f1bb77 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Add upper tester flag for multiple CCID

This is needed to pass some of the qualification tests.

Bug: 240145685
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test bluetooth_test_broadcaster_state_machine bluetooth_test_broadcaster --no-bazel-mode
Change-Id: I47eca845ee07cdabdf093389bc5810cf9eaf2d5b
Merged-In: I47eca845ee07cdabdf093389bc5810cf9eaf2d5b
(cherry picked from commit 69a2cd2b)
parent 7bc6148d
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "device/include/controller.h"
#include "embdrv/lc3/include/lc3.h"
#include "gd/common/strings.h"
#include "internal_include/stack_config.h"
#include "osi/include/log.h"
#include "osi/include/properties.h"
#include "stack/include/btm_api_types.h"
@@ -263,6 +264,27 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks {
    uint16_t context_type =
        static_cast<std::underlying_type<LeAudioContextType>::type>(
            LeAudioContextType::MEDIA);

    /* Adds multiple contexts and CCIDs regardless of the incoming audio
     * context. Android has only two CCIDs, one for Media and one for
     * Conversational context. Even though we are not broadcasting
     * Conversational streams, some PTS test cases wants multiple CCIDs.
     */
    if (stack_config_get_interface()
            ->get_pts_force_le_audio_multiple_contexts_metadata()) {
      context_type =
          static_cast<std::underlying_type<LeAudioContextType>::type>(
              LeAudioContextType::MEDIA) |
          static_cast<std::underlying_type<LeAudioContextType>::type>(
              LeAudioContextType::CONVERSATIONAL);
      auto stream_context_vec =
          ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext);
      if (stream_context_vec) {
        auto pp = stream_context_vec.value().data();
        UINT16_TO_STREAM(pp, context_type);
      }
    }

    auto stream_context_vec =
        ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext);
    if (stream_context_vec) {
@@ -302,6 +324,27 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks {
    uint16_t context_type =
        static_cast<std::underlying_type<LeAudioContextType>::type>(
            LeAudioContextType::MEDIA);

    /* Adds multiple contexts and CCIDs regardless of the incoming audio
     * context. Android has only two CCIDs, one for Media and one for
     * Conversational context. Even though we are not broadcasting
     * Conversational streams, some PTS test cases wants multiple CCIDs.
     */
    if (stack_config_get_interface()
            ->get_pts_force_le_audio_multiple_contexts_metadata()) {
      context_type =
          static_cast<std::underlying_type<LeAudioContextType>::type>(
              LeAudioContextType::MEDIA) |
          static_cast<std::underlying_type<LeAudioContextType>::type>(
              LeAudioContextType::CONVERSATIONAL);
      auto stream_context_vec =
          ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext);
      if (stream_context_vec) {
        auto pp = stream_context_vec.value().data();
        UINT16_TO_STREAM(pp, context_type);
      }
    }

    auto stream_context_vec =
        ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext);
    if (stream_context_vec) {
+54 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include "embdrv/lc3/include/lc3.h"
#include "gatt/bta_gattc_int.h"
#include "gd/common/strings.h"
#include "internal_include/stack_config.h"
#include "le_audio_set_configuration_provider.h"
#include "le_audio_types.h"
#include "le_audio_utils.h"
@@ -3140,6 +3141,40 @@ class LeAudioClientImpl : public LeAudioClient {
    metadata_context_types_ = GetAllowedAudioContextsFromSourceMetadata(
        source_metadata, group->GetActiveContexts());

    if (stack_config_get_interface()
            ->get_pts_force_le_audio_multiple_contexts_metadata()) {
      // Use common audio stream contexts exposed by the PTS
      metadata_context_types_ = 0xFFFF;
      for (auto device = group->GetFirstDevice(); device != nullptr;
           device = group->GetNextDevice(device)) {
        metadata_context_types_ &= device->GetAvailableContexts();
      }
      if (metadata_context_types_ == 0xFFFF) {
        metadata_context_types_ =
            static_cast<uint16_t>(LeAudioContextType::UNSPECIFIED);
      }
      LOG_WARN("Overriding metadata_context_types_ with: %lu",
               metadata_context_types_.to_ulong());

      /* Configuration is the same for new context, just will do update
       * metadata of stream
       */
      auto new_configuration_context =
          ChooseConfigurationContextType(metadata_context_types_);
      GroupStream(active_group_id_,
                  static_cast<uint16_t>(new_configuration_context),
                  metadata_context_types_);
      return;
    }

    if (metadata_context_types_.none()) {
      LOG_WARN(
          " invalid/unknown context metadata, using 'UNSPECIFIED' instead");
      metadata_context_types_ =
          static_cast<std::underlying_type<LeAudioContextType>::type>(
              LeAudioContextType::UNSPECIFIED);
    }

    auto new_configuration_context =
        ChooseConfigurationContextType(metadata_context_types_);
    LOG_DEBUG("new_configuration_context_type: %s",
@@ -3192,6 +3227,25 @@ class LeAudioClientImpl : public LeAudioClient {
      return;
    }

    if (stack_config_get_interface()
            ->get_pts_force_le_audio_multiple_contexts_metadata()) {
      // Use common audio stream contexts exposed by the PTS
      metadata_context_types_ = 0xFFFF;
      for (auto device = group->GetFirstDevice(); device != nullptr;
           device = group->GetNextDevice(device)) {
        metadata_context_types_ &= device->GetAvailableContexts();
      }
      if (metadata_context_types_ == 0xFFFF) {
        metadata_context_types_ =
            static_cast<uint16_t>(LeAudioContextType::UNSPECIFIED);
      }
      metadata_context_types_ =
          metadata_context_types_.to_ulong() |
          static_cast<uint16_t>(LeAudioContextType::VOICEASSISTANTS);
      LOG_WARN("Overriding metadata_context_types_ with: %lu",
               metadata_context_types_.to_ulong());
    }

    /* Do nothing, since audio source is not valid and if voice assistant
     * scenario is currently not supported by group
     */
+42 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "fake_osi.h"
#include "gatt/database_builder.h"
#include "hardware/bt_gatt_types.h"
#include "internal_include/stack_config.h"
#include "le_audio_set_configuration_provider.h"
#include "le_audio_types.h"
#include "mock_controller.h"
@@ -119,6 +120,47 @@ static void cleanup_message_loop_thread() {
void invoke_switch_codec_cb(bool is_low_latency_buffer_size) {}
void invoke_switch_buffer_size_cb(bool is_low_latency_buffer_size) {}

const std::string kSmpOptions("mock smp options");
bool get_trace_config_enabled(void) { return false; }
bool get_pts_avrcp_test(void) { return false; }
bool get_pts_secure_only_mode(void) { return false; }
bool get_pts_conn_updates_disabled(void) { return false; }
bool get_pts_crosskey_sdp_disable(void) { return false; }
const std::string* get_pts_smp_options(void) { return &kSmpOptions; }
int get_pts_smp_failure_case(void) { return 123; }
bool get_pts_force_eatt_for_notifications(void) { return false; }
bool get_pts_connect_eatt_unconditionally(void) { return false; }
bool get_pts_connect_eatt_before_encryption(void) { return false; }
bool get_pts_unencrypt_broadcast(void) { return false; }
bool get_pts_eatt_peripheral_collision_support(void) { return false; }
bool get_pts_force_le_audio_multiple_contexts_metadata(void) { return false; }
config_t* get_all(void) { return nullptr; }

stack_config_t mock_stack_config{
    .get_trace_config_enabled = get_trace_config_enabled,
    .get_pts_avrcp_test = get_pts_avrcp_test,
    .get_pts_secure_only_mode = get_pts_secure_only_mode,
    .get_pts_conn_updates_disabled = get_pts_conn_updates_disabled,
    .get_pts_crosskey_sdp_disable = get_pts_crosskey_sdp_disable,
    .get_pts_smp_options = get_pts_smp_options,
    .get_pts_smp_failure_case = get_pts_smp_failure_case,
    .get_pts_force_eatt_for_notifications =
        get_pts_force_eatt_for_notifications,
    .get_pts_connect_eatt_unconditionally =
        get_pts_connect_eatt_unconditionally,
    .get_pts_connect_eatt_before_encryption =
        get_pts_connect_eatt_before_encryption,
    .get_pts_unencrypt_broadcast = get_pts_unencrypt_broadcast,
    .get_pts_eatt_peripheral_collision_support =
        get_pts_eatt_peripheral_collision_support,
    .get_pts_force_le_audio_multiple_contexts_metadata =
        get_pts_force_le_audio_multiple_contexts_metadata,
    .get_all = get_all,
};
const stack_config_t* stack_config_get_interface(void) {
  return &mock_stack_config;
}

namespace le_audio {
namespace {
class MockLeAudioClientCallbacks
+3 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ TRC_HID_DEV=2
# Use EATT for all services
#PTS_UseEattForAllServices=true

# Force to update metadata with multiple CCIDs
#PTS_ForceLeAudioMultipleContextsMetadata=true

# SMP Certification Failure Cases
# Set any of the following SMP error values (from smp_api_types.h)
# to induce pairing failues for various PTS SMP test cases.
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ typedef struct {
  bool (*get_pts_unencrypt_broadcast)(void);
  bool (*get_pts_eatt_peripheral_collision_support)(void);
  bool (*get_pts_use_eatt_for_all_services)(void);
  bool (*get_pts_force_le_audio_multiple_contexts_metadata)(void);
  bool (*get_pts_l2cap_ecoc_upper_tester)(void);
  int (*get_pts_l2cap_ecoc_min_key_size)(void);
  int (*get_pts_l2cap_ecoc_initial_chan_cnt)(void);
Loading