Clean up HalGroup::forEachInstance usage
Add a few functions to MatrixInstance to print
out human-readable strings so that analyze_matrix / vintf
can use them.
Bug: 140832836
Test: libvintf_test
Test: analyze_matrix --interfaces \
--input hardware/interfaces/compatibility_matrices/compatibility_matrix.current.xml
Test: adb shell vintf
Change-Id: Ice13f299ba24808119f5536ecacc2777cfa870a2
diff --git a/MatrixInstance.cpp b/MatrixInstance.cpp
index fb1cb33..2e95ee3 100644
--- a/MatrixInstance.cpp
+++ b/MatrixInstance.cpp
@@ -19,6 +19,7 @@
#include <utility>
#include "Regex.h"
+#include "parse_string.h"
namespace android {
namespace vintf {
@@ -100,5 +101,32 @@
return mIsRegex;
}
+std::string MatrixInstance::interfaceDescription(Version replaceVersion) const {
+ switch (format()) {
+ case HalFormat::HIDL:
+ [[fallthrough]];
+ case HalFormat::NATIVE: {
+ return toFQNameString(package(), replaceVersion, interface());
+ } break;
+ case HalFormat::AIDL: {
+ return toAidlFqnameString(package(), interface());
+ } break;
+ }
+}
+
+std::string MatrixInstance::description(Version replaceVersion) const {
+ std::string instanceDescription = isRegex() ? regexPattern() : exactInstance();
+ switch (format()) {
+ case HalFormat::HIDL:
+ [[fallthrough]];
+ case HalFormat::NATIVE: {
+ return toFQNameString(package(), replaceVersion, interface(), instanceDescription);
+ } break;
+ case HalFormat::AIDL: {
+ return toAidlFqnameString(package(), interface(), instanceDescription);
+ } break;
+ }
+}
+
} // namespace vintf
} // namespace android