Update for listManifestByInterface.

See addition of this API in system/libhidl.

This is to support libvintf not being in the VNDK, provide an
alternative to listByInterface which makes more sense with lazy HALs,
and also, help code be consistent with the manifest.

Fixes: 76108617
Test: hidl_test
Change-Id: Ia45263f429d11c31cc34cdfa54193485da119f95
diff --git a/Vintf.cpp b/Vintf.cpp
index 989adc0..263f9a4 100644
--- a/Vintf.cpp
+++ b/Vintf.cpp
@@ -4,7 +4,6 @@
 #include "Vintf.h"
 
 #include <android-base/logging.h>
-#include <hidl-util/FQName.h>
 #include <vintf/parse_string.h>
 #include <vintf/VintfObject.h>
 
@@ -27,7 +26,7 @@
 
     if (!FQName::parse(interfaceName, &fqName)) {
         LOG(ERROR) << __FUNCTION__ << ": " << interfaceName
-                   << " is not a valid fully-qualified name ";
+                   << " is not a valid fully-qualified name.";
         return vintf::Transport::EMPTY;
     }
     if (!fqName.hasVersion()) {
@@ -58,5 +57,33 @@
     return vintf::Transport::EMPTY;
 }
 
+std::set<std::string> getInstances(const std::string& interfaceName) {
+    FQName fqName;
+    if (!FQName::parse(interfaceName, &fqName) || !fqName.isFullyQualified() ||
+            fqName.isValidValueName() || !fqName.isInterfaceName()) {
+        LOG(ERROR) << __FUNCTION__ << ": " << interfaceName
+                   << " is not a valid fully-qualified name.";
+        return {};
+    }
+
+    std::set<std::string> ret;
+
+    auto deviceManifest = vintf::VintfObject::GetDeviceHalManifest();
+    auto frameworkManifest = vintf::VintfObject::GetFrameworkHalManifest();
+
+    vintf::Version version = {fqName.getPackageMajorVersion(), fqName.getPackageMinorVersion()};
+
+    std::set<std::string> deviceSet =
+        deviceManifest->getInstances(fqName.package(), version, fqName.name());
+    std::set<std::string> frameworkSet =
+        frameworkManifest->getInstances(fqName.package(), version, fqName.name());
+
+    ret.insert(deviceSet.begin(), deviceSet.end());
+    ret.insert(frameworkSet.begin(), frameworkSet.end());
+
+    return ret;
+}
+
+
 }  // hardware
 }  // android