checkUnusedHals: use hidl metadata
Use libhidlmetadata to infer relationships between interfaces. For
example, if GNSS@2.0 is listed as "optional", but a manifest lists
GNSS@1.1 and 2.0 (because 2.0 inherits from 1.1), do not complain
about an unused 1.1 HAL.
Bug: 131717099
Test: drop GNSS 1.1 from matrix and `m check-vintf-all`
Change-Id: I1c0ef715bf64cacf99de590ed6627afa2b60f4b1
Merged-In: I1c0ef715bf64cacf99de590ed6627afa2b60f4b1
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 4f47622..320f97f 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -25,6 +25,7 @@
#include <android-base/logging.h>
#include <android-base/result.h>
#include <android-base/strings.h>
+#include <hidl/metadata.h>
#include "CompatibilityMatrix.h"
#include "parse_string.h"
@@ -833,7 +834,8 @@
return false;
}
-android::base::Result<void> VintfObject::checkUnusedHals() {
+android::base::Result<void> VintfObject::checkUnusedHals(
+ const std::vector<HidlInterfaceMetadata>& hidlMetadata) {
auto matrix = getFrameworkCompatibilityMatrix();
if (matrix == nullptr) {
return android::base::Error(-NAME_NOT_FOUND) << "Missing framework matrix.";
@@ -842,7 +844,7 @@
if (manifest == nullptr) {
return android::base::Error(-NAME_NOT_FOUND) << "Missing device manifest.";
}
- auto unused = manifest->checkUnusedHals(*matrix);
+ auto unused = manifest->checkUnusedHals(*matrix, hidlMetadata);
if (!unused.empty()) {
return android::base::Error()
<< "The following instances are in the device manifest but "