AIDL effect: Initial IEffect interface implementation and vts test

Bug: 238913361
Test: atest VtsHalAudioEffectTargetTest
Merged-In: Id64d28af9122e82acd96e3349cf37c3d9728069a
Change-Id: Id64d28af9122e82acd96e3349cf37c3d9728069a
diff --git a/audio/aidl/default/EffectFactory.cpp b/audio/aidl/default/EffectFactory.cpp
index a31e23f..ea9d470 100644
--- a/audio/aidl/default/EffectFactory.cpp
+++ b/audio/aidl/default/EffectFactory.cpp
@@ -36,6 +36,8 @@
                {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
     id.uuid = EqualizerUUID;
     mIdentityList.push_back(id);
+    // TODO: Add visualizer with default implementation later
+#if 0
     id.type = {static_cast<int32_t>(0xd3467faa),
                0xacc7,
                0x4d34,
@@ -43,6 +45,7 @@
                {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
     id.uuid = VisualizerUUID;
     mIdentityList.push_back(id);
+#endif
 }
 
 ndk::ScopedAStatus Factory::queryEffects(const std::optional<AudioUuid>& in_type,
@@ -56,4 +59,28 @@
     return ndk::ScopedAStatus::ok();
 }
 
+ndk::ScopedAStatus Factory::createEffect(
+        const AudioUuid& in_impl_uuid,
+        std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>* _aidl_return) {
+    LOG(DEBUG) << __func__ << ": UUID " << in_impl_uuid.toString();
+    if (in_impl_uuid == EqualizerUUID) {
+        *_aidl_return = ndk::SharedRefBase::make<Equalizer>();
+    } else {
+        LOG(ERROR) << __func__ << ": UUID "
+                   << " not supported";
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+    }
+    return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus Factory::destroyEffect(
+        const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_handle) {
+    if (in_handle) {
+        // TODO: b/245393900 need check the instance state with IEffect.getState before destroy.
+        return ndk::ScopedAStatus::ok();
+    } else {
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+    }
+}
+
 }  // namespace aidl::android::hardware::audio::effect