VintfObject::verify() will fetch data from device

- If no info is provided then all data is fetched from device.
- Add hook to mock retrieving files from device.
- Add test.
- Print more detailed messages on AVB failures.

Test: Ran vintf_object_test and libvintf_test
Bug: 37863689
Bug: 36814984
Change-Id: Ia33f4e2e73c863bc0f8f68f5ed61c30df8eff53d
Merged-In: Ia33f4e2e73c863bc0f8f68f5ed61c30df8eff53d
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 1ef6edc..342f032 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -176,9 +176,9 @@
     const RuntimeInfo *runtimeInfo;
 };
 
-// Parse all information from package;
-// Get missing information from the device;
-// Do compatibility check.
+// Checks given compatibility info against info on the device. If no
+// compatability info is given then the device info will be checked against
+// itself.
 int32_t checkCompatibility(const std::vector<std::string> &xmls, bool mount,
         std::function<status_t(void)> mountSystem,
         std::function<status_t(void)> umountSystem,
@@ -194,11 +194,6 @@
     PackageInfo pkg; // All information from package.
     UpdatedInfo updated; // All files and runtime info after the update.
 
-    if (xmls.empty()) {
-        ADD_MESSAGE("nothing to update");
-        return BAD_VALUE;
-    }
-
     // parse all information from package
     for (const auto &xml : xmls) {
         parseStatus = tryParse(xml, gHalManifestConverter, &pkg.fwk.manifest, &pkg.dev.manifest);
@@ -232,10 +227,18 @@
             std::bind(GetDeviceHalManifest, true /* skipCache */))) != OK) {
         return status;
     }
+    if ((status = getMissing(
+             pkg.fwk.matrix.get(), mount, mountVendor, umountVendor, &updated.fwk.matrix,
+             std::bind(VintfObject::GetFrameworkCompatibilityMatrix, true /* skipCache */))) !=
+        OK) {
+        return status;
+    }
+    if ((status = getMissing(
+             pkg.dev.matrix.get(), mount, mountSystem, umountSystem, &updated.dev.matrix,
+             std::bind(VintfObject::GetDeviceCompatibilityMatrix, true /* skipCache */))) != OK) {
+        return status;
+    }
     updated.runtimeInfo = GetRuntimeInfo(true /* skipCache */);
-    // TODO(b/37321309) get matrices from the device as well.
-    updated.fwk.matrix = pkg.fwk.matrix.get();
-    updated.dev.matrix = pkg.dev.matrix.get();
 
     // null checks for files and runtime info after the update
     // TODO(b/37321309) if a compat mat is missing, it is not matched and considered compatible.