Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <aidl/Gtest.h> |
| 17 | #include <aidl/Vintf.h> |
| 18 | #include <aidl/android/hardware/bluetooth/audio/BnBluetoothAudioPort.h> |
| 19 | #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.h> |
| 20 | #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.h> |
| 21 | #include <android/binder_auto_utils.h> |
| 22 | #include <android/binder_manager.h> |
| 23 | #include <android/binder_process.h> |
| 24 | #include <binder/IServiceManager.h> |
| 25 | #include <binder/ProcessState.h> |
| 26 | #include <fmq/AidlMessageQueue.h> |
| 27 | |
| 28 | #include <cstdint> |
| 29 | #include <future> |
| 30 | #include <unordered_set> |
| 31 | #include <vector> |
| 32 | |
| 33 | using aidl::android::hardware::audio::common::SinkMetadata; |
| 34 | using aidl::android::hardware::audio::common::SourceMetadata; |
| 35 | using aidl::android::hardware::bluetooth::audio::AacCapabilities; |
| 36 | using aidl::android::hardware::bluetooth::audio::AacConfiguration; |
| 37 | using aidl::android::hardware::bluetooth::audio::AptxCapabilities; |
| 38 | using aidl::android::hardware::bluetooth::audio::AptxConfiguration; |
| 39 | using aidl::android::hardware::bluetooth::audio::AudioCapabilities; |
| 40 | using aidl::android::hardware::bluetooth::audio::AudioConfiguration; |
| 41 | using aidl::android::hardware::bluetooth::audio::BnBluetoothAudioPort; |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 42 | using aidl::android::hardware::bluetooth::audio::BroadcastCapability; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 43 | using aidl::android::hardware::bluetooth::audio::ChannelMode; |
| 44 | using aidl::android::hardware::bluetooth::audio::CodecCapabilities; |
| 45 | using aidl::android::hardware::bluetooth::audio::CodecConfiguration; |
| 46 | using aidl::android::hardware::bluetooth::audio::CodecType; |
| 47 | using aidl::android::hardware::bluetooth::audio::IBluetoothAudioPort; |
| 48 | using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider; |
| 49 | using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProviderFactory; |
| 50 | using aidl::android::hardware::bluetooth::audio::LatencyMode; |
| 51 | using aidl::android::hardware::bluetooth::audio::Lc3Capabilities; |
| 52 | using aidl::android::hardware::bluetooth::audio::Lc3Configuration; |
| 53 | using aidl::android::hardware::bluetooth::audio::LdacCapabilities; |
| 54 | using aidl::android::hardware::bluetooth::audio::LdacConfiguration; |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 55 | using aidl::android::hardware::bluetooth::audio::LeAudioBroadcastConfiguration; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 56 | using aidl::android::hardware::bluetooth::audio:: |
| 57 | LeAudioCodecCapabilitiesSetting; |
| 58 | using aidl::android::hardware::bluetooth::audio::LeAudioCodecConfiguration; |
| 59 | using aidl::android::hardware::bluetooth::audio::LeAudioConfiguration; |
| 60 | using aidl::android::hardware::bluetooth::audio::PcmConfiguration; |
| 61 | using aidl::android::hardware::bluetooth::audio::PresentationPosition; |
| 62 | using aidl::android::hardware::bluetooth::audio::SbcAllocMethod; |
| 63 | using aidl::android::hardware::bluetooth::audio::SbcCapabilities; |
| 64 | using aidl::android::hardware::bluetooth::audio::SbcChannelMode; |
| 65 | using aidl::android::hardware::bluetooth::audio::SbcConfiguration; |
| 66 | using aidl::android::hardware::bluetooth::audio::SessionType; |
| 67 | using aidl::android::hardware::bluetooth::audio::UnicastCapability; |
| 68 | using aidl::android::hardware::common::fmq::MQDescriptor; |
| 69 | using aidl::android::hardware::common::fmq::SynchronizedReadWrite; |
| 70 | using android::AidlMessageQueue; |
| 71 | using android::ProcessState; |
| 72 | using android::String16; |
| 73 | using ndk::ScopedAStatus; |
| 74 | using ndk::SpAIBinder; |
| 75 | |
| 76 | using MqDataType = int8_t; |
| 77 | using MqDataMode = SynchronizedReadWrite; |
| 78 | using DataMQ = AidlMessageQueue<MqDataType, MqDataMode>; |
| 79 | using DataMQDesc = MQDescriptor<MqDataType, MqDataMode>; |
| 80 | |
| 81 | // Constants |
| 82 | |
| 83 | static constexpr int32_t a2dp_sample_rates[] = {0, 44100, 48000, 88200, 96000}; |
| 84 | static constexpr int8_t a2dp_bits_per_samples[] = {0, 16, 24, 32}; |
| 85 | static constexpr ChannelMode a2dp_channel_modes[] = { |
| 86 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 87 | static constexpr CodecType a2dp_codec_types[] = { |
| 88 | CodecType::UNKNOWN, CodecType::SBC, CodecType::AAC, |
| 89 | CodecType::APTX, CodecType::APTX_HD, CodecType::LDAC, |
| 90 | CodecType::LC3, CodecType::APTX_ADAPTIVE}; |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 91 | static std::vector<LatencyMode> latency_modes = {LatencyMode::FREE}; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 92 | // Helpers |
| 93 | |
| 94 | template <typename T> |
| 95 | struct identity { |
| 96 | typedef T type; |
| 97 | }; |
| 98 | |
| 99 | template <class T> |
| 100 | bool contained_in_vector(const std::vector<T>& vector, |
| 101 | const typename identity<T>::type& target) { |
| 102 | return std::find(vector.begin(), vector.end(), target) != vector.end(); |
| 103 | } |
| 104 | |
| 105 | void copy_codec_specific(CodecConfiguration::CodecSpecific& dst, |
| 106 | const CodecConfiguration::CodecSpecific& src) { |
| 107 | switch (src.getTag()) { |
| 108 | case CodecConfiguration::CodecSpecific::sbcConfig: |
| 109 | dst.set<CodecConfiguration::CodecSpecific::sbcConfig>( |
| 110 | src.get<CodecConfiguration::CodecSpecific::sbcConfig>()); |
| 111 | break; |
| 112 | case CodecConfiguration::CodecSpecific::aacConfig: |
| 113 | dst.set<CodecConfiguration::CodecSpecific::aacConfig>( |
| 114 | src.get<CodecConfiguration::CodecSpecific::aacConfig>()); |
| 115 | break; |
| 116 | case CodecConfiguration::CodecSpecific::ldacConfig: |
| 117 | dst.set<CodecConfiguration::CodecSpecific::ldacConfig>( |
| 118 | src.get<CodecConfiguration::CodecSpecific::ldacConfig>()); |
| 119 | break; |
| 120 | case CodecConfiguration::CodecSpecific::aptxConfig: |
| 121 | dst.set<CodecConfiguration::CodecSpecific::aptxConfig>( |
| 122 | src.get<CodecConfiguration::CodecSpecific::aptxConfig>()); |
| 123 | break; |
| 124 | case CodecConfiguration::CodecSpecific::lc3Config: |
| 125 | dst.set<CodecConfiguration::CodecSpecific::lc3Config>( |
| 126 | src.get<CodecConfiguration::CodecSpecific::lc3Config>()); |
| 127 | break; |
| 128 | case CodecConfiguration::CodecSpecific::aptxAdaptiveConfig: |
| 129 | dst.set<CodecConfiguration::CodecSpecific::aptxAdaptiveConfig>( |
| 130 | src.get<CodecConfiguration::CodecSpecific::aptxAdaptiveConfig>()); |
| 131 | break; |
| 132 | default: |
| 133 | break; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | class BluetoothAudioPort : public BnBluetoothAudioPort { |
| 138 | public: |
| 139 | BluetoothAudioPort() {} |
| 140 | |
| 141 | ndk::ScopedAStatus startStream() { return ScopedAStatus::ok(); } |
| 142 | |
| 143 | ndk::ScopedAStatus suspendStream() { return ScopedAStatus::ok(); } |
| 144 | |
| 145 | ndk::ScopedAStatus stopStream() { return ScopedAStatus::ok(); } |
| 146 | |
| 147 | ndk::ScopedAStatus getPresentationPosition(PresentationPosition*) { |
| 148 | return ScopedAStatus::ok(); |
| 149 | } |
| 150 | |
| 151 | ndk::ScopedAStatus updateSourceMetadata(const SourceMetadata&) { |
| 152 | return ScopedAStatus::ok(); |
| 153 | } |
| 154 | |
| 155 | ndk::ScopedAStatus updateSinkMetadata(const SinkMetadata&) { |
| 156 | return ScopedAStatus::ok(); |
| 157 | } |
| 158 | |
| 159 | ndk::ScopedAStatus setLatencyMode(const LatencyMode) { |
| 160 | return ScopedAStatus::ok(); |
| 161 | } |
| 162 | |
| 163 | ndk::ScopedAStatus setCodecType(const CodecType) { |
| 164 | return ScopedAStatus::ok(); |
| 165 | } |
| 166 | |
| 167 | protected: |
| 168 | virtual ~BluetoothAudioPort() = default; |
| 169 | }; |
| 170 | |
| 171 | class BluetoothAudioProviderFactoryAidl |
| 172 | : public testing::TestWithParam<std::string> { |
| 173 | public: |
| 174 | virtual void SetUp() override { |
| 175 | provider_factory_ = IBluetoothAudioProviderFactory::fromBinder( |
| 176 | SpAIBinder(AServiceManager_getService(GetParam().c_str()))); |
| 177 | audio_provider_ = nullptr; |
| 178 | ASSERT_NE(provider_factory_, nullptr); |
| 179 | } |
| 180 | |
| 181 | virtual void TearDown() override { provider_factory_ = nullptr; } |
| 182 | |
| 183 | void GetProviderCapabilitiesHelper(const SessionType& session_type) { |
| 184 | temp_provider_capabilities_.clear(); |
| 185 | auto aidl_retval = provider_factory_->getProviderCapabilities( |
| 186 | session_type, &temp_provider_capabilities_); |
| 187 | // AIDL calls should not be failed and callback has to be executed |
| 188 | ASSERT_TRUE(aidl_retval.isOk()); |
| 189 | switch (session_type) { |
| 190 | case SessionType::UNKNOWN: { |
| 191 | ASSERT_TRUE(temp_provider_capabilities_.empty()); |
| 192 | } break; |
| 193 | case SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH: |
| 194 | case SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH: |
| 195 | case SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH: |
| 196 | case SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH: |
| 197 | case SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH: { |
| 198 | // All software paths are mandatory and must have exact 1 |
| 199 | // "PcmParameters" |
| 200 | ASSERT_EQ(temp_provider_capabilities_.size(), 1); |
| 201 | ASSERT_EQ(temp_provider_capabilities_[0].getTag(), |
| 202 | AudioCapabilities::pcmCapabilities); |
| 203 | } break; |
| 204 | case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH: { |
| 205 | std::unordered_set<CodecType> codec_types; |
| 206 | // empty capability means offload is unsupported |
| 207 | for (auto& audio_capability : temp_provider_capabilities_) { |
| 208 | ASSERT_EQ(audio_capability.getTag(), |
| 209 | AudioCapabilities::a2dpCapabilities); |
| 210 | const auto& codec_capabilities = |
| 211 | audio_capability.get<AudioCapabilities::a2dpCapabilities>(); |
| 212 | // Every codec can present once at most |
| 213 | ASSERT_EQ(codec_types.count(codec_capabilities.codecType), 0); |
| 214 | switch (codec_capabilities.codecType) { |
| 215 | case CodecType::SBC: |
| 216 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 217 | CodecCapabilities::Capabilities::sbcCapabilities); |
| 218 | break; |
| 219 | case CodecType::AAC: |
| 220 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 221 | CodecCapabilities::Capabilities::aacCapabilities); |
| 222 | break; |
| 223 | case CodecType::APTX: |
| 224 | case CodecType::APTX_HD: |
| 225 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 226 | CodecCapabilities::Capabilities::aptxCapabilities); |
| 227 | break; |
| 228 | case CodecType::LDAC: |
| 229 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 230 | CodecCapabilities::Capabilities::ldacCapabilities); |
| 231 | break; |
| 232 | case CodecType::LC3: |
| 233 | ASSERT_EQ(codec_capabilities.capabilities.getTag(), |
| 234 | CodecCapabilities::Capabilities::lc3Capabilities); |
| 235 | break; |
| 236 | case CodecType::APTX_ADAPTIVE: |
| 237 | case CodecType::VENDOR: |
| 238 | case CodecType::UNKNOWN: |
| 239 | break; |
| 240 | } |
| 241 | codec_types.insert(codec_capabilities.codecType); |
| 242 | } |
| 243 | } break; |
| 244 | case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH: |
| 245 | case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH: |
| 246 | case SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH: { |
| 247 | ASSERT_FALSE(temp_provider_capabilities_.empty()); |
| 248 | for (auto audio_capability : temp_provider_capabilities_) { |
| 249 | ASSERT_EQ(audio_capability.getTag(), |
| 250 | AudioCapabilities::leAudioCapabilities); |
| 251 | } |
| 252 | } break; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | /*** |
| 257 | * This helps to open the specified provider and check the openProvider() |
| 258 | * has corruct return values. BUT, to keep it simple, it does not consider |
| 259 | * the capability, and please do so at the SetUp of each session's test. |
| 260 | ***/ |
| 261 | void OpenProviderHelper(const SessionType& session_type) { |
| 262 | auto aidl_retval = |
| 263 | provider_factory_->openProvider(session_type, &audio_provider_); |
| 264 | if (aidl_retval.isOk()) { |
| 265 | ASSERT_NE(session_type, SessionType::UNKNOWN); |
| 266 | ASSERT_NE(audio_provider_, nullptr); |
| 267 | audio_port_ = ndk::SharedRefBase::make<BluetoothAudioPort>(); |
| 268 | } else { |
| 269 | // Hardware offloading is optional |
| 270 | ASSERT_TRUE( |
| 271 | session_type == SessionType::UNKNOWN || |
| 272 | session_type == |
| 273 | SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH || |
| 274 | session_type == |
| 275 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH || |
| 276 | session_type == |
| 277 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || |
| 278 | session_type == |
| 279 | SessionType:: |
| 280 | LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 281 | ASSERT_EQ(audio_provider_, nullptr); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | bool IsPcmConfigSupported(const PcmConfiguration& pcm_config) { |
| 286 | if (temp_provider_capabilities_.size() != 1 || |
| 287 | temp_provider_capabilities_[0].getTag() != |
| 288 | AudioCapabilities::pcmCapabilities) { |
| 289 | return false; |
| 290 | } |
| 291 | auto pcm_capability = temp_provider_capabilities_[0] |
| 292 | .get<AudioCapabilities::pcmCapabilities>(); |
| 293 | return (contained_in_vector(pcm_capability.channelMode, |
| 294 | pcm_config.channelMode) && |
| 295 | contained_in_vector(pcm_capability.sampleRateHz, |
| 296 | pcm_config.sampleRateHz) && |
| 297 | contained_in_vector(pcm_capability.bitsPerSample, |
| 298 | pcm_config.bitsPerSample)); |
| 299 | } |
| 300 | |
| 301 | std::shared_ptr<IBluetoothAudioProviderFactory> provider_factory_; |
| 302 | std::shared_ptr<IBluetoothAudioProvider> audio_provider_; |
| 303 | std::shared_ptr<IBluetoothAudioPort> audio_port_; |
| 304 | std::vector<AudioCapabilities> temp_provider_capabilities_; |
| 305 | |
| 306 | static constexpr SessionType kSessionTypes[] = { |
| 307 | SessionType::UNKNOWN, |
| 308 | SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH, |
| 309 | SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH, |
| 310 | SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH, |
| 311 | SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH, |
| 312 | SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH, |
| 313 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH, |
| 314 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH, |
| 315 | SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH, |
| 316 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH, |
| 317 | }; |
| 318 | }; |
| 319 | |
| 320 | /** |
| 321 | * Test whether we can get the FactoryService from HIDL |
| 322 | */ |
| 323 | TEST_P(BluetoothAudioProviderFactoryAidl, GetProviderFactoryService) {} |
| 324 | |
| 325 | /** |
| 326 | * Test whether we can open a provider for each provider returned by |
| 327 | * getProviderCapabilities() with non-empty capabalities |
| 328 | */ |
| 329 | TEST_P(BluetoothAudioProviderFactoryAidl, |
| 330 | OpenProviderAndCheckCapabilitiesBySession) { |
| 331 | for (auto session_type : kSessionTypes) { |
| 332 | GetProviderCapabilitiesHelper(session_type); |
| 333 | OpenProviderHelper(session_type); |
| 334 | // We must be able to open a provider if its getProviderCapabilities() |
| 335 | // returns non-empty list. |
| 336 | EXPECT_TRUE(temp_provider_capabilities_.empty() || |
| 337 | audio_provider_ != nullptr); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * openProvider A2DP_SOFTWARE_ENCODING_DATAPATH |
| 343 | */ |
| 344 | class BluetoothAudioProviderA2dpSoftwareAidl |
| 345 | : public BluetoothAudioProviderFactoryAidl { |
| 346 | public: |
| 347 | virtual void SetUp() override { |
| 348 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 349 | GetProviderCapabilitiesHelper(SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH); |
| 350 | OpenProviderHelper(SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH); |
| 351 | ASSERT_NE(audio_provider_, nullptr); |
| 352 | } |
| 353 | |
| 354 | virtual void TearDown() override { |
| 355 | audio_port_ = nullptr; |
| 356 | audio_provider_ = nullptr; |
| 357 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 358 | } |
| 359 | }; |
| 360 | |
| 361 | /** |
| 362 | * Test whether we can open a provider of type |
| 363 | */ |
| 364 | TEST_P(BluetoothAudioProviderA2dpSoftwareAidl, OpenA2dpSoftwareProvider) {} |
| 365 | |
| 366 | /** |
| 367 | * Test whether each provider of type |
| 368 | * SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with |
| 369 | * different PCM config |
| 370 | */ |
| 371 | TEST_P(BluetoothAudioProviderA2dpSoftwareAidl, |
| 372 | StartAndEndA2dpSoftwareSessionWithPossiblePcmConfig) { |
| 373 | for (auto sample_rate : a2dp_sample_rates) { |
| 374 | for (auto bits_per_sample : a2dp_bits_per_samples) { |
| 375 | for (auto channel_mode : a2dp_channel_modes) { |
| 376 | PcmConfiguration pcm_config{ |
| 377 | .sampleRateHz = sample_rate, |
| 378 | .bitsPerSample = bits_per_sample, |
| 379 | .channelMode = channel_mode, |
| 380 | }; |
| 381 | bool is_codec_config_valid = IsPcmConfigSupported(pcm_config); |
| 382 | DataMQDesc mq_desc; |
| 383 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 384 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 385 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 386 | DataMQ data_mq(mq_desc); |
| 387 | |
| 388 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 389 | if (is_codec_config_valid) { |
| 390 | EXPECT_TRUE(data_mq.isValid()); |
| 391 | } |
| 392 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * openProvider A2DP_HARDWARE_OFFLOAD_DATAPATH |
| 400 | */ |
| 401 | class BluetoothAudioProviderA2dpHardwareAidl |
| 402 | : public BluetoothAudioProviderFactoryAidl { |
| 403 | public: |
| 404 | virtual void SetUp() override { |
| 405 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 406 | GetProviderCapabilitiesHelper( |
| 407 | SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 408 | OpenProviderHelper(SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 409 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 410 | audio_provider_ != nullptr); |
| 411 | } |
| 412 | |
| 413 | virtual void TearDown() override { |
| 414 | audio_port_ = nullptr; |
| 415 | audio_provider_ = nullptr; |
| 416 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 417 | } |
| 418 | |
| 419 | bool IsOffloadSupported() { return (temp_provider_capabilities_.size() > 0); } |
| 420 | |
| 421 | void GetA2dpOffloadCapabilityHelper(const CodecType& codec_type) { |
| 422 | temp_codec_capabilities_ = nullptr; |
Josh Wu | 4d2938f | 2022-02-15 09:21:10 -0800 | [diff] [blame] | 423 | for (auto& codec_capability : temp_provider_capabilities_) { |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 424 | auto& a2dp_capabilities = |
| 425 | codec_capability.get<AudioCapabilities::a2dpCapabilities>(); |
| 426 | if (a2dp_capabilities.codecType != codec_type) { |
| 427 | continue; |
| 428 | } |
| 429 | temp_codec_capabilities_ = &a2dp_capabilities; |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | std::vector<CodecConfiguration::CodecSpecific> |
| 434 | GetSbcCodecSpecificSupportedList(bool supported) { |
| 435 | std::vector<CodecConfiguration::CodecSpecific> sbc_codec_specifics; |
| 436 | if (!supported) { |
| 437 | SbcConfiguration sbc_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 438 | sbc_codec_specifics.push_back( |
| 439 | CodecConfiguration::CodecSpecific(sbc_config)); |
| 440 | return sbc_codec_specifics; |
| 441 | } |
| 442 | GetA2dpOffloadCapabilityHelper(CodecType::SBC); |
| 443 | if (temp_codec_capabilities_ == nullptr || |
| 444 | temp_codec_capabilities_->codecType != CodecType::SBC) { |
| 445 | return sbc_codec_specifics; |
| 446 | } |
| 447 | // parse the capability |
| 448 | auto& sbc_capability = |
| 449 | temp_codec_capabilities_->capabilities |
| 450 | .get<CodecCapabilities::Capabilities::sbcCapabilities>(); |
| 451 | if (sbc_capability.minBitpool > sbc_capability.maxBitpool) { |
| 452 | return sbc_codec_specifics; |
| 453 | } |
| 454 | |
| 455 | // combine those parameters into one list of |
| 456 | // CodecConfiguration::CodecSpecific |
| 457 | for (int32_t sample_rate : sbc_capability.sampleRateHz) { |
| 458 | for (int8_t block_length : sbc_capability.blockLength) { |
| 459 | for (int8_t num_subbands : sbc_capability.numSubbands) { |
| 460 | for (int8_t bits_per_sample : sbc_capability.bitsPerSample) { |
| 461 | for (auto channel_mode : sbc_capability.channelMode) { |
| 462 | for (auto alloc_method : sbc_capability.allocMethod) { |
| 463 | SbcConfiguration sbc_data = { |
| 464 | .sampleRateHz = sample_rate, |
| 465 | .channelMode = channel_mode, |
| 466 | .blockLength = block_length, |
| 467 | .numSubbands = num_subbands, |
| 468 | .allocMethod = alloc_method, |
| 469 | .bitsPerSample = bits_per_sample, |
| 470 | .minBitpool = sbc_capability.minBitpool, |
| 471 | .maxBitpool = sbc_capability.maxBitpool}; |
| 472 | sbc_codec_specifics.push_back( |
| 473 | CodecConfiguration::CodecSpecific(sbc_data)); |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | return sbc_codec_specifics; |
| 481 | } |
| 482 | |
| 483 | std::vector<CodecConfiguration::CodecSpecific> |
| 484 | GetAacCodecSpecificSupportedList(bool supported) { |
| 485 | std::vector<CodecConfiguration::CodecSpecific> aac_codec_specifics; |
| 486 | if (!supported) { |
| 487 | AacConfiguration aac_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 488 | aac_codec_specifics.push_back( |
| 489 | CodecConfiguration::CodecSpecific(aac_config)); |
| 490 | return aac_codec_specifics; |
| 491 | } |
| 492 | GetA2dpOffloadCapabilityHelper(CodecType::AAC); |
| 493 | if (temp_codec_capabilities_ == nullptr || |
| 494 | temp_codec_capabilities_->codecType != CodecType::AAC) { |
| 495 | return aac_codec_specifics; |
| 496 | } |
| 497 | // parse the capability |
| 498 | auto& aac_capability = |
| 499 | temp_codec_capabilities_->capabilities |
| 500 | .get<CodecCapabilities::Capabilities::aacCapabilities>(); |
| 501 | |
| 502 | std::vector<bool> variable_bit_rate_enableds = {false}; |
| 503 | if (aac_capability.variableBitRateSupported) { |
| 504 | variable_bit_rate_enableds.push_back(true); |
| 505 | } |
| 506 | |
| 507 | // combine those parameters into one list of |
| 508 | // CodecConfiguration::CodecSpecific |
| 509 | for (auto object_type : aac_capability.objectType) { |
| 510 | for (int32_t sample_rate : aac_capability.sampleRateHz) { |
| 511 | for (auto channel_mode : aac_capability.channelMode) { |
| 512 | for (int8_t bits_per_sample : aac_capability.bitsPerSample) { |
| 513 | for (auto variable_bit_rate_enabled : variable_bit_rate_enableds) { |
| 514 | AacConfiguration aac_data{ |
| 515 | .objectType = object_type, |
| 516 | .sampleRateHz = sample_rate, |
| 517 | .channelMode = channel_mode, |
| 518 | .variableBitRateEnabled = variable_bit_rate_enabled, |
| 519 | .bitsPerSample = bits_per_sample}; |
| 520 | aac_codec_specifics.push_back( |
| 521 | CodecConfiguration::CodecSpecific(aac_data)); |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | return aac_codec_specifics; |
| 528 | } |
| 529 | |
| 530 | std::vector<CodecConfiguration::CodecSpecific> |
| 531 | GetLdacCodecSpecificSupportedList(bool supported) { |
| 532 | std::vector<CodecConfiguration::CodecSpecific> ldac_codec_specifics; |
| 533 | if (!supported) { |
| 534 | LdacConfiguration ldac_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 535 | ldac_codec_specifics.push_back( |
| 536 | CodecConfiguration::CodecSpecific(ldac_config)); |
| 537 | return ldac_codec_specifics; |
| 538 | } |
| 539 | GetA2dpOffloadCapabilityHelper(CodecType::LDAC); |
| 540 | if (temp_codec_capabilities_ == nullptr || |
| 541 | temp_codec_capabilities_->codecType != CodecType::LDAC) { |
| 542 | return ldac_codec_specifics; |
| 543 | } |
| 544 | // parse the capability |
| 545 | auto& ldac_capability = |
| 546 | temp_codec_capabilities_->capabilities |
| 547 | .get<CodecCapabilities::Capabilities::ldacCapabilities>(); |
| 548 | |
| 549 | // combine those parameters into one list of |
| 550 | // CodecConfiguration::CodecSpecific |
| 551 | for (int32_t sample_rate : ldac_capability.sampleRateHz) { |
| 552 | for (int8_t bits_per_sample : ldac_capability.bitsPerSample) { |
| 553 | for (auto channel_mode : ldac_capability.channelMode) { |
| 554 | for (auto quality_index : ldac_capability.qualityIndex) { |
| 555 | LdacConfiguration ldac_data{.sampleRateHz = sample_rate, |
| 556 | .channelMode = channel_mode, |
| 557 | .qualityIndex = quality_index, |
| 558 | .bitsPerSample = bits_per_sample}; |
| 559 | ldac_codec_specifics.push_back( |
| 560 | CodecConfiguration::CodecSpecific(ldac_data)); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | return ldac_codec_specifics; |
| 566 | } |
| 567 | |
| 568 | std::vector<CodecConfiguration::CodecSpecific> |
| 569 | GetAptxCodecSpecificSupportedList(bool is_hd, bool supported) { |
| 570 | std::vector<CodecConfiguration::CodecSpecific> aptx_codec_specifics; |
| 571 | if (!supported) { |
| 572 | AptxConfiguration aptx_config{.sampleRateHz = 0, .bitsPerSample = 0}; |
| 573 | aptx_codec_specifics.push_back( |
| 574 | CodecConfiguration::CodecSpecific(aptx_config)); |
| 575 | return aptx_codec_specifics; |
| 576 | } |
| 577 | GetA2dpOffloadCapabilityHelper( |
| 578 | (is_hd ? CodecType::APTX_HD : CodecType::APTX)); |
| 579 | if (temp_codec_capabilities_ == nullptr) { |
| 580 | return aptx_codec_specifics; |
| 581 | } |
| 582 | if ((is_hd && temp_codec_capabilities_->codecType != CodecType::APTX_HD) || |
| 583 | (!is_hd && temp_codec_capabilities_->codecType != CodecType::APTX)) { |
| 584 | return aptx_codec_specifics; |
| 585 | } |
| 586 | |
| 587 | // parse the capability |
| 588 | auto& aptx_capability = |
| 589 | temp_codec_capabilities_->capabilities |
| 590 | .get<CodecCapabilities::Capabilities::aptxCapabilities>(); |
| 591 | |
| 592 | // combine those parameters into one list of |
| 593 | // CodecConfiguration::CodecSpecific |
| 594 | for (int8_t bits_per_sample : aptx_capability.bitsPerSample) { |
| 595 | for (int32_t sample_rate : aptx_capability.sampleRateHz) { |
| 596 | for (auto channel_mode : aptx_capability.channelMode) { |
| 597 | AptxConfiguration aptx_data{.sampleRateHz = sample_rate, |
| 598 | .channelMode = channel_mode, |
| 599 | .bitsPerSample = bits_per_sample}; |
| 600 | aptx_codec_specifics.push_back( |
| 601 | CodecConfiguration::CodecSpecific(aptx_data)); |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | return aptx_codec_specifics; |
| 606 | } |
| 607 | |
| 608 | std::vector<CodecConfiguration::CodecSpecific> |
| 609 | GetLc3CodecSpecificSupportedList(bool supported) { |
| 610 | std::vector<CodecConfiguration::CodecSpecific> lc3_codec_specifics; |
| 611 | if (!supported) { |
| 612 | Lc3Configuration lc3_config{.samplingFrequencyHz = 0, |
| 613 | .frameDurationUs = 0}; |
| 614 | lc3_codec_specifics.push_back( |
| 615 | CodecConfiguration::CodecSpecific(lc3_config)); |
| 616 | return lc3_codec_specifics; |
| 617 | } |
| 618 | GetA2dpOffloadCapabilityHelper(CodecType::LC3); |
| 619 | if (temp_codec_capabilities_ == nullptr || |
| 620 | temp_codec_capabilities_->codecType != CodecType::LC3) { |
| 621 | return lc3_codec_specifics; |
| 622 | } |
| 623 | // parse the capability |
| 624 | auto& lc3_capability = |
| 625 | temp_codec_capabilities_->capabilities |
| 626 | .get<CodecCapabilities::Capabilities::lc3Capabilities>(); |
| 627 | |
| 628 | // combine those parameters into one list of |
| 629 | // CodecConfiguration::CodecSpecific |
| 630 | for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) { |
| 631 | for (int32_t frameDurationUs : lc3_capability.frameDurationUs) { |
| 632 | for (auto channel_mode : lc3_capability.channelMode) { |
| 633 | Lc3Configuration lc3_data{.samplingFrequencyHz = samplingFrequencyHz, |
| 634 | .channelMode = channel_mode, |
| 635 | .frameDurationUs = frameDurationUs}; |
| 636 | lc3_codec_specifics.push_back( |
| 637 | CodecConfiguration::CodecSpecific(lc3_data)); |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | return lc3_codec_specifics; |
| 642 | } |
| 643 | |
| 644 | // temp storage saves the specified codec capability by |
| 645 | // GetOffloadCodecCapabilityHelper() |
| 646 | CodecCapabilities* temp_codec_capabilities_; |
| 647 | }; |
| 648 | |
| 649 | /** |
| 650 | * Test whether we can open a provider of type |
| 651 | */ |
| 652 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, OpenA2dpHardwareProvider) {} |
| 653 | |
| 654 | /** |
| 655 | * Test whether each provider of type |
| 656 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 657 | * SBC hardware encoding config |
| 658 | */ |
| 659 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, |
| 660 | StartAndEndA2dpSbcHardwareSession) { |
| 661 | if (!IsOffloadSupported()) { |
| 662 | return; |
| 663 | } |
| 664 | |
| 665 | CodecConfiguration codec_config = { |
| 666 | .codecType = CodecType::SBC, |
| 667 | .encodedAudioBitrate = 328000, |
| 668 | .peerMtu = 1005, |
| 669 | .isScmstEnabled = false, |
| 670 | }; |
| 671 | auto sbc_codec_specifics = GetSbcCodecSpecificSupportedList(true); |
| 672 | |
| 673 | for (auto& codec_specific : sbc_codec_specifics) { |
| 674 | copy_codec_specific(codec_config.config, codec_specific); |
| 675 | DataMQDesc mq_desc; |
| 676 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 677 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 678 | |
| 679 | ASSERT_TRUE(aidl_retval.isOk()); |
| 680 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | /** |
| 685 | * Test whether each provider of type |
| 686 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 687 | * AAC hardware encoding config |
| 688 | */ |
| 689 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, |
| 690 | StartAndEndA2dpAacHardwareSession) { |
| 691 | if (!IsOffloadSupported()) { |
| 692 | return; |
| 693 | } |
| 694 | |
| 695 | CodecConfiguration codec_config = { |
| 696 | .codecType = CodecType::AAC, |
| 697 | .encodedAudioBitrate = 320000, |
| 698 | .peerMtu = 1005, |
| 699 | .isScmstEnabled = false, |
| 700 | }; |
| 701 | auto aac_codec_specifics = GetAacCodecSpecificSupportedList(true); |
| 702 | |
| 703 | for (auto& codec_specific : aac_codec_specifics) { |
| 704 | copy_codec_specific(codec_config.config, codec_specific); |
| 705 | DataMQDesc mq_desc; |
| 706 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 707 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 708 | |
| 709 | ASSERT_TRUE(aidl_retval.isOk()); |
| 710 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Test whether each provider of type |
| 716 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 717 | * LDAC hardware encoding config |
| 718 | */ |
| 719 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, |
| 720 | StartAndEndA2dpLdacHardwareSession) { |
| 721 | if (!IsOffloadSupported()) { |
| 722 | return; |
| 723 | } |
| 724 | |
| 725 | CodecConfiguration codec_config = { |
| 726 | .codecType = CodecType::LDAC, |
| 727 | .encodedAudioBitrate = 990000, |
| 728 | .peerMtu = 1005, |
| 729 | .isScmstEnabled = false, |
| 730 | }; |
| 731 | auto ldac_codec_specifics = GetLdacCodecSpecificSupportedList(true); |
| 732 | |
| 733 | for (auto& codec_specific : ldac_codec_specifics) { |
| 734 | copy_codec_specific(codec_config.config, codec_specific); |
| 735 | DataMQDesc mq_desc; |
| 736 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 737 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 738 | |
| 739 | ASSERT_TRUE(aidl_retval.isOk()); |
| 740 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * Test whether each provider of type |
| 746 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 747 | * LDAC hardware encoding config |
| 748 | */ |
| 749 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, |
| 750 | StartAndEndA2dpLc3HardwareSession) { |
| 751 | if (!IsOffloadSupported()) { |
| 752 | return; |
| 753 | } |
| 754 | |
| 755 | CodecConfiguration codec_config = { |
| 756 | .codecType = CodecType::LC3, |
| 757 | .encodedAudioBitrate = 990000, |
| 758 | .peerMtu = 1005, |
| 759 | .isScmstEnabled = false, |
| 760 | }; |
| 761 | auto lc3_codec_specifics = GetLc3CodecSpecificSupportedList(true); |
| 762 | |
| 763 | for (auto& codec_specific : lc3_codec_specifics) { |
| 764 | copy_codec_specific(codec_config.config, codec_specific); |
| 765 | DataMQDesc mq_desc; |
| 766 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 767 | audio_port_, AudioConfiguration(codec_config), latency_modes, &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 768 | |
| 769 | ASSERT_TRUE(aidl_retval.isOk()); |
| 770 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | /** |
| 775 | * Test whether each provider of type |
| 776 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 777 | * AptX hardware encoding config |
| 778 | */ |
| 779 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, |
| 780 | StartAndEndA2dpAptxHardwareSession) { |
| 781 | if (!IsOffloadSupported()) { |
| 782 | return; |
| 783 | } |
| 784 | |
| 785 | for (auto codec_type : {CodecType::APTX, CodecType::APTX_HD}) { |
| 786 | CodecConfiguration codec_config = { |
| 787 | .codecType = codec_type, |
| 788 | .encodedAudioBitrate = |
| 789 | (codec_type == CodecType::APTX ? 352000 : 576000), |
| 790 | .peerMtu = 1005, |
| 791 | .isScmstEnabled = false, |
| 792 | }; |
| 793 | |
| 794 | auto aptx_codec_specifics = GetAptxCodecSpecificSupportedList( |
| 795 | (codec_type == CodecType::APTX_HD ? true : false), true); |
| 796 | |
| 797 | for (auto& codec_specific : aptx_codec_specifics) { |
| 798 | copy_codec_specific(codec_config.config, codec_specific); |
| 799 | DataMQDesc mq_desc; |
| 800 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 801 | audio_port_, AudioConfiguration(codec_config), latency_modes, |
| 802 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 803 | |
| 804 | ASSERT_TRUE(aidl_retval.isOk()); |
| 805 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 806 | } |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | /** |
| 811 | * Test whether each provider of type |
| 812 | * SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with |
| 813 | * an invalid codec config |
| 814 | */ |
| 815 | TEST_P(BluetoothAudioProviderA2dpHardwareAidl, |
| 816 | StartAndEndA2dpHardwareSessionInvalidCodecConfig) { |
| 817 | if (!IsOffloadSupported()) { |
| 818 | return; |
| 819 | } |
| 820 | ASSERT_NE(audio_provider_, nullptr); |
| 821 | |
| 822 | std::vector<CodecConfiguration::CodecSpecific> codec_specifics; |
| 823 | for (auto codec_type : a2dp_codec_types) { |
| 824 | switch (codec_type) { |
| 825 | case CodecType::SBC: |
| 826 | codec_specifics = GetSbcCodecSpecificSupportedList(false); |
| 827 | break; |
| 828 | case CodecType::AAC: |
| 829 | codec_specifics = GetAacCodecSpecificSupportedList(false); |
| 830 | break; |
| 831 | case CodecType::LDAC: |
| 832 | codec_specifics = GetLdacCodecSpecificSupportedList(false); |
| 833 | break; |
| 834 | case CodecType::APTX: |
| 835 | codec_specifics = GetAptxCodecSpecificSupportedList(false, false); |
| 836 | break; |
| 837 | case CodecType::APTX_HD: |
| 838 | codec_specifics = GetAptxCodecSpecificSupportedList(true, false); |
| 839 | break; |
| 840 | case CodecType::LC3: |
| 841 | codec_specifics = GetLc3CodecSpecificSupportedList(false); |
| 842 | continue; |
| 843 | case CodecType::APTX_ADAPTIVE: |
| 844 | case CodecType::VENDOR: |
| 845 | case CodecType::UNKNOWN: |
| 846 | codec_specifics.clear(); |
| 847 | break; |
| 848 | } |
| 849 | if (codec_specifics.empty()) { |
| 850 | continue; |
| 851 | } |
| 852 | |
| 853 | CodecConfiguration codec_config = { |
| 854 | .codecType = codec_type, |
| 855 | .encodedAudioBitrate = 328000, |
| 856 | .peerMtu = 1005, |
| 857 | .isScmstEnabled = false, |
| 858 | }; |
| 859 | for (auto codec_specific : codec_specifics) { |
| 860 | copy_codec_specific(codec_config.config, codec_specific); |
| 861 | DataMQDesc mq_desc; |
| 862 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 863 | audio_port_, AudioConfiguration(codec_config), latency_modes, |
| 864 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 865 | |
| 866 | // AIDL call should fail on invalid codec |
| 867 | ASSERT_FALSE(aidl_retval.isOk()); |
| 868 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 869 | } |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | /** |
| 874 | * openProvider HEARING_AID_SOFTWARE_ENCODING_DATAPATH |
| 875 | */ |
| 876 | class BluetoothAudioProviderHearingAidSoftwareAidl |
| 877 | : public BluetoothAudioProviderFactoryAidl { |
| 878 | public: |
| 879 | virtual void SetUp() override { |
| 880 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 881 | GetProviderCapabilitiesHelper( |
| 882 | SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH); |
| 883 | OpenProviderHelper(SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH); |
| 884 | ASSERT_NE(audio_provider_, nullptr); |
| 885 | } |
| 886 | |
| 887 | virtual void TearDown() override { |
| 888 | audio_port_ = nullptr; |
| 889 | audio_provider_ = nullptr; |
| 890 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 891 | } |
| 892 | |
| 893 | static constexpr int32_t hearing_aid_sample_rates_[] = {0, 16000, 24000}; |
| 894 | static constexpr int8_t hearing_aid_bits_per_samples_[] = {0, 16, 24}; |
| 895 | static constexpr ChannelMode hearing_aid_channel_modes_[] = { |
| 896 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 897 | }; |
| 898 | |
| 899 | /** |
| 900 | * Test whether we can open a provider of type |
| 901 | */ |
| 902 | TEST_P(BluetoothAudioProviderHearingAidSoftwareAidl, |
| 903 | OpenHearingAidSoftwareProvider) {} |
| 904 | |
| 905 | /** |
| 906 | * Test whether each provider of type |
| 907 | * SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH can be started and |
| 908 | * stopped with different PCM config |
| 909 | */ |
| 910 | TEST_P(BluetoothAudioProviderHearingAidSoftwareAidl, |
| 911 | StartAndEndHearingAidSessionWithPossiblePcmConfig) { |
| 912 | for (int32_t sample_rate : hearing_aid_sample_rates_) { |
| 913 | for (int8_t bits_per_sample : hearing_aid_bits_per_samples_) { |
| 914 | for (auto channel_mode : hearing_aid_channel_modes_) { |
| 915 | PcmConfiguration pcm_config{ |
| 916 | .sampleRateHz = sample_rate, |
| 917 | .bitsPerSample = bits_per_sample, |
| 918 | .channelMode = channel_mode, |
| 919 | }; |
| 920 | bool is_codec_config_valid = IsPcmConfigSupported(pcm_config); |
| 921 | DataMQDesc mq_desc; |
| 922 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 923 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 924 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 925 | DataMQ data_mq(mq_desc); |
| 926 | |
| 927 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 928 | if (is_codec_config_valid) { |
| 929 | EXPECT_TRUE(data_mq.isValid()); |
| 930 | } |
| 931 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 932 | } |
| 933 | } |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | /** |
| 938 | * openProvider LE_AUDIO_SOFTWARE_ENCODING_DATAPATH |
| 939 | */ |
| 940 | class BluetoothAudioProviderLeAudioOutputSoftwareAidl |
| 941 | : public BluetoothAudioProviderFactoryAidl { |
| 942 | public: |
| 943 | virtual void SetUp() override { |
| 944 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 945 | GetProviderCapabilitiesHelper( |
| 946 | SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH); |
| 947 | OpenProviderHelper(SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH); |
| 948 | ASSERT_NE(audio_provider_, nullptr); |
| 949 | } |
| 950 | |
| 951 | virtual void TearDown() override { |
| 952 | audio_port_ = nullptr; |
| 953 | audio_provider_ = nullptr; |
| 954 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 955 | } |
| 956 | |
| 957 | static constexpr int32_t le_audio_output_sample_rates_[] = { |
| 958 | 0, 8000, 16000, 24000, 32000, 44100, 48000, |
| 959 | }; |
| 960 | static constexpr int8_t le_audio_output_bits_per_samples_[] = {0, 16, 24}; |
| 961 | static constexpr ChannelMode le_audio_output_channel_modes_[] = { |
| 962 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 963 | static constexpr int32_t le_audio_output_data_interval_us_[] = { |
| 964 | 0 /* Invalid */, 10000 /* Valid 10ms */}; |
| 965 | }; |
| 966 | |
| 967 | /** |
| 968 | * Test whether each provider of type |
| 969 | * SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH can be started and |
| 970 | * stopped |
| 971 | */ |
| 972 | TEST_P(BluetoothAudioProviderLeAudioOutputSoftwareAidl, |
| 973 | OpenLeAudioOutputSoftwareProvider) {} |
| 974 | |
| 975 | /** |
| 976 | * Test whether each provider of type |
| 977 | * SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH can be started and |
| 978 | * stopped with different PCM config |
| 979 | */ |
| 980 | TEST_P(BluetoothAudioProviderLeAudioOutputSoftwareAidl, |
| 981 | StartAndEndLeAudioOutputSessionWithPossiblePcmConfig) { |
| 982 | for (auto sample_rate : le_audio_output_sample_rates_) { |
| 983 | for (auto bits_per_sample : le_audio_output_bits_per_samples_) { |
| 984 | for (auto channel_mode : le_audio_output_channel_modes_) { |
| 985 | for (auto data_interval_us : le_audio_output_data_interval_us_) { |
| 986 | PcmConfiguration pcm_config{ |
| 987 | .sampleRateHz = sample_rate, |
| 988 | .bitsPerSample = bits_per_sample, |
| 989 | .channelMode = channel_mode, |
| 990 | .dataIntervalUs = data_interval_us, |
| 991 | }; |
Josh Wu | 8a1be76 | 2022-02-15 09:37:29 -0800 | [diff] [blame] | 992 | bool is_codec_config_valid = |
| 993 | IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 994 | DataMQDesc mq_desc; |
| 995 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 996 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 997 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 998 | DataMQ data_mq(mq_desc); |
| 999 | |
| 1000 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1001 | if (is_codec_config_valid) { |
| 1002 | EXPECT_TRUE(data_mq.isValid()); |
| 1003 | } |
| 1004 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1005 | } |
| 1006 | } |
| 1007 | } |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | /** |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1012 | * openProvider LE_AUDIO_SOFTWARE_DECODING_DATAPATH |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1013 | */ |
| 1014 | class BluetoothAudioProviderLeAudioInputSoftwareAidl |
| 1015 | : public BluetoothAudioProviderFactoryAidl { |
| 1016 | public: |
| 1017 | virtual void SetUp() override { |
| 1018 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1019 | GetProviderCapabilitiesHelper( |
| 1020 | SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH); |
| 1021 | OpenProviderHelper(SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH); |
| 1022 | ASSERT_NE(audio_provider_, nullptr); |
| 1023 | } |
| 1024 | |
| 1025 | virtual void TearDown() override { |
| 1026 | audio_port_ = nullptr; |
| 1027 | audio_provider_ = nullptr; |
| 1028 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1029 | } |
| 1030 | |
| 1031 | static constexpr int32_t le_audio_input_sample_rates_[] = { |
| 1032 | 0, 8000, 16000, 24000, 32000, 44100, 48000}; |
| 1033 | static constexpr int8_t le_audio_input_bits_per_samples_[] = {0, 16, 24}; |
| 1034 | static constexpr ChannelMode le_audio_input_channel_modes_[] = { |
| 1035 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 1036 | static constexpr int32_t le_audio_input_data_interval_us_[] = { |
| 1037 | 0 /* Invalid */, 10000 /* Valid 10ms */}; |
| 1038 | }; |
| 1039 | |
| 1040 | /** |
| 1041 | * Test whether each provider of type |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1042 | * SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH can be started and |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1043 | * stopped |
| 1044 | */ |
| 1045 | TEST_P(BluetoothAudioProviderLeAudioInputSoftwareAidl, |
| 1046 | OpenLeAudioInputSoftwareProvider) {} |
| 1047 | |
| 1048 | /** |
| 1049 | * Test whether each provider of type |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1050 | * SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH can be started and |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1051 | * stopped with different PCM config |
| 1052 | */ |
| 1053 | TEST_P(BluetoothAudioProviderLeAudioInputSoftwareAidl, |
| 1054 | StartAndEndLeAudioInputSessionWithPossiblePcmConfig) { |
| 1055 | for (auto sample_rate : le_audio_input_sample_rates_) { |
| 1056 | for (auto bits_per_sample : le_audio_input_bits_per_samples_) { |
| 1057 | for (auto channel_mode : le_audio_input_channel_modes_) { |
| 1058 | for (auto data_interval_us : le_audio_input_data_interval_us_) { |
| 1059 | PcmConfiguration pcm_config{ |
| 1060 | .sampleRateHz = sample_rate, |
| 1061 | .bitsPerSample = bits_per_sample, |
| 1062 | .channelMode = channel_mode, |
| 1063 | .dataIntervalUs = data_interval_us, |
| 1064 | }; |
Josh Wu | 8a1be76 | 2022-02-15 09:37:29 -0800 | [diff] [blame] | 1065 | bool is_codec_config_valid = |
| 1066 | IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1067 | DataMQDesc mq_desc; |
| 1068 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1069 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 1070 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1071 | DataMQ data_mq(mq_desc); |
| 1072 | |
| 1073 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1074 | if (is_codec_config_valid) { |
| 1075 | EXPECT_TRUE(data_mq.isValid()); |
| 1076 | } |
| 1077 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | /** |
Alice Kuo | 04a399a | 2022-02-16 09:19:56 +0800 | [diff] [blame] | 1085 | * openProvider LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1086 | */ |
| 1087 | class BluetoothAudioProviderLeAudioOutputHardwareAidl |
| 1088 | : public BluetoothAudioProviderFactoryAidl { |
| 1089 | public: |
| 1090 | virtual void SetUp() override { |
| 1091 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1092 | GetProviderCapabilitiesHelper( |
| 1093 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1094 | OpenProviderHelper( |
| 1095 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1096 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1097 | audio_provider_ != nullptr); |
| 1098 | } |
| 1099 | |
| 1100 | virtual void TearDown() override { |
| 1101 | audio_port_ = nullptr; |
| 1102 | audio_provider_ = nullptr; |
| 1103 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1104 | } |
| 1105 | |
| 1106 | bool IsOffloadOutputSupported() { |
| 1107 | for (auto& capability : temp_provider_capabilities_) { |
| 1108 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1109 | continue; |
| 1110 | } |
| 1111 | auto& le_audio_capability = |
| 1112 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1113 | if (le_audio_capability.unicastEncodeCapability.codecType != |
| 1114 | CodecType::UNKNOWN) |
| 1115 | return true; |
| 1116 | } |
| 1117 | return false; |
| 1118 | } |
| 1119 | |
| 1120 | std::vector<Lc3Configuration> GetUnicastLc3SupportedList(bool decoding, |
| 1121 | bool supported) { |
| 1122 | std::vector<Lc3Configuration> le_audio_codec_configs; |
| 1123 | if (!supported) { |
| 1124 | Lc3Configuration lc3_config{.samplingFrequencyHz = 0, .pcmBitDepth = 0}; |
| 1125 | le_audio_codec_configs.push_back(lc3_config); |
| 1126 | return le_audio_codec_configs; |
| 1127 | } |
| 1128 | |
| 1129 | // There might be more than one LeAudioCodecCapabilitiesSetting |
| 1130 | std::vector<Lc3Capabilities> lc3_capabilities; |
| 1131 | for (auto& capability : temp_provider_capabilities_) { |
| 1132 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1133 | continue; |
| 1134 | } |
| 1135 | auto& le_audio_capability = |
| 1136 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1137 | auto& unicast_capability = |
| 1138 | decoding ? le_audio_capability.unicastDecodeCapability |
| 1139 | : le_audio_capability.unicastEncodeCapability; |
| 1140 | if (unicast_capability.codecType != CodecType::LC3) { |
| 1141 | continue; |
| 1142 | } |
| 1143 | auto& lc3_capability = unicast_capability.leAudioCodecCapabilities.get< |
| 1144 | UnicastCapability::LeAudioCodecCapabilities::lc3Capabilities>(); |
| 1145 | lc3_capabilities.push_back(lc3_capability); |
| 1146 | } |
| 1147 | |
| 1148 | // Combine those parameters into one list of LeAudioCodecConfiguration |
| 1149 | // This seems horrible, but usually each Lc3Capability only contains a |
| 1150 | // single Lc3Configuration, which means every array has a length of 1. |
| 1151 | for (auto& lc3_capability : lc3_capabilities) { |
| 1152 | for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) { |
| 1153 | for (int32_t frameDurationUs : lc3_capability.frameDurationUs) { |
| 1154 | for (int32_t octetsPerFrame : lc3_capability.octetsPerFrame) { |
| 1155 | Lc3Configuration lc3_config = { |
| 1156 | .samplingFrequencyHz = samplingFrequencyHz, |
| 1157 | .frameDurationUs = frameDurationUs, |
| 1158 | .octetsPerFrame = octetsPerFrame, |
| 1159 | }; |
| 1160 | le_audio_codec_configs.push_back(lc3_config); |
| 1161 | } |
| 1162 | } |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | return le_audio_codec_configs; |
| 1167 | } |
| 1168 | |
| 1169 | LeAudioCodecCapabilitiesSetting temp_le_audio_capabilities_; |
| 1170 | }; |
| 1171 | |
| 1172 | /** |
| 1173 | * Test whether each provider of type |
| 1174 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1175 | * stopped |
| 1176 | */ |
| 1177 | TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1178 | OpenLeAudioOutputHardwareProvider) {} |
| 1179 | |
| 1180 | /** |
| 1181 | * Test whether each provider of type |
| 1182 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1183 | * stopped with Unicast hardware encoding config |
| 1184 | */ |
| 1185 | TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1186 | StartAndEndLeAudioOutputSessionWithPossibleUnicastConfig) { |
| 1187 | if (!IsOffloadOutputSupported()) { |
| 1188 | return; |
| 1189 | } |
| 1190 | |
| 1191 | auto lc3_codec_configs = |
| 1192 | GetUnicastLc3SupportedList(false /* decoding */, true /* supported */); |
| 1193 | LeAudioConfiguration le_audio_config = { |
| 1194 | .codecType = CodecType::LC3, |
| 1195 | .peerDelayUs = 0, |
| 1196 | }; |
| 1197 | |
| 1198 | for (auto& lc3_config : lc3_codec_configs) { |
| 1199 | le_audio_config.leAudioCodecConfig |
| 1200 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1201 | DataMQDesc mq_desc; |
| 1202 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1203 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1204 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1205 | |
| 1206 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1207 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * Test whether each provider of type |
| 1213 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1214 | * stopped with Unicast hardware encoding config |
| 1215 | * |
| 1216 | * Disabled since offload codec checking is not ready |
| 1217 | */ |
| 1218 | TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1219 | DISABLED_StartAndEndLeAudioOutputSessionWithInvalidAudioConfiguration) { |
| 1220 | if (!IsOffloadOutputSupported()) { |
| 1221 | return; |
| 1222 | } |
| 1223 | |
| 1224 | auto lc3_codec_configs = |
| 1225 | GetUnicastLc3SupportedList(false /* decoding */, false /* supported */); |
| 1226 | LeAudioConfiguration le_audio_config = { |
| 1227 | .codecType = CodecType::LC3, |
| 1228 | .peerDelayUs = 0, |
| 1229 | }; |
| 1230 | |
| 1231 | for (auto& lc3_config : lc3_codec_configs) { |
| 1232 | le_audio_config.leAudioCodecConfig |
| 1233 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1234 | DataMQDesc mq_desc; |
| 1235 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1236 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1237 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1238 | |
| 1239 | // AIDL call should fail on invalid codec |
| 1240 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1241 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1242 | } |
| 1243 | } |
| 1244 | |
| 1245 | /** |
| 1246 | * openProvider LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH |
| 1247 | */ |
| 1248 | class BluetoothAudioProviderLeAudioInputHardwareAidl |
| 1249 | : public BluetoothAudioProviderLeAudioOutputHardwareAidl { |
| 1250 | public: |
| 1251 | virtual void SetUp() override { |
| 1252 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1253 | GetProviderCapabilitiesHelper( |
| 1254 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH); |
| 1255 | OpenProviderHelper( |
| 1256 | SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH); |
| 1257 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1258 | audio_provider_ != nullptr); |
| 1259 | } |
| 1260 | |
| 1261 | bool IsOffloadInputSupported() { |
| 1262 | for (auto& capability : temp_provider_capabilities_) { |
| 1263 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1264 | continue; |
| 1265 | } |
| 1266 | auto& le_audio_capability = |
| 1267 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1268 | if (le_audio_capability.unicastDecodeCapability.codecType != |
| 1269 | CodecType::UNKNOWN) |
| 1270 | return true; |
| 1271 | } |
| 1272 | return false; |
| 1273 | } |
| 1274 | |
| 1275 | virtual void TearDown() override { |
| 1276 | audio_port_ = nullptr; |
| 1277 | audio_provider_ = nullptr; |
| 1278 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1279 | } |
| 1280 | }; |
| 1281 | |
| 1282 | /** |
| 1283 | * Test whether each provider of type |
| 1284 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1285 | * stopped |
| 1286 | */ |
| 1287 | TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1288 | OpenLeAudioInputHardwareProvider) {} |
| 1289 | |
| 1290 | /** |
| 1291 | * Test whether each provider of type |
| 1292 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1293 | * stopped with Unicast hardware encoding config |
| 1294 | */ |
| 1295 | TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1296 | StartAndEndLeAudioInputSessionWithPossibleUnicastConfig) { |
| 1297 | if (!IsOffloadInputSupported()) { |
| 1298 | return; |
| 1299 | } |
| 1300 | |
| 1301 | auto lc3_codec_configs = |
| 1302 | GetUnicastLc3SupportedList(true /* decoding */, true /* supported */); |
| 1303 | LeAudioConfiguration le_audio_config = { |
| 1304 | .codecType = CodecType::LC3, |
| 1305 | .peerDelayUs = 0, |
| 1306 | }; |
| 1307 | |
| 1308 | for (auto& lc3_config : lc3_codec_configs) { |
| 1309 | le_audio_config.leAudioCodecConfig |
| 1310 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1311 | DataMQDesc mq_desc; |
| 1312 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1313 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1314 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1315 | |
| 1316 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1317 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | /** |
| 1322 | * Test whether each provider of type |
| 1323 | * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and |
| 1324 | * stopped with Unicast hardware encoding config |
| 1325 | * |
| 1326 | * Disabled since offload codec checking is not ready |
| 1327 | */ |
| 1328 | TEST_P(BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1329 | DISABLED_StartAndEndLeAudioInputSessionWithInvalidAudioConfiguration) { |
| 1330 | if (!IsOffloadInputSupported()) { |
| 1331 | return; |
| 1332 | } |
| 1333 | |
| 1334 | auto lc3_codec_configs = |
| 1335 | GetUnicastLc3SupportedList(true /* decoding */, false /* supported */); |
| 1336 | LeAudioConfiguration le_audio_config = { |
| 1337 | .codecType = CodecType::LC3, |
| 1338 | .peerDelayUs = 0, |
| 1339 | }; |
| 1340 | |
| 1341 | for (auto& lc3_config : lc3_codec_configs) { |
| 1342 | le_audio_config.leAudioCodecConfig |
| 1343 | .set<LeAudioCodecConfiguration::lc3Config>(lc3_config); |
| 1344 | |
| 1345 | DataMQDesc mq_desc; |
| 1346 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1347 | audio_port_, AudioConfiguration(le_audio_config), latency_modes, |
| 1348 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1349 | |
| 1350 | // AIDL call should fail on invalid codec |
| 1351 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1352 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1353 | } |
| 1354 | } |
| 1355 | |
| 1356 | /** |
| 1357 | * openProvider LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH |
| 1358 | */ |
| 1359 | class BluetoothAudioProviderLeAudioBroadcastSoftwareAidl |
| 1360 | : public BluetoothAudioProviderFactoryAidl { |
| 1361 | public: |
| 1362 | virtual void SetUp() override { |
| 1363 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1364 | GetProviderCapabilitiesHelper( |
| 1365 | SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH); |
| 1366 | OpenProviderHelper( |
| 1367 | SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH); |
| 1368 | ASSERT_NE(audio_provider_, nullptr); |
| 1369 | } |
| 1370 | |
| 1371 | virtual void TearDown() override { |
| 1372 | audio_port_ = nullptr; |
| 1373 | audio_provider_ = nullptr; |
| 1374 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1375 | } |
| 1376 | |
| 1377 | static constexpr int32_t le_audio_output_sample_rates_[] = { |
| 1378 | 0, 8000, 16000, 24000, 32000, 44100, 48000, |
| 1379 | }; |
| 1380 | static constexpr int8_t le_audio_output_bits_per_samples_[] = {0, 16, 24}; |
| 1381 | static constexpr ChannelMode le_audio_output_channel_modes_[] = { |
| 1382 | ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO}; |
| 1383 | static constexpr int32_t le_audio_output_data_interval_us_[] = { |
| 1384 | 0 /* Invalid */, 10000 /* Valid 10ms */}; |
| 1385 | }; |
| 1386 | |
| 1387 | /** |
| 1388 | * Test whether each provider of type |
| 1389 | * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started and |
| 1390 | * stopped |
| 1391 | */ |
| 1392 | TEST_P(BluetoothAudioProviderLeAudioBroadcastSoftwareAidl, |
| 1393 | DISABLED_OpenLeAudioOutputSoftwareProvider) {} |
| 1394 | |
| 1395 | /** |
| 1396 | * Test whether each provider of type |
| 1397 | * SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH can be started and |
| 1398 | * stopped with different PCM config |
| 1399 | */ |
| 1400 | TEST_P(BluetoothAudioProviderLeAudioBroadcastSoftwareAidl, |
| 1401 | DISABLED_StartAndEndLeAudioOutputSessionWithPossiblePcmConfig) { |
| 1402 | for (auto sample_rate : le_audio_output_sample_rates_) { |
| 1403 | for (auto bits_per_sample : le_audio_output_bits_per_samples_) { |
| 1404 | for (auto channel_mode : le_audio_output_channel_modes_) { |
| 1405 | for (auto data_interval_us : le_audio_output_data_interval_us_) { |
| 1406 | PcmConfiguration pcm_config{ |
| 1407 | .sampleRateHz = sample_rate, |
| 1408 | .bitsPerSample = bits_per_sample, |
| 1409 | .channelMode = channel_mode, |
| 1410 | .dataIntervalUs = data_interval_us, |
| 1411 | }; |
Josh Wu | 8a1be76 | 2022-02-15 09:37:29 -0800 | [diff] [blame] | 1412 | bool is_codec_config_valid = |
| 1413 | IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0; |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1414 | DataMQDesc mq_desc; |
| 1415 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 1416 | audio_port_, AudioConfiguration(pcm_config), latency_modes, |
| 1417 | &mq_desc); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1418 | DataMQ data_mq(mq_desc); |
| 1419 | |
| 1420 | EXPECT_EQ(aidl_retval.isOk(), is_codec_config_valid); |
| 1421 | if (is_codec_config_valid) { |
| 1422 | EXPECT_TRUE(data_mq.isValid()); |
| 1423 | } |
| 1424 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1425 | } |
| 1426 | } |
| 1427 | } |
| 1428 | } |
| 1429 | } |
| 1430 | |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1431 | /** |
| 1432 | * openProvider LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH |
| 1433 | */ |
| 1434 | class BluetoothAudioProviderLeAudioBroadcastHardwareAidl |
| 1435 | : public BluetoothAudioProviderFactoryAidl { |
| 1436 | public: |
| 1437 | virtual void SetUp() override { |
| 1438 | BluetoothAudioProviderFactoryAidl::SetUp(); |
| 1439 | GetProviderCapabilitiesHelper( |
| 1440 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1441 | OpenProviderHelper( |
| 1442 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH); |
| 1443 | ASSERT_TRUE(temp_provider_capabilities_.empty() || |
| 1444 | audio_provider_ != nullptr); |
| 1445 | } |
| 1446 | |
| 1447 | virtual void TearDown() override { |
| 1448 | audio_port_ = nullptr; |
| 1449 | audio_provider_ = nullptr; |
| 1450 | BluetoothAudioProviderFactoryAidl::TearDown(); |
| 1451 | } |
| 1452 | |
| 1453 | bool IsBroadcastOffloadSupported() { |
| 1454 | for (auto& capability : temp_provider_capabilities_) { |
| 1455 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1456 | continue; |
| 1457 | } |
| 1458 | auto& le_audio_capability = |
| 1459 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1460 | if (le_audio_capability.broadcastCapability.codecType != |
| 1461 | CodecType::UNKNOWN) |
| 1462 | return true; |
| 1463 | } |
| 1464 | return false; |
| 1465 | } |
| 1466 | |
| 1467 | std::vector<Lc3Configuration> GetBroadcastLc3SupportedList(bool supported) { |
| 1468 | std::vector<Lc3Configuration> le_audio_codec_configs; |
| 1469 | if (!supported) { |
| 1470 | Lc3Configuration lc3_config{.samplingFrequencyHz = 0, .pcmBitDepth = 0}; |
| 1471 | le_audio_codec_configs.push_back(lc3_config); |
| 1472 | return le_audio_codec_configs; |
| 1473 | } |
| 1474 | |
| 1475 | // There might be more than one LeAudioCodecCapabilitiesSetting |
| 1476 | std::vector<Lc3Capabilities> lc3_capabilities; |
| 1477 | for (auto& capability : temp_provider_capabilities_) { |
| 1478 | if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { |
| 1479 | continue; |
| 1480 | } |
| 1481 | auto& le_audio_capability = |
| 1482 | capability.get<AudioCapabilities::leAudioCapabilities>(); |
| 1483 | auto& broadcast_capability = le_audio_capability.broadcastCapability; |
| 1484 | if (broadcast_capability.codecType != CodecType::LC3) { |
| 1485 | continue; |
| 1486 | } |
| 1487 | auto& lc3_capability = broadcast_capability.leAudioCodecCapabilities.get< |
| 1488 | BroadcastCapability::LeAudioCodecCapabilities::lc3Capabilities>(); |
| 1489 | for (int idx = 0; idx < lc3_capability->size(); idx++) |
| 1490 | lc3_capabilities.push_back(*lc3_capability->at(idx)); |
| 1491 | } |
| 1492 | |
| 1493 | // Combine those parameters into one list of LeAudioCodecConfiguration |
| 1494 | // This seems horrible, but usually each Lc3Capability only contains a |
| 1495 | // single Lc3Configuration, which means every array has a length of 1. |
| 1496 | for (auto& lc3_capability : lc3_capabilities) { |
| 1497 | for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) { |
| 1498 | for (int32_t frameDurationUs : lc3_capability.frameDurationUs) { |
| 1499 | for (int32_t octetsPerFrame : lc3_capability.octetsPerFrame) { |
| 1500 | Lc3Configuration lc3_config = { |
| 1501 | .samplingFrequencyHz = samplingFrequencyHz, |
| 1502 | .frameDurationUs = frameDurationUs, |
| 1503 | .octetsPerFrame = octetsPerFrame, |
| 1504 | }; |
| 1505 | le_audio_codec_configs.push_back(lc3_config); |
| 1506 | } |
| 1507 | } |
| 1508 | } |
| 1509 | } |
| 1510 | |
| 1511 | return le_audio_codec_configs; |
| 1512 | } |
| 1513 | |
| 1514 | LeAudioCodecCapabilitiesSetting temp_le_audio_capabilities_; |
| 1515 | }; |
| 1516 | |
| 1517 | /** |
| 1518 | * Test whether each provider of type |
| 1519 | * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be |
| 1520 | * started and stopped |
| 1521 | */ |
| 1522 | TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1523 | OpenLeAudioOutputHardwareProvider) {} |
| 1524 | |
| 1525 | /** |
| 1526 | * Test whether each provider of type |
| 1527 | * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be |
| 1528 | * started and stopped with broadcast hardware encoding config |
| 1529 | */ |
| 1530 | TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1531 | StartAndEndLeAudioBroadcastSessionWithPossibleBroadcastConfig) { |
| 1532 | if (!IsBroadcastOffloadSupported()) { |
| 1533 | return; |
| 1534 | } |
| 1535 | |
| 1536 | auto lc3_codec_configs = GetBroadcastLc3SupportedList(true /* supported */); |
| 1537 | LeAudioBroadcastConfiguration le_audio_broadcast_config = { |
| 1538 | .codecType = CodecType::LC3, |
| 1539 | .streamMap = {}, |
| 1540 | }; |
| 1541 | |
| 1542 | for (auto& lc3_config : lc3_codec_configs) { |
| 1543 | le_audio_broadcast_config.streamMap[0] |
| 1544 | .leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>( |
| 1545 | lc3_config); |
| 1546 | DataMQDesc mq_desc; |
| 1547 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | 60d52e4 | 2022-02-16 12:19:12 -0800 | [diff] [blame^] | 1548 | audio_port_, AudioConfiguration(le_audio_broadcast_config), |
| 1549 | latency_modes, &mq_desc); |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1550 | |
| 1551 | ASSERT_TRUE(aidl_retval.isOk()); |
| 1552 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | /** |
| 1557 | * Test whether each provider of type |
| 1558 | * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be |
| 1559 | * started and stopped with Broadcast hardware encoding config |
| 1560 | * |
| 1561 | * Disabled since offload codec checking is not ready |
| 1562 | */ |
| 1563 | TEST_P( |
| 1564 | BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1565 | DISABLED_StartAndEndLeAudioBroadcastSessionWithInvalidAudioConfiguration) { |
| 1566 | if (!IsBroadcastOffloadSupported()) { |
| 1567 | return; |
| 1568 | } |
| 1569 | |
| 1570 | auto lc3_codec_configs = GetBroadcastLc3SupportedList(false /* supported */); |
| 1571 | LeAudioBroadcastConfiguration le_audio_broadcast_config = { |
| 1572 | .codecType = CodecType::LC3, |
| 1573 | .streamMap = {}, |
| 1574 | }; |
| 1575 | |
| 1576 | for (auto& lc3_config : lc3_codec_configs) { |
| 1577 | le_audio_broadcast_config.streamMap[0] |
| 1578 | .leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>( |
| 1579 | lc3_config); |
| 1580 | DataMQDesc mq_desc; |
| 1581 | auto aidl_retval = audio_provider_->startSession( |
Chen Chen | 60d52e4 | 2022-02-16 12:19:12 -0800 | [diff] [blame^] | 1582 | audio_port_, AudioConfiguration(le_audio_broadcast_config), |
| 1583 | latency_modes, &mq_desc); |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1584 | |
| 1585 | // AIDL call should fail on invalid codec |
| 1586 | ASSERT_FALSE(aidl_retval.isOk()); |
| 1587 | EXPECT_TRUE(audio_provider_->endSession().isOk()); |
| 1588 | } |
| 1589 | } |
| 1590 | |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1591 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1592 | BluetoothAudioProviderFactoryAidl); |
| 1593 | INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProviderFactoryAidl, |
| 1594 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1595 | IBluetoothAudioProviderFactory::descriptor)), |
| 1596 | android::PrintInstanceNameToString); |
| 1597 | |
| 1598 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1599 | BluetoothAudioProviderA2dpSoftwareAidl); |
| 1600 | INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProviderA2dpSoftwareAidl, |
| 1601 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1602 | IBluetoothAudioProviderFactory::descriptor)), |
| 1603 | android::PrintInstanceNameToString); |
| 1604 | |
| 1605 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1606 | BluetoothAudioProviderA2dpHardwareAidl); |
| 1607 | INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProviderA2dpHardwareAidl, |
| 1608 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1609 | IBluetoothAudioProviderFactory::descriptor)), |
| 1610 | android::PrintInstanceNameToString); |
| 1611 | |
| 1612 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1613 | BluetoothAudioProviderHearingAidSoftwareAidl); |
| 1614 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1615 | BluetoothAudioProviderHearingAidSoftwareAidl, |
| 1616 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1617 | IBluetoothAudioProviderFactory::descriptor)), |
| 1618 | android::PrintInstanceNameToString); |
| 1619 | |
| 1620 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1621 | BluetoothAudioProviderLeAudioOutputSoftwareAidl); |
| 1622 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1623 | BluetoothAudioProviderLeAudioOutputSoftwareAidl, |
| 1624 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1625 | IBluetoothAudioProviderFactory::descriptor)), |
| 1626 | android::PrintInstanceNameToString); |
| 1627 | |
| 1628 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1629 | BluetoothAudioProviderLeAudioInputSoftwareAidl); |
| 1630 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1631 | BluetoothAudioProviderLeAudioInputSoftwareAidl, |
| 1632 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1633 | IBluetoothAudioProviderFactory::descriptor)), |
| 1634 | android::PrintInstanceNameToString); |
| 1635 | |
| 1636 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1637 | BluetoothAudioProviderLeAudioOutputHardwareAidl); |
| 1638 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1639 | BluetoothAudioProviderLeAudioOutputHardwareAidl, |
| 1640 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1641 | IBluetoothAudioProviderFactory::descriptor)), |
| 1642 | android::PrintInstanceNameToString); |
| 1643 | |
| 1644 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1645 | BluetoothAudioProviderLeAudioInputHardwareAidl); |
| 1646 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1647 | BluetoothAudioProviderLeAudioInputHardwareAidl, |
| 1648 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1649 | IBluetoothAudioProviderFactory::descriptor)), |
| 1650 | android::PrintInstanceNameToString); |
| 1651 | |
| 1652 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1653 | BluetoothAudioProviderLeAudioBroadcastSoftwareAidl); |
| 1654 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1655 | BluetoothAudioProviderLeAudioBroadcastSoftwareAidl, |
| 1656 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1657 | IBluetoothAudioProviderFactory::descriptor)), |
| 1658 | android::PrintInstanceNameToString); |
| 1659 | |
Alice Kuo | 336d90c | 2022-02-16 09:09:59 +0800 | [diff] [blame] | 1660 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST( |
| 1661 | BluetoothAudioProviderLeAudioBroadcastHardwareAidl); |
| 1662 | INSTANTIATE_TEST_SUITE_P(PerInstance, |
| 1663 | BluetoothAudioProviderLeAudioBroadcastHardwareAidl, |
| 1664 | testing::ValuesIn(android::getAidlHalInstanceNames( |
| 1665 | IBluetoothAudioProviderFactory::descriptor)), |
| 1666 | android::PrintInstanceNameToString); |
Josh Wu | 049e2cd | 2022-01-12 05:42:58 -0800 | [diff] [blame] | 1667 | |
| 1668 | int main(int argc, char** argv) { |
| 1669 | ::testing::InitGoogleTest(&argc, argv); |
| 1670 | ABinderProcess_setThreadPoolMaxThreadCount(1); |
| 1671 | ABinderProcess_startThreadPool(); |
| 1672 | return RUN_ALL_TESTS(); |
| 1673 | } |