vintf: fix output for minor versions in compatibility matrix.
This is a follow-up change to forEachInstance() functions.
Test: adb shell vintf
Bug: 73556059
Change-Id: I471749f7ec79fa4c5215a8d75a4dd284c14df514
diff --git a/main.cpp b/main.cpp
index 7843cb5..1c3dfef 100644
--- a/main.cpp
+++ b/main.cpp
@@ -199,7 +199,6 @@
void insert(const CompatibilityMatrix* matrix, Table* table, const RowMutator& mutate) {
if (matrix == nullptr) return;
matrix->forEachInstance([&](const auto& matrixInstance) {
- bool missed = false;
for (auto minorVer = matrixInstance.versionRange().minMinor;
minorVer <= matrixInstance.versionRange().maxMinor; ++minorVer) {
std::string key = toFQNameString(
@@ -207,18 +206,14 @@
matrixInstance.interface(), matrixInstance.instance());
auto it = table->find(key);
if (it == table->end()) {
- missed = true;
+ mutate(&(*table)[key]);
} else {
mutate(&it->second);
- it->second.required = !matrixInstance.optional();
+ if (minorVer == matrixInstance.versionRange().minMinor) {
+ it->second.required = !matrixInstance.optional();
+ }
}
}
- if (missed) {
- std::string key =
- toFQNameString(matrixInstance.package(), matrixInstance.versionRange(),
- matrixInstance.interface(), matrixInstance.instance());
- mutate(&(*table)[key]);
- }
return true;
});
}