blob: ee834eb75df9e426a925d4c1899e608995cf9ca4 [file] [log] [blame]
Yifan Hong3daec812017-02-27 18:49:11 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "VintfObject.h"
18
Yifan Hong143cfe62017-04-13 20:18:01 -070019#include "CompatibilityMatrix.h"
20#include "parse_xml.h"
Yifan Hong8640cd12017-05-17 12:02:28 -070021#include "utils.h"
Yifan Hong143cfe62017-04-13 20:18:01 -070022
Yifan Hongd52bf3e2018-01-11 16:56:51 -080023#include <dirent.h>
24
Yifan Hong3daec812017-02-27 18:49:11 -080025#include <functional>
26#include <memory>
27#include <mutex>
28
Bowgo Tsai39adc142017-11-03 12:46:26 +080029#ifdef LIBVINTF_TARGET
30#include <android-base/properties.h>
31#endif
32
Yifan Hong60217032018-01-08 16:19:42 -080033#include <android-base/logging.h>
34
Yifan Hongd52bf3e2018-01-11 16:56:51 -080035#define FRAMEWORK_MATRIX_DIR "/system/etc/vintf/"
36
Yifan Hong60217032018-01-08 16:19:42 -080037using std::placeholders::_1;
38using std::placeholders::_2;
39
Yifan Hong3daec812017-02-27 18:49:11 -080040namespace android {
41namespace vintf {
42
43template <typename T>
Yifan Hongfc73edf2017-08-29 11:39:07 -070044struct LockedSharedPtr {
45 std::shared_ptr<T> object;
Yifan Hong3daec812017-02-27 18:49:11 -080046 std::mutex mutex;
Yifan Hong7219ba12018-01-08 16:23:49 -080047 bool fetchedOnce = false;
Yifan Hong3daec812017-02-27 18:49:11 -080048};
49
Yifan Hong1fb004e2017-09-26 15:04:44 -070050struct LockedRuntimeInfoCache {
51 std::shared_ptr<RuntimeInfo> object;
52 std::mutex mutex;
53 RuntimeInfo::FetchFlags fetchedFlags = RuntimeInfo::FetchFlag::NONE;
54};
55
Yifan Hong3daec812017-02-27 18:49:11 -080056template <typename T, typename F>
Yifan Hongfc73edf2017-08-29 11:39:07 -070057static std::shared_ptr<const T> Get(
58 LockedSharedPtr<T> *ptr,
Yifan Hong143cfe62017-04-13 20:18:01 -070059 bool skipCache,
Yifan Hong3daec812017-02-27 18:49:11 -080060 const F &fetchAllInformation) {
61 std::unique_lock<std::mutex> _lock(ptr->mutex);
Yifan Hong7219ba12018-01-08 16:23:49 -080062 if (skipCache || !ptr->fetchedOnce) {
Yifan Hong3daec812017-02-27 18:49:11 -080063 ptr->object = std::make_unique<T>();
Yifan Hong60217032018-01-08 16:19:42 -080064 std::string error;
65 if (fetchAllInformation(ptr->object.get(), &error) != OK) {
66 LOG(WARNING) << error;
Yifan Hong3daec812017-02-27 18:49:11 -080067 ptr->object = nullptr; // frees the old object
68 }
Yifan Hong7219ba12018-01-08 16:23:49 -080069 ptr->fetchedOnce = true;
Yifan Hong3daec812017-02-27 18:49:11 -080070 }
Yifan Hongfc73edf2017-08-29 11:39:07 -070071 return ptr->object;
Yifan Hong3daec812017-02-27 18:49:11 -080072}
73
74// static
Yifan Hongfc73edf2017-08-29 11:39:07 -070075std::shared_ptr<const HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) {
Steven Moreland648a0012017-10-19 21:23:41 -070076 static LockedSharedPtr<HalManifest> gVendorManifest;
Yifan Hong5a93bf22018-01-17 18:22:32 -080077 return Get(&gVendorManifest, skipCache, &VintfObject::FetchDeviceHalManifest);
Yifan Hong3daec812017-02-27 18:49:11 -080078}
79
80// static
Yifan Hongfc73edf2017-08-29 11:39:07 -070081std::shared_ptr<const HalManifest> VintfObject::GetFrameworkHalManifest(bool skipCache) {
82 static LockedSharedPtr<HalManifest> gFrameworkManifest;
Yifan Hong143cfe62017-04-13 20:18:01 -070083 return Get(&gFrameworkManifest, skipCache,
Yifan Hong60217032018-01-08 16:19:42 -080084 std::bind(&HalManifest::fetchAllInformation, _1, "/system/manifest.xml", _2));
Yifan Hong3daec812017-02-27 18:49:11 -080085}
86
Yifan Hong2272bf82017-04-28 14:37:56 -070087
88// static
Yifan Hongfc73edf2017-08-29 11:39:07 -070089std::shared_ptr<const CompatibilityMatrix> VintfObject::GetDeviceCompatibilityMatrix(bool skipCache) {
90 static LockedSharedPtr<CompatibilityMatrix> gDeviceMatrix;
Yifan Hong2272bf82017-04-28 14:37:56 -070091 return Get(&gDeviceMatrix, skipCache,
Yifan Hong60217032018-01-08 16:19:42 -080092 std::bind(&CompatibilityMatrix::fetchAllInformation, _1,
93 "/vendor/compatibility_matrix.xml", _2));
Yifan Hong2272bf82017-04-28 14:37:56 -070094}
95
96// static
Yifan Hongfc73edf2017-08-29 11:39:07 -070097std::shared_ptr<const CompatibilityMatrix> VintfObject::GetFrameworkCompatibilityMatrix(bool skipCache) {
98 static LockedSharedPtr<CompatibilityMatrix> gFrameworkMatrix;
Yifan Hongd52bf3e2018-01-11 16:56:51 -080099 static LockedSharedPtr<CompatibilityMatrix> gCombinedFrameworkMatrix;
100 static std::mutex gFrameworkCompatibilityMatrixMutex;
101
102 // To avoid deadlock, get device manifest before any locks.
103 auto deviceManifest = GetDeviceHalManifest();
104
105 std::unique_lock<std::mutex> _lock(gFrameworkCompatibilityMatrixMutex);
106
107 auto combined =
108 Get(&gCombinedFrameworkMatrix, skipCache,
109 std::bind(&VintfObject::GetCombinedFrameworkMatrix, deviceManifest, _1, _2));
110 if (combined != nullptr) {
111 return combined;
112 }
113
Yifan Hong2272bf82017-04-28 14:37:56 -0700114 return Get(&gFrameworkMatrix, skipCache,
Yifan Hong60217032018-01-08 16:19:42 -0800115 std::bind(&CompatibilityMatrix::fetchAllInformation, _1,
116 "/system/compatibility_matrix.xml", _2));
Yifan Hong2272bf82017-04-28 14:37:56 -0700117}
118
Yifan Hongd52bf3e2018-01-11 16:56:51 -0800119status_t VintfObject::GetCombinedFrameworkMatrix(
120 const std::shared_ptr<const HalManifest>& deviceManifest, CompatibilityMatrix* out,
121 std::string* error) {
122 auto matrixFragments = GetAllFrameworkMatrixLevels(error);
123 if (matrixFragments.empty()) {
124 return NAME_NOT_FOUND;
125 }
126
127 Level deviceLevel = Level::UNSPECIFIED;
128
129 if (deviceManifest != nullptr) {
130 deviceLevel = deviceManifest->level();
131 }
132
133 // TODO(b/70628538): Do not infer from Shipping API level.
134#ifdef LIBVINTF_TARGET
135 if (deviceLevel == Level::UNSPECIFIED) {
136 auto shippingApi =
137 android::base::GetUintProperty<uint64_t>("ro.product.first_api_level", 0u);
138 if (shippingApi != 0u) {
139 deviceLevel = details::convertFromApiLevel(shippingApi);
140 }
141 }
142#endif
143
144 if (deviceLevel == Level::UNSPECIFIED) {
145 // Cannot infer FCM version. Combine all matrices by assuming
146 // Shipping FCM Version == min(all supported FCM Versions in the framework)
147 for (auto&& pair : matrixFragments) {
148 Level fragmentLevel = pair.object.level();
149 if (fragmentLevel != Level::UNSPECIFIED && deviceLevel > fragmentLevel) {
150 deviceLevel = fragmentLevel;
151 }
152 }
153 }
154
155 if (deviceLevel == Level::UNSPECIFIED) {
156 // None of the fragments specify any FCM version. Should never happen except
157 // for inconsistent builds.
158 if (error) {
159 *error = "No framework compatibility matrix files under " FRAMEWORK_MATRIX_DIR
160 " declare FCM version.";
161 }
162 return NAME_NOT_FOUND;
163 }
164
165 CompatibilityMatrix* combined =
166 CompatibilityMatrix::combine(deviceLevel, &matrixFragments, error);
167 if (combined == nullptr) {
168 return BAD_VALUE;
169 }
170 *out = std::move(*combined);
171 return OK;
172}
173
Yifan Hong5a93bf22018-01-17 18:22:32 -0800174// Priority for loading vendor manifest:
175// 1. If {sku} sysprop is set and both files exist,
176// /vendor/etc/manifest.xml + /odm/etc/manifest_{sku}.xml
177// 2. If both files exist,
178// /vendor/etc/manifest.xml + /odm/etc/manifest.xml
179// 3. If file exists, /vendor/etc/manifest.xml
180// 4. If {sku} sysprop is set and file exists,
181// /odm/etc/manifest_{sku}.xml
182// 5. If file exists, /odm/etc/manifest.xml
183// 6. If file exists, /vendor/manifest.xml
184// where:
185// {sku} is the value of ro.boot.product.hardware.sku
186// A + B means adding <hal> tags from B to A (so that <hal>s from B can override A)
187status_t VintfObject::FetchDeviceHalManifest(HalManifest* out, std::string* error) {
188 // fetchAllInformation returns NAME_NOT_FOUND if file is missing.
189 HalManifest vendorManifest;
190 status_t vendorStatus = vendorManifest.fetchAllInformation("/vendor/etc/manifest.xml", error);
191 if (vendorStatus != OK && vendorStatus != NAME_NOT_FOUND) {
192 return vendorStatus;
193 }
194
195 HalManifest odmManifest;
196 status_t odmStatus = NAME_NOT_FOUND;
197
198#ifdef LIBVINTF_TARGET
199 std::string productModel = android::base::GetProperty("ro.boot.product.hardware.sku", "");
200 if (!productModel.empty()) {
201 odmStatus =
202 odmManifest.fetchAllInformation("/odm/etc/manifest_" + productModel + ".xml", error);
203 if (odmStatus != OK && odmStatus != NAME_NOT_FOUND) {
204 return odmStatus;
205 }
206 }
207#endif
208
209 if (odmStatus == NAME_NOT_FOUND) {
210 odmStatus = odmManifest.fetchAllInformation("/odm/etc/manifest.xml", error);
211 if (odmStatus != OK && odmStatus != NAME_NOT_FOUND) {
212 return odmStatus;
213 }
214 }
215
216 // Both files exist. Use vendor manifest as base manifest and let ODM manifest override it.
217 if (vendorStatus == OK && odmStatus == OK) {
218 *out = std::move(vendorManifest);
219 out->addAllHals(&odmManifest);
220 return OK;
221 }
222
223 // Only vendor manifest exists. Use it.
224 if (vendorStatus == OK) {
225 *out = std::move(vendorManifest);
226 return OK;
227 }
228
229 // Only ODM manifest exists. use it.
230 if (odmStatus == OK) {
231 *out = std::move(odmManifest);
232 return OK;
233 }
234
235 // Use legacy /vendor/manifest.xml
236 return out->fetchAllInformation("/vendor/manifest.xml", error);
237}
238
Yifan Hongd52bf3e2018-01-11 16:56:51 -0800239std::vector<Named<CompatibilityMatrix>> VintfObject::GetAllFrameworkMatrixLevels(
240 std::string* error) {
241 std::vector<std::string> fileNames;
242 std::vector<Named<CompatibilityMatrix>> results;
243
244 if (details::gFetcher->listFiles(FRAMEWORK_MATRIX_DIR, &fileNames, error) != OK) {
245 return {};
246 }
247 for (const std::string& fileName : fileNames) {
248 std::string path = FRAMEWORK_MATRIX_DIR + fileName;
249
250 std::string content;
251 std::string fetchError;
252 status_t status = details::gFetcher->fetch(path, content, &fetchError);
253 if (status != OK) {
254 if (error) {
255 *error += "Ignore file " + path + ": " + fetchError + "\n";
256 }
257 continue;
258 }
259
260 auto it = results.emplace(results.end());
261 if (!gCompatibilityMatrixConverter(&it->object, content)) {
262 if (error) {
263 // TODO(b/71874788): do not use lastError() because it is not thread-safe.
264 *error +=
265 "Ignore file " + path + ": " + gCompatibilityMatrixConverter.lastError() + "\n";
266 }
267 results.erase(it);
268 continue;
269 }
270 }
271
272 if (results.empty()) {
273 if (error) {
274 *error = "No framework matrices under " FRAMEWORK_MATRIX_DIR
275 " can be fetched or parsed.\n" +
276 *error;
277 }
278 } else {
279 if (error && !error->empty()) {
280 LOG(WARNING) << *error;
281 *error = "";
282 }
283 }
284
285 return results;
286}
287
Yifan Hong3daec812017-02-27 18:49:11 -0800288// static
Yifan Hong1fb004e2017-09-26 15:04:44 -0700289std::shared_ptr<const RuntimeInfo> VintfObject::GetRuntimeInfo(bool skipCache,
290 RuntimeInfo::FetchFlags flags) {
291 static LockedRuntimeInfoCache gDeviceRuntimeInfo;
292 std::unique_lock<std::mutex> _lock(gDeviceRuntimeInfo.mutex);
293
294 if (!skipCache) {
295 flags &= (~gDeviceRuntimeInfo.fetchedFlags);
296 }
297
298 if (gDeviceRuntimeInfo.object == nullptr) {
Yifan Hong29bb2d42017-09-27 13:28:00 -0700299 gDeviceRuntimeInfo.object = details::gRuntimeInfoFactory->make_shared();
Yifan Hong1fb004e2017-09-26 15:04:44 -0700300 }
301
302 status_t status = gDeviceRuntimeInfo.object->fetchAllInformation(flags);
303 if (status != OK) {
304 gDeviceRuntimeInfo.fetchedFlags &= (~flags); // mark the fields as "not fetched"
305 return nullptr;
306 }
307
308 gDeviceRuntimeInfo.fetchedFlags |= flags;
309 return gDeviceRuntimeInfo.object;
Yifan Hong3daec812017-02-27 18:49:11 -0800310}
311
Yifan Hong143cfe62017-04-13 20:18:01 -0700312namespace details {
313
Yifan Hong143cfe62017-04-13 20:18:01 -0700314enum class ParseStatus {
315 OK,
316 PARSE_ERROR,
317 DUPLICATED_FWK_ENTRY,
318 DUPLICATED_DEV_ENTRY,
319};
320
Yifan Hong9532bd22017-04-14 15:30:52 -0700321static std::string toString(ParseStatus status) {
Yifan Hong143cfe62017-04-13 20:18:01 -0700322 switch(status) {
323 case ParseStatus::OK: return "OK";
324 case ParseStatus::PARSE_ERROR: return "parse error";
325 case ParseStatus::DUPLICATED_FWK_ENTRY: return "duplicated framework";
326 case ParseStatus::DUPLICATED_DEV_ENTRY: return "duplicated device";
327 }
328 return "";
329}
330
331template<typename T>
Yifan Hong9532bd22017-04-14 15:30:52 -0700332static ParseStatus tryParse(const std::string &xml, const XmlConverter<T> &parse,
Yifan Hongfc73edf2017-08-29 11:39:07 -0700333 std::shared_ptr<T> *fwk, std::shared_ptr<T> *dev) {
334 std::shared_ptr<T> ret = std::make_shared<T>();
Yifan Hong143cfe62017-04-13 20:18:01 -0700335 if (!parse(ret.get(), xml)) {
336 return ParseStatus::PARSE_ERROR;
337 }
338 if (ret->type() == SchemaType::FRAMEWORK) {
339 if (fwk->get() != nullptr) {
340 return ParseStatus::DUPLICATED_FWK_ENTRY;
341 }
342 *fwk = std::move(ret);
343 } else if (ret->type() == SchemaType::DEVICE) {
344 if (dev->get() != nullptr) {
345 return ParseStatus::DUPLICATED_DEV_ENTRY;
346 }
347 *dev = std::move(ret);
348 }
349 return ParseStatus::OK;
350}
351
352template<typename T, typename GetFunction>
Yifan Hongfc73edf2017-08-29 11:39:07 -0700353static status_t getMissing(const std::shared_ptr<T>& pkg, bool mount,
Yifan Hong143cfe62017-04-13 20:18:01 -0700354 std::function<status_t(void)> mountFunction,
Yifan Hongfc73edf2017-08-29 11:39:07 -0700355 std::shared_ptr<const T>* updated,
Yifan Hong143cfe62017-04-13 20:18:01 -0700356 GetFunction getFunction) {
357 if (pkg != nullptr) {
358 *updated = pkg;
359 } else {
360 if (mount) {
361 (void)mountFunction(); // ignore mount errors
362 }
363 *updated = getFunction();
364 }
365 return OK;
366}
367
368#define ADD_MESSAGE(__error__) \
369 if (error != nullptr) { \
370 *error += (__error__); \
371 } \
372
373struct PackageInfo {
374 struct Pair {
Yifan Hongfc73edf2017-08-29 11:39:07 -0700375 std::shared_ptr<HalManifest> manifest;
376 std::shared_ptr<CompatibilityMatrix> matrix;
Yifan Hong143cfe62017-04-13 20:18:01 -0700377 };
378 Pair dev;
379 Pair fwk;
380};
381
382struct UpdatedInfo {
383 struct Pair {
Yifan Hongfc73edf2017-08-29 11:39:07 -0700384 std::shared_ptr<const HalManifest> manifest;
385 std::shared_ptr<const CompatibilityMatrix> matrix;
Yifan Hong143cfe62017-04-13 20:18:01 -0700386 };
387 Pair dev;
388 Pair fwk;
Yifan Hongfc73edf2017-08-29 11:39:07 -0700389 std::shared_ptr<const RuntimeInfo> runtimeInfo;
Yifan Hong143cfe62017-04-13 20:18:01 -0700390};
391
Michael Schwartz97dc0f92017-05-08 14:07:14 -0700392// Checks given compatibility info against info on the device. If no
393// compatability info is given then the device info will be checked against
394// itself.
Yifan Hongdb6423e2017-09-11 14:38:46 -0700395int32_t checkCompatibility(const std::vector<std::string>& xmls, bool mount,
396 const PartitionMounter& mounter, std::string* error,
397 DisabledChecks disabledChecks) {
Yifan Hong143cfe62017-04-13 20:18:01 -0700398 status_t status;
399 ParseStatus parseStatus;
400 PackageInfo pkg; // All information from package.
401 UpdatedInfo updated; // All files and runtime info after the update.
402
Yifan Hong143cfe62017-04-13 20:18:01 -0700403 // parse all information from package
404 for (const auto &xml : xmls) {
405 parseStatus = tryParse(xml, gHalManifestConverter, &pkg.fwk.manifest, &pkg.dev.manifest);
406 if (parseStatus == ParseStatus::OK) {
407 continue; // work on next one
408 }
409 if (parseStatus != ParseStatus::PARSE_ERROR) {
410 ADD_MESSAGE(toString(parseStatus) + " manifest");
411 return ALREADY_EXISTS;
412 }
413 parseStatus = tryParse(xml, gCompatibilityMatrixConverter, &pkg.fwk.matrix, &pkg.dev.matrix);
414 if (parseStatus == ParseStatus::OK) {
415 continue; // work on next one
416 }
417 if (parseStatus != ParseStatus::PARSE_ERROR) {
418 ADD_MESSAGE(toString(parseStatus) + " matrix");
419 return ALREADY_EXISTS;
420 }
421 ADD_MESSAGE(toString(parseStatus)); // parse error
422 return BAD_VALUE;
423 }
424
425 // get missing info from device
Yifan Hong8640cd12017-05-17 12:02:28 -0700426 // use functions instead of std::bind because std::bind doesn't work well with mock objects
427 auto mountSystem = [&mounter] { return mounter.mountSystem(); };
428 auto mountVendor = [&mounter] { return mounter.mountVendor(); };
429 if ((status = getMissing(
Yifan Hongfc73edf2017-08-29 11:39:07 -0700430 pkg.fwk.manifest, mount, mountSystem, &updated.fwk.manifest,
Yifan Hong8640cd12017-05-17 12:02:28 -0700431 std::bind(VintfObject::GetFrameworkHalManifest, true /* skipCache */))) != OK) {
Yifan Hong143cfe62017-04-13 20:18:01 -0700432 return status;
433 }
Michael Schwartz97dc0f92017-05-08 14:07:14 -0700434 if ((status = getMissing(
Yifan Hongfc73edf2017-08-29 11:39:07 -0700435 pkg.dev.manifest, mount, mountVendor, &updated.dev.manifest,
Yifan Hong8640cd12017-05-17 12:02:28 -0700436 std::bind(VintfObject::GetDeviceHalManifest, true /* skipCache */))) != OK) {
437 return status;
438 }
439 if ((status = getMissing(
Yifan Hongfc73edf2017-08-29 11:39:07 -0700440 pkg.fwk.matrix, mount, mountSystem, &updated.fwk.matrix,
Michael Schwartz97dc0f92017-05-08 14:07:14 -0700441 std::bind(VintfObject::GetFrameworkCompatibilityMatrix, true /* skipCache */))) !=
442 OK) {
443 return status;
444 }
445 if ((status = getMissing(
Yifan Hongfc73edf2017-08-29 11:39:07 -0700446 pkg.dev.matrix, mount, mountVendor, &updated.dev.matrix,
Michael Schwartz97dc0f92017-05-08 14:07:14 -0700447 std::bind(VintfObject::GetDeviceCompatibilityMatrix, true /* skipCache */))) != OK) {
448 return status;
449 }
Yifan Hong8640cd12017-05-17 12:02:28 -0700450
451 if (mount) {
452 (void)mounter.umountSystem(); // ignore errors
453 (void)mounter.umountVendor(); // ignore errors
454 }
455
456 updated.runtimeInfo = VintfObject::GetRuntimeInfo(true /* skipCache */);
Yifan Hong143cfe62017-04-13 20:18:01 -0700457
458 // null checks for files and runtime info after the update
459 // TODO(b/37321309) if a compat mat is missing, it is not matched and considered compatible.
460 if (updated.fwk.manifest == nullptr) {
461 ADD_MESSAGE("No framework manifest file from device or from update package");
462 return NO_INIT;
463 }
464 if (updated.dev.manifest == nullptr) {
465 ADD_MESSAGE("No device manifest file from device or from update package");
466 return NO_INIT;
467 }
468 if (updated.fwk.matrix == nullptr) {
469 ADD_MESSAGE("No framework matrix, skipping;");
470 // TODO(b/37321309) consider missing matricies as errors.
471 }
472 if (updated.dev.matrix == nullptr) {
473 ADD_MESSAGE("No device matrix, skipping;");
474 // TODO(b/37321309) consider missing matricies as errors.
475 }
476 if (updated.runtimeInfo == nullptr) {
477 ADD_MESSAGE("No runtime info from device");
478 return NO_INIT;
479 }
480
481 // compatiblity check.
482 // TODO(b/37321309) outer if checks can be removed if we consider missing matrices as errors.
483 if (updated.dev.manifest && updated.fwk.matrix) {
484 if (!updated.dev.manifest->checkCompatibility(*updated.fwk.matrix, error)) {
Yifan Hong0d4be122017-05-15 17:04:22 -0700485 if (error)
486 error->insert(0, "Device manifest and framework compatibility matrix "
487 "are incompatible: ");
Yifan Hong143cfe62017-04-13 20:18:01 -0700488 return INCOMPATIBLE;
489 }
490 }
491 if (updated.fwk.manifest && updated.dev.matrix) {
492 if (!updated.fwk.manifest->checkCompatibility(*updated.dev.matrix, error)) {
Yifan Hong0d4be122017-05-15 17:04:22 -0700493 if (error)
494 error->insert(0, "Framework manifest and device compatibility matrix "
495 "are incompatible: ");
Yifan Hong143cfe62017-04-13 20:18:01 -0700496 return INCOMPATIBLE;
497 }
498 }
499 if (updated.runtimeInfo && updated.fwk.matrix) {
Yifan Hongdb6423e2017-09-11 14:38:46 -0700500 if (!updated.runtimeInfo->checkCompatibility(*updated.fwk.matrix, error, disabledChecks)) {
Yifan Hong0d4be122017-05-15 17:04:22 -0700501 if (error)
502 error->insert(0, "Runtime info and framework compatibility matrix "
503 "are incompatible: ");
Yifan Honge8b86842017-05-25 17:59:22 +0000504 return INCOMPATIBLE;
Yifan Hong143cfe62017-04-13 20:18:01 -0700505 }
506 }
507
508 return COMPATIBLE;
509}
510
511} // namespace details
512
Yifan Hongfbbf0472017-04-07 18:14:18 -0700513// static
Yifan Hongdb6423e2017-09-11 14:38:46 -0700514int32_t VintfObject::CheckCompatibility(const std::vector<std::string>& xmls, std::string* error,
515 DisabledChecks disabledChecks) {
516 return details::checkCompatibility(xmls, false /* mount */, *details::gPartitionMounter, error,
517 disabledChecks);
Yifan Hongfbbf0472017-04-07 18:14:18 -0700518}
519
Yifan Hong3daec812017-02-27 18:49:11 -0800520
521} // namespace vintf
522} // namespace android