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 | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 19 | #include <dirent.h> |
| 20 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 21 | #include <functional> |
| 22 | #include <memory> |
| 23 | #include <mutex> |
| 24 | |
Yifan Hong | 6021703 | 2018-01-08 16:19:42 -0800 | [diff] [blame] | 25 | #include <android-base/logging.h> |
Yifan Hong | b02d87d | 2019-12-19 11:15:27 -0800 | [diff] [blame] | 26 | #include <android-base/strings.h> |
Yifan Hong | 6021703 | 2018-01-08 16:19:42 -0800 | [diff] [blame] | 27 | |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 28 | #include "CompatibilityMatrix.h" |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 29 | #include "parse_string.h" |
| 30 | #include "parse_xml.h" |
| 31 | #include "utils.h" |
| 32 | |
Yifan Hong | 6021703 | 2018-01-08 16:19:42 -0800 | [diff] [blame] | 33 | using std::placeholders::_1; |
| 34 | using std::placeholders::_2; |
| 35 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 36 | namespace android { |
| 37 | namespace vintf { |
| 38 | |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 39 | using namespace details; |
| 40 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 41 | #ifdef LIBVINTF_TARGET |
| 42 | static constexpr bool kIsTarget = true; |
| 43 | #else |
| 44 | static constexpr bool kIsTarget = false; |
| 45 | #endif |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 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>(); |
Yifan Hong | 6021703 | 2018-01-08 16:19:42 -0800 | [diff] [blame] | 55 | std::string error; |
| 56 | if (fetchAllInformation(ptr->object.get(), &error) != OK) { |
| 57 | LOG(WARNING) << error; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 58 | ptr->object = nullptr; // frees the old object |
| 59 | } |
Yifan Hong | 7219ba1 | 2018-01-08 16:23:49 -0800 | [diff] [blame] | 60 | ptr->fetchedOnce = true; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 61 | } |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 62 | return ptr->object; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 63 | } |
| 64 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 65 | static std::unique_ptr<FileSystem> createDefaultFileSystem() { |
| 66 | std::unique_ptr<FileSystem> fileSystem; |
| 67 | if (kIsTarget) { |
| 68 | fileSystem = std::make_unique<details::FileSystemImpl>(); |
| 69 | } else { |
| 70 | fileSystem = std::make_unique<details::FileSystemNoOp>(); |
| 71 | } |
| 72 | return fileSystem; |
| 73 | } |
| 74 | |
| 75 | static std::unique_ptr<PropertyFetcher> createDefaultPropertyFetcher() { |
| 76 | std::unique_ptr<PropertyFetcher> propertyFetcher; |
| 77 | if (kIsTarget) { |
| 78 | propertyFetcher = std::make_unique<details::PropertyFetcherImpl>(); |
| 79 | } else { |
| 80 | propertyFetcher = std::make_unique<details::PropertyFetcherNoOp>(); |
| 81 | } |
| 82 | return propertyFetcher; |
| 83 | } |
| 84 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 85 | std::shared_ptr<VintfObject> VintfObject::GetInstance() { |
Steven Moreland | c16ff2b | 2020-02-26 17:03:37 -0800 | [diff] [blame] | 86 | static details::LockedSharedPtr<VintfObject> sInstance{}; |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 87 | std::unique_lock<std::mutex> lock(sInstance.mutex); |
| 88 | if (sInstance.object == nullptr) { |
Yifan Hong | 78f5b57 | 2018-11-27 14:05:03 -0800 | [diff] [blame] | 89 | sInstance.object = std::shared_ptr<VintfObject>(VintfObject::Builder().build().release()); |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 90 | } |
| 91 | return sInstance.object; |
| 92 | } |
| 93 | |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 94 | std::shared_ptr<const HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 95 | return GetInstance()->getDeviceHalManifest(skipCache); |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 96 | } |
| 97 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 98 | std::shared_ptr<const HalManifest> VintfObject::getDeviceHalManifest(bool skipCache) { |
| 99 | return Get(&mDeviceManifest, skipCache, |
| 100 | std::bind(&VintfObject::fetchDeviceHalManifest, this, _1, _2)); |
| 101 | } |
| 102 | |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 103 | std::shared_ptr<const HalManifest> VintfObject::GetFrameworkHalManifest(bool skipCache) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 104 | return GetInstance()->getFrameworkHalManifest(skipCache); |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 105 | } |
| 106 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 107 | std::shared_ptr<const HalManifest> VintfObject::getFrameworkHalManifest(bool skipCache) { |
| 108 | return Get(&mFrameworkManifest, skipCache, |
| 109 | std::bind(&VintfObject::fetchFrameworkHalManifest, this, _1, _2)); |
| 110 | } |
Yifan Hong | 2272bf8 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 111 | |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 112 | std::shared_ptr<const CompatibilityMatrix> VintfObject::GetDeviceCompatibilityMatrix(bool skipCache) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 113 | return GetInstance()->getDeviceCompatibilityMatrix(skipCache); |
Yifan Hong | 2272bf8 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 116 | std::shared_ptr<const CompatibilityMatrix> VintfObject::getDeviceCompatibilityMatrix( |
| 117 | bool skipCache) { |
| 118 | return Get(&mDeviceMatrix, skipCache, std::bind(&VintfObject::fetchDeviceMatrix, this, _1, _2)); |
| 119 | } |
| 120 | |
Yifan Hong | fc73edf | 2017-08-29 11:39:07 -0700 | [diff] [blame] | 121 | std::shared_ptr<const CompatibilityMatrix> VintfObject::GetFrameworkCompatibilityMatrix(bool skipCache) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 122 | return GetInstance()->getFrameworkCompatibilityMatrix(skipCache); |
| 123 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 124 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 125 | std::shared_ptr<const CompatibilityMatrix> VintfObject::getFrameworkCompatibilityMatrix( |
| 126 | bool skipCache) { |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 127 | // To avoid deadlock, get device manifest before any locks. |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 128 | auto deviceManifest = getDeviceHalManifest(); |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 129 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 130 | std::unique_lock<std::mutex> _lock(mFrameworkCompatibilityMatrixMutex); |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 131 | |
| 132 | auto combined = |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 133 | Get(&mCombinedFrameworkMatrix, skipCache, |
| 134 | std::bind(&VintfObject::getCombinedFrameworkMatrix, this, deviceManifest, _1, _2)); |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 135 | if (combined != nullptr) { |
| 136 | return combined; |
| 137 | } |
| 138 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 139 | return Get(&mFrameworkMatrix, skipCache, |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 140 | std::bind(&CompatibilityMatrix::fetchAllInformation, _1, getFileSystem().get(), |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 141 | kSystemLegacyMatrix, _2)); |
Yifan Hong | 2272bf8 | 2017-04-28 14:37:56 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 144 | status_t VintfObject::getCombinedFrameworkMatrix( |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 145 | const std::shared_ptr<const HalManifest>& deviceManifest, CompatibilityMatrix* out, |
| 146 | std::string* error) { |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 147 | std::vector<Named<CompatibilityMatrix>> matrixFragments; |
| 148 | auto matrixFragmentsStatus = getAllFrameworkMatrixLevels(&matrixFragments, error); |
| 149 | if (matrixFragmentsStatus != OK) { |
| 150 | return matrixFragmentsStatus; |
| 151 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 152 | if (matrixFragments.empty()) { |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 153 | if (error && error->empty()) { |
| 154 | *error = "Cannot get framework matrix for each FCM version for unknown error."; |
| 155 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 156 | return NAME_NOT_FOUND; |
| 157 | } |
| 158 | |
| 159 | Level deviceLevel = Level::UNSPECIFIED; |
| 160 | |
| 161 | if (deviceManifest != nullptr) { |
| 162 | deviceLevel = deviceManifest->level(); |
| 163 | } |
| 164 | |
| 165 | // TODO(b/70628538): Do not infer from Shipping API level. |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 166 | if (deviceLevel == Level::UNSPECIFIED) { |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 167 | auto shippingApi = getPropertyFetcher()->getUintProperty("ro.product.first_api_level", 0u); |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 168 | if (shippingApi != 0u) { |
| 169 | deviceLevel = details::convertFromApiLevel(shippingApi); |
| 170 | } |
| 171 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 172 | |
| 173 | if (deviceLevel == Level::UNSPECIFIED) { |
| 174 | // Cannot infer FCM version. Combine all matrices by assuming |
| 175 | // Shipping FCM Version == min(all supported FCM Versions in the framework) |
| 176 | for (auto&& pair : matrixFragments) { |
| 177 | Level fragmentLevel = pair.object.level(); |
| 178 | if (fragmentLevel != Level::UNSPECIFIED && deviceLevel > fragmentLevel) { |
| 179 | deviceLevel = fragmentLevel; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | if (deviceLevel == Level::UNSPECIFIED) { |
| 185 | // None of the fragments specify any FCM version. Should never happen except |
| 186 | // for inconsistent builds. |
| 187 | if (error) { |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 188 | *error = "No framework compatibility matrix files under " + kSystemVintfDir + |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 189 | " declare FCM version."; |
| 190 | } |
| 191 | return NAME_NOT_FOUND; |
| 192 | } |
| 193 | |
Yifan Hong | e7837b1 | 2018-10-11 10:38:57 -0700 | [diff] [blame] | 194 | auto combined = CompatibilityMatrix::combine(deviceLevel, &matrixFragments, error); |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 195 | if (combined == nullptr) { |
| 196 | return BAD_VALUE; |
| 197 | } |
| 198 | *out = std::move(*combined); |
| 199 | return OK; |
| 200 | } |
| 201 | |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 202 | // Load and combine all of the manifests in a directory |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 203 | status_t VintfObject::addDirectoryManifests(const std::string& directory, HalManifest* manifest, |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 204 | std::string* error) { |
| 205 | std::vector<std::string> fileNames; |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 206 | status_t err = getFileSystem()->listFiles(directory, &fileNames, error); |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 207 | // if the directory isn't there, that's okay |
| 208 | if (err == NAME_NOT_FOUND) return OK; |
| 209 | if (err != OK) return err; |
| 210 | |
| 211 | for (const std::string& file : fileNames) { |
| 212 | // Only adds HALs because all other things are added by libvintf |
| 213 | // itself for now. |
| 214 | HalManifest fragmentManifest; |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 215 | err = fetchOneHalManifest(directory + file, &fragmentManifest, error); |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 216 | if (err != OK) return err; |
| 217 | |
Yifan Hong | 4c6962d | 2019-01-30 15:50:46 -0800 | [diff] [blame] | 218 | if (!manifest->addAll(&fragmentManifest, error)) { |
| 219 | if (error) { |
| 220 | error->insert(0, "Cannot add manifest fragment " + directory + file + ":"); |
| 221 | } |
| 222 | return UNKNOWN_ERROR; |
| 223 | } |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | return OK; |
| 227 | } |
| 228 | |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 229 | // Priority for loading vendor manifest: |
Roopesh Nataraja | d629d38 | 2020-02-26 09:51:38 -0800 | [diff] [blame] | 230 | // 1. Vendor manifest + device fragments + ODM manifest (optional) + odm fragments |
| 231 | // 2. Vendor manifest + device fragments |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 232 | // 3. ODM manifest (optional) + odm fragments |
| 233 | // 4. /vendor/manifest.xml (legacy, no fragments) |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 234 | // where: |
Steven Moreland | 30a532c | 2018-11-01 08:46:32 -0700 | [diff] [blame] | 235 | // A + B means unioning <hal> tags from A and B. If B declares an override, then this takes priority |
| 236 | // over A. |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 237 | status_t VintfObject::fetchDeviceHalManifest(HalManifest* out, std::string* error) { |
Roopesh Nataraja | d629d38 | 2020-02-26 09:51:38 -0800 | [diff] [blame] | 238 | HalManifest vendorManifest; |
| 239 | status_t vendorStatus = fetchVendorHalManifest(&vendorManifest, error); |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 240 | if (vendorStatus != OK && vendorStatus != NAME_NOT_FOUND) { |
| 241 | return vendorStatus; |
| 242 | } |
| 243 | |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 244 | if (vendorStatus == OK) { |
Roopesh Nataraja | d629d38 | 2020-02-26 09:51:38 -0800 | [diff] [blame] | 245 | *out = std::move(vendorManifest); |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 246 | status_t fragmentStatus = addDirectoryManifests(kVendorManifestFragmentDir, out, error); |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 247 | if (fragmentStatus != OK) { |
| 248 | return fragmentStatus; |
| 249 | } |
| 250 | } |
| 251 | |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 252 | HalManifest odmManifest; |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 253 | status_t odmStatus = fetchOdmHalManifest(&odmManifest, error); |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 254 | if (odmStatus != OK && odmStatus != NAME_NOT_FOUND) { |
| 255 | return odmStatus; |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 256 | } |
| 257 | |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 258 | if (vendorStatus == OK) { |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 259 | if (odmStatus == OK) { |
Yifan Hong | 4c6962d | 2019-01-30 15:50:46 -0800 | [diff] [blame] | 260 | if (!out->addAll(&odmManifest, error)) { |
| 261 | if (error) { |
| 262 | error->insert(0, "Cannot add ODM manifest :"); |
| 263 | } |
| 264 | return UNKNOWN_ERROR; |
| 265 | } |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 266 | } |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 267 | return addDirectoryManifests(kOdmManifestFragmentDir, out, error); |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 270 | // vendorStatus != OK, "out" is not changed. |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 271 | if (odmStatus == OK) { |
| 272 | *out = std::move(odmManifest); |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 273 | return addDirectoryManifests(kOdmManifestFragmentDir, out, error); |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | // Use legacy /vendor/manifest.xml |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 277 | return out->fetchAllInformation(getFileSystem().get(), kVendorLegacyManifest, error); |
Yifan Hong | 5a93bf2 | 2018-01-17 18:22:32 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Roopesh Nataraja | d629d38 | 2020-02-26 09:51:38 -0800 | [diff] [blame] | 280 | // Priority: |
| 281 | // 1. if {vendorSku} is defined, /vendor/etc/vintf/manifest_{vendorSku}.xml |
| 282 | // 2. /vendor/etc/vintf/manifest.xml |
| 283 | // where: |
| 284 | // {vendorSku} is the value of ro.boot.product.vendor.sku |
| 285 | status_t VintfObject::fetchVendorHalManifest(HalManifest* out, std::string* error) { |
| 286 | status_t status; |
| 287 | |
| 288 | std::string vendorSku; |
| 289 | vendorSku = getPropertyFetcher()->getProperty("ro.boot.product.vendor.sku", ""); |
| 290 | |
| 291 | if (!vendorSku.empty()) { |
| 292 | status = |
| 293 | fetchOneHalManifest(kVendorVintfDir + "manifest_" + vendorSku + ".xml", out, error); |
| 294 | if (status == OK || status != NAME_NOT_FOUND) { |
| 295 | return status; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | status = fetchOneHalManifest(kVendorManifest, out, error); |
| 300 | if (status == OK || status != NAME_NOT_FOUND) { |
| 301 | return status; |
| 302 | } |
| 303 | |
| 304 | return NAME_NOT_FOUND; |
| 305 | } |
| 306 | |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 307 | // "out" is written to iff return status is OK. |
| 308 | // Priority: |
| 309 | // 1. if {sku} is defined, /odm/etc/vintf/manifest_{sku}.xml |
| 310 | // 2. /odm/etc/vintf/manifest.xml |
| 311 | // 3. if {sku} is defined, /odm/etc/manifest_{sku}.xml |
| 312 | // 4. /odm/etc/manifest.xml |
| 313 | // where: |
| 314 | // {sku} is the value of ro.boot.product.hardware.sku |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 315 | status_t VintfObject::fetchOdmHalManifest(HalManifest* out, std::string* error) { |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 316 | status_t status; |
| 317 | |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 318 | std::string productModel; |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 319 | productModel = getPropertyFetcher()->getProperty("ro.boot.product.hardware.sku", ""); |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 320 | |
| 321 | if (!productModel.empty()) { |
| 322 | status = |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 323 | fetchOneHalManifest(kOdmVintfDir + "manifest_" + productModel + ".xml", out, error); |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 324 | if (status == OK || status != NAME_NOT_FOUND) { |
| 325 | return status; |
| 326 | } |
| 327 | } |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 328 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 329 | status = fetchOneHalManifest(kOdmManifest, out, error); |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 330 | if (status == OK || status != NAME_NOT_FOUND) { |
| 331 | return status; |
| 332 | } |
| 333 | |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 334 | if (!productModel.empty()) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 335 | status = fetchOneHalManifest(kOdmLegacyVintfDir + "manifest_" + productModel + ".xml", out, |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 336 | error); |
| 337 | if (status == OK || status != NAME_NOT_FOUND) { |
| 338 | return status; |
| 339 | } |
| 340 | } |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 341 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 342 | status = fetchOneHalManifest(kOdmLegacyManifest, out, error); |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 343 | if (status == OK || status != NAME_NOT_FOUND) { |
| 344 | return status; |
| 345 | } |
| 346 | |
| 347 | return NAME_NOT_FOUND; |
| 348 | } |
| 349 | |
| 350 | // Fetch one manifest.xml file. "out" is written to iff return status is OK. |
| 351 | // Returns NAME_NOT_FOUND if file is missing. |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 352 | status_t VintfObject::fetchOneHalManifest(const std::string& path, HalManifest* out, |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 353 | std::string* error) { |
| 354 | HalManifest ret; |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 355 | status_t status = ret.fetchAllInformation(getFileSystem().get(), path, error); |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 356 | if (status == OK) { |
| 357 | *out = std::move(ret); |
| 358 | } |
| 359 | return status; |
| 360 | } |
| 361 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 362 | status_t VintfObject::fetchDeviceMatrix(CompatibilityMatrix* out, std::string* error) { |
Yifan Hong | b64ec9e | 2018-01-18 18:57:52 -0800 | [diff] [blame] | 363 | CompatibilityMatrix etcMatrix; |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 364 | if (etcMatrix.fetchAllInformation(getFileSystem().get(), kVendorMatrix, error) == OK) { |
Yifan Hong | b64ec9e | 2018-01-18 18:57:52 -0800 | [diff] [blame] | 365 | *out = std::move(etcMatrix); |
| 366 | return OK; |
| 367 | } |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 368 | return out->fetchAllInformation(getFileSystem().get(), kVendorLegacyMatrix, error); |
Yifan Hong | b64ec9e | 2018-01-18 18:57:52 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 371 | // Priority: |
| 372 | // 1. /system/etc/vintf/manifest.xml |
| 373 | // + /system/etc/vintf/manifest/*.xml if they exist |
| 374 | // + /product/etc/vintf/manifest.xml if it exists |
| 375 | // + /product/etc/vintf/manifest/*.xml if they exist |
| 376 | // 2. (deprecated) /system/manifest.xml |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 377 | status_t VintfObject::fetchFrameworkHalManifest(HalManifest* out, std::string* error) { |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 378 | auto systemEtcStatus = fetchOneHalManifest(kSystemManifest, out, error); |
| 379 | if (systemEtcStatus == OK) { |
| 380 | auto dirStatus = addDirectoryManifests(kSystemManifestFragmentDir, out, error); |
| 381 | if (dirStatus != OK) { |
| 382 | return dirStatus; |
| 383 | } |
| 384 | |
Yifan Hong | 659feac | 2020-03-19 18:09:54 -0700 | [diff] [blame^] | 385 | std::vector<std::pair<const std::string&, const std::string&>> extensions{ |
| 386 | {kProductManifest, kProductManifestFragmentDir}, |
| 387 | {kSystemExtManifest, kSystemExtManifestFragmentDir}, |
| 388 | }; |
| 389 | for (auto&& [manifestPath, frags] : extensions) { |
| 390 | HalManifest halManifest; |
| 391 | auto status = fetchOneHalManifest(manifestPath, &halManifest, error); |
| 392 | if (status != OK && status != NAME_NOT_FOUND) { |
| 393 | return status; |
| 394 | } |
| 395 | if (status == OK) { |
| 396 | if (!out->addAll(&halManifest, error)) { |
| 397 | if (error) { |
| 398 | error->insert(0, "Cannot add " + manifestPath + ":"); |
| 399 | } |
| 400 | return UNKNOWN_ERROR; |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 401 | } |
Yifan Hong | 659feac | 2020-03-19 18:09:54 -0700 | [diff] [blame^] | 402 | } |
| 403 | |
| 404 | auto fragmentStatus = addDirectoryManifests(frags, out, error); |
| 405 | if (fragmentStatus != OK) { |
| 406 | return fragmentStatus; |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 407 | } |
| 408 | } |
Yifan Hong | 659feac | 2020-03-19 18:09:54 -0700 | [diff] [blame^] | 409 | return OK; |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 410 | } else { |
| 411 | LOG(WARNING) << "Cannot fetch " << kSystemManifest << ": " |
| 412 | << (error ? *error : strerror(-systemEtcStatus)); |
Yifan Hong | de6d00e | 2018-02-27 17:11:28 -0800 | [diff] [blame] | 413 | } |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 414 | |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 415 | return out->fetchAllInformation(getFileSystem().get(), kSystemLegacyManifest, error); |
Yifan Hong | de6d00e | 2018-02-27 17:11:28 -0800 | [diff] [blame] | 416 | } |
| 417 | |
Yifan Hong | 9f8f656 | 2018-11-06 16:26:20 -0800 | [diff] [blame] | 418 | static void appendLine(std::string* error, const std::string& message) { |
| 419 | if (error != nullptr) { |
| 420 | if (!error->empty()) *error += "\n"; |
| 421 | *error += message; |
| 422 | } |
| 423 | } |
| 424 | |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 425 | status_t VintfObject::getOneMatrix(const std::string& path, Named<CompatibilityMatrix>* out, |
| 426 | std::string* error) { |
| 427 | std::string content; |
| 428 | status_t status = getFileSystem()->fetch(path, &content, error); |
| 429 | if (status != OK) { |
| 430 | return status; |
| 431 | } |
| 432 | if (!gCompatibilityMatrixConverter(&out->object, content, error)) { |
| 433 | if (error) { |
| 434 | error->insert(0, "Cannot parse " + path + ": "); |
| 435 | } |
| 436 | return BAD_VALUE; |
| 437 | } |
| 438 | out->name = path; |
| 439 | return OK; |
| 440 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 441 | |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 442 | status_t VintfObject::getAllFrameworkMatrixLevels(std::vector<Named<CompatibilityMatrix>>* results, |
| 443 | std::string* error) { |
Yifan Hong | b02d87d | 2019-12-19 11:15:27 -0800 | [diff] [blame] | 444 | std::vector<std::string> dirs = { |
| 445 | kSystemVintfDir, |
Yifan Hong | a0968e8 | 2019-12-19 14:08:13 -0800 | [diff] [blame] | 446 | kSystemExtVintfDir, |
Yifan Hong | b02d87d | 2019-12-19 11:15:27 -0800 | [diff] [blame] | 447 | kProductVintfDir, |
| 448 | }; |
| 449 | for (const auto& dir : dirs) { |
| 450 | std::vector<std::string> fileNames; |
| 451 | status_t listStatus = getFileSystem()->listFiles(dir, &fileNames, error); |
| 452 | if (listStatus == NAME_NOT_FOUND) { |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 453 | continue; |
| 454 | } |
Yifan Hong | b02d87d | 2019-12-19 11:15:27 -0800 | [diff] [blame] | 455 | if (listStatus != OK) { |
| 456 | return listStatus; |
| 457 | } |
| 458 | for (const std::string& fileName : fileNames) { |
| 459 | std::string path = dir + fileName; |
| 460 | Named<CompatibilityMatrix> namedMatrix; |
| 461 | std::string matrixError; |
| 462 | status_t matrixStatus = getOneMatrix(path, &namedMatrix, &matrixError); |
| 463 | if (matrixStatus != OK) { |
| 464 | // Manifests and matrices share the same dir. Client may not have enough |
| 465 | // permissions to read system manifests, or may not be able to parse it. |
| 466 | auto logLevel = matrixStatus == BAD_VALUE ? base::DEBUG : base::ERROR; |
| 467 | LOG(logLevel) << "Framework Matrix: Ignore file " << path << ": " << matrixError; |
| 468 | continue; |
| 469 | } |
| 470 | results->emplace_back(std::move(namedMatrix)); |
| 471 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 472 | |
Yifan Hong | b02d87d | 2019-12-19 11:15:27 -0800 | [diff] [blame] | 473 | if (dir == kSystemVintfDir && results->empty()) { |
| 474 | if (error) { |
| 475 | *error = "No framework matrices under " + dir + " can be fetched or parsed.\n"; |
| 476 | } |
| 477 | return NAME_NOT_FOUND; |
| 478 | } |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 479 | } |
| 480 | |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 481 | if (results->empty()) { |
| 482 | if (error) { |
| 483 | *error = |
Yifan Hong | b02d87d | 2019-12-19 11:15:27 -0800 | [diff] [blame] | 484 | "No framework matrices can be fetched or parsed. " |
| 485 | "The following directories are searched:\n " + |
| 486 | android::base::Join(dirs, "\n "); |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 487 | } |
| 488 | return NAME_NOT_FOUND; |
| 489 | } |
| 490 | return OK; |
Yifan Hong | d52bf3e | 2018-01-11 16:56:51 -0800 | [diff] [blame] | 491 | } |
| 492 | |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 493 | std::shared_ptr<const RuntimeInfo> VintfObject::GetRuntimeInfo(bool skipCache, |
| 494 | RuntimeInfo::FetchFlags flags) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 495 | return GetInstance()->getRuntimeInfo(skipCache, flags); |
| 496 | } |
| 497 | std::shared_ptr<const RuntimeInfo> VintfObject::getRuntimeInfo(bool skipCache, |
| 498 | RuntimeInfo::FetchFlags flags) { |
| 499 | std::unique_lock<std::mutex> _lock(mDeviceRuntimeInfo.mutex); |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 500 | |
| 501 | if (!skipCache) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 502 | flags &= (~mDeviceRuntimeInfo.fetchedFlags); |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 505 | if (mDeviceRuntimeInfo.object == nullptr) { |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 506 | mDeviceRuntimeInfo.object = getRuntimeInfoFactory()->make_shared(); |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Yifan Hong | f324798 | 2019-12-12 12:11:36 -0800 | [diff] [blame] | 509 | // Fetch kernel FCM version from device HAL manifest and store it in RuntimeInfo too. |
| 510 | if ((flags & RuntimeInfo::FetchFlag::KERNEL_FCM) != 0) { |
| 511 | auto manifest = getDeviceHalManifest(); |
| 512 | if (!manifest) { |
| 513 | mDeviceRuntimeInfo.fetchedFlags &= ~RuntimeInfo::FetchFlag::KERNEL_FCM; |
| 514 | return nullptr; |
| 515 | } |
| 516 | Level level = Level::UNSPECIFIED; |
| 517 | if (manifest->kernel().has_value()) { |
| 518 | level = manifest->kernel()->level(); |
| 519 | } |
| 520 | mDeviceRuntimeInfo.object->setKernelLevel(level); |
| 521 | flags &= ~RuntimeInfo::FetchFlag::KERNEL_FCM; |
| 522 | } |
| 523 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 524 | status_t status = mDeviceRuntimeInfo.object->fetchAllInformation(flags); |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 525 | if (status != OK) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 526 | mDeviceRuntimeInfo.fetchedFlags &= (~flags); // mark the fields as "not fetched" |
Yifan Hong | 1fb004e | 2017-09-26 15:04:44 -0700 | [diff] [blame] | 527 | return nullptr; |
| 528 | } |
| 529 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 530 | mDeviceRuntimeInfo.fetchedFlags |= flags; |
| 531 | return mDeviceRuntimeInfo.object; |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 532 | } |
| 533 | |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 534 | int32_t VintfObject::checkCompatibility(std::string* error, CheckFlags::Type flags) { |
| 535 | status_t status = OK; |
| 536 | // null checks for files and runtime info |
| 537 | if (getFrameworkHalManifest() == nullptr) { |
Yifan Hong | 878556e | 2018-07-13 13:45:30 -0700 | [diff] [blame] | 538 | appendLine(error, "No framework manifest file from device or from update package"); |
| 539 | status = NO_INIT; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 540 | } |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 541 | if (getDeviceHalManifest() == nullptr) { |
Yifan Hong | 878556e | 2018-07-13 13:45:30 -0700 | [diff] [blame] | 542 | appendLine(error, "No device manifest file from device or from update package"); |
| 543 | status = NO_INIT; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 544 | } |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 545 | if (getFrameworkCompatibilityMatrix() == nullptr) { |
Yifan Hong | 878556e | 2018-07-13 13:45:30 -0700 | [diff] [blame] | 546 | appendLine(error, "No framework matrix file from device or from update package"); |
| 547 | status = NO_INIT; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 548 | } |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 549 | if (getDeviceCompatibilityMatrix() == nullptr) { |
Yifan Hong | 878556e | 2018-07-13 13:45:30 -0700 | [diff] [blame] | 550 | appendLine(error, "No device matrix file from device or from update package"); |
| 551 | status = NO_INIT; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 552 | } |
Yifan Hong | 69c1b11 | 2018-02-27 17:06:00 -0800 | [diff] [blame] | 553 | |
Yifan Hong | 072f12d | 2018-08-08 13:04:51 -0700 | [diff] [blame] | 554 | if (flags.isRuntimeInfoEnabled()) { |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 555 | if (getRuntimeInfo() == nullptr) { |
Yifan Hong | 878556e | 2018-07-13 13:45:30 -0700 | [diff] [blame] | 556 | appendLine(error, "No runtime info from device"); |
| 557 | status = NO_INIT; |
Yifan Hong | 69c1b11 | 2018-02-27 17:06:00 -0800 | [diff] [blame] | 558 | } |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 559 | } |
Yifan Hong | 878556e | 2018-07-13 13:45:30 -0700 | [diff] [blame] | 560 | if (status != OK) return status; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 561 | |
| 562 | // compatiblity check. |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 563 | if (!getDeviceHalManifest()->checkCompatibility(*getFrameworkCompatibilityMatrix(), error)) { |
Yifan Hong | ca386fe | 2018-02-07 11:29:03 -0800 | [diff] [blame] | 564 | if (error) { |
| 565 | error->insert(0, |
| 566 | "Device manifest and framework compatibility matrix are incompatible: "); |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 567 | } |
Yifan Hong | ca386fe | 2018-02-07 11:29:03 -0800 | [diff] [blame] | 568 | return INCOMPATIBLE; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 569 | } |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 570 | if (!getFrameworkHalManifest()->checkCompatibility(*getDeviceCompatibilityMatrix(), error)) { |
Yifan Hong | ca386fe | 2018-02-07 11:29:03 -0800 | [diff] [blame] | 571 | if (error) { |
| 572 | error->insert(0, |
| 573 | "Framework manifest and device compatibility matrix are incompatible: "); |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 574 | } |
Yifan Hong | ca386fe | 2018-02-07 11:29:03 -0800 | [diff] [blame] | 575 | return INCOMPATIBLE; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 576 | } |
Yifan Hong | 69c1b11 | 2018-02-27 17:06:00 -0800 | [diff] [blame] | 577 | |
Yifan Hong | 072f12d | 2018-08-08 13:04:51 -0700 | [diff] [blame] | 578 | if (flags.isRuntimeInfoEnabled()) { |
Yifan Hong | 12e23c2 | 2018-11-05 14:53:30 -0800 | [diff] [blame] | 579 | if (!getRuntimeInfo()->checkCompatibility(*getFrameworkCompatibilityMatrix(), error, |
Yifan Hong | 85e589e | 2019-12-18 13:12:29 -0800 | [diff] [blame] | 580 | flags)) { |
Yifan Hong | 69c1b11 | 2018-02-27 17:06:00 -0800 | [diff] [blame] | 581 | if (error) { |
| 582 | error->insert(0, |
| 583 | "Runtime info and framework compatibility matrix are incompatible: "); |
| 584 | } |
| 585 | return INCOMPATIBLE; |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 586 | } |
| 587 | } |
| 588 | |
| 589 | return COMPATIBLE; |
| 590 | } |
| 591 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 592 | namespace details { |
| 593 | |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 594 | const std::string kSystemVintfDir = "/system/etc/vintf/"; |
Yifan Hong | ccbea05 | 2018-01-18 18:48:46 -0800 | [diff] [blame] | 595 | const std::string kVendorVintfDir = "/vendor/etc/vintf/"; |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 596 | const std::string kOdmVintfDir = "/odm/etc/vintf/"; |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 597 | const std::string kProductVintfDir = "/product/etc/vintf/"; |
Yifan Hong | 5bbc4ae | 2020-01-09 14:30:27 -0800 | [diff] [blame] | 598 | const std::string kSystemExtVintfDir = "/system_ext/etc/vintf/"; |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 599 | |
| 600 | const std::string kVendorManifest = kVendorVintfDir + "manifest.xml"; |
Yifan Hong | a5ddddf | 2018-01-18 18:50:13 -0800 | [diff] [blame] | 601 | const std::string kSystemManifest = kSystemVintfDir + "manifest.xml"; |
Yifan Hong | b64ec9e | 2018-01-18 18:57:52 -0800 | [diff] [blame] | 602 | const std::string kVendorMatrix = kVendorVintfDir + "compatibility_matrix.xml"; |
Yifan Hong | 12a11ac | 2018-01-19 13:58:32 -0800 | [diff] [blame] | 603 | const std::string kOdmManifest = kOdmVintfDir + "manifest.xml"; |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 604 | const std::string kProductMatrix = kProductVintfDir + "compatibility_matrix.xml"; |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 605 | const std::string kProductManifest = kProductVintfDir + "manifest.xml"; |
Yifan Hong | 659feac | 2020-03-19 18:09:54 -0700 | [diff] [blame^] | 606 | const std::string kSystemExtManifest = kSystemExtVintfDir + "manifest.xml"; |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 607 | |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 608 | const std::string kVendorManifestFragmentDir = kVendorVintfDir + "manifest/"; |
| 609 | const std::string kSystemManifestFragmentDir = kSystemVintfDir + "manifest/"; |
| 610 | const std::string kOdmManifestFragmentDir = kOdmVintfDir + "manifest/"; |
Yifan Hong | 5f4e57e | 2019-04-23 15:16:25 -0700 | [diff] [blame] | 611 | const std::string kProductManifestFragmentDir = kProductVintfDir + "manifest/"; |
Yifan Hong | 659feac | 2020-03-19 18:09:54 -0700 | [diff] [blame^] | 612 | const std::string kSystemExtManifestFragmentDir = kSystemExtVintfDir + "manifest/"; |
Steven Moreland | eedf2d4 | 2018-04-04 16:36:27 -0700 | [diff] [blame] | 613 | |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 614 | const std::string kVendorLegacyManifest = "/vendor/manifest.xml"; |
| 615 | const std::string kVendorLegacyMatrix = "/vendor/compatibility_matrix.xml"; |
Yifan Hong | de6d00e | 2018-02-27 17:11:28 -0800 | [diff] [blame] | 616 | const std::string kSystemLegacyManifest = "/system/manifest.xml"; |
Yifan Hong | 270b565 | 2018-01-18 18:46:01 -0800 | [diff] [blame] | 617 | const std::string kSystemLegacyMatrix = "/system/compatibility_matrix.xml"; |
| 618 | const std::string kOdmLegacyVintfDir = "/odm/etc/"; |
| 619 | const std::string kOdmLegacyManifest = kOdmLegacyVintfDir + "manifest.xml"; |
| 620 | |
Yifan Hong | 69c1b11 | 2018-02-27 17:06:00 -0800 | [diff] [blame] | 621 | std::vector<std::string> dumpFileList() { |
| 622 | return { |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 623 | // clang-format off |
| 624 | kSystemVintfDir, |
| 625 | kVendorVintfDir, |
| 626 | kOdmVintfDir, |
| 627 | kProductVintfDir, |
Yifan Hong | a0968e8 | 2019-12-19 14:08:13 -0800 | [diff] [blame] | 628 | kSystemExtVintfDir, |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 629 | kOdmLegacyVintfDir, |
| 630 | kVendorLegacyManifest, |
| 631 | kVendorLegacyMatrix, |
| 632 | kSystemLegacyManifest, |
| 633 | kSystemLegacyMatrix, |
| 634 | // clang-format on |
Yifan Hong | 69c1b11 | 2018-02-27 17:06:00 -0800 | [diff] [blame] | 635 | }; |
| 636 | } |
| 637 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 638 | } // namespace details |
Yifan Hong | 143cfe6 | 2017-04-13 20:18:01 -0700 | [diff] [blame] | 639 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 640 | bool VintfObject::IsHalDeprecated(const MatrixHal& oldMatrixHal, |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 641 | const CompatibilityMatrix& targetMatrix, |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 642 | const ListInstances& listInstances, std::string* error) { |
Yifan Hong | 7e9e04d | 2018-03-20 13:06:00 -0700 | [diff] [blame] | 643 | bool isDeprecated = false; |
| 644 | oldMatrixHal.forEachInstance([&](const MatrixInstance& oldMatrixInstance) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 645 | if (IsInstanceDeprecated(oldMatrixInstance, targetMatrix, listInstances, error)) { |
Yifan Hong | 7e9e04d | 2018-03-20 13:06:00 -0700 | [diff] [blame] | 646 | isDeprecated = true; |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 647 | } |
Yifan Hong | 7e9e04d | 2018-03-20 13:06:00 -0700 | [diff] [blame] | 648 | return !isDeprecated; // continue if no deprecated instance is found. |
| 649 | }); |
| 650 | return isDeprecated; |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 651 | } |
| 652 | |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 653 | // Let oldMatrixInstance = package@x.y-w::interface with instancePattern. |
| 654 | // If any "servedInstance" in listInstances(package@x.y::interface) matches instancePattern, return |
| 655 | // true iff: |
| 656 | // 1. package@x.?::interface/servedInstance is not in targetMatrix; OR |
| 657 | // 2. package@x.z::interface/servedInstance is in targetMatrix but |
| 658 | // servedInstance is not in listInstances(package@x.z::interface) |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 659 | bool VintfObject::IsInstanceDeprecated(const MatrixInstance& oldMatrixInstance, |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 660 | const CompatibilityMatrix& targetMatrix, |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 661 | const ListInstances& listInstances, std::string* error) { |
Yifan Hong | 7e9e04d | 2018-03-20 13:06:00 -0700 | [diff] [blame] | 662 | const std::string& package = oldMatrixInstance.package(); |
| 663 | const Version& version = oldMatrixInstance.versionRange().minVer(); |
| 664 | const std::string& interface = oldMatrixInstance.interface(); |
Yifan Hong | 7e9e04d | 2018-03-20 13:06:00 -0700 | [diff] [blame] | 665 | |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 666 | std::vector<std::string> instanceHint; |
| 667 | if (!oldMatrixInstance.isRegex()) { |
| 668 | instanceHint.push_back(oldMatrixInstance.exactInstance()); |
| 669 | } |
| 670 | |
| 671 | auto list = listInstances(package, version, interface, instanceHint); |
| 672 | for (const auto& pair : list) { |
| 673 | const std::string& servedInstance = pair.first; |
| 674 | Version servedVersion = pair.second; |
| 675 | if (!oldMatrixInstance.matchInstance(servedInstance)) { |
| 676 | continue; |
| 677 | } |
| 678 | |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 679 | // Find any package@x.? in target matrix, and check if instance is in target matrix. |
Yifan Hong | 217f47e | 2018-03-15 12:34:05 -0700 | [diff] [blame] | 680 | bool foundInstance = false; |
| 681 | Version targetMatrixMinVer; |
Yifan Hong | 0b1916f | 2019-09-10 19:04:52 -0700 | [diff] [blame] | 682 | targetMatrix.forEachHidlInstanceOfPackage(package, [&](const auto& targetMatrixInstance) { |
Yifan Hong | 217f47e | 2018-03-15 12:34:05 -0700 | [diff] [blame] | 683 | if (targetMatrixInstance.versionRange().majorVer == version.majorVer && |
| 684 | targetMatrixInstance.interface() == interface && |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 685 | targetMatrixInstance.matchInstance(servedInstance)) { |
Yifan Hong | 217f47e | 2018-03-15 12:34:05 -0700 | [diff] [blame] | 686 | targetMatrixMinVer = targetMatrixInstance.versionRange().minVer(); |
| 687 | foundInstance = true; |
| 688 | } |
| 689 | return !foundInstance; // continue if not found |
| 690 | }); |
| 691 | if (!foundInstance) { |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 692 | if (error) { |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 693 | *error = toFQNameString(package, servedVersion, interface, servedInstance) + |
Steven Moreland | a1b984c | 2018-03-09 13:09:15 -0800 | [diff] [blame] | 694 | " is deprecated in compatibility matrix at FCM Version " + |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 695 | to_string(targetMatrix.level()) + "; it should not be served."; |
| 696 | } |
| 697 | return true; |
| 698 | } |
| 699 | |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 700 | // Assuming that targetMatrix requires @x.u-v, require that at least @x.u is served. |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 701 | bool targetVersionServed = false; |
| 702 | for (const auto& newPair : |
| 703 | listInstances(package, targetMatrixMinVer, interface, instanceHint)) { |
| 704 | if (newPair.first == servedInstance) { |
| 705 | targetVersionServed = true; |
| 706 | break; |
| 707 | } |
| 708 | } |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 709 | |
| 710 | if (!targetVersionServed) { |
Yifan Hong | 9f8f656 | 2018-11-06 16:26:20 -0800 | [diff] [blame] | 711 | appendLine(error, toFQNameString(package, servedVersion, interface, servedInstance) + |
| 712 | " is deprecated; requires at least " + |
| 713 | to_string(targetMatrixMinVer)); |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 714 | return true; |
| 715 | } |
| 716 | } |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 717 | |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 718 | return false; |
| 719 | } |
| 720 | |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 721 | int32_t VintfObject::CheckDeprecation(const ListInstances& listInstances, std::string* error) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 722 | return GetInstance()->checkDeprecation(listInstances, error); |
| 723 | } |
| 724 | int32_t VintfObject::checkDeprecation(const ListInstances& listInstances, std::string* error) { |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 725 | std::vector<Named<CompatibilityMatrix>> matrixFragments; |
| 726 | auto matrixFragmentsStatus = getAllFrameworkMatrixLevels(&matrixFragments, error); |
| 727 | if (matrixFragmentsStatus != OK) { |
| 728 | return matrixFragmentsStatus; |
| 729 | } |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 730 | if (matrixFragments.empty()) { |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 731 | if (error && error->empty()) { |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 732 | *error = "Cannot get framework matrix for each FCM version for unknown error."; |
Yifan Hong | 73bde59 | 2019-01-22 13:30:23 -0800 | [diff] [blame] | 733 | } |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 734 | return NAME_NOT_FOUND; |
| 735 | } |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 736 | auto deviceManifest = getDeviceHalManifest(); |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 737 | if (deviceManifest == nullptr) { |
| 738 | if (error) *error = "No device manifest."; |
| 739 | return NAME_NOT_FOUND; |
| 740 | } |
| 741 | Level deviceLevel = deviceManifest->level(); |
| 742 | if (deviceLevel == Level::UNSPECIFIED) { |
| 743 | if (error) *error = "Device manifest does not specify Shipping FCM Version."; |
| 744 | return BAD_VALUE; |
| 745 | } |
| 746 | |
| 747 | const CompatibilityMatrix* targetMatrix = nullptr; |
| 748 | for (const auto& namedMatrix : matrixFragments) { |
| 749 | if (namedMatrix.object.level() == deviceLevel) { |
| 750 | targetMatrix = &namedMatrix.object; |
| 751 | } |
| 752 | } |
| 753 | if (targetMatrix == nullptr) { |
| 754 | if (error) |
| 755 | *error = "Cannot find framework matrix at FCM version " + to_string(deviceLevel) + "."; |
| 756 | return NAME_NOT_FOUND; |
| 757 | } |
| 758 | |
| 759 | bool hasDeprecatedHals = false; |
| 760 | for (const auto& namedMatrix : matrixFragments) { |
| 761 | if (namedMatrix.object.level() == Level::UNSPECIFIED) continue; |
| 762 | if (namedMatrix.object.level() >= deviceLevel) continue; |
| 763 | |
| 764 | const auto& oldMatrix = namedMatrix.object; |
| 765 | for (const MatrixHal& hal : oldMatrix.getHals()) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 766 | hasDeprecatedHals |= IsHalDeprecated(hal, *targetMatrix, listInstances, error); |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | |
| 770 | return hasDeprecatedHals ? DEPRECATED : NO_DEPRECATED_HALS; |
| 771 | } |
| 772 | |
| 773 | int32_t VintfObject::CheckDeprecation(std::string* error) { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 774 | return GetInstance()->checkDeprecation(error); |
| 775 | } |
| 776 | int32_t VintfObject::checkDeprecation(std::string* error) { |
Yifan Hong | 2a90ffe | 2018-03-05 17:45:34 -0800 | [diff] [blame] | 777 | using namespace std::placeholders; |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 778 | auto deviceManifest = getDeviceHalManifest(); |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 779 | ListInstances inManifest = |
| 780 | [&deviceManifest](const std::string& package, Version version, const std::string& interface, |
| 781 | const std::vector<std::string>& /* hintInstances */) { |
| 782 | std::vector<std::pair<std::string, Version>> ret; |
| 783 | deviceManifest->forEachInstanceOfInterface( |
Yifan Hong | ac62148 | 2019-09-10 19:27:20 -0700 | [diff] [blame] | 784 | HalFormat::HIDL, package, version, interface, |
| 785 | [&ret](const ManifestInstance& manifestInstance) { |
Yifan Hong | a8a8fa9 | 2018-03-20 14:42:43 -0700 | [diff] [blame] | 786 | ret.push_back( |
| 787 | std::make_pair(manifestInstance.instance(), manifestInstance.version())); |
| 788 | return true; |
| 789 | }); |
| 790 | return ret; |
| 791 | }; |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 792 | return checkDeprecation(inManifest, error); |
Yifan Hong | f73ba51 | 2018-01-17 15:52:30 -0800 | [diff] [blame] | 793 | } |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 794 | |
Yifan Hong | 378c408 | 2019-12-23 13:10:57 -0800 | [diff] [blame] | 795 | Level VintfObject::getKernelLevel(std::string* error) { |
| 796 | auto manifest = getDeviceHalManifest(); |
| 797 | if (!manifest) { |
| 798 | if (error) *error = "Cannot retrieve device manifest."; |
| 799 | return Level::UNSPECIFIED; |
Yifan Hong | 1e8febd | 2019-08-07 16:17:19 -0700 | [diff] [blame] | 800 | } |
Yifan Hong | 378c408 | 2019-12-23 13:10:57 -0800 | [diff] [blame] | 801 | if (manifest->kernel().has_value() && manifest->kernel()->level() != Level::UNSPECIFIED) { |
| 802 | return manifest->kernel()->level(); |
Yifan Hong | 1e8febd | 2019-08-07 16:17:19 -0700 | [diff] [blame] | 803 | } |
Yifan Hong | 378c408 | 2019-12-23 13:10:57 -0800 | [diff] [blame] | 804 | if (error) *error = "Device manifest does not specify kernel FCM version."; |
| 805 | return Level::UNSPECIFIED; |
Yifan Hong | 1e8febd | 2019-08-07 16:17:19 -0700 | [diff] [blame] | 806 | } |
| 807 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 808 | const std::unique_ptr<FileSystem>& VintfObject::getFileSystem() { |
| 809 | return mFileSystem; |
| 810 | } |
| 811 | |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 812 | const std::unique_ptr<PropertyFetcher>& VintfObject::getPropertyFetcher() { |
| 813 | return mPropertyFetcher; |
| 814 | } |
| 815 | |
Yifan Hong | d038b2b | 2018-11-27 13:57:56 -0800 | [diff] [blame] | 816 | const std::unique_ptr<ObjectFactory<RuntimeInfo>>& VintfObject::getRuntimeInfoFactory() { |
Yifan Hong | 9f78c18 | 2018-07-12 14:45:52 -0700 | [diff] [blame] | 817 | return mRuntimeInfoFactory; |
Yifan Hong | 10d8622 | 2018-04-06 15:41:05 -0700 | [diff] [blame] | 818 | } |
| 819 | |
Yifan Hong | 78f5b57 | 2018-11-27 14:05:03 -0800 | [diff] [blame] | 820 | // make_unique does not work because VintfObject constructor is private. |
| 821 | VintfObject::Builder::Builder() : mObject(std::unique_ptr<VintfObject>(new VintfObject())) {} |
| 822 | |
| 823 | VintfObject::Builder& VintfObject::Builder::setFileSystem(std::unique_ptr<FileSystem>&& e) { |
| 824 | mObject->mFileSystem = std::move(e); |
| 825 | return *this; |
| 826 | } |
| 827 | |
| 828 | VintfObject::Builder& VintfObject::Builder::setRuntimeInfoFactory( |
| 829 | std::unique_ptr<ObjectFactory<RuntimeInfo>>&& e) { |
| 830 | mObject->mRuntimeInfoFactory = std::move(e); |
| 831 | return *this; |
| 832 | } |
| 833 | |
| 834 | VintfObject::Builder& VintfObject::Builder::setPropertyFetcher( |
| 835 | std::unique_ptr<PropertyFetcher>&& e) { |
| 836 | mObject->mPropertyFetcher = std::move(e); |
| 837 | return *this; |
| 838 | } |
| 839 | |
| 840 | std::unique_ptr<VintfObject> VintfObject::Builder::build() { |
| 841 | if (!mObject->mFileSystem) mObject->mFileSystem = createDefaultFileSystem(); |
| 842 | if (!mObject->mRuntimeInfoFactory) |
| 843 | mObject->mRuntimeInfoFactory = std::make_unique<ObjectFactory<RuntimeInfo>>(); |
| 844 | if (!mObject->mPropertyFetcher) mObject->mPropertyFetcher = createDefaultPropertyFetcher(); |
| 845 | return std::move(mObject); |
| 846 | } |
| 847 | |
Yifan Hong | 3daec81 | 2017-02-27 18:49:11 -0800 | [diff] [blame] | 848 | } // namespace vintf |
| 849 | } // namespace android |