diff options
author | 2022-08-12 12:28:02 +0000 | |
---|---|---|
committer | 2022-08-24 20:11:52 +0000 | |
commit | 69a2cd2b4405bf20b42f0798dca938a80581e657 (patch) | |
tree | b37554e1abbe669bb67ad0c53550403fee3e0879 | |
parent | cb987b9f7aa53c2146bfbbddcc63689f0fcbad19 (diff) |
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
-rw-r--r-- | system/bta/le_audio/broadcaster/broadcaster.cc | 43 | ||||
-rw-r--r-- | system/bta/le_audio/client.cc | 54 | ||||
-rw-r--r-- | system/bta/le_audio/le_audio_client_test.cc | 42 | ||||
-rw-r--r-- | system/conf/bt_stack.conf | 3 | ||||
-rw-r--r-- | system/internal_include/stack_config.h | 1 | ||||
-rw-r--r-- | system/main/stack_config.cc | 51 | ||||
-rw-r--r-- | system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc | 2 | ||||
-rw-r--r-- | system/profile/avrcp/tests/avrcp_device_test.cc | 2 | ||||
-rw-r--r-- | system/stack/test/btm/stack_btm_test.cc | 3 | ||||
-rw-r--r-- | system/stack/test/stack_smp_test.cc | 3 | ||||
-rw-r--r-- | system/test/common/stack_config.cc | 3 |
11 files changed, 184 insertions, 23 deletions
diff --git a/system/bta/le_audio/broadcaster/broadcaster.cc b/system/bta/le_audio/broadcaster/broadcaster.cc index 3b0a7fcec9..8e7ab2f890 100644 --- a/system/bta/le_audio/broadcaster/broadcaster.cc +++ b/system/bta/le_audio/broadcaster/broadcaster.cc @@ -26,6 +26,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" @@ -264,6 +265,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) { @@ -303,6 +325,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) { diff --git a/system/bta/le_audio/client.cc b/system/bta/le_audio/client.cc index 09cb59d8f5..a1cea960a0 100644 --- a/system/bta/le_audio/client.cc +++ b/system/bta/le_audio/client.cc @@ -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 */ diff --git a/system/bta/le_audio/le_audio_client_test.cc b/system/bta/le_audio/le_audio_client_test.cc index 8a7bd0139d..32c1c6190f 100644 --- a/system/bta/le_audio/le_audio_client_test.cc +++ b/system/bta/le_audio/le_audio_client_test.cc @@ -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 diff --git a/system/conf/bt_stack.conf b/system/conf/bt_stack.conf index daadeb368f..84e1a99b6f 100644 --- a/system/conf/bt_stack.conf +++ b/system/conf/bt_stack.conf @@ -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. diff --git a/system/internal_include/stack_config.h b/system/internal_include/stack_config.h index 9d396c790e..080d40183a 100644 --- a/system/internal_include/stack_config.h +++ b/system/internal_include/stack_config.h @@ -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); diff --git a/system/main/stack_config.cc b/system/main/stack_config.cc index 97033c5daf..58994735c0 100644 --- a/system/main/stack_config.cc +++ b/system/main/stack_config.cc @@ -38,6 +38,8 @@ const char* PTS_CONNECT_EATT_UNCONDITIONALLY = "PTS_ConnectEattUncondictionally"; const char* PTS_CONNECT_EATT_UNENCRYPTED = "PTS_ConnectEattUnencrypted"; const char* PTS_BROADCAST_UNENCRYPTED = "PTS_BroadcastUnencrypted"; +const char* PTS_FORCE_LE_AUDIO_MULTIPLE_CONTEXTS_METADATA = + "PTS_ForceLeAudioMultipleContextsMetadata"; const char* PTS_EATT_PERIPHERAL_COLLISION_SUPPORT = "PTS_EattPeripheralCollionSupport"; const char* PTS_EATT_USE_FOR_ALL_SERVICES = "PTS_UseEattForAllServices"; @@ -156,6 +158,11 @@ static bool get_pts_use_eatt_for_all_services(void) { PTS_EATT_USE_FOR_ALL_SERVICES, false); } +static bool get_pts_force_le_audio_multiple_contexts_metadata(void) { + return config_get_bool(*config, CONFIG_DEFAULT_SECTION, + PTS_FORCE_LE_AUDIO_MULTIPLE_CONTEXTS_METADATA, false); +} + static bool get_pts_l2cap_ecoc_upper_tester(void) { return config_get_bool(*config, CONFIG_DEFAULT_SECTION, PTS_L2CAP_ECOC_UPPER_TESTER, false); @@ -197,26 +204,28 @@ static const std::string* get_pts_broadcast_audio_config_options(void) { static config_t* get_all(void) { return config.get(); } -const stack_config_t interface = {get_trace_config_enabled, - get_pts_avrcp_test, - get_pts_secure_only_mode, - get_pts_conn_updates_disabled, - get_pts_crosskey_sdp_disable, - get_pts_smp_options, - get_pts_smp_failure_case, - get_pts_force_eatt_for_notifications, - get_pts_connect_eatt_unconditionally, - get_pts_connect_eatt_before_encryption, - get_pts_unencrypt_broadcast, - get_pts_eatt_peripheral_collision_support, - get_pts_use_eatt_for_all_services, - get_pts_l2cap_ecoc_upper_tester, - get_pts_l2cap_ecoc_min_key_size, - get_pts_l2cap_ecoc_initial_chan_cnt, - get_pts_l2cap_ecoc_connect_remaining, - get_pts_l2cap_ecoc_send_num_of_sdu, - get_pts_l2cap_ecoc_reconfigure, - get_pts_broadcast_audio_config_options, - get_all}; +const stack_config_t interface = { + get_trace_config_enabled, + get_pts_avrcp_test, + get_pts_secure_only_mode, + get_pts_conn_updates_disabled, + get_pts_crosskey_sdp_disable, + get_pts_smp_options, + get_pts_smp_failure_case, + get_pts_force_eatt_for_notifications, + get_pts_connect_eatt_unconditionally, + get_pts_connect_eatt_before_encryption, + get_pts_unencrypt_broadcast, + get_pts_eatt_peripheral_collision_support, + get_pts_use_eatt_for_all_services, + get_pts_force_le_audio_multiple_contexts_metadata, + get_pts_l2cap_ecoc_upper_tester, + get_pts_l2cap_ecoc_min_key_size, + get_pts_l2cap_ecoc_initial_chan_cnt, + get_pts_l2cap_ecoc_connect_remaining, + get_pts_l2cap_ecoc_send_num_of_sdu, + get_pts_l2cap_ecoc_reconfigure, + get_pts_broadcast_audio_config_options, + get_all}; const stack_config_t* stack_config_get_interface(void) { return &interface; } diff --git a/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc b/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc index 55a5d89b39..42e9ba61ef 100644 --- a/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc +++ b/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc @@ -64,7 +64,7 @@ const stack_config_t interface = {nullptr, get_pts_avrcp_test, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr}; + nullptr, nullptr}; void Callback(uint8_t, bool, std::unique_ptr<::bluetooth::PacketBuilder>) {} diff --git a/system/profile/avrcp/tests/avrcp_device_test.cc b/system/profile/avrcp/tests/avrcp_device_test.cc index e88bd6c2f7..f59330b287 100644 --- a/system/profile/avrcp/tests/avrcp_device_test.cc +++ b/system/profile/avrcp/tests/avrcp_device_test.cc @@ -60,7 +60,7 @@ const stack_config_t interface = {nullptr, get_pts_avrcp_test, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr}; + nullptr, nullptr}; // TODO (apanicke): All the tests below are just basic positive unit tests. // Add more tests to increase code coverage. diff --git a/system/stack/test/btm/stack_btm_test.cc b/system/stack/test/btm/stack_btm_test.cc index 5895d6826e..150012eee9 100644 --- a/system/stack/test/btm/stack_btm_test.cc +++ b/system/stack/test/btm/stack_btm_test.cc @@ -78,6 +78,7 @@ 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_use_eatt_for_all_services(void) { return false; } +bool get_pts_force_le_audio_multiple_contexts_metadata(void) { return false; } bool get_pts_l2cap_ecoc_upper_tester(void) { return false; } int get_pts_l2cap_ecoc_min_key_size(void) { return -1; } int get_pts_l2cap_ecoc_initial_chan_cnt(void) { return -1; } @@ -109,6 +110,8 @@ stack_config_t mock_stack_config{ get_pts_eatt_peripheral_collision_support, .get_pts_l2cap_ecoc_upper_tester = get_pts_l2cap_ecoc_upper_tester, .get_pts_l2cap_ecoc_min_key_size = get_pts_l2cap_ecoc_min_key_size, + .get_pts_force_le_audio_multiple_contexts_metadata = + get_pts_force_le_audio_multiple_contexts_metadata, .get_pts_l2cap_ecoc_initial_chan_cnt = get_pts_l2cap_ecoc_initial_chan_cnt, .get_pts_l2cap_ecoc_connect_remaining = get_pts_l2cap_ecoc_connect_remaining, diff --git a/system/stack/test/stack_smp_test.cc b/system/stack/test/stack_smp_test.cc index f057c6cd63..d0c7c0fabc 100644 --- a/system/stack/test/stack_smp_test.cc +++ b/system/stack/test/stack_smp_test.cc @@ -53,6 +53,7 @@ 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_use_eatt_for_all_services(void) { return false; } +bool get_pts_force_le_audio_multiple_contexts_metadata(void) { return false; } bool get_pts_l2cap_ecoc_upper_tester(void) { return false; } int get_pts_l2cap_ecoc_min_key_size(void) { return -1; } int get_pts_l2cap_ecoc_initial_chan_cnt(void) { return -1; } @@ -84,6 +85,8 @@ stack_config_t mock_stack_config{ get_pts_eatt_peripheral_collision_support, .get_pts_use_eatt_for_all_services = get_pts_use_eatt_for_all_services, .get_pts_l2cap_ecoc_upper_tester = get_pts_l2cap_ecoc_upper_tester, + .get_pts_force_le_audio_multiple_contexts_metadata = + get_pts_force_le_audio_multiple_contexts_metadata, .get_pts_l2cap_ecoc_min_key_size = get_pts_l2cap_ecoc_min_key_size, .get_pts_l2cap_ecoc_initial_chan_cnt = get_pts_l2cap_ecoc_initial_chan_cnt, .get_pts_l2cap_ecoc_connect_remaining = diff --git a/system/test/common/stack_config.cc b/system/test/common/stack_config.cc index 9078a9ca40..300f0d6442 100644 --- a/system/test/common/stack_config.cc +++ b/system/test/common/stack_config.cc @@ -38,6 +38,7 @@ 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_use_eatt_for_all_services(void) { return false; } +bool get_pts_force_le_audio_multiple_contexts_metadata(void) { return false; } bool get_pts_l2cap_ecoc_upper_tester(void) { return false; } int get_pts_l2cap_ecoc_min_key_size(void) { return -1; } int get_pts_l2cap_ecoc_initial_chan_cnt(void) { return -1; } @@ -71,6 +72,8 @@ stack_config_t mock_stack_config{ get_pts_eatt_peripheral_collision_support, .get_pts_use_eatt_for_all_services = get_pts_use_eatt_for_all_services, .get_pts_l2cap_ecoc_upper_tester = get_pts_l2cap_ecoc_upper_tester, + .get_pts_force_le_audio_multiple_contexts_metadata = + get_pts_force_le_audio_multiple_contexts_metadata, .get_pts_l2cap_ecoc_min_key_size = get_pts_l2cap_ecoc_min_key_size, .get_pts_l2cap_ecoc_initial_chan_cnt = get_pts_l2cap_ecoc_initial_chan_cnt, .get_pts_l2cap_ecoc_connect_remaining = |