Merge "Revert^2 "Use vendor api level instead of sdk version"" into main
diff --git a/treble/vintf/SingleManifestTest.cpp b/treble/vintf/SingleManifestTest.cpp
index c6e8fbd..9c4baca 100644
--- a/treble/vintf/SingleManifestTest.cpp
+++ b/treble/vintf/SingleManifestTest.cpp
@@ -641,6 +641,16 @@
   return false;
 }
 
+static bool IsAndroidTvVertical() {
+  return DeviceSupportsFeature("android.software.leanback");
+}
+
+// For Android TV devices that have ThreadNetwork HAL backported, exempt the AIDL
+// frozen requirement.
+static bool IsHalPackageFreezeExempt(const string& package) {
+  return IsAndroidTvVertical() && package == "android.hardware.threadnetwork";
+}
+
 // An AIDL HAL with VINTF stability can only be registered if it is in the
 // manifest. However, we still must manually check that every declared HAL is
 // actually present on the device.
@@ -690,7 +700,11 @@
 
   if (is_aosp) {
     if (!found_hash) {
-      if (is_release || (reliable_version && is_existing)) {
+      if (IsHalPackageFreezeExempt(package)) {
+        std::cout << "Warning: Interface " << name << " has an unrecognized hash: '"
+                  << hash << "' but the package '" << package
+                  << "' has been exempted from the test.";
+      } else if (is_release || (reliable_version && is_existing)) {
         ADD_FAILURE() << "Interface " << name << " has an unrecognized hash: '"
                       << hash << "'. The following hashes are known:\n"
                       << base::Join(hashes, '\n')
diff --git a/treble/vintf/utils.cpp b/treble/vintf/utils.cpp
index c749539..2548759 100644
--- a/treble/vintf/utils.cpp
+++ b/treble/vintf/utils.cpp
@@ -167,6 +167,26 @@
   return Partition::UNKNOWN;
 }
 
+bool DeviceSupportsFeature(const char *feature) {
+  bool device_supports_feature = false;
+  FILE *p = popen("pm list features", "re");
+  if (!p) {
+    return false;
+  }
+
+  char *line = NULL;
+  size_t len = 0;
+  while (getline(&line, &len, p) > 0) {
+    if (strstr(line, feature)) {
+      device_supports_feature = true;
+      break;
+    }
+  }
+  pclose(p);
+
+  return device_supports_feature;
+}
+
 }  // namespace testing
 }  // namespace vintf
 }  // namespace android
diff --git a/treble/vintf/utils.h b/treble/vintf/utils.h
index cd89e16..fad1b87 100644
--- a/treble/vintf/utils.h
+++ b/treble/vintf/utils.h
@@ -174,6 +174,9 @@
 // Returns SYSTEM for FRAMEWORK, VENDOR for DEVICE.
 Partition PartitionOfType(SchemaType type);
 
+// Returns true iff the device has the specified feature.
+bool DeviceSupportsFeature(const char* feature);
+
 }  // namespace testing
 }  // namespace vintf