Put APV Codec creation under flag

Bug: 376770121
Bug: 363333555

Test: manual, verifying that codec is not created when flag is not set
Change-Id: I04a9be9972107475c8960faaa3212aae51bf965e
diff --git a/media/codec2/components/apv/C2SoftApvDec.cpp b/media/codec2/components/apv/C2SoftApvDec.cpp
index 6e92b6f..0617d06 100644
--- a/media/codec2/components/apv/C2SoftApvDec.cpp
+++ b/media/codec2/components/apv/C2SoftApvDec.cpp
@@ -1231,6 +1231,10 @@
 }  // namespace android
 
 __attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
+    if (!android::media::swcodec::flags::apv_software_codec()) {
+        ALOGV("APV SW Codec is not enabled");
+        return nullptr;
+    }
     return new ::android::C2SoftApvDecFactory();
 }
 
diff --git a/media/codec2/components/apv/C2SoftApvEnc.cpp b/media/codec2/components/apv/C2SoftApvEnc.cpp
index c395e20..999c08d 100644
--- a/media/codec2/components/apv/C2SoftApvEnc.cpp
+++ b/media/codec2/components/apv/C2SoftApvEnc.cpp
@@ -18,6 +18,8 @@
 #define LOG_TAG "C2SoftApvEnc"
 #include <log/log.h>
 
+#include <android_media_swcodec_flags.h>
+
 #include <media/hardware/VideoAPI.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MediaErrors.h>
@@ -1267,6 +1269,10 @@
 }  // namespace android
 
 __attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
+    if (!android::media::swcodec::flags::apv_software_codec()) {
+        ALOGV("APV SW Codec is not enabled");
+        return nullptr;
+    }
     return new ::android::C2SoftApvEncFactory();
 }