Call libvintf to verify package compatibility.

The libvintf API has landed. Hook up to do the actual verification.

Bug: 36597505
Test: recovery_component_test
Test: m recoveryimage; adb sideload on angler and sailfish, with
      packages that contain dummy compatibility entries.
Test: m recoveryimage; adb sideload on angler and sailfish, with
      packages that don't contain any compatibility entries.
Change-Id: Idbd6f5aaef605ca51b20e667505d686de5ac781f
diff --git a/install.cpp b/install.cpp
index 4fb8099..ffeba2e 100644
--- a/install.cpp
+++ b/install.cpp
@@ -44,6 +44,7 @@
 #include <android-base/properties.h>
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
+#include <vintf/VintfObjectRecovery.h>
 #include <ziparchive/zip_archive.h>
 
 #include "common.h"
@@ -544,10 +545,15 @@
   }
   CloseArchive(zip_handle);
 
-  // TODO(b/36814503): Enable the actual verification when VintfObject::CheckCompatibility() lands.
-  // VintfObject::CheckCompatibility returns zero on success.
-  // return (android::vintf::VintfObject::CheckCompatibility(compatibility_info, true) == 0);
-  return true;
+  // VintfObjectRecovery::CheckCompatibility returns zero on success.
+  std::string err;
+  int result = android::vintf::VintfObjectRecovery::CheckCompatibility(compatibility_info, &err);
+  if (result == 0) {
+    return true;
+  }
+
+  LOG(ERROR) << "Failed to verify package compatibility (result " << result << "): " << err;
+  return false;
 }
 
 static int
@@ -599,7 +605,6 @@
 
     // Additionally verify the compatibility of the package.
     if (!verify_package_compatibility(zip)) {
-      LOG(ERROR) << "Failed to verify package compatibility";
       log_buffer.push_back(android::base::StringPrintf("error: %d", kPackageCompatibilityFailure));
       sysReleaseMap(&map);
       CloseArchive(zip);