Update EffectUUID initialization
Avoid dynamic initialization global UUID variables
Bug: 271500140
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit
Change-Id: I7574c1fe1ba0aaff1d9d29a9eed10de1aef33806
diff --git a/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp
index 21f5eb5..7b9477d 100644
--- a/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp
@@ -28,6 +28,7 @@
#include <android/binder_interface_utils.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
+#include <system/audio_effects/effect_uuid.h>
#include <aidl/android/hardware/audio/effect/IFactory.h>
@@ -38,10 +39,10 @@
using namespace android;
using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::getEffectUuidNull;
+using aidl::android::hardware::audio::effect::getEffectUuidZero;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
-using aidl::android::hardware::audio::effect::kEffectNullUuid;
-using aidl::android::hardware::audio::effect::kEffectZeroUuid;
using aidl::android::hardware::audio::effect::Processing;
using aidl::android::media::audio::common::AudioSource;
using aidl::android::media::audio::common::AudioStreamType;
@@ -65,8 +66,8 @@
std::unique_ptr<EffectFactoryHelper> mFactoryHelper;
std::shared_ptr<IFactory> mEffectFactory;
std::vector<std::shared_ptr<IEffect>> mEffects;
- const Descriptor::Identity kNullId = {.uuid = kEffectNullUuid};
- const Descriptor::Identity kZeroId = {.uuid = kEffectZeroUuid};
+ const Descriptor::Identity kNullId = {.uuid = getEffectUuidNull()};
+ const Descriptor::Identity kZeroId = {.uuid = getEffectUuidZero()};
const Descriptor kNullDesc = {.common.id = kNullId};
const Descriptor kZeroDesc = {.common.id = kZeroId};
@@ -132,13 +133,13 @@
TEST_P(EffectFactoryTest, ExpectAllAospEffectTypes) {
std::vector<Descriptor> descs;
std::set<AudioUuid> typeUuidSet(
- {aidl::android::hardware::audio::effect::kBassBoostTypeUUID,
- aidl::android::hardware::audio::effect::kEqualizerTypeUUID,
- aidl::android::hardware::audio::effect::kEnvReverbTypeUUID,
- aidl::android::hardware::audio::effect::kPresetReverbTypeUUID,
- aidl::android::hardware::audio::effect::kDynamicsProcessingTypeUUID,
- aidl::android::hardware::audio::effect::kHapticGeneratorTypeUUID,
- aidl::android::hardware::audio::effect::kVirtualizerTypeUUID});
+ {aidl::android::hardware::audio::effect::getEffectTypeUuidBassBoost(),
+ aidl::android::hardware::audio::effect::getEffectTypeUuidEqualizer(),
+ aidl::android::hardware::audio::effect::getEffectTypeUuidEnvReverb(),
+ aidl::android::hardware::audio::effect::getEffectTypeUuidPresetReverb(),
+ aidl::android::hardware::audio::effect::getEffectTypeUuidDynamicsProcessing(),
+ aidl::android::hardware::audio::effect::getEffectTypeUuidHapticGenerator(),
+ aidl::android::hardware::audio::effect::getEffectTypeUuidVirtualizer()});
EXPECT_IS_OK(mEffectFactory->queryEffects(std::nullopt, std::nullopt, std::nullopt, &descs));
EXPECT_TRUE(descs.size() >= typeUuidSet.size());
@@ -155,19 +156,22 @@
TEST_P(EffectFactoryTest, QueryNullTypeUuid) {
std::vector<Descriptor> descs;
- EXPECT_IS_OK(mEffectFactory->queryEffects(kEffectNullUuid, std::nullopt, std::nullopt, &descs));
+ EXPECT_IS_OK(
+ mEffectFactory->queryEffects(getEffectUuidNull(), std::nullopt, std::nullopt, &descs));
EXPECT_EQ(descs.size(), 0UL);
}
TEST_P(EffectFactoryTest, QueriedNullImplUuid) {
std::vector<Descriptor> descs;
- EXPECT_IS_OK(mEffectFactory->queryEffects(std::nullopt, kEffectNullUuid, std::nullopt, &descs));
+ EXPECT_IS_OK(
+ mEffectFactory->queryEffects(std::nullopt, getEffectUuidNull(), std::nullopt, &descs));
EXPECT_EQ(descs.size(), 0UL);
}
TEST_P(EffectFactoryTest, QueriedNullProxyUuid) {
std::vector<Descriptor> descs;
- EXPECT_IS_OK(mEffectFactory->queryEffects(std::nullopt, std::nullopt, kEffectNullUuid, &descs));
+ EXPECT_IS_OK(
+ mEffectFactory->queryEffects(std::nullopt, std::nullopt, getEffectUuidNull(), &descs));
EXPECT_EQ(descs.size(), 0UL);
}