Snap for 7978549 from 87bcb22f7b05d95fc6f07b2777dd59ae0bcf1184 to android11-tests-release

Change-Id: I8fd0abb3538cf5f92aabab975b34e66d94cf34dc
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp
index 5f7b835..daa0c53 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp
@@ -29,6 +29,7 @@
 #include <C2Config.h>
 #include <C2Debug.h>
 #include <codec2/hidl/client.h>
+#include <android-base/properties.h>
 
 using android::C2AllocatorIon;
 
@@ -55,7 +56,12 @@
     // google.codec2 Audio test setup
     virtual void SetUp() override {
         getParams();
-        mDisableTest = false;
+        int option = android::base::GetIntProperty("debug.stagefright.ccodec", 4);
+        if (option == 0) {
+            mDisableTest = true;
+        } else {
+            mDisableTest = false;
+        }
         ALOGV("Codec2AudioDecHidlTest SetUp");
         mClient = android::Codec2Client::CreateFromService(
                 mInstanceName.c_str(),
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
index e3a4f68..6c9516f 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
@@ -30,6 +30,7 @@
 #include <C2Config.h>
 #include <C2Debug.h>
 #include <codec2/hidl/client.h>
+#include <android-base/properties.h>
 
 using android::C2AllocatorIon;
 
@@ -54,7 +55,12 @@
     // google.codec2 Audio test setup
     virtual void SetUp() override {
         getParams();
-        mDisableTest = false;
+        int option = android::base::GetIntProperty("debug.stagefright.ccodec", 4);
+        if (option == 0) {
+            mDisableTest = true;
+        } else {
+            mDisableTest = false;
+        }
         ALOGV("Codec2AudioEncHidlTest SetUp");
         mClient = android::Codec2Client::CreateFromService(
                 mInstanceName.c_str(),
diff --git a/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp b/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp
index 6122225..66a08e3 100644
--- a/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp
@@ -23,7 +23,7 @@
 
 #include <C2Config.h>
 #include <codec2/hidl/client.h>
-
+#include <android-base/properties.h>
 #include "media_c2_hidl_test_common.h"
 
 /* Time_Out for start(), stop(), reset(), release(), flush(), queue() are
@@ -62,6 +62,11 @@
   public:
     virtual void SetUp() override {
         getParams();
+        mDisableTest = false;
+        int option = android::base::GetIntProperty("debug.stagefright.ccodec", 4);
+        if (!option) {
+            mDisableTest = true;
+        }
         mEos = false;
         mClient = android::Codec2Client::CreateFromService(mInstanceName.c_str());
         ASSERT_NE(mClient, nullptr);
@@ -106,6 +111,7 @@
     std::string mInstanceName;
     std::string mComponentName;
     bool mEos;
+    bool mDisableTest;
     std::mutex mQueueLock;
     std::condition_variable mQueueCondition;
     std::list<std::unique_ptr<C2Work>> mWorkQueue;
@@ -132,6 +138,7 @@
 // Test Empty Flush
 TEST_P(Codec2ComponentHidlTest, EmptyFlush) {
     ALOGV("Empty Flush Test");
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
     c2_status_t err = mComponent->start();
     ASSERT_EQ(err, C2_OK);
 
@@ -148,6 +155,7 @@
 // Test Queue Empty Work
 TEST_P(Codec2ComponentHidlTest, QueueEmptyWork) {
     ALOGV("Queue Empty Work Test");
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
     c2_status_t err = mComponent->start();
     ASSERT_EQ(err, C2_OK);
 
@@ -162,6 +170,7 @@
 // Test Component Configuration
 TEST_P(Codec2ComponentHidlTest, Config) {
     ALOGV("Configuration Test");
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
 
     C2String name = mComponent->getName();
     EXPECT_NE(name.empty(), true) << "Invalid Component Name";
@@ -191,6 +200,7 @@
 // Test Multiple Start Stop Reset Test
 TEST_P(Codec2ComponentHidlTest, MultipleStartStopReset) {
     ALOGV("Multiple Start Stop and Reset Test");
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
 
     for (size_t i = 0; i < MAX_RETRY; i++) {
         mComponent->start();
@@ -213,6 +223,7 @@
 // Test Component Release API
 TEST_P(Codec2ComponentHidlTest, MultipleRelease) {
     ALOGV("Multiple Release Test");
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
     c2_status_t err = mComponent->start();
     ASSERT_EQ(err, C2_OK);
 
@@ -238,6 +249,7 @@
 // Test API's Timeout
 TEST_P(Codec2ComponentHidlTest, Timeout) {
     ALOGV("Timeout Test");
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
     c2_status_t err = C2_OK;
 
     int64_t startTime = getNowUs();
@@ -329,7 +341,7 @@
 
 TEST_P(Codec2ComponentInputTests, InputBufferTest) {
     description("Tests for different inputs");
-
+    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
     uint32_t flags = std::stoul(std::get<2>(GetParam()));
     bool isNullBuffer = !std::get<3>(GetParam()).compare("true");
     if (isNullBuffer)
diff --git a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp
index b520c17..8db2894 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp
@@ -34,6 +34,7 @@
 #include <gui/IConsumerListener.h>
 #include <gui/IProducerListener.h>
 #include <system/window.h>
+#include <android-base/properties.h>
 
 using android::C2AllocatorIon;
 
@@ -64,7 +65,13 @@
     // google.codec2 Video test setup
     virtual void SetUp() override {
         getParams();
-        mDisableTest = false;
+        // Disable the tests if device does not support codec2
+        int option = android::base::GetIntProperty("debug.stagefright.ccodec", 4);
+        if (option == 0) {
+            mDisableTest = true;
+        } else {
+            mDisableTest = false;
+        }
         ALOGV("Codec2VideoDecHidlTest SetUp");
         mClient = android::Codec2Client::CreateFromService(
                 mInstanceName.c_str(),
diff --git a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp
index 5bcea5b..a2ef20c 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp
@@ -29,6 +29,7 @@
 #include <C2Config.h>
 #include <C2Debug.h>
 #include <codec2/hidl/client.h>
+#include <android-base/properties.h>
 
 using android::C2AllocatorIon;
 
@@ -56,7 +57,12 @@
     // google.codec2 Video test setup
     virtual void SetUp() override {
         getParams();
-        mDisableTest = false;
+        int option = android::base::GetIntProperty("debug.stagefright.ccodec", 4);
+        if (option == 0) {
+            mDisableTest = true;
+        } else {
+            mDisableTest = false;
+        }
         ALOGV("Codec2VideoEncHidlTest SetUp");
         mClient = android::Codec2Client::CreateFromService(
                 mInstanceName.c_str(),