CompatMatrix::combine allow to use hal versions at higher FCM version.
Test: libvintf_test
Test: vintf_object_test
Test: vts_treble_vintf_test
Test: build compatibility matrix with device of target-level 2 (marlin),
audio 2.0 and 4.0 are now in "OR" relationship.
Bug: 74341777
Fixes: 70673533
Change-Id: I7e9eb09e846304d6cb6c0479c7e7dffaeffad9df
diff --git a/MatrixHal.cpp b/MatrixHal.cpp
index 9788545..d716a8d 100644
--- a/MatrixHal.cpp
+++ b/MatrixHal.cpp
@@ -16,6 +16,8 @@
#include "MatrixHal.h"
+#include <algorithm>
+
#include "MapValueIterator.h"
namespace android {
@@ -130,5 +132,22 @@
[&](const auto& providedVersion) { return vr.supportedBy(providedVersion); });
}
+void MatrixHal::setOptional(bool o) {
+ this->optional = o;
+}
+
+void MatrixHal::insertVersionRanges(const MatrixHal& other) {
+ for (const VersionRange& otherVr : other.versionRanges) {
+ auto existingVr = std::find_if(this->versionRanges.begin(), this->versionRanges.end(),
+ [&](const auto& e) { return e.overlaps(otherVr); });
+
+ if (existingVr == this->versionRanges.end()) {
+ this->versionRanges.push_back(otherVr);
+ } else {
+ existingVr->maxMinor = std::max(existingVr->maxMinor, otherVr.maxMinor);
+ }
+ }
+}
+
} // namespace vintf
} // namespace android