Skip thermal VTS on emulators

Bug: 395011603
Test: atest VtsHalPowerTargetTest (on acloud devices)
Flag: TEST_ONLY
Change-Id: Iaafa6f8a2d10009362505f2ce80eb14ac2e8d46f
diff --git a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
index 17653b4..9dd5153 100644
--- a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
+++ b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
@@ -38,6 +38,7 @@
 #include <android/binder_manager.h>
 #include <android/binder_process.h>
 #include <android/binder_status.h>
+#include <cutils/properties.h>
 #include <gtest/gtest.h>
 
 #include <unistd.h>
@@ -179,6 +180,34 @@
             ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
         }
     }
+
+    bool isEmulator() {
+        if (property_get_bool("ro.boot.qemu", false)) {
+            return true;
+        }
+        char device[PROP_VALUE_MAX];
+        char model[PROP_VALUE_MAX];
+        char name[PROP_VALUE_MAX];
+        char hardware[PROP_VALUE_MAX];
+
+        property_get("ro.product.device", device, "");
+        property_get("ro.product.model", model, "");
+        property_get("ro.product.name", name, "");
+        property_get("ro.hardware", hardware, "");
+
+        std::string deviceStr(device);
+        std::string modelStr(model);
+        std::string nameStr(name);
+        std::string hardwareStr(hardware);
+
+        return deviceStr.rfind("vsoc_", 0) == 0 || modelStr.rfind("Cuttlefish ", 0) == 0 ||
+               nameStr.rfind("cf_", 0) == 0 || nameStr.rfind("aosp_cf_", 0) == 0 ||
+               hardwareStr.find("goldfish") != std::string::npos ||
+               hardwareStr.find("ranchu") != std::string::npos ||
+               hardwareStr.find("cutf_cvm") != std::string::npos ||
+               hardwareStr.find("starfish") != std::string::npos;
+    }
+
     // Stores thermal version
     int32_t thermal_version;
 
@@ -359,6 +388,9 @@
     if (apiLevel < 202404) {
         GTEST_SKIP() << "Skipping test as the vendor level is below 202404: " << apiLevel;
     }
+    if (isEmulator()) {
+        GTEST_SKIP() << "Skipping test on emulator";
+    }
     for (const auto& feature : kNonHandheldFeatures) {
         if (::testing::deviceSupportsFeature(feature.c_str())) {
             GTEST_SKIP() << "Skipping test as the device has feature: " << feature;