summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2018-10-08 16:25:48 -0500
committerGerrit Code Review2018-10-08 16:25:48 -0500
commit34168f34e0263f76aa2e6bfde59c50bf3e9769f3 (patch)
tree6afe5c70da3c2eb2ffe627d223db593588842f88
parentcb648df76b1cd8895682de622485044efd6afc09 (diff)
parent0df914b2d74bb3e5414acfb367a7d88e9e904d7a (diff)
downloadplatform-system-libvintf-34168f34e0263f76aa2e6bfde59c50bf3e9769f3.tar.gz
platform-system-libvintf-34168f34e0263f76aa2e6bfde59c50bf3e9769f3.tar.xz
platform-system-libvintf-34168f34e0263f76aa2e6bfde59c50bf3e9769f3.zip
Merge "<kernel> compat check can be split"
-rw-r--r--RuntimeInfo.cpp64
-rw-r--r--include/vintf/CheckFlags.h2
2 files changed, 35 insertions, 31 deletions
diff --git a/RuntimeInfo.cpp b/RuntimeInfo.cpp
index 5727a21..2338cd2 100644
--- a/RuntimeInfo.cpp
+++ b/RuntimeInfo.cpp
@@ -122,43 +122,45 @@ bool RuntimeInfo::checkCompatibility(const CompatibilityMatrix& mat, std::string
122 // mat.mSepolicy.sepolicyVersion() is checked against static 122 // mat.mSepolicy.sepolicyVersion() is checked against static
123 // HalManifest.device.mSepolicyVersion in HalManifest::checkCompatibility. 123 // HalManifest.device.mSepolicyVersion in HalManifest::checkCompatibility.
124 124
125 bool foundMatchedKernelVersion = false; 125 if (flags.isKernelEnabled()) {
126 bool foundMatchedConditions = false; 126 bool foundMatchedKernelVersion = false;
127 for (const MatrixKernel& matrixKernel : mat.framework.mKernels) { 127 bool foundMatchedConditions = false;
128 if (!matchKernelVersion(matrixKernel.minLts())) { 128 for (const MatrixKernel& matrixKernel : mat.framework.mKernels) {
129 continue; 129 if (!matchKernelVersion(matrixKernel.minLts())) {
130 } 130 continue;
131 foundMatchedKernelVersion = true; 131 }
132 // ignore this fragment if not all conditions are met. 132 foundMatchedKernelVersion = true;
133 if (!matchKernelConfigs(matrixKernel.conditions(), error)) { 133 // ignore this fragment if not all conditions are met.
134 continue; 134 if (!matchKernelConfigs(matrixKernel.conditions(), error)) {
135 continue;
136 }
137 foundMatchedConditions = true;
138 if (!matchKernelConfigs(matrixKernel.configs(), error)) {
139 return false;
140 }
135 } 141 }
136 foundMatchedConditions = true; 142 if (!foundMatchedKernelVersion) {
137 if (!matchKernelConfigs(matrixKernel.configs(), error)) { 143 if (error != nullptr) {
144 std::stringstream ss;
145 ss << "Framework is incompatible with kernel version " << mKernelVersion
146 << ", compatible kernel versions are";
147 for (const MatrixKernel& matrixKernel : mat.framework.mKernels)
148 ss << " " << matrixKernel.minLts();
149 *error = ss.str();
150 }
138 return false; 151 return false;
139 } 152 }
140 } 153 if (!foundMatchedConditions) {
141 if (!foundMatchedKernelVersion) { 154 // This should not happen because first <conditions> for each <kernel> must be
142 if (error != nullptr) { 155 // empty. Reject here for inconsistency.
143 std::stringstream ss; 156 if (error != nullptr) {
144 ss << "Framework is incompatible with kernel version " << mKernelVersion 157 error->insert(0, "Framework match kernel version with unmet conditions:");
145 << ", compatible kernel versions are"; 158 }
146 for (const MatrixKernel& matrixKernel : mat.framework.mKernels) 159 return false;
147 ss << " " << matrixKernel.minLts();
148 *error = ss.str();
149 } 160 }
150 return false;
151 }
152 if (!foundMatchedConditions) {
153 // This should not happen because first <conditions> for each <kernel> must be
154 // empty. Reject here for inconsistency.
155 if (error != nullptr) { 161 if (error != nullptr) {
156 error->insert(0, "Framework match kernel version with unmet conditions:"); 162 error->clear();
157 } 163 }
158 return false;
159 }
160 if (error != nullptr) {
161 error->clear();
162 } 164 }
163 165
164 if (flags.isAvbEnabled()) { 166 if (flags.isAvbEnabled()) {
diff --git a/include/vintf/CheckFlags.h b/include/vintf/CheckFlags.h
index df247d9..d63a809 100644
--- a/include/vintf/CheckFlags.h
+++ b/include/vintf/CheckFlags.h
@@ -32,6 +32,7 @@ class Type {
32 32
33 VINTF_CHECK_FLAGS_FIELD(Avb, 0) 33 VINTF_CHECK_FLAGS_FIELD(Avb, 0)
34 VINTF_CHECK_FLAGS_FIELD(RuntimeInfo, 1) 34 VINTF_CHECK_FLAGS_FIELD(RuntimeInfo, 1)
35 VINTF_CHECK_FLAGS_FIELD(Kernel, 2)
35#undef VINTF_CHECK_FLAGS_FIELD 36#undef VINTF_CHECK_FLAGS_FIELD
36 37
37 explicit constexpr Type(int32_t value) : mValue(value) {} 38 explicit constexpr Type(int32_t value) : mValue(value) {}
@@ -41,6 +42,7 @@ class Type {
41}; 42};
42 43
43constexpr Type ENABLE_ALL_CHECKS{~0}; 44constexpr Type ENABLE_ALL_CHECKS{~0};
45constexpr Type DISABLE_ALL_CHECKS{0};
44// Disable AVB version check in RuntimeInfo::checkCompatibility 46// Disable AVB version check in RuntimeInfo::checkCompatibility
45constexpr Type DISABLE_AVB_CHECK = ENABLE_ALL_CHECKS.disableAvb(); 47constexpr Type DISABLE_AVB_CHECK = ENABLE_ALL_CHECKS.disableAvb();
46// Disable RuntimeInfo <-> Framework Matrix check. This implies DISABLE_AVB_CHECK. 48// Disable RuntimeInfo <-> Framework Matrix check. This implies DISABLE_AVB_CHECK.