• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 
17 #include <vector>
18 
19 #define LOG_TAG "AudioEffectHidlHalTest"
20 #include <android-base/logging.h>
21 #if MAJOR_VERSION <= 6
22 #include <system/audio.h>
23 #endif
24 
25 #include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h)
26 #include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h)
27 #include PATH(android/hardware/audio/effect/FILE_VERSION/IEqualizerEffect.h)
28 #include PATH(android/hardware/audio/effect/FILE_VERSION/ILoudnessEnhancerEffect.h)
29 #include PATH(android/hardware/audio/effect/FILE_VERSION/types.h)
30 #include <android/hidl/allocator/1.0/IAllocator.h>
31 #include <android/hidl/memory/1.0/IMemory.h>
32 #if MAJOR_VERSION >= 7
33 #include <android_audio_policy_configuration_V7_0-enums.h>
34 #endif
35 
36 #include <common/all-versions/VersionUtils.h>
37 
38 #include <cutils/properties.h>
39 #include <gtest/gtest.h>
40 #include <hidl/GtestPrinter.h>
41 #include <hidl/ServiceManagement.h>
42 
43 using ::android::sp;
44 using ::android::hardware::hidl_handle;
45 using ::android::hardware::hidl_memory;
46 using ::android::hardware::hidl_string;
47 using ::android::hardware::hidl_vec;
48 using ::android::hardware::MQDescriptorSync;
49 using ::android::hardware::Return;
50 using ::android::hardware::Void;
51 using ::android::hardware::audio::common::utils::mkEnumBitfield;
52 using ::android::hidl::allocator::V1_0::IAllocator;
53 using ::android::hidl::memory::V1_0::IMemory;
54 using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
55 using namespace ::android::hardware::audio::effect::CPP_VERSION;
56 #if MAJOR_VERSION >= 7
57 // Make an alias for enumerations generated from the APM config XSD.
58 namespace xsd {
59 using namespace ::android::audio::policy::configuration::CPP_VERSION;
60 }
61 #endif
62 
63 #ifndef ARRAY_SIZE
64 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
65 #endif
66 
67 class AudioEffectsFactoryHidlTest : public ::testing::TestWithParam<std::string> {
68   public:
SetUp()69     void SetUp() override {
70         effectsFactory = IEffectsFactory::getService(GetParam());
71         ASSERT_NE(effectsFactory, nullptr);
72     }
TearDown()73     void TearDown() override { effectsFactory.clear(); }
74 
75    protected:
description(const std::string & description)76     static void description(const std::string& description) {
77         RecordProperty("description", description);
78     }
79 
80     sp<IEffectsFactory> effectsFactory;
81 };
82 
TEST_P(AudioEffectsFactoryHidlTest,EnumerateEffects)83 TEST_P(AudioEffectsFactoryHidlTest, EnumerateEffects) {
84     description("Verify that EnumerateEffects returns at least one effect");
85     Result retval = Result::NOT_INITIALIZED;
86     size_t effectCount = 0;
87     Return<void> ret =
88         effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
89             retval = r;
90             effectCount = result.size();
91         });
92     EXPECT_TRUE(ret.isOk());
93     EXPECT_EQ(Result::OK, retval);
94     EXPECT_GT(effectCount, 0u);
95 }
96 
TEST_P(AudioEffectsFactoryHidlTest,CreateEffect)97 TEST_P(AudioEffectsFactoryHidlTest, CreateEffect) {
98     description("Verify that an effect can be created via CreateEffect");
99     bool gotEffect = false;
100     Uuid effectUuid;
101     Return<void> ret =
102         effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
103             if (r == Result::OK && result.size() > 0) {
104                 gotEffect = true;
105                 effectUuid = result[0].uuid;
106             }
107         });
108     ASSERT_TRUE(ret.isOk());
109     ASSERT_TRUE(gotEffect);
110     Result retval = Result::NOT_INITIALIZED;
111     sp<IEffect> effect;
112     ret = effectsFactory->createEffect(
113             effectUuid, 1 /*session*/, 1 /*ioHandle*/,
114 #if MAJOR_VERSION >= 6
115             0 /*device*/,
116 #endif
117             [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
118                 retval = r;
119                 if (r == Result::OK) {
120                     effect = result;
121                 }
122             });
123     EXPECT_TRUE(ret.isOk());
124     EXPECT_EQ(Result::OK, retval);
125     EXPECT_NE(nullptr, effect.get());
126 }
127 
TEST_P(AudioEffectsFactoryHidlTest,GetDescriptor)128 TEST_P(AudioEffectsFactoryHidlTest, GetDescriptor) {
129     description(
130         "Verify that effects factory can provide an effect descriptor via "
131         "GetDescriptor");
132     hidl_vec<EffectDescriptor> allDescriptors;
133     Return<void> ret =
134         effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
135             if (r == Result::OK) {
136                 allDescriptors = result;
137             }
138         });
139     ASSERT_TRUE(ret.isOk());
140     ASSERT_GT(allDescriptors.size(), 0u);
141     for (size_t i = 0; i < allDescriptors.size(); ++i) {
142         ret = effectsFactory->getDescriptor(allDescriptors[i].uuid,
143                                             [&](Result r, const EffectDescriptor& result) {
144                                                 EXPECT_EQ(r, Result::OK);
145                                                 EXPECT_EQ(result, allDescriptors[i]);
146                                             });
147     }
148     EXPECT_TRUE(ret.isOk());
149 }
150 
TEST_P(AudioEffectsFactoryHidlTest,DebugDumpInvalidArgument)151 TEST_P(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
152     description("Verify that debugDump doesn't crash on invalid arguments");
153 #if MAJOR_VERSION == 2
154     Return<void> ret = effectsFactory->debugDump(hidl_handle());
155 #elif MAJOR_VERSION >= 4
156     Return<void> ret = effectsFactory->debug(hidl_handle(), {});
157 #endif
158     ASSERT_TRUE(ret.isOk());
159 }
160 
161 // Equalizer effect is required by CDD, but only the type is fixed.
162 // This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java.
163 static const Uuid EQUALIZER_EFFECT_TYPE = {
164     0x0bed4300, 0xddd6, 0x11db, 0x8f34,
165     std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}};
166 // Loudness Enhancer effect is required by CDD, but only the type is fixed.
167 // This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java.
168 static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
169     0xfe3199be, 0xaed0, 0x413f, 0x87bb,
170     std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
171 
172 enum { PARAM_FACTORY_NAME, PARAM_EFFECT_UUID };
173 using EffectParameter = std::tuple<std::string, Uuid>;
174 
EffectParameterToString(const::testing::TestParamInfo<EffectParameter> & info)175 static inline std::string EffectParameterToString(
176         const ::testing::TestParamInfo<EffectParameter>& info) {
177     return ::android::hardware::PrintInstanceNameToString(::testing::TestParamInfo<std::string>{
178             std::get<PARAM_FACTORY_NAME>(info.param), info.index});
179 }
180 
181 // The main test class for Audio Effect HIDL HAL.
182 class AudioEffectHidlTest : public ::testing::TestWithParam<EffectParameter> {
183   public:
SetUp()184     void SetUp() override {
185         effectsFactory = IEffectsFactory::getService(std::get<PARAM_FACTORY_NAME>(GetParam()));
186         ASSERT_NE(nullptr, effectsFactory.get());
187 
188         ASSERT_NO_FATAL_FAILURE(findAndCreateEffect(getEffectType()));
189         ASSERT_NE(nullptr, effect.get());
190 
191         Return<Result> ret = effect->init();
192         ASSERT_TRUE(ret.isOk());
193         ASSERT_EQ(Result::OK, ret);
194     }
195 
TearDown()196     void TearDown() override {
197         effect.clear();
198         effectsFactory.clear();
199     }
200 
201    protected:
description(const std::string & description)202     static void description(const std::string& description) {
203         RecordProperty("description", description);
204     }
205 
getEffectType() const206     Uuid getEffectType() const { return std::get<PARAM_EFFECT_UUID>(GetParam()); }
207 
208     void findAndCreateEffect(const Uuid& type);
209     void findEffectInstance(const Uuid& type, Uuid* uuid);
210     void getChannelCount(uint32_t* channelCount);
211 
212     sp<IEffectsFactory> effectsFactory;
213     sp<IEffect> effect;
214 };
215 
findAndCreateEffect(const Uuid & type)216 void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
217     Uuid effectUuid;
218     ASSERT_NO_FATAL_FAILURE(findEffectInstance(type, &effectUuid));
219     Return<void> ret = effectsFactory->createEffect(
220             effectUuid, 1 /*session*/, 1 /*ioHandle*/,
221 #if MAJOR_VERSION >= 6
222             0 /*device*/,
223 #endif
224             [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
225                 if (r == Result::OK) {
226                     effect = result;
227                 }
228             });
229     ASSERT_TRUE(ret.isOk());
230 }
231 
findEffectInstance(const Uuid & type,Uuid * uuid)232 void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) {
233     bool effectFound = false;
234     Return<void> ret =
235         effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) {
236             if (r == Result::OK) {
237                 for (const auto& desc : result) {
238                     if (desc.type == type) {
239                         effectFound = true;
240                         *uuid = desc.uuid;
241                         break;
242                     }
243                 }
244             }
245         });
246     ASSERT_TRUE(ret.isOk());
247     ASSERT_TRUE(effectFound);
248 }
249 
getChannelCount(uint32_t * channelCount)250 void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
251     Result retval;
252     EffectConfig currentConfig;
253     Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
254         retval = r;
255         if (r == Result::OK) {
256             currentConfig = conf;
257         }
258     });
259     ASSERT_TRUE(ret.isOk());
260     ASSERT_EQ(Result::OK, retval);
261 #if MAJOR_VERSION <= 6
262     ASSERT_TRUE(audio_channel_mask_is_valid(
263         static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)));
264     *channelCount = audio_channel_count_from_out_mask(
265         static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
266 #else
267     ASSERT_EQ(AudioConfigBaseOptional::ChannelMask::hidl_discriminator::value,
268               currentConfig.outputCfg.base.channelMask.getDiscriminator());
269     *channelCount = android::audio::policy::configuration::V7_0::getChannelCount(
270             currentConfig.outputCfg.base.channelMask.value());
271     ASSERT_NE(*channelCount, 0);
272 #endif
273 }
274 
TEST_P(AudioEffectHidlTest,Close)275 TEST_P(AudioEffectHidlTest, Close) {
276     description("Verify that an effect can be closed");
277     Return<Result> ret = effect->close();
278     EXPECT_TRUE(ret.isOk());
279     EXPECT_EQ(Result::OK, ret);
280 }
281 
TEST_P(AudioEffectHidlTest,GetDescriptor)282 TEST_P(AudioEffectHidlTest, GetDescriptor) {
283     description("Verify that an effect can return its own descriptor via GetDescriptor");
284     Result retval = Result::NOT_INITIALIZED;
285     Uuid actualType;
286     Return<void> ret = effect->getDescriptor([&](Result r, const EffectDescriptor& desc) {
287         retval = r;
288         if (r == Result::OK) {
289             actualType = desc.type;
290         }
291     });
292     EXPECT_TRUE(ret.isOk());
293     EXPECT_EQ(Result::OK, retval);
294     EXPECT_EQ(getEffectType(), actualType);
295 }
296 
TEST_P(AudioEffectHidlTest,GetSetConfig)297 TEST_P(AudioEffectHidlTest, GetSetConfig) {
298     description(
299         "Verify that it is possible to manipulate effect config via Get / "
300         "SetConfig");
301     Result retval = Result::NOT_INITIALIZED;
302     EffectConfig currentConfig;
303     Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
304         retval = r;
305         if (r == Result::OK) {
306             currentConfig = conf;
307         }
308     });
309     EXPECT_TRUE(ret.isOk());
310     EXPECT_EQ(Result::OK, retval);
311     Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr);
312     EXPECT_TRUE(ret2.isOk());
313     EXPECT_EQ(Result::OK, ret2);
314 }
315 
316 #if MAJOR_VERSION >= 7
generateInvalidConfigs(const EffectBufferConfig & src)317 std::vector<EffectBufferConfig> generateInvalidConfigs(const EffectBufferConfig& src) {
318     std::vector<EffectBufferConfig> result;
319     EffectBufferConfig invalidFormat = src;
320     invalidFormat.base.format.value("random_string");
321     result.push_back(std::move(invalidFormat));
322     EffectBufferConfig invalidChannelMask = src;
323     invalidChannelMask.base.channelMask.value("random_string");
324     result.push_back(std::move(invalidChannelMask));
325     return result;
326 }
327 
TEST_P(AudioEffectHidlTest,SetConfigInvalidArguments)328 TEST_P(AudioEffectHidlTest, SetConfigInvalidArguments) {
329     description("Verify that invalid arguments are rejected by SetConfig");
330     Result retval = Result::NOT_INITIALIZED;
331     EffectConfig currentConfig;
332     Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
333         retval = r;
334         if (r == Result::OK) {
335             currentConfig = conf;
336         }
337     });
338     EXPECT_TRUE(ret.isOk());
339     EXPECT_EQ(Result::OK, retval);
340     for (const auto& invalidInputCfg : generateInvalidConfigs(currentConfig.inputCfg)) {
341         EffectConfig invalidConfig = currentConfig;
342         invalidConfig.inputCfg = invalidInputCfg;
343         Return<Result> ret = effect->setConfig(invalidConfig, nullptr, nullptr);
344         EXPECT_TRUE(ret.isOk());
345         EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
346     }
347     for (const auto& invalidOutputCfg : generateInvalidConfigs(currentConfig.outputCfg)) {
348         EffectConfig invalidConfig = currentConfig;
349         invalidConfig.outputCfg = invalidOutputCfg;
350         Return<Result> ret = effect->setConfig(invalidConfig, nullptr, nullptr);
351         EXPECT_TRUE(ret.isOk());
352         EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
353     }
354 }
355 #endif
356 
TEST_P(AudioEffectHidlTest,GetConfigReverse)357 TEST_P(AudioEffectHidlTest, GetConfigReverse) {
358     description("Verify that GetConfigReverse does not crash");
359     Return<void> ret = effect->getConfigReverse([&](Result, const EffectConfig&) {});
360     EXPECT_TRUE(ret.isOk());
361 }
362 
TEST_P(AudioEffectHidlTest,GetSupportedAuxChannelsConfigs)363 TEST_P(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
364     description("Verify that GetSupportedAuxChannelsConfigs does not crash");
365     Return<void> ret = effect->getSupportedAuxChannelsConfigs(
366         0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {});
367     EXPECT_TRUE(ret.isOk());
368 }
369 
TEST_P(AudioEffectHidlTest,GetAuxChannelsConfig)370 TEST_P(AudioEffectHidlTest, GetAuxChannelsConfig) {
371     description("Verify that GetAuxChannelsConfig does not crash");
372     Return<void> ret = effect->getAuxChannelsConfig([&](Result, const EffectAuxChannelsConfig&) {});
373     EXPECT_TRUE(ret.isOk());
374 }
375 
TEST_P(AudioEffectHidlTest,SetAuxChannelsConfig)376 TEST_P(AudioEffectHidlTest, SetAuxChannelsConfig) {
377     description("Verify that SetAuxChannelsConfig does not crash");
378     Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig());
379     EXPECT_TRUE(ret.isOk());
380 }
381 
382 // Not generated automatically because AudioBuffer contains
383 // instances of hidl_memory which can't be compared properly
384 // in general case due to presence of handles.
385 //
386 // However, in this particular case, handles must not present
387 // thus comparison is possible.
388 //
389 // operator== must be defined in the same namespace as the structures.
390 namespace android {
391 namespace hardware {
392 namespace audio {
393 namespace effect {
394 namespace CPP_VERSION {
operator ==(const AudioBuffer & lhs,const AudioBuffer & rhs)395 inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
396     return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount && lhs.data.handle() == nullptr &&
397            rhs.data.handle() == nullptr;
398 }
399 
400 #if MAJOR_VERSION <= 6
operator ==(const EffectBufferConfig & lhs,const EffectBufferConfig & rhs)401 inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) {
402     return lhs.buffer == rhs.buffer &&
403            lhs.samplingRateHz == rhs.samplingRateHz && lhs.channels == rhs.channels &&
404            lhs.format == rhs.format &&
405            lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
406 }
407 #else
operator ==(const EffectBufferConfig & lhs,const EffectBufferConfig & rhs)408 inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) {
409     return lhs.buffer.getDiscriminator() == rhs.buffer.getDiscriminator() &&
410            (lhs.buffer.getDiscriminator() ==
411                     EffectBufferConfig::OptionalBuffer::hidl_discriminator::unspecified ||
412             lhs.buffer.buf() == rhs.buffer.buf()) &&
413            lhs.base == rhs.base && lhs.accessMode == rhs.accessMode;
414 }
415 #endif  // MAJOR_VERSION <= 6
416 
operator ==(const EffectConfig & lhs,const EffectConfig & rhs)417 inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
418     return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg;
419 }
420 }  // namespace CPP_VERSION
421 }  // namespace effect
422 }  // namespace audio
423 }  // namespace hardware
424 }  // namespace android
425 
TEST_P(AudioEffectHidlTest,Reset)426 TEST_P(AudioEffectHidlTest, Reset) {
427     description("Verify that Reset preserves effect configuration");
428     Result retval = Result::NOT_INITIALIZED;
429     EffectConfig originalConfig;
430     Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
431         retval = r;
432         if (r == Result::OK) {
433             originalConfig = conf;
434         }
435     });
436     ASSERT_TRUE(ret.isOk());
437     ASSERT_EQ(Result::OK, retval);
438     Return<Result> ret2 = effect->reset();
439     EXPECT_TRUE(ret2.isOk());
440     EXPECT_EQ(Result::OK, ret2);
441     EffectConfig configAfterReset;
442     ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
443         retval = r;
444         if (r == Result::OK) {
445             configAfterReset = conf;
446         }
447     });
448     EXPECT_EQ(originalConfig, configAfterReset);
449 }
450 
TEST_P(AudioEffectHidlTest,DisableEnableDisable)451 TEST_P(AudioEffectHidlTest, DisableEnableDisable) {
452     description("Verify Disable -> Enable -> Disable sequence for an effect");
453     Return<Result> ret = effect->disable();
454     EXPECT_TRUE(ret.isOk());
455     // Note: some legacy effects may return -EINVAL (INVALID_ARGUMENTS),
456     //       more canonical is to return -ENOSYS (NOT_SUPPORTED)
457     EXPECT_TRUE(ret == Result::NOT_SUPPORTED || ret == Result::INVALID_ARGUMENTS);
458     ret = effect->enable();
459     EXPECT_TRUE(ret.isOk());
460     EXPECT_EQ(Result::OK, ret);
461     ret = effect->disable();
462     EXPECT_TRUE(ret.isOk());
463     EXPECT_EQ(Result::OK, ret);
464 }
465 
466 #if MAJOR_VERSION >= 7
TEST_P(AudioEffectHidlTest,SetDeviceInvalidDeviceAddress)467 TEST_P(AudioEffectHidlTest, SetDeviceInvalidDeviceAddress) {
468     description("Verify that invalid device address is rejected by SetDevice");
469     DeviceAddress device{.deviceType = "random_string"};
470     Return<Result> ret = effect->setDevice(device);
471     EXPECT_TRUE(ret.isOk());
472     EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
473 }
474 #endif
475 
TEST_P(AudioEffectHidlTest,SetDevice)476 TEST_P(AudioEffectHidlTest, SetDevice) {
477     description("Verify that SetDevice works for an output chain effect");
478 #if MAJOR_VERSION <= 6
479     Return<Result> ret = effect->setDevice(mkEnumBitfield(AudioDevice::OUT_SPEAKER));
480 #else
481     DeviceAddress device{.deviceType = toString(xsd::AudioDevice::AUDIO_DEVICE_OUT_SPEAKER)};
482     Return<Result> ret = effect->setDevice(device);
483 #endif
484     EXPECT_TRUE(ret.isOk());
485     EXPECT_EQ(Result::OK, ret);
486 }
487 
TEST_P(AudioEffectHidlTest,SetAndGetVolume)488 TEST_P(AudioEffectHidlTest, SetAndGetVolume) {
489     description("Verify that SetAndGetVolume method works for an effect");
490     uint32_t channelCount;
491     getChannelCount(&channelCount);
492     hidl_vec<uint32_t> volumes;
493     volumes.resize(channelCount);
494     for (uint32_t i = 0; i < channelCount; ++i) {
495         volumes[i] = 0;
496     }
497     Result retval = Result::NOT_INITIALIZED;
498     Return<void> ret =
499         effect->setAndGetVolume(volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; });
500     EXPECT_TRUE(ret.isOk());
501     EXPECT_EQ(Result::OK, retval);
502 }
503 
TEST_P(AudioEffectHidlTest,VolumeChangeNotification)504 TEST_P(AudioEffectHidlTest, VolumeChangeNotification) {
505     description("Verify that effect accepts VolumeChangeNotification");
506     uint32_t channelCount;
507     getChannelCount(&channelCount);
508     hidl_vec<uint32_t> volumes;
509     volumes.resize(channelCount);
510     for (uint32_t i = 0; i < channelCount; ++i) {
511         volumes[i] = 0;
512     }
513     Return<Result> ret = effect->volumeChangeNotification(volumes);
514     EXPECT_TRUE(ret.isOk());
515     EXPECT_EQ(Result::OK, ret);
516 }
517 
TEST_P(AudioEffectHidlTest,SetAudioMode)518 TEST_P(AudioEffectHidlTest, SetAudioMode) {
519     description("Verify that SetAudioMode works for an effect");
520     Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
521     EXPECT_TRUE(ret.isOk());
522     EXPECT_EQ(Result::OK, ret);
523 }
524 
TEST_P(AudioEffectHidlTest,SetConfigReverse)525 TEST_P(AudioEffectHidlTest, SetConfigReverse) {
526     description("Verify that SetConfigReverse does not crash");
527     Return<Result> ret = effect->setConfigReverse(EffectConfig(), nullptr, nullptr);
528     EXPECT_TRUE(ret.isOk());
529 }
530 
531 #if MAJOR_VERSION >= 7
TEST_P(AudioEffectHidlTest,SetInputDeviceInvalidDeviceAddress)532 TEST_P(AudioEffectHidlTest, SetInputDeviceInvalidDeviceAddress) {
533     description("Verify that invalid device address is rejected by SetInputDevice");
534     DeviceAddress device{.deviceType = "random_string"};
535     Return<Result> ret = effect->setInputDevice(device);
536     EXPECT_TRUE(ret.isOk());
537     EXPECT_TRUE(ret == Result::INVALID_ARGUMENTS || ret == Result::NOT_SUPPORTED)
538             << ::testing::PrintToString(ret);
539 }
540 #endif
541 
TEST_P(AudioEffectHidlTest,SetInputDevice)542 TEST_P(AudioEffectHidlTest, SetInputDevice) {
543     description("Verify that SetInputDevice does not crash");
544 #if MAJOR_VERSION <= 6
545     Return<Result> ret = effect->setInputDevice(mkEnumBitfield(AudioDevice::IN_BUILTIN_MIC));
546 #else
547     DeviceAddress device{.deviceType = toString(xsd::AudioDevice::AUDIO_DEVICE_IN_BUILTIN_MIC)};
548     Return<Result> ret = effect->setInputDevice(device);
549 #endif
550     EXPECT_TRUE(ret.isOk());
551 }
552 
553 #if MAJOR_VERSION >= 7
TEST_P(AudioEffectHidlTest,SetInvalidAudioSource)554 TEST_P(AudioEffectHidlTest, SetInvalidAudioSource) {
555     description("Verify that an invalid audio source is rejected by SetAudioSource");
556     Return<Result> ret = effect->setAudioSource("random_string");
557     ASSERT_TRUE(ret.isOk());
558     EXPECT_TRUE(ret == Result::INVALID_ARGUMENTS || ret == Result::NOT_SUPPORTED)
559             << ::testing::PrintToString(ret);
560 }
561 #endif
562 
TEST_P(AudioEffectHidlTest,SetAudioSource)563 TEST_P(AudioEffectHidlTest, SetAudioSource) {
564     description("Verify that SetAudioSource does not crash");
565 #if MAJOR_VERSION <= 6
566     Return<Result> ret = effect->setAudioSource(AudioSource::MIC);
567 #else
568     Return<Result> ret = effect->setAudioSource(toString(xsd::AudioSource::AUDIO_SOURCE_MIC));
569 #endif
570     EXPECT_TRUE(ret.isOk());
571 }
572 
TEST_P(AudioEffectHidlTest,Offload)573 TEST_P(AudioEffectHidlTest, Offload) {
574     description("Verify that calling Offload method does not crash");
575     Return<Result> ret = effect->offload(EffectOffloadParameter{});
576     EXPECT_TRUE(ret.isOk());
577 }
578 
TEST_P(AudioEffectHidlTest,PrepareForProcessing)579 TEST_P(AudioEffectHidlTest, PrepareForProcessing) {
580     description("Verify that PrepareForProcessing method works for an effect");
581     Result retval = Result::NOT_INITIALIZED;
582     Return<void> ret = effect->prepareForProcessing(
583         [&](Result r, const MQDescriptorSync<Result>&) { retval = r; });
584     EXPECT_TRUE(ret.isOk());
585     EXPECT_EQ(Result::OK, retval);
586 }
587 
TEST_P(AudioEffectHidlTest,SetProcessBuffers)588 TEST_P(AudioEffectHidlTest, SetProcessBuffers) {
589     description("Verify that SetProcessBuffers works for an effect");
590     sp<IAllocator> ashmem = IAllocator::getService("ashmem");
591     ASSERT_NE(nullptr, ashmem.get());
592     bool success = false;
593     AudioBuffer buffer;
594     Return<void> ret = ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) {
595         success = s;
596         if (s) {
597             buffer.data = memory;
598         }
599     });
600     ASSERT_TRUE(ret.isOk());
601     ASSERT_TRUE(success);
602     Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer);
603     EXPECT_TRUE(ret2.isOk());
604     EXPECT_EQ(Result::OK, ret2);
605 }
606 
TEST_P(AudioEffectHidlTest,Command)607 TEST_P(AudioEffectHidlTest, Command) {
608     description("Verify that Command does not crash");
609     Return<void> ret =
610         effect->command(0, hidl_vec<uint8_t>(), 0, [&](int32_t, const hidl_vec<uint8_t>&) {});
611     EXPECT_TRUE(ret.isOk());
612 }
613 
TEST_P(AudioEffectHidlTest,SetParameter)614 TEST_P(AudioEffectHidlTest, SetParameter) {
615     description("Verify that SetParameter does not crash");
616     Return<Result> ret = effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>());
617     EXPECT_TRUE(ret.isOk());
618 }
619 
TEST_P(AudioEffectHidlTest,GetParameter)620 TEST_P(AudioEffectHidlTest, GetParameter) {
621     description("Verify that GetParameter does not crash");
622     Return<void> ret =
623         effect->getParameter(hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {});
624     EXPECT_TRUE(ret.isOk());
625 }
626 
TEST_P(AudioEffectHidlTest,GetParameterInvalidMaxReplySize)627 TEST_P(AudioEffectHidlTest, GetParameterInvalidMaxReplySize) {
628     description("Verify that GetParameter caps the maximum reply size");
629     const bool isNewDeviceLaunchingOnTPlus = property_get_int32("ro.vendor.api_level", 0) >= 33;
630     if (!isNewDeviceLaunchingOnTPlus) {
631         GTEST_SKIP() << "The test only applies to devices launching on T or later";
632     }
633     // Use a non-empty parameter to avoid being rejected by any earlier checks.
634     hidl_vec<uint8_t> parameter;
635     parameter.resize(16);
636     // Use very large size to ensure that the service does not crash. Since parameters
637     // are specific to each effect, and some effects may not have parameters at all,
638     // simply checking the return value would not reveal an issue of using an uncapped value.
639     const uint32_t veryLargeReplySize = std::numeric_limits<uint32_t>::max() - 100;
640     Result retval = Result::OK;
641     Return<void> ret =
642             effect->getParameter(parameter, veryLargeReplySize,
643                                  [&](Result r, const hidl_vec<uint8_t>&) { retval = r; });
644     EXPECT_TRUE(ret.isOk());
645     EXPECT_EQ(Result::INVALID_ARGUMENTS, retval);
646 }
647 
TEST_P(AudioEffectHidlTest,GetSupportedConfigsForFeature)648 TEST_P(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
649     description("Verify that GetSupportedConfigsForFeature does not crash");
650     Return<void> ret = effect->getSupportedConfigsForFeature(
651         0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {});
652     EXPECT_TRUE(ret.isOk());
653 }
654 
TEST_P(AudioEffectHidlTest,GetCurrentConfigForFeature)655 TEST_P(AudioEffectHidlTest, GetCurrentConfigForFeature) {
656     description("Verify that GetCurrentConfigForFeature does not crash");
657     Return<void> ret =
658         effect->getCurrentConfigForFeature(0, 0, [&](Result, const hidl_vec<uint8_t>&) {});
659     EXPECT_TRUE(ret.isOk());
660 }
661 
TEST_P(AudioEffectHidlTest,SetCurrentConfigForFeature)662 TEST_P(AudioEffectHidlTest, SetCurrentConfigForFeature) {
663     description("Verify that SetCurrentConfigForFeature does not crash");
664     Return<Result> ret = effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>());
665     EXPECT_TRUE(ret.isOk());
666 }
667 
TEST_P(AudioEffectHidlTest,GetSupportedConfigsForFeatureInvalidConfigSize)668 TEST_P(AudioEffectHidlTest, GetSupportedConfigsForFeatureInvalidConfigSize) {
669     description("Verify that GetSupportedConfigsForFeature caps the maximum config size");
670     const bool isNewDeviceLaunchingOnTPlus = property_get_int32("ro.vendor.api_level", 0) >= 33;
671     if (!isNewDeviceLaunchingOnTPlus) {
672         GTEST_SKIP() << "The test only applies to devices launching on T or later";
673     }
674     // Use very large size to ensure that the service does not crash.
675     const uint32_t veryLargeConfigSize = std::numeric_limits<uint32_t>::max() - 100;
676     Result retval = Result::OK;
677     Return<void> ret = effect->getSupportedConfigsForFeature(
678             0, 1, veryLargeConfigSize,
679             [&](Result r, uint32_t, const hidl_vec<uint8_t>&) { retval = r; });
680     EXPECT_TRUE(ret.isOk());
681     EXPECT_EQ(Result::INVALID_ARGUMENTS, retval);
682 }
683 
TEST_P(AudioEffectHidlTest,GetCurrentConfigForFeatureInvalidConfigSize)684 TEST_P(AudioEffectHidlTest, GetCurrentConfigForFeatureInvalidConfigSize) {
685     description("Verify that GetCurrentConfigForFeature caps the maximum config size");
686     const bool isNewDeviceLaunchingOnTPlus = property_get_int32("ro.vendor.api_level", 0) >= 33;
687     if (!isNewDeviceLaunchingOnTPlus) {
688         GTEST_SKIP() << "The test only applies to devices launching on T or later";
689     }
690     // Use very large size to ensure that the service does not crash.
691     const uint32_t veryLargeConfigSize = std::numeric_limits<uint32_t>::max() - 100;
692     Result retval = Result::OK;
693     Return<void> ret = effect->getCurrentConfigForFeature(
694             0, veryLargeConfigSize, [&](Result r, const hidl_vec<uint8_t>&) { retval = r; });
695     EXPECT_TRUE(ret.isOk());
696     EXPECT_EQ(Result::INVALID_ARGUMENTS, retval);
697 }
698 
699 // The main test class for Equalizer Audio Effect HIDL HAL.
700 class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest {
701   public:
SetUp()702     void SetUp() override {
703         AudioEffectHidlTest::SetUp();
704         equalizer = IEqualizerEffect::castFrom(effect);
705         ASSERT_NE(nullptr, equalizer.get());
706     }
707 
TearDown()708     void TearDown() override {
709         equalizer.clear();
710         AudioEffectHidlTest::TearDown();
711     }
712 
713   protected:
714     void getNumBands(uint16_t* numBands);
715     void getLevelRange(int16_t* minLevel, int16_t* maxLevel);
716     void getBandFrequencyRange(uint16_t band, uint32_t* minFreq, uint32_t* centerFreq,
717                                uint32_t* maxFreq);
718     void getPresetCount(size_t* count);
719 
720     sp<IEqualizerEffect> equalizer;
721 };
722 
getNumBands(uint16_t * numBands)723 void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) {
724     Result retval = Result::NOT_INITIALIZED;
725     Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) {
726         retval = r;
727         if (retval == Result::OK) {
728             *numBands = b;
729         }
730     });
731     ASSERT_TRUE(ret.isOk());
732     ASSERT_EQ(Result::OK, retval);
733 }
734 
getLevelRange(int16_t * minLevel,int16_t * maxLevel)735 void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel, int16_t* maxLevel) {
736     Result retval = Result::NOT_INITIALIZED;
737     Return<void> ret = equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) {
738         retval = r;
739         if (retval == Result::OK) {
740             *minLevel = min;
741             *maxLevel = max;
742         }
743     });
744     ASSERT_TRUE(ret.isOk());
745     ASSERT_EQ(Result::OK, retval);
746 }
747 
getBandFrequencyRange(uint16_t band,uint32_t * minFreq,uint32_t * centerFreq,uint32_t * maxFreq)748 void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band, uint32_t* minFreq,
749                                                          uint32_t* centerFreq, uint32_t* maxFreq) {
750     Result retval = Result::NOT_INITIALIZED;
751     Return<void> ret =
752         equalizer->getBandFrequencyRange(band, [&](Result r, uint32_t min, uint32_t max) {
753             retval = r;
754             if (retval == Result::OK) {
755                 *minFreq = min;
756                 *maxFreq = max;
757             }
758         });
759     ASSERT_TRUE(ret.isOk());
760     ASSERT_EQ(Result::OK, retval);
761     ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) {
762         retval = r;
763         if (retval == Result::OK) {
764             *centerFreq = center;
765         }
766     });
767     ASSERT_TRUE(ret.isOk());
768     ASSERT_EQ(Result::OK, retval);
769 }
770 
getPresetCount(size_t * count)771 void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
772     Result retval = Result::NOT_INITIALIZED;
773     Return<void> ret = equalizer->getPresetNames([&](Result r, const hidl_vec<hidl_string>& names) {
774         retval = r;
775         if (retval == Result::OK) {
776             *count = names.size();
777         }
778     });
779     ASSERT_TRUE(ret.isOk());
780     ASSERT_EQ(Result::OK, retval);
781 }
782 
TEST_P(EqualizerAudioEffectHidlTest,GetNumBands)783 TEST_P(EqualizerAudioEffectHidlTest, GetNumBands) {
784     description("Verify that Equalizer effect reports at least one band");
785     uint16_t numBands = 0;
786     getNumBands(&numBands);
787     EXPECT_GT(numBands, 0);
788 }
789 
TEST_P(EqualizerAudioEffectHidlTest,GetLevelRange)790 TEST_P(EqualizerAudioEffectHidlTest, GetLevelRange) {
791     description("Verify that Equalizer effect reports adequate band level range");
792     int16_t minLevel = 0x7fff, maxLevel = 0;
793     getLevelRange(&minLevel, &maxLevel);
794     EXPECT_GT(maxLevel, minLevel);
795 }
796 
TEST_P(EqualizerAudioEffectHidlTest,GetSetBandLevel)797 TEST_P(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
798     description("Verify that manipulating band levels works for Equalizer effect");
799     uint16_t numBands = 0;
800     getNumBands(&numBands);
801     ASSERT_GT(numBands, 0);
802     int16_t levels[3]{0x7fff, 0, 0};
803     getLevelRange(&levels[0], &levels[2]);
804     ASSERT_GT(levels[2], levels[0]);
805     levels[1] = (levels[2] + levels[0]) / 2;
806     for (uint16_t i = 0; i < numBands; ++i) {
807         for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) {
808             Return<Result> ret = equalizer->setBandLevel(i, levels[j]);
809             EXPECT_TRUE(ret.isOk());
810             EXPECT_EQ(Result::OK, ret);
811             Result retval = Result::NOT_INITIALIZED;
812             int16_t actualLevel;
813             Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) {
814                 retval = r;
815                 if (retval == Result::OK) {
816                     actualLevel = l;
817                 }
818             });
819             EXPECT_TRUE(ret2.isOk());
820             EXPECT_EQ(Result::OK, retval);
821             EXPECT_EQ(levels[j], actualLevel);
822         }
823     }
824 }
825 
TEST_P(EqualizerAudioEffectHidlTest,GetBandCenterFrequencyAndRange)826 TEST_P(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
827     description("Verify that Equalizer effect reports adequate band frequency range");
828     uint16_t numBands = 0;
829     getNumBands(&numBands);
830     ASSERT_GT(numBands, 0);
831     for (uint16_t i = 0; i < numBands; ++i) {
832         uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff, maxFreq = 0xffffffff;
833         getBandFrequencyRange(i, &minFreq, &centerFreq, &maxFreq);
834         // Note: NXP legacy implementation reports "1" as upper bound for last band,
835         // so this check fails.
836         EXPECT_GE(maxFreq, centerFreq);
837         EXPECT_GE(centerFreq, minFreq);
838     }
839 }
840 
TEST_P(EqualizerAudioEffectHidlTest,GetBandForFrequency)841 TEST_P(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
842     description("Verify that Equalizer effect supports GetBandForFrequency correctly");
843     uint16_t numBands = 0;
844     getNumBands(&numBands);
845     ASSERT_GT(numBands, 0);
846     for (uint16_t i = 0; i < numBands; ++i) {
847         uint32_t freqs[3]{0, 0, 0};
848         getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]);
849         // NXP legacy implementation reports "1" as upper bound for last band, some
850         // of the checks fail.
851         for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) {
852             if (j == 0) {
853                 freqs[j]++;
854             }  // Min frequency is an open interval.
855             Result retval = Result::NOT_INITIALIZED;
856             uint16_t actualBand = numBands + 1;
857             Return<void> ret = equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) {
858                 retval = r;
859                 if (retval == Result::OK) {
860                     actualBand = b;
861                 }
862             });
863             EXPECT_TRUE(ret.isOk());
864             EXPECT_EQ(Result::OK, retval);
865             EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j];
866         }
867     }
868 }
869 
TEST_P(EqualizerAudioEffectHidlTest,GetPresetNames)870 TEST_P(EqualizerAudioEffectHidlTest, GetPresetNames) {
871     description("Verify that Equalizer effect reports at least one preset");
872     size_t presetCount;
873     getPresetCount(&presetCount);
874     EXPECT_GT(presetCount, 0u);
875 }
876 
TEST_P(EqualizerAudioEffectHidlTest,GetSetCurrentPreset)877 TEST_P(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
878     description("Verify that manipulating the current preset for Equalizer effect");
879     size_t presetCount;
880     getPresetCount(&presetCount);
881     ASSERT_GT(presetCount, 0u);
882     for (uint16_t i = 0; i < presetCount; ++i) {
883         Return<Result> ret = equalizer->setCurrentPreset(i);
884         EXPECT_TRUE(ret.isOk());
885         EXPECT_EQ(Result::OK, ret);
886         Result retval = Result::NOT_INITIALIZED;
887         uint16_t actualPreset = 0xffff;
888         Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) {
889             retval = r;
890             if (retval == Result::OK) {
891                 actualPreset = p;
892             }
893         });
894         EXPECT_TRUE(ret2.isOk());
895         EXPECT_EQ(Result::OK, retval);
896         EXPECT_EQ(i, actualPreset);
897     }
898 }
899 
TEST_P(EqualizerAudioEffectHidlTest,GetSetAllProperties)900 TEST_P(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
901     description(
902         "Verify that setting band levels and presets works via Get / "
903         "SetAllProperties for Equalizer effect");
904     using AllProperties =
905         ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect::AllProperties;
906     uint16_t numBands = 0;
907     getNumBands(&numBands);
908     ASSERT_GT(numBands, 0);
909     AllProperties props;
910     props.bandLevels.resize(numBands);
911     for (size_t i = 0; i < numBands; ++i) {
912         props.bandLevels[i] = 0;
913     }
914 
915     AllProperties actualProps;
916     Result retval = Result::NOT_INITIALIZED;
917 
918     // Verify setting of the band levels via properties.
919     props.curPreset = -1;
920     Return<Result> ret = equalizer->setAllProperties(props);
921     EXPECT_TRUE(ret.isOk());
922     EXPECT_EQ(Result::OK, ret);
923     Return<void> ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
924         retval = r;
925         if (retval == Result::OK) {
926             actualProps = p;
927         }
928     });
929     EXPECT_TRUE(ret2.isOk());
930     EXPECT_EQ(Result::OK, retval);
931     EXPECT_EQ(props.bandLevels, actualProps.bandLevels);
932 
933     // Verify setting of the current preset via properties.
934     props.curPreset = 0;  // Assuming there is at least one preset.
935     ret = equalizer->setAllProperties(props);
936     EXPECT_TRUE(ret.isOk());
937     EXPECT_EQ(Result::OK, ret);
938     ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
939         retval = r;
940         if (retval == Result::OK) {
941             actualProps = p;
942         }
943     });
944     EXPECT_TRUE(ret2.isOk());
945     EXPECT_EQ(Result::OK, retval);
946     EXPECT_EQ(props.curPreset, actualProps.curPreset);
947 }
948 
949 // The main test class for Equalizer Audio Effect HIDL HAL.
950 class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
951   public:
SetUp()952     void SetUp() override {
953         AudioEffectHidlTest::SetUp();
954         enhancer = ILoudnessEnhancerEffect::castFrom(effect);
955         ASSERT_NE(nullptr, enhancer.get());
956     }
957 
TearDown()958     void TearDown() override {
959         enhancer.clear();
960         AudioEffectHidlTest::TearDown();
961     }
962 
963   protected:
964     sp<ILoudnessEnhancerEffect> enhancer;
965 };
966 
TEST_P(LoudnessEnhancerAudioEffectHidlTest,GetSetTargetGain)967 TEST_P(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
968     description(
969         "Verify that manipulating the target gain works for Loudness Enhancer "
970         "effect");
971     const int32_t gain = 100;
972     Return<Result> ret = enhancer->setTargetGain(gain);
973     EXPECT_TRUE(ret.isOk());
974     EXPECT_EQ(Result::OK, ret);
975     int32_t actualGain = 0;
976     Result retval;
977     Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) {
978         retval = r;
979         if (retval == Result::OK) {
980             actualGain = g;
981         }
982     });
983     EXPECT_TRUE(ret2.isOk());
984     EXPECT_EQ(Result::OK, retval);
985     EXPECT_EQ(gain, actualGain);
986 }
987 
988 INSTANTIATE_TEST_SUITE_P(EffectsFactory, AudioEffectsFactoryHidlTest,
989                          ::testing::ValuesIn(::android::hardware::getAllHalInstanceNames(
990                                  IEffectsFactory::descriptor)),
991                          ::android::hardware::PrintInstanceNameToString);
992 INSTANTIATE_TEST_SUITE_P(
993         Equalizer_IEffect, AudioEffectHidlTest,
994         ::testing::Combine(::testing::ValuesIn(::android::hardware::getAllHalInstanceNames(
995                                    IEffectsFactory::descriptor)),
996                            ::testing::Values(EQUALIZER_EFFECT_TYPE)),
997         EffectParameterToString);
998 INSTANTIATE_TEST_SUITE_P(
999         LoudnessEnhancer_IEffect, AudioEffectHidlTest,
1000         ::testing::Combine(::testing::ValuesIn(::android::hardware::getAllHalInstanceNames(
1001                                    IEffectsFactory::descriptor)),
1002                            ::testing::Values(LOUDNESS_ENHANCER_EFFECT_TYPE)),
1003         EffectParameterToString);
1004 INSTANTIATE_TEST_SUITE_P(
1005         Equalizer, EqualizerAudioEffectHidlTest,
1006         ::testing::Combine(::testing::ValuesIn(::android::hardware::getAllHalInstanceNames(
1007                                    IEffectsFactory::descriptor)),
1008                            ::testing::Values(EQUALIZER_EFFECT_TYPE)),
1009         EffectParameterToString);
1010 INSTANTIATE_TEST_SUITE_P(
1011         LoudnessEnhancer, LoudnessEnhancerAudioEffectHidlTest,
1012         ::testing::Combine(::testing::ValuesIn(::android::hardware::getAllHalInstanceNames(
1013                                    IEffectsFactory::descriptor)),
1014                            ::testing::Values(LOUDNESS_ENHANCER_EFFECT_TYPE)),
1015         EffectParameterToString);
1016 // When the VTS test runs on a device lacking the corresponding HAL version the parameter
1017 // list is empty, this isn't a problem.
1018 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioEffectsFactoryHidlTest);
1019 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioEffectHidlTest);
1020 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EqualizerAudioEffectHidlTest);
1021 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(LoudnessEnhancerAudioEffectHidlTest);
1022