Also consider kernelLevel when combining FCMs.
If VintfObject::getKernelLevel() returns a level less than
target FCM (device manifest level), then CompatibilityMatrix::combine
did not include kernel requirements from older FCM.
Fix this by passing the kernel level to CompatibiltiyMatrix::combine,
so that old kernel requirements are also included.
Test: libvintf_test
Test: vintf_object_test
Fixes: 188939851
Change-Id: Ib57e8bd03046a07e3a86f21aaafe4aabc5e72710
diff --git a/CompatibilityMatrix.cpp b/CompatibilityMatrix.cpp
index f8d7d05..582914f 100644
--- a/CompatibilityMatrix.cpp
+++ b/CompatibilityMatrix.cpp
@@ -334,7 +334,8 @@
}
std::unique_ptr<CompatibilityMatrix> CompatibilityMatrix::combine(
- Level deviceLevel, std::vector<CompatibilityMatrix>* matrices, std::string* error) {
+ Level deviceLevel, Level kernelLevel, std::vector<CompatibilityMatrix>* matrices,
+ std::string* error) {
// Check type.
for (const auto& e : *matrices) {
if (e.type() != SchemaType::FRAMEWORK) {
@@ -363,12 +364,12 @@
std::vector<std::string> parsedFiles;
for (auto& e : *matrices) {
- if (e.level() < deviceLevel) {
- continue;
- }
-
bool success = false;
- if (e.level() == deviceLevel) {
+ if (e.level() < deviceLevel) {
+ if (kernelLevel == Level::UNSPECIFIED) continue;
+ if (e.level() < kernelLevel) continue;
+ success = baseMatrix->addAllKernels(&e, error);
+ } else if (e.level() == deviceLevel) {
success = baseMatrix->addAll(&e, error);
} else {
success = baseMatrix->addAllAsOptional(&e, error);