Call libvintf to verify package compatibility. am: da320ac6ab
am: 34ae4d02ce

Change-Id: I96580281c3d898b382e9870f3dbc8db218114e27
diff --git a/Android.mk b/Android.mk
index 9e374de..adf478f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -55,6 +55,7 @@
 LOCAL_MODULE := librecovery
 LOCAL_STATIC_LIBRARIES := \
     libminui \
+    libvintf_recovery \
     libcrypto_utils \
     libcrypto \
     libbase
@@ -114,6 +115,9 @@
     libfs_mgr \
     libcrypto_utils \
     libcrypto \
+    libvintf_recovery \
+    libvintf \
+    libtinyxml2 \
     libbase \
     libcutils \
     libutils \
diff --git a/install.cpp b/install.cpp
index 73ddf5e..e5a59b8 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"
@@ -535,10 +536,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
@@ -590,7 +596,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);
diff --git a/tests/Android.mk b/tests/Android.mk
index 20cbcc1..e526630 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -132,6 +132,9 @@
     libdivsufsort64 \
     libfs_mgr \
     liblog \
+    libvintf_recovery \
+    libvintf \
+    libtinyxml2 \
     libselinux \
     libext4_utils \
     libsparse \