VintfObject now provides instance methods.
VintfObject used to only contain static methods. It now
contains instance methods, and the static methods are
delegates to the instance methods. For example:
GetDeviceHalManifest calls GetInstance()->getDeviceHalManifest()
getDeviceHalManifest does the actual job.
The static dependencies (FileSystem, PropertyFetcher, PartitionMounter,
ObjectFactory<RuntimeInfo> are also moved from utils.cpp to the
static VintfObject instance.
Tests are updated to create a test VintfObject instance with
the mocked dependencies, and run test on the test object.
As a result, utils.cpp is now empty and removed, and
libvintf_common is the same as libvintf. Hence libvintf_common is also
removed.
This allows:
- Allows better mocking in tests. Tests are now independent of
each other because a new VintfObject is created for every test.
(Previously this is done very badly by clearing the global states,
which is error prone)
- A bug in VintfObjectTest.FrameworkCompatibilityMatrixCombine
is discovered because it depends on setting global states in
previous test cases. This is also fixed in this CL.
- In recovery, two VintfObject is required; one for XMLs in the
recovery image (under /) and one for XMLs in system/vendor image
(under /mnt). HIDL HAL getService in recovery depends on the former,
and OTA depends on the latter. This CL prepares recovery to work.
(A follow-up CL is needed to update VintfObjectRecovery to use
/mnt for getService).
Some other notable changes in the CL:
- CompatibilityMatrix/HalManifest fetchAllInformation now takes
a FileSystem argument to fetch files correctly, because the global
FileSystem object is removed.
- Globals in utils.cpp / utils-fake.cpp is removed
- DevicePropertyFetcher is moved from utils.cpp to PropertyFetcher.cpp
and is always built (for both host and target); but host VintfObject
uses dummy PropertyFetcher by default. (See
createDefaultPropertyFetcher in VintfObject.cpp).
Bug: 110855270
Bug: 80132328
Bug: 111372832
Test: vintf_object_test
Test: livintf_test
Change-Id: I24320662191b977c0e562129e49b33e80de727cc
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 0e757ca..c34f0bb 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -37,18 +37,11 @@
using namespace details;
-template <typename T>
-struct LockedSharedPtr {
- std::shared_ptr<T> object;
- std::mutex mutex;
- bool fetchedOnce = false;
-};
-
-struct LockedRuntimeInfoCache {
- std::shared_ptr<RuntimeInfo> object;
- std::mutex mutex;
- RuntimeInfo::FetchFlags fetchedFlags = RuntimeInfo::FetchFlag::NONE;
-};
+#ifdef LIBVINTF_TARGET
+static constexpr bool kIsTarget = true;
+#else
+static constexpr bool kIsTarget = false;
+#endif
template <typename T, typename F>
static std::shared_ptr<const T> Get(
@@ -68,51 +61,102 @@
return ptr->object;
}
-// static
+static std::unique_ptr<FileSystem> createDefaultFileSystem() {
+ std::unique_ptr<FileSystem> fileSystem;
+ if (kIsTarget) {
+ fileSystem = std::make_unique<details::FileSystemImpl>();
+ } else {
+ fileSystem = std::make_unique<details::FileSystemNoOp>();
+ }
+ return fileSystem;
+}
+
+static std::unique_ptr<PropertyFetcher> createDefaultPropertyFetcher() {
+ std::unique_ptr<PropertyFetcher> propertyFetcher;
+ if (kIsTarget) {
+ propertyFetcher = std::make_unique<details::PropertyFetcherImpl>();
+ } else {
+ propertyFetcher = std::make_unique<details::PropertyFetcherNoOp>();
+ }
+ return propertyFetcher;
+}
+
+VintfObject::VintfObject(std::unique_ptr<FileSystem>&& fileSystem,
+ std::unique_ptr<details::PartitionMounter>&& partitionMounter,
+ std::unique_ptr<details::ObjectFactory<RuntimeInfo>>&& runtimeInfoFactory,
+ std::unique_ptr<details::PropertyFetcher>&& propertyFetcher)
+ : mFileSystem(fileSystem ? std::move(fileSystem) : createDefaultFileSystem()),
+ mPartitionMounter(partitionMounter ? std::move(partitionMounter)
+ : std::make_unique<details::PartitionMounter>()),
+ mRuntimeInfoFactory(runtimeInfoFactory
+ ? std::move(runtimeInfoFactory)
+ : std::make_unique<details::ObjectFactory<RuntimeInfo>>()),
+ mPropertyFetcher(propertyFetcher ? std::move(propertyFetcher)
+ : createDefaultPropertyFetcher()) {}
+
+details::LockedSharedPtr<VintfObject> VintfObject::sInstance{};
+std::shared_ptr<VintfObject> VintfObject::GetInstance() {
+ std::unique_lock<std::mutex> lock(sInstance.mutex);
+ if (sInstance.object == nullptr) {
+ sInstance.object = std::make_shared<VintfObject>();
+ }
+ return sInstance.object;
+}
+
std::shared_ptr<const HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) {
- static LockedSharedPtr<HalManifest> gVendorManifest;
- return Get(&gVendorManifest, skipCache, &VintfObject::FetchDeviceHalManifest);
+ return GetInstance()->getDeviceHalManifest(skipCache);
}
-// static
+std::shared_ptr<const HalManifest> VintfObject::getDeviceHalManifest(bool skipCache) {
+ return Get(&mDeviceManifest, skipCache,
+ std::bind(&VintfObject::fetchDeviceHalManifest, this, _1, _2));
+}
+
std::shared_ptr<const HalManifest> VintfObject::GetFrameworkHalManifest(bool skipCache) {
- static LockedSharedPtr<HalManifest> gFrameworkManifest;
- return Get(&gFrameworkManifest, skipCache, &VintfObject::FetchFrameworkHalManifest);
+ return GetInstance()->getFrameworkHalManifest(skipCache);
}
+std::shared_ptr<const HalManifest> VintfObject::getFrameworkHalManifest(bool skipCache) {
+ return Get(&mFrameworkManifest, skipCache,
+ std::bind(&VintfObject::fetchFrameworkHalManifest, this, _1, _2));
+}
-// static
std::shared_ptr<const CompatibilityMatrix> VintfObject::GetDeviceCompatibilityMatrix(bool skipCache) {
- static LockedSharedPtr<CompatibilityMatrix> gDeviceMatrix;
- return Get(&gDeviceMatrix, skipCache, &VintfObject::FetchDeviceMatrix);
+ return GetInstance()->getDeviceCompatibilityMatrix(skipCache);
}
-// static
+std::shared_ptr<const CompatibilityMatrix> VintfObject::getDeviceCompatibilityMatrix(
+ bool skipCache) {
+ return Get(&mDeviceMatrix, skipCache, std::bind(&VintfObject::fetchDeviceMatrix, this, _1, _2));
+}
+
std::shared_ptr<const CompatibilityMatrix> VintfObject::GetFrameworkCompatibilityMatrix(bool skipCache) {
- static LockedSharedPtr<CompatibilityMatrix> gFrameworkMatrix;
- static LockedSharedPtr<CompatibilityMatrix> gCombinedFrameworkMatrix;
- static std::mutex gFrameworkCompatibilityMatrixMutex;
+ return GetInstance()->getFrameworkCompatibilityMatrix(skipCache);
+}
+std::shared_ptr<const CompatibilityMatrix> VintfObject::getFrameworkCompatibilityMatrix(
+ bool skipCache) {
// To avoid deadlock, get device manifest before any locks.
- auto deviceManifest = GetDeviceHalManifest();
+ auto deviceManifest = getDeviceHalManifest();
- std::unique_lock<std::mutex> _lock(gFrameworkCompatibilityMatrixMutex);
+ std::unique_lock<std::mutex> _lock(mFrameworkCompatibilityMatrixMutex);
auto combined =
- Get(&gCombinedFrameworkMatrix, skipCache,
- std::bind(&VintfObject::GetCombinedFrameworkMatrix, deviceManifest, _1, _2));
+ Get(&mCombinedFrameworkMatrix, skipCache,
+ std::bind(&VintfObject::getCombinedFrameworkMatrix, this, deviceManifest, _1, _2));
if (combined != nullptr) {
return combined;
}
- return Get(&gFrameworkMatrix, skipCache,
- std::bind(&CompatibilityMatrix::fetchAllInformation, _1, kSystemLegacyMatrix, _2));
+ return Get(&mFrameworkMatrix, skipCache,
+ std::bind(&CompatibilityMatrix::fetchAllInformation, _1, mFileSystem.get(),
+ kSystemLegacyMatrix, _2));
}
-status_t VintfObject::GetCombinedFrameworkMatrix(
+status_t VintfObject::getCombinedFrameworkMatrix(
const std::shared_ptr<const HalManifest>& deviceManifest, CompatibilityMatrix* out,
std::string* error) {
- auto matrixFragments = GetAllFrameworkMatrixLevels(error);
+ auto matrixFragments = getAllFrameworkMatrixLevels(error);
if (matrixFragments.empty()) {
return NAME_NOT_FOUND;
}
@@ -125,7 +169,7 @@
// TODO(b/70628538): Do not infer from Shipping API level.
if (deviceLevel == Level::UNSPECIFIED) {
- auto shippingApi = getPropertyFetcher().getUintProperty("ro.product.first_api_level", 0u);
+ auto shippingApi = mPropertyFetcher->getUintProperty("ro.product.first_api_level", 0u);
if (shippingApi != 0u) {
deviceLevel = details::convertFromApiLevel(shippingApi);
}
@@ -162,10 +206,10 @@
}
// Load and combine all of the manifests in a directory
-status_t VintfObject::AddDirectoryManifests(const std::string& directory, HalManifest* manifest,
+status_t VintfObject::addDirectoryManifests(const std::string& directory, HalManifest* manifest,
std::string* error) {
std::vector<std::string> fileNames;
- status_t err = details::getFileSystem().listFiles(directory, &fileNames, error);
+ status_t err = mFileSystem->listFiles(directory, &fileNames, error);
// if the directory isn't there, that's okay
if (err == NAME_NOT_FOUND) return OK;
if (err != OK) return err;
@@ -174,7 +218,7 @@
// Only adds HALs because all other things are added by libvintf
// itself for now.
HalManifest fragmentManifest;
- err = FetchOneHalManifest(directory + file, &fragmentManifest, error);
+ err = fetchOneHalManifest(directory + file, &fragmentManifest, error);
if (err != OK) return err;
manifest->addAllHals(&fragmentManifest);
@@ -190,21 +234,21 @@
// 4. /vendor/manifest.xml (legacy, no fragments)
// where:
// A + B means adding <hal> tags from B to A (so that <hal>s from B can override A)
-status_t VintfObject::FetchDeviceHalManifest(HalManifest* out, std::string* error) {
- status_t vendorStatus = FetchOneHalManifest(kVendorManifest, out, error);
+status_t VintfObject::fetchDeviceHalManifest(HalManifest* out, std::string* error) {
+ status_t vendorStatus = fetchOneHalManifest(kVendorManifest, out, error);
if (vendorStatus != OK && vendorStatus != NAME_NOT_FOUND) {
return vendorStatus;
}
if (vendorStatus == OK) {
- status_t fragmentStatus = AddDirectoryManifests(kVendorManifestFragmentDir, out, error);
+ status_t fragmentStatus = addDirectoryManifests(kVendorManifestFragmentDir, out, error);
if (fragmentStatus != OK) {
return fragmentStatus;
}
}
HalManifest odmManifest;
- status_t odmStatus = FetchOdmHalManifest(&odmManifest, error);
+ status_t odmStatus = fetchOdmHalManifest(&odmManifest, error);
if (odmStatus != OK && odmStatus != NAME_NOT_FOUND) {
return odmStatus;
}
@@ -213,17 +257,17 @@
if (odmStatus == OK) {
out->addAllHals(&odmManifest);
}
- return AddDirectoryManifests(kOdmManifestFragmentDir, out, error);
+ return addDirectoryManifests(kOdmManifestFragmentDir, out, error);
}
// vendorStatus != OK, "out" is not changed.
if (odmStatus == OK) {
*out = std::move(odmManifest);
- return AddDirectoryManifests(kOdmManifestFragmentDir, out, error);
+ return addDirectoryManifests(kOdmManifestFragmentDir, out, error);
}
// Use legacy /vendor/manifest.xml
- return out->fetchAllInformation(kVendorLegacyManifest, error);
+ return out->fetchAllInformation(mFileSystem.get(), kVendorLegacyManifest, error);
}
// "out" is written to iff return status is OK.
@@ -234,34 +278,34 @@
// 4. /odm/etc/manifest.xml
// where:
// {sku} is the value of ro.boot.product.hardware.sku
-status_t VintfObject::FetchOdmHalManifest(HalManifest* out, std::string* error) {
+status_t VintfObject::fetchOdmHalManifest(HalManifest* out, std::string* error) {
status_t status;
std::string productModel;
- productModel = getPropertyFetcher().getProperty("ro.boot.product.hardware.sku", "");
+ productModel = mPropertyFetcher->getProperty("ro.boot.product.hardware.sku", "");
if (!productModel.empty()) {
status =
- FetchOneHalManifest(kOdmVintfDir + "manifest_" + productModel + ".xml", out, error);
+ fetchOneHalManifest(kOdmVintfDir + "manifest_" + productModel + ".xml", out, error);
if (status == OK || status != NAME_NOT_FOUND) {
return status;
}
}
- status = FetchOneHalManifest(kOdmManifest, out, error);
+ status = fetchOneHalManifest(kOdmManifest, out, error);
if (status == OK || status != NAME_NOT_FOUND) {
return status;
}
if (!productModel.empty()) {
- status = FetchOneHalManifest(kOdmLegacyVintfDir + "manifest_" + productModel + ".xml", out,
+ status = fetchOneHalManifest(kOdmLegacyVintfDir + "manifest_" + productModel + ".xml", out,
error);
if (status == OK || status != NAME_NOT_FOUND) {
return status;
}
}
- status = FetchOneHalManifest(kOdmLegacyManifest, out, error);
+ status = fetchOneHalManifest(kOdmLegacyManifest, out, error);
if (status == OK || status != NAME_NOT_FOUND) {
return status;
}
@@ -271,40 +315,40 @@
// Fetch one manifest.xml file. "out" is written to iff return status is OK.
// Returns NAME_NOT_FOUND if file is missing.
-status_t VintfObject::FetchOneHalManifest(const std::string& path, HalManifest* out,
+status_t VintfObject::fetchOneHalManifest(const std::string& path, HalManifest* out,
std::string* error) {
HalManifest ret;
- status_t status = ret.fetchAllInformation(path, error);
+ status_t status = ret.fetchAllInformation(mFileSystem.get(), path, error);
if (status == OK) {
*out = std::move(ret);
}
return status;
}
-status_t VintfObject::FetchDeviceMatrix(CompatibilityMatrix* out, std::string* error) {
+status_t VintfObject::fetchDeviceMatrix(CompatibilityMatrix* out, std::string* error) {
CompatibilityMatrix etcMatrix;
- if (etcMatrix.fetchAllInformation(kVendorMatrix, error) == OK) {
+ if (etcMatrix.fetchAllInformation(mFileSystem.get(), kVendorMatrix, error) == OK) {
*out = std::move(etcMatrix);
return OK;
}
- return out->fetchAllInformation(kVendorLegacyMatrix, error);
+ return out->fetchAllInformation(mFileSystem.get(), kVendorLegacyMatrix, error);
}
-status_t VintfObject::FetchFrameworkHalManifest(HalManifest* out, std::string* error) {
+status_t VintfObject::fetchFrameworkHalManifest(HalManifest* out, std::string* error) {
HalManifest etcManifest;
- if (etcManifest.fetchAllInformation(kSystemManifest, error) == OK) {
+ if (etcManifest.fetchAllInformation(mFileSystem.get(), kSystemManifest, error) == OK) {
*out = std::move(etcManifest);
- return AddDirectoryManifests(kSystemManifestFragmentDir, out, error);
+ return addDirectoryManifests(kSystemManifestFragmentDir, out, error);
}
- return out->fetchAllInformation(kSystemLegacyManifest, error);
+ return out->fetchAllInformation(mFileSystem.get(), kSystemLegacyManifest, error);
}
-std::vector<Named<CompatibilityMatrix>> VintfObject::GetAllFrameworkMatrixLevels(
+std::vector<Named<CompatibilityMatrix>> VintfObject::getAllFrameworkMatrixLevels(
std::string* error) {
std::vector<std::string> fileNames;
std::vector<Named<CompatibilityMatrix>> results;
- if (details::getFileSystem().listFiles(kSystemVintfDir, &fileNames, error) != OK) {
+ if (mFileSystem->listFiles(kSystemVintfDir, &fileNames, error) != OK) {
return {};
}
for (const std::string& fileName : fileNames) {
@@ -312,7 +356,7 @@
std::string content;
std::string fetchError;
- status_t status = details::getFileSystem().fetch(path, &content, &fetchError);
+ status_t status = mFileSystem->fetch(path, &content, &fetchError);
if (status != OK) {
if (error) {
*error += "Framework Matrix: Ignore file " + path + ": " + fetchError + "\n";
@@ -345,28 +389,30 @@
return results;
}
-// static
std::shared_ptr<const RuntimeInfo> VintfObject::GetRuntimeInfo(bool skipCache,
RuntimeInfo::FetchFlags flags) {
- static LockedRuntimeInfoCache gDeviceRuntimeInfo;
- std::unique_lock<std::mutex> _lock(gDeviceRuntimeInfo.mutex);
+ return GetInstance()->getRuntimeInfo(skipCache, flags);
+}
+std::shared_ptr<const RuntimeInfo> VintfObject::getRuntimeInfo(bool skipCache,
+ RuntimeInfo::FetchFlags flags) {
+ std::unique_lock<std::mutex> _lock(mDeviceRuntimeInfo.mutex);
if (!skipCache) {
- flags &= (~gDeviceRuntimeInfo.fetchedFlags);
+ flags &= (~mDeviceRuntimeInfo.fetchedFlags);
}
- if (gDeviceRuntimeInfo.object == nullptr) {
- gDeviceRuntimeInfo.object = details::gRuntimeInfoFactory->make_shared();
+ if (mDeviceRuntimeInfo.object == nullptr) {
+ mDeviceRuntimeInfo.object = mRuntimeInfoFactory->make_shared();
}
- status_t status = gDeviceRuntimeInfo.object->fetchAllInformation(flags);
+ status_t status = mDeviceRuntimeInfo.object->fetchAllInformation(flags);
if (status != OK) {
- gDeviceRuntimeInfo.fetchedFlags &= (~flags); // mark the fields as "not fetched"
+ mDeviceRuntimeInfo.fetchedFlags &= (~flags); // mark the fields as "not fetched"
return nullptr;
}
- gDeviceRuntimeInfo.fetchedFlags |= flags;
- return gDeviceRuntimeInfo.object;
+ mDeviceRuntimeInfo.fetchedFlags |= flags;
+ return mDeviceRuntimeInfo.object;
}
namespace details {
@@ -449,12 +495,13 @@
std::shared_ptr<const RuntimeInfo> runtimeInfo;
};
+} // namespace details
+
// Checks given compatibility info against info on the device. If no
// compatability info is given then the device info will be checked against
// itself.
-int32_t checkCompatibility(const std::vector<std::string>& xmls, bool mount,
- const PartitionMounter& mounter, std::string* error,
- DisabledChecks disabledChecks) {
+int32_t VintfObject::checkCompatibility(const std::vector<std::string>& xmls, bool mount,
+ std::string* error, DisabledChecks disabledChecks) {
status_t status;
ParseStatus parseStatus;
PackageInfo pkg; // All information from package.
@@ -484,37 +531,36 @@
// get missing info from device
// use functions instead of std::bind because std::bind doesn't work well with mock objects
- auto mountSystem = [&mounter] { return mounter.mountSystem(); };
- auto mountVendor = [&mounter] { return mounter.mountVendor(); };
+ auto mountSystem = [this] { return this->mPartitionMounter->mountSystem(); };
+ auto mountVendor = [this] { return this->mPartitionMounter->mountVendor(); };
if ((status = getMissing(
pkg.fwk.manifest, mount, mountSystem, &updated.fwk.manifest,
- std::bind(VintfObject::GetFrameworkHalManifest, true /* skipCache */))) != OK) {
+ std::bind(&VintfObject::getFrameworkHalManifest, this, true /* skipCache */))) != OK) {
return status;
}
if ((status = getMissing(
pkg.dev.manifest, mount, mountVendor, &updated.dev.manifest,
- std::bind(VintfObject::GetDeviceHalManifest, true /* skipCache */))) != OK) {
+ std::bind(&VintfObject::getDeviceHalManifest, this, true /* skipCache */))) != OK) {
return status;
}
- if ((status = getMissing(
- pkg.fwk.matrix, mount, mountSystem, &updated.fwk.matrix,
- std::bind(VintfObject::GetFrameworkCompatibilityMatrix, true /* skipCache */))) !=
- OK) {
+ if ((status = getMissing(pkg.fwk.matrix, mount, mountSystem, &updated.fwk.matrix,
+ std::bind(&VintfObject::getFrameworkCompatibilityMatrix, this,
+ true /* skipCache */))) != OK) {
return status;
}
- if ((status = getMissing(
- pkg.dev.matrix, mount, mountVendor, &updated.dev.matrix,
- std::bind(VintfObject::GetDeviceCompatibilityMatrix, true /* skipCache */))) != OK) {
+ if ((status = getMissing(pkg.dev.matrix, mount, mountVendor, &updated.dev.matrix,
+ std::bind(&VintfObject::getDeviceCompatibilityMatrix, this,
+ true /* skipCache */))) != OK) {
return status;
}
if (mount) {
- (void)mounter.umountSystem(); // ignore errors
- (void)mounter.umountVendor(); // ignore errors
+ (void)mPartitionMounter->umountSystem(); // ignore errors
+ (void)mPartitionMounter->umountVendor(); // ignore errors
}
if ((disabledChecks & DISABLE_RUNTIME_INFO) == 0) {
- updated.runtimeInfo = VintfObject::GetRuntimeInfo(true /* skipCache */);
+ updated.runtimeInfo = getRuntimeInfo(true /* skipCache */);
}
// null checks for files and runtime info after the update
@@ -571,6 +617,8 @@
return COMPATIBLE;
}
+namespace details {
+
const std::string kSystemVintfDir = "/system/etc/vintf/";
const std::string kVendorVintfDir = "/vendor/etc/vintf/";
const std::string kOdmVintfDir = "/odm/etc/vintf/";
@@ -599,21 +647,24 @@
};
}
-} // namespace details
+} // namespace details
-// static
int32_t VintfObject::CheckCompatibility(const std::vector<std::string>& xmls, std::string* error,
DisabledChecks disabledChecks) {
- return details::checkCompatibility(xmls, false /* mount */, *details::gPartitionMounter, error,
- disabledChecks);
+ return GetInstance()->checkCompatibility(xmls, error, disabledChecks);
}
-bool VintfObject::isHalDeprecated(const MatrixHal& oldMatrixHal,
+int32_t VintfObject::checkCompatibility(const std::vector<std::string>& xmls, std::string* error,
+ DisabledChecks disabledChecks) {
+ return checkCompatibility(xmls, false /* mount */, error, disabledChecks);
+}
+
+bool VintfObject::IsHalDeprecated(const MatrixHal& oldMatrixHal,
const CompatibilityMatrix& targetMatrix,
const ListInstances& listInstances, std::string* error) {
bool isDeprecated = false;
oldMatrixHal.forEachInstance([&](const MatrixInstance& oldMatrixInstance) {
- if (isInstanceDeprecated(oldMatrixInstance, targetMatrix, listInstances, error)) {
+ if (IsInstanceDeprecated(oldMatrixInstance, targetMatrix, listInstances, error)) {
isDeprecated = true;
}
return !isDeprecated; // continue if no deprecated instance is found.
@@ -627,7 +678,7 @@
// 1. package@x.?::interface/servedInstance is not in targetMatrix; OR
// 2. package@x.z::interface/servedInstance is in targetMatrix but
// servedInstance is not in listInstances(package@x.z::interface)
-bool VintfObject::isInstanceDeprecated(const MatrixInstance& oldMatrixInstance,
+bool VintfObject::IsInstanceDeprecated(const MatrixInstance& oldMatrixInstance,
const CompatibilityMatrix& targetMatrix,
const ListInstances& listInstances, std::string* error) {
const std::string& package = oldMatrixInstance.package();
@@ -692,13 +743,16 @@
}
int32_t VintfObject::CheckDeprecation(const ListInstances& listInstances, std::string* error) {
- auto matrixFragments = GetAllFrameworkMatrixLevels(error);
+ return GetInstance()->checkDeprecation(listInstances, error);
+}
+int32_t VintfObject::checkDeprecation(const ListInstances& listInstances, std::string* error) {
+ auto matrixFragments = getAllFrameworkMatrixLevels(error);
if (matrixFragments.empty()) {
if (error && error->empty())
*error = "Cannot get framework matrix for each FCM version for unknown error.";
return NAME_NOT_FOUND;
}
- auto deviceManifest = GetDeviceHalManifest();
+ auto deviceManifest = getDeviceHalManifest();
if (deviceManifest == nullptr) {
if (error) *error = "No device manifest.";
return NAME_NOT_FOUND;
@@ -728,7 +782,7 @@
const auto& oldMatrix = namedMatrix.object;
for (const MatrixHal& hal : oldMatrix.getHals()) {
- hasDeprecatedHals |= isHalDeprecated(hal, *targetMatrix, listInstances, error);
+ hasDeprecatedHals |= IsHalDeprecated(hal, *targetMatrix, listInstances, error);
}
}
@@ -736,8 +790,11 @@
}
int32_t VintfObject::CheckDeprecation(std::string* error) {
+ return GetInstance()->checkDeprecation(error);
+}
+int32_t VintfObject::checkDeprecation(std::string* error) {
using namespace std::placeholders;
- auto deviceManifest = GetDeviceHalManifest();
+ auto deviceManifest = getDeviceHalManifest();
ListInstances inManifest =
[&deviceManifest](const std::string& package, Version version, const std::string& interface,
const std::vector<std::string>& /* hintInstances */) {
@@ -750,11 +807,23 @@
});
return ret;
};
- return CheckDeprecation(inManifest, error);
+ return checkDeprecation(inManifest, error);
}
-bool VintfObject::InitFileSystem(std::unique_ptr<FileSystem>&& fileSystem) {
- return details::initFileSystem(std::move(fileSystem));
+const std::unique_ptr<FileSystem>& VintfObject::getFileSystem() {
+ return mFileSystem;
+}
+
+const std::unique_ptr<PartitionMounter>& VintfObject::getPartitionMounter() {
+ return mPartitionMounter;
+}
+
+const std::unique_ptr<PropertyFetcher>& VintfObject::getPropertyFetcher() {
+ return mPropertyFetcher;
+}
+
+const std::unique_ptr<details::ObjectFactory<RuntimeInfo>>& VintfObject::getRuntimeInfoFactory() {
+ return mRuntimeInfoFactory;
}
} // namespace vintf