Instance is the smallest unit of manifests/matrices.

Introduce forEachInstance on HalManifest and CompatibilityMatrix,
because <hal> are no longer the smallest unit of tests, but
rather a ManifestInstance / MatrixInstance object.

Bug: 73556059
Bug: 74247301

Test: libvintf_test
Test: vintf_object_test

Change-Id: If7186617db52acd67f255ac6e6c99f34a7570206
diff --git a/VintfObject.cpp b/VintfObject.cpp
index c10949c..254a0dc 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -691,25 +691,23 @@
 }
 
 int32_t VintfObject::CheckDeprecation(std::string* error) {
+    using namespace std::placeholders;
     auto deviceManifest = GetDeviceHalManifest();
     IsInstanceInUse inManifest = [&deviceManifest](const std::string& package, Version version,
-                                                    const std::string& interface,
-                                                    const std::string& instance) {
-        const ManifestHal* hal = deviceManifest->getHal(package, version);
-        if (hal == nullptr) {
-            return std::make_pair(false, Version{});
-        }
-        const auto& instances = hal->getInstances(interface);
-        if (instances.find(instance) == instances.end()) {
-            return std::make_pair(false, Version{});
-        }
-
-        for (Version v : hal->versions) {
-            if (v.minorAtLeast(version)) {
-                return std::make_pair(true, v);
-            }
-        }
-        return std::make_pair(false, Version{});
+                                                   const std::string& interface,
+                                                   const std::string& instance) {
+        std::pair<bool, Version> ret(false, Version{});
+        deviceManifest->forEachInstanceOfInterface(
+            package, version, interface,
+            [&instance, &ret](const ManifestInstance& manifestInstance) {
+                if (manifestInstance.instance() == instance) {
+                    ret.first = true;
+                    ret.second = manifestInstance.version();
+                    return false;
+                }
+                return true;
+            });
+        return ret;
     };
     return CheckDeprecation(inManifest, error);
 }