Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 1 | /* |
| 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 Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 19 | #include "CompatibilityMatrix.h" |
| 20 | #include "parse_xml.h" |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 21 | #include "utils.h" |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 22 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 23 | #include <functional> |
| 24 | #include <memory> |
| 25 | #include <mutex> |
| 26 | |
Bowgo Tsai | 39adc14 | 2017-11-03 12:46:26 +0800 | [diff] [blame] | 27 | #ifdef LIBVINTF_TARGET |
| 28 | #include <android-base/properties.h> |
| 29 | #endif |
| 30 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 31 | namespace android { |
| 32 | namespace vintf { |
| 33 | |
| 34 | template <typename T> |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 35 | struct LockedSharedPtr { |
| 36 | std::shared_ptr<T> object; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 37 | std::mutex mutex; |
Yifan Hong | 7219ba1 | 2018-01-08 16:23:49 -0800 | [diff] [blame^] | 38 | bool fetchedOnce = false; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 39 | }; |
| 40 | |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 41 | struct LockedRuntimeInfoCache { |
| 42 | std::shared_ptr<RuntimeInfo> object; |
| 43 | std::mutex mutex; |
| 44 | RuntimeInfo::FetchFlags fetchedFlags = RuntimeInfo::FetchFlag::NONE; |
| 45 | }; |
| 46 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 47 | template <typename T, typename F> |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 48 | static std::shared_ptr<const T> Get( |
| 49 | LockedSharedPtr<T> *ptr, |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 50 | bool skipCache, |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 51 | const F &fetchAllInformation) { |
| 52 | std::unique_lock<std::mutex> _lock(ptr->mutex); |
Yifan Hong | 7219ba1 | 2018-01-08 16:23:49 -0800 | [diff] [blame^] | 53 | if (skipCache || !ptr->fetchedOnce) { |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 54 | ptr->object = std::make_unique<T>(); |
| 55 | if (fetchAllInformation(ptr->object.get()) != OK) { |
| 56 | ptr->object = nullptr; // frees the old object |
| 57 | } |
Yifan Hong | 7219ba1 | 2018-01-08 16:23:49 -0800 | [diff] [blame^] | 58 | ptr->fetchedOnce = true; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 59 | } |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 60 | return ptr->object; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | // static |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 64 | std::shared_ptr<const HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) { |
Steven Moreland | 648a001 | 2017-10-19 21:23:41 -0700 | [diff] [blame] | 65 | static LockedSharedPtr<HalManifest> gVendorManifest; |
| 66 | static LockedSharedPtr<HalManifest> gOdmManifest; |
Bowgo Tsai | 39adc14 | 2017-11-03 12:46:26 +0800 | [diff] [blame] | 67 | #ifdef LIBVINTF_TARGET |
| 68 | static LockedSharedPtr<HalManifest> gProductManifest; |
| 69 | #endif |
Steven Moreland | 648a001 | 2017-10-19 21:23:41 -0700 | [diff] [blame] | 70 | static std::mutex gDeviceManifestMutex; |
| 71 | |
| 72 | std::unique_lock<std::mutex> _lock(gDeviceManifestMutex); |
| 73 | |
Bowgo Tsai | 39adc14 | 2017-11-03 12:46:26 +0800 | [diff] [blame] | 74 | #ifdef LIBVINTF_TARGET |
| 75 | std::string productModel = android::base::GetProperty("ro.product.model", ""); |
| 76 | if (!productModel.empty()) { |
| 77 | auto product = Get(&gProductManifest, skipCache, |
| 78 | std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, |
| 79 | "/odm/manifest_" + productModel + ".xml")); |
| 80 | if (product != nullptr) { |
| 81 | return product; |
| 82 | } |
| 83 | } |
| 84 | #endif |
| 85 | |
Steven Moreland | 648a001 | 2017-10-19 21:23:41 -0700 | [diff] [blame] | 86 | auto odm = Get( |
| 87 | &gOdmManifest, skipCache, |
| 88 | std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, "/odm/manifest.xml")); |
| 89 | if (odm != nullptr) { |
| 90 | return odm; |
| 91 | } |
| 92 | |
| 93 | return Get(&gVendorManifest, skipCache, |
| 94 | std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, |
| 95 | "/vendor/manifest.xml")); |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | // static |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 99 | std::shared_ptr<const HalManifest> VintfObject::GetFrameworkHalManifest(bool skipCache) { |
| 100 | static LockedSharedPtr<HalManifest> gFrameworkManifest; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 101 | return Get(&gFrameworkManifest, skipCache, |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 102 | std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, |
| 103 | "/system/manifest.xml")); |
| 104 | } |
| 105 | |
Yifan Hong | 2272bf8 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 106 | |
| 107 | // static |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 108 | std::shared_ptr<const CompatibilityMatrix> VintfObject::GetDeviceCompatibilityMatrix(bool skipCache) { |
| 109 | static LockedSharedPtr<CompatibilityMatrix> gDeviceMatrix; |
Yifan Hong | 2272bf8 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 110 | return Get(&gDeviceMatrix, skipCache, |
| 111 | std::bind(&CompatibilityMatrix::fetchAllInformation, std::placeholders::_1, |
| 112 | "/vendor/compatibility_matrix.xml")); |
| 113 | } |
| 114 | |
| 115 | // static |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 116 | std::shared_ptr<const CompatibilityMatrix> VintfObject::GetFrameworkCompatibilityMatrix(bool skipCache) { |
| 117 | static LockedSharedPtr<CompatibilityMatrix> gFrameworkMatrix; |
Yifan Hong | 2272bf8 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 118 | return Get(&gFrameworkMatrix, skipCache, |
| 119 | std::bind(&CompatibilityMatrix::fetchAllInformation, std::placeholders::_1, |
| 120 | "/system/compatibility_matrix.xml")); |
| 121 | } |
| 122 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 123 | // static |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 124 | std::shared_ptr<const RuntimeInfo> VintfObject::GetRuntimeInfo(bool skipCache, |
| 125 | RuntimeInfo::FetchFlags flags) { |
| 126 | static LockedRuntimeInfoCache gDeviceRuntimeInfo; |
| 127 | std::unique_lock<std::mutex> _lock(gDeviceRuntimeInfo.mutex); |
| 128 | |
| 129 | if (!skipCache) { |
| 130 | flags &= (~gDeviceRuntimeInfo.fetchedFlags); |
| 131 | } |
| 132 | |
| 133 | if (gDeviceRuntimeInfo.object == nullptr) { |
Yifan Hong | 29bb2d4 | 2017-09-27 13:28:00 -0700 | [diff] [blame] | 134 | gDeviceRuntimeInfo.object = details::gRuntimeInfoFactory->make_shared(); |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | status_t status = gDeviceRuntimeInfo.object->fetchAllInformation(flags); |
| 138 | if (status != OK) { |
| 139 | gDeviceRuntimeInfo.fetchedFlags &= (~flags); // mark the fields as "not fetched" |
| 140 | return nullptr; |
| 141 | } |
| 142 | |
| 143 | gDeviceRuntimeInfo.fetchedFlags |= flags; |
| 144 | return gDeviceRuntimeInfo.object; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 145 | } |
| 146 | |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 147 | namespace details { |
| 148 | |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 149 | enum class ParseStatus { |
| 150 | OK, |
| 151 | PARSE_ERROR, |
| 152 | DUPLICATED_FWK_ENTRY, |
| 153 | DUPLICATED_DEV_ENTRY, |
| 154 | }; |
| 155 | |
Yifan Hong | 9532bd2 | 2017-04-14 15:30:52 -0700 | [diff] [blame] | 156 | static std::string toString(ParseStatus status) { |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 157 | switch(status) { |
| 158 | case ParseStatus::OK: return "OK"; |
| 159 | case ParseStatus::PARSE_ERROR: return "parse error"; |
| 160 | case ParseStatus::DUPLICATED_FWK_ENTRY: return "duplicated framework"; |
| 161 | case ParseStatus::DUPLICATED_DEV_ENTRY: return "duplicated device"; |
| 162 | } |
| 163 | return ""; |
| 164 | } |
| 165 | |
| 166 | template<typename T> |
Yifan Hong | 9532bd2 | 2017-04-14 15:30:52 -0700 | [diff] [blame] | 167 | static ParseStatus tryParse(const std::string &xml, const XmlConverter<T> &parse, |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 168 | std::shared_ptr<T> *fwk, std::shared_ptr<T> *dev) { |
| 169 | std::shared_ptr<T> ret = std::make_shared<T>(); |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 170 | if (!parse(ret.get(), xml)) { |
| 171 | return ParseStatus::PARSE_ERROR; |
| 172 | } |
| 173 | if (ret->type() == SchemaType::FRAMEWORK) { |
| 174 | if (fwk->get() != nullptr) { |
| 175 | return ParseStatus::DUPLICATED_FWK_ENTRY; |
| 176 | } |
| 177 | *fwk = std::move(ret); |
| 178 | } else if (ret->type() == SchemaType::DEVICE) { |
| 179 | if (dev->get() != nullptr) { |
| 180 | return ParseStatus::DUPLICATED_DEV_ENTRY; |
| 181 | } |
| 182 | *dev = std::move(ret); |
| 183 | } |
| 184 | return ParseStatus::OK; |
| 185 | } |
| 186 | |
| 187 | template<typename T, typename GetFunction> |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 188 | static status_t getMissing(const std::shared_ptr<T>& pkg, bool mount, |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 189 | std::function<status_t(void)> mountFunction, |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 190 | std::shared_ptr<const T>* updated, |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 191 | GetFunction getFunction) { |
| 192 | if (pkg != nullptr) { |
| 193 | *updated = pkg; |
| 194 | } else { |
| 195 | if (mount) { |
| 196 | (void)mountFunction(); // ignore mount errors |
| 197 | } |
| 198 | *updated = getFunction(); |
| 199 | } |
| 200 | return OK; |
| 201 | } |
| 202 | |
| 203 | #define ADD_MESSAGE(__error__) \ |
| 204 | if (error != nullptr) { \ |
| 205 | *error += (__error__); \ |
| 206 | } \ |
| 207 | |
| 208 | struct PackageInfo { |
| 209 | struct Pair { |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 210 | std::shared_ptr<HalManifest> manifest; |
| 211 | std::shared_ptr<CompatibilityMatrix> matrix; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 212 | }; |
| 213 | Pair dev; |
| 214 | Pair fwk; |
| 215 | }; |
| 216 | |
| 217 | struct UpdatedInfo { |
| 218 | struct Pair { |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 219 | std::shared_ptr<const HalManifest> manifest; |
| 220 | std::shared_ptr<const CompatibilityMatrix> matrix; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 221 | }; |
| 222 | Pair dev; |
| 223 | Pair fwk; |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 224 | std::shared_ptr<const RuntimeInfo> runtimeInfo; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 225 | }; |
| 226 | |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 227 | // Checks given compatibility info against info on the device. If no |
| 228 | // compatability info is given then the device info will be checked against |
| 229 | // itself. |
Yifan Hong | db6423e | 2017-09-11 14:38:46 -0700 | [diff] [blame] | 230 | int32_t checkCompatibility(const std::vector<std::string>& xmls, bool mount, |
| 231 | const PartitionMounter& mounter, std::string* error, |
| 232 | DisabledChecks disabledChecks) { |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 233 | status_t status; |
| 234 | ParseStatus parseStatus; |
| 235 | PackageInfo pkg; // All information from package. |
| 236 | UpdatedInfo updated; // All files and runtime info after the update. |
| 237 | |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 238 | // parse all information from package |
| 239 | for (const auto &xml : xmls) { |
| 240 | parseStatus = tryParse(xml, gHalManifestConverter, &pkg.fwk.manifest, &pkg.dev.manifest); |
| 241 | if (parseStatus == ParseStatus::OK) { |
| 242 | continue; // work on next one |
| 243 | } |
| 244 | if (parseStatus != ParseStatus::PARSE_ERROR) { |
| 245 | ADD_MESSAGE(toString(parseStatus) + " manifest"); |
| 246 | return ALREADY_EXISTS; |
| 247 | } |
| 248 | parseStatus = tryParse(xml, gCompatibilityMatrixConverter, &pkg.fwk.matrix, &pkg.dev.matrix); |
| 249 | if (parseStatus == ParseStatus::OK) { |
| 250 | continue; // work on next one |
| 251 | } |
| 252 | if (parseStatus != ParseStatus::PARSE_ERROR) { |
| 253 | ADD_MESSAGE(toString(parseStatus) + " matrix"); |
| 254 | return ALREADY_EXISTS; |
| 255 | } |
| 256 | ADD_MESSAGE(toString(parseStatus)); // parse error |
| 257 | return BAD_VALUE; |
| 258 | } |
| 259 | |
| 260 | // get missing info from device |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 261 | // use functions instead of std::bind because std::bind doesn't work well with mock objects |
| 262 | auto mountSystem = [&mounter] { return mounter.mountSystem(); }; |
| 263 | auto mountVendor = [&mounter] { return mounter.mountVendor(); }; |
| 264 | if ((status = getMissing( |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 265 | pkg.fwk.manifest, mount, mountSystem, &updated.fwk.manifest, |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 266 | std::bind(VintfObject::GetFrameworkHalManifest, true /* skipCache */))) != OK) { |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 267 | return status; |
| 268 | } |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 269 | if ((status = getMissing( |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 270 | pkg.dev.manifest, mount, mountVendor, &updated.dev.manifest, |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 271 | std::bind(VintfObject::GetDeviceHalManifest, true /* skipCache */))) != OK) { |
| 272 | return status; |
| 273 | } |
| 274 | if ((status = getMissing( |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 275 | pkg.fwk.matrix, mount, mountSystem, &updated.fwk.matrix, |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 276 | std::bind(VintfObject::GetFrameworkCompatibilityMatrix, true /* skipCache */))) != |
| 277 | OK) { |
| 278 | return status; |
| 279 | } |
| 280 | if ((status = getMissing( |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 281 | pkg.dev.matrix, mount, mountVendor, &updated.dev.matrix, |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 282 | std::bind(VintfObject::GetDeviceCompatibilityMatrix, true /* skipCache */))) != OK) { |
| 283 | return status; |
| 284 | } |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 285 | |
| 286 | if (mount) { |
| 287 | (void)mounter.umountSystem(); // ignore errors |
| 288 | (void)mounter.umountVendor(); // ignore errors |
| 289 | } |
| 290 | |
| 291 | updated.runtimeInfo = VintfObject::GetRuntimeInfo(true /* skipCache */); |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 292 | |
| 293 | // null checks for files and runtime info after the update |
| 294 | // TODO(b/37321309) if a compat mat is missing, it is not matched and considered compatible. |
| 295 | if (updated.fwk.manifest == nullptr) { |
| 296 | ADD_MESSAGE("No framework manifest file from device or from update package"); |
| 297 | return NO_INIT; |
| 298 | } |
| 299 | if (updated.dev.manifest == nullptr) { |
| 300 | ADD_MESSAGE("No device manifest file from device or from update package"); |
| 301 | return NO_INIT; |
| 302 | } |
| 303 | if (updated.fwk.matrix == nullptr) { |
| 304 | ADD_MESSAGE("No framework matrix, skipping;"); |
| 305 | // TODO(b/37321309) consider missing matricies as errors. |
| 306 | } |
| 307 | if (updated.dev.matrix == nullptr) { |
| 308 | ADD_MESSAGE("No device matrix, skipping;"); |
| 309 | // TODO(b/37321309) consider missing matricies as errors. |
| 310 | } |
| 311 | if (updated.runtimeInfo == nullptr) { |
| 312 | ADD_MESSAGE("No runtime info from device"); |
| 313 | return NO_INIT; |
| 314 | } |
| 315 | |
| 316 | // compatiblity check. |
| 317 | // TODO(b/37321309) outer if checks can be removed if we consider missing matrices as errors. |
| 318 | if (updated.dev.manifest && updated.fwk.matrix) { |
| 319 | if (!updated.dev.manifest->checkCompatibility(*updated.fwk.matrix, error)) { |
Yifan Hong | 0d4be12 | 2017-05-15 17:04:22 -0700 | [diff] [blame] | 320 | if (error) |
| 321 | error->insert(0, "Device manifest and framework compatibility matrix " |
| 322 | "are incompatible: "); |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 323 | return INCOMPATIBLE; |
| 324 | } |
| 325 | } |
| 326 | if (updated.fwk.manifest && updated.dev.matrix) { |
| 327 | if (!updated.fwk.manifest->checkCompatibility(*updated.dev.matrix, error)) { |
Yifan Hong | 0d4be12 | 2017-05-15 17:04:22 -0700 | [diff] [blame] | 328 | if (error) |
| 329 | error->insert(0, "Framework manifest and device compatibility matrix " |
| 330 | "are incompatible: "); |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 331 | return INCOMPATIBLE; |
| 332 | } |
| 333 | } |
| 334 | if (updated.runtimeInfo && updated.fwk.matrix) { |
Yifan Hong | db6423e | 2017-09-11 14:38:46 -0700 | [diff] [blame] | 335 | if (!updated.runtimeInfo->checkCompatibility(*updated.fwk.matrix, error, disabledChecks)) { |
Yifan Hong | 0d4be12 | 2017-05-15 17:04:22 -0700 | [diff] [blame] | 336 | if (error) |
| 337 | error->insert(0, "Runtime info and framework compatibility matrix " |
| 338 | "are incompatible: "); |
Yifan Hong | e8b8684 | 2017-05-25 17:59:22 +0000 | [diff] [blame] | 339 | return INCOMPATIBLE; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | |
| 343 | return COMPATIBLE; |
| 344 | } |
| 345 | |
| 346 | } // namespace details |
| 347 | |
Yifan Hong | fbbf047 | 2017-04-07 18:14:18 -0700 | [diff] [blame] | 348 | // static |
Yifan Hong | db6423e | 2017-09-11 14:38:46 -0700 | [diff] [blame] | 349 | int32_t VintfObject::CheckCompatibility(const std::vector<std::string>& xmls, std::string* error, |
| 350 | DisabledChecks disabledChecks) { |
| 351 | return details::checkCompatibility(xmls, false /* mount */, *details::gPartitionMounter, error, |
| 352 | disabledChecks); |
Yifan Hong | fbbf047 | 2017-04-07 18:14:18 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 355 | |
| 356 | } // namespace vintf |
| 357 | } // namespace android |