Add VintfObject::getKernelLevel.
Remove the unused API VintfObject::getCompatibleKernelRequirements and
add a more useful VintfObject::getKernelLevel. The new API
returns the kernel FCM version specified in the device manifest.
For example, if a device runs kernel from 4.19-r branch
(with kernel version 4.19.y), then this API should return
Level::R.
Old tests for getCompatibleKernelRequirements are deleted.
New tests for getKernelLevel() are added.
Fixes: 139015688
Test: vintf_object_test
Change-Id: Icddc48c679e78588b436ea91fbc6ce18308386ee
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 0030b4f..b706599 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -742,34 +742,17 @@
return checkDeprecation(inManifest, error);
}
-std::optional<KernelRequirement> VintfObject::getCompatibleKernelRequirement(std::string* error) {
- auto matrix = getFrameworkCompatibilityMatrix();
- if (!matrix) {
- if (error) *error = "Cannot retrieve framework compatibility matrix";
- return std::nullopt;
+Level VintfObject::getKernelLevel(std::string* error) {
+ auto manifest = getDeviceHalManifest();
+ if (!manifest) {
+ if (error) *error = "Cannot retrieve device manifest.";
+ return Level::UNSPECIFIED;
}
- auto runtime_info = getRuntimeInfo();
- if (!runtime_info) {
- if (error) *error = "Cannot retrieve runtime information";
- return std::nullopt;
+ if (manifest->kernel().has_value() && manifest->kernel()->level() != Level::UNSPECIFIED) {
+ return manifest->kernel()->level();
}
- auto reqs = runtime_info->mKernel.getMatchedKernelRequirements(
- matrix->framework.mKernels, runtime_info->kernelLevel(), error);
- if (reqs.empty()) {
- if (error) error->insert(0, "Cannot find any matched kernel requirements: ");
- return std::nullopt;
- }
- for (const MatrixKernel* matrixKernel : reqs) {
- if (matrixKernel->conditions().empty()) {
- return KernelRequirement(matrixKernel->minLts(),
- matrix->getSourceMatrixLevel(matrixKernel));
- }
- }
- KernelRequirement ret(reqs[0]->minLts(), matrix->getSourceMatrixLevel(reqs[0]));
- LOG(ERROR) << "Cannot find kernel requirement with empty conditions; "
- << "this should not happen. Returning (" << ret.minLts() << ", " << ret.level()
- << ") as a heuristic.";
- return ret;
+ if (error) *error = "Device manifest does not specify kernel FCM version.";
+ return Level::UNSPECIFIED;
}
const std::unique_ptr<FileSystem>& VintfObject::getFileSystem() {