Loading system/bta/le_audio/broadcaster/broadcaster.cc +43 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "device/include/controller.h" #include "device/include/controller.h" #include "embdrv/lc3/include/lc3.h" #include "embdrv/lc3/include/lc3.h" #include "gd/common/strings.h" #include "gd/common/strings.h" #include "internal_include/stack_config.h" #include "osi/include/log.h" #include "osi/include/log.h" #include "osi/include/properties.h" #include "osi/include/properties.h" #include "stack/include/btm_api_types.h" #include "stack/include/btm_api_types.h" Loading Loading @@ -264,6 +265,27 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks { uint16_t context_type = uint16_t context_type = static_cast<std::underlying_type<LeAudioContextType>::type>( static_cast<std::underlying_type<LeAudioContextType>::type>( LeAudioContextType::MEDIA); 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 = auto stream_context_vec = ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); if (stream_context_vec) { if (stream_context_vec) { Loading Loading @@ -303,6 +325,27 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks { uint16_t context_type = uint16_t context_type = static_cast<std::underlying_type<LeAudioContextType>::type>( static_cast<std::underlying_type<LeAudioContextType>::type>( LeAudioContextType::MEDIA); 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 = auto stream_context_vec = ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); if (stream_context_vec) { if (stream_context_vec) { Loading system/bta/le_audio/client.cc +54 −0 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include "embdrv/lc3/include/lc3.h" #include "embdrv/lc3/include/lc3.h" #include "gatt/bta_gattc_int.h" #include "gatt/bta_gattc_int.h" #include "gd/common/strings.h" #include "gd/common/strings.h" #include "internal_include/stack_config.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_types.h" #include "le_audio_types.h" #include "le_audio_utils.h" #include "le_audio_utils.h" Loading Loading @@ -3140,6 +3141,40 @@ class LeAudioClientImpl : public LeAudioClient { metadata_context_types_ = GetAllowedAudioContextsFromSourceMetadata( metadata_context_types_ = GetAllowedAudioContextsFromSourceMetadata( source_metadata, group->GetActiveContexts()); 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 = auto new_configuration_context = ChooseConfigurationContextType(metadata_context_types_); ChooseConfigurationContextType(metadata_context_types_); LOG_DEBUG("new_configuration_context_type: %s", LOG_DEBUG("new_configuration_context_type: %s", Loading Loading @@ -3192,6 +3227,25 @@ class LeAudioClientImpl : public LeAudioClient { return; 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 /* Do nothing, since audio source is not valid and if voice assistant * scenario is currently not supported by group * scenario is currently not supported by group */ */ Loading system/bta/le_audio/le_audio_client_test.cc +42 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "fake_osi.h" #include "fake_osi.h" #include "gatt/database_builder.h" #include "gatt/database_builder.h" #include "hardware/bt_gatt_types.h" #include "hardware/bt_gatt_types.h" #include "internal_include/stack_config.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_types.h" #include "le_audio_types.h" #include "mock_controller.h" #include "mock_controller.h" Loading Loading @@ -119,6 +120,47 @@ static void cleanup_message_loop_thread() { void invoke_switch_codec_cb(bool is_low_latency_buffer_size) {} void invoke_switch_codec_cb(bool is_low_latency_buffer_size) {} void invoke_switch_buffer_size_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 le_audio { namespace { namespace { class MockLeAudioClientCallbacks class MockLeAudioClientCallbacks Loading system/conf/bt_stack.conf +3 −0 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,9 @@ TRC_HID_DEV=2 # Use EATT for all services # Use EATT for all services #PTS_UseEattForAllServices=true #PTS_UseEattForAllServices=true # Force to update metadata with multiple CCIDs #PTS_ForceLeAudioMultipleContextsMetadata=true # SMP Certification Failure Cases # SMP Certification Failure Cases # Set any of the following SMP error values (from smp_api_types.h) # Set any of the following SMP error values (from smp_api_types.h) # to induce pairing failues for various PTS SMP test cases. # to induce pairing failues for various PTS SMP test cases. Loading system/internal_include/stack_config.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ typedef struct { bool (*get_pts_unencrypt_broadcast)(void); bool (*get_pts_unencrypt_broadcast)(void); bool (*get_pts_eatt_peripheral_collision_support)(void); bool (*get_pts_eatt_peripheral_collision_support)(void); bool (*get_pts_use_eatt_for_all_services)(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); bool (*get_pts_l2cap_ecoc_upper_tester)(void); int (*get_pts_l2cap_ecoc_min_key_size)(void); int (*get_pts_l2cap_ecoc_min_key_size)(void); int (*get_pts_l2cap_ecoc_initial_chan_cnt)(void); int (*get_pts_l2cap_ecoc_initial_chan_cnt)(void); Loading Loading
system/bta/le_audio/broadcaster/broadcaster.cc +43 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "device/include/controller.h" #include "device/include/controller.h" #include "embdrv/lc3/include/lc3.h" #include "embdrv/lc3/include/lc3.h" #include "gd/common/strings.h" #include "gd/common/strings.h" #include "internal_include/stack_config.h" #include "osi/include/log.h" #include "osi/include/log.h" #include "osi/include/properties.h" #include "osi/include/properties.h" #include "stack/include/btm_api_types.h" #include "stack/include/btm_api_types.h" Loading Loading @@ -264,6 +265,27 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks { uint16_t context_type = uint16_t context_type = static_cast<std::underlying_type<LeAudioContextType>::type>( static_cast<std::underlying_type<LeAudioContextType>::type>( LeAudioContextType::MEDIA); 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 = auto stream_context_vec = ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); if (stream_context_vec) { if (stream_context_vec) { Loading Loading @@ -303,6 +325,27 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks { uint16_t context_type = uint16_t context_type = static_cast<std::underlying_type<LeAudioContextType>::type>( static_cast<std::underlying_type<LeAudioContextType>::type>( LeAudioContextType::MEDIA); 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 = auto stream_context_vec = ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); ltv.Find(le_audio::types::kLeAudioMetadataTypeStreamingAudioContext); if (stream_context_vec) { if (stream_context_vec) { Loading
system/bta/le_audio/client.cc +54 −0 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include "embdrv/lc3/include/lc3.h" #include "embdrv/lc3/include/lc3.h" #include "gatt/bta_gattc_int.h" #include "gatt/bta_gattc_int.h" #include "gd/common/strings.h" #include "gd/common/strings.h" #include "internal_include/stack_config.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_types.h" #include "le_audio_types.h" #include "le_audio_utils.h" #include "le_audio_utils.h" Loading Loading @@ -3140,6 +3141,40 @@ class LeAudioClientImpl : public LeAudioClient { metadata_context_types_ = GetAllowedAudioContextsFromSourceMetadata( metadata_context_types_ = GetAllowedAudioContextsFromSourceMetadata( source_metadata, group->GetActiveContexts()); 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 = auto new_configuration_context = ChooseConfigurationContextType(metadata_context_types_); ChooseConfigurationContextType(metadata_context_types_); LOG_DEBUG("new_configuration_context_type: %s", LOG_DEBUG("new_configuration_context_type: %s", Loading Loading @@ -3192,6 +3227,25 @@ class LeAudioClientImpl : public LeAudioClient { return; 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 /* Do nothing, since audio source is not valid and if voice assistant * scenario is currently not supported by group * scenario is currently not supported by group */ */ Loading
system/bta/le_audio/le_audio_client_test.cc +42 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "fake_osi.h" #include "fake_osi.h" #include "gatt/database_builder.h" #include "gatt/database_builder.h" #include "hardware/bt_gatt_types.h" #include "hardware/bt_gatt_types.h" #include "internal_include/stack_config.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_set_configuration_provider.h" #include "le_audio_types.h" #include "le_audio_types.h" #include "mock_controller.h" #include "mock_controller.h" Loading Loading @@ -119,6 +120,47 @@ static void cleanup_message_loop_thread() { void invoke_switch_codec_cb(bool is_low_latency_buffer_size) {} void invoke_switch_codec_cb(bool is_low_latency_buffer_size) {} void invoke_switch_buffer_size_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 le_audio { namespace { namespace { class MockLeAudioClientCallbacks class MockLeAudioClientCallbacks Loading
system/conf/bt_stack.conf +3 −0 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,9 @@ TRC_HID_DEV=2 # Use EATT for all services # Use EATT for all services #PTS_UseEattForAllServices=true #PTS_UseEattForAllServices=true # Force to update metadata with multiple CCIDs #PTS_ForceLeAudioMultipleContextsMetadata=true # SMP Certification Failure Cases # SMP Certification Failure Cases # Set any of the following SMP error values (from smp_api_types.h) # Set any of the following SMP error values (from smp_api_types.h) # to induce pairing failues for various PTS SMP test cases. # to induce pairing failues for various PTS SMP test cases. Loading
system/internal_include/stack_config.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ typedef struct { bool (*get_pts_unencrypt_broadcast)(void); bool (*get_pts_unencrypt_broadcast)(void); bool (*get_pts_eatt_peripheral_collision_support)(void); bool (*get_pts_eatt_peripheral_collision_support)(void); bool (*get_pts_use_eatt_for_all_services)(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); bool (*get_pts_l2cap_ecoc_upper_tester)(void); int (*get_pts_l2cap_ecoc_min_key_size)(void); int (*get_pts_l2cap_ecoc_min_key_size)(void); int (*get_pts_l2cap_ecoc_initial_chan_cnt)(void); int (*get_pts_l2cap_ecoc_initial_chan_cnt)(void); Loading