diff options
author | Yifan Hong | 2018-07-12 16:45:52 -0500 |
---|---|---|
committer | Yifan Hong | 2018-07-13 17:42:15 -0500 |
commit | 9f78c180ff6c1cff8d0cd5c3a656bed85492685f (patch) | |
tree | 3e25137e2bd18522df9cdfd62c0601c730569bb5 /VintfObjectRecovery.cpp | |
parent | f3378017ea2c8818e9ea645328dae1cf5a9fe95a (diff) | |
download | platform-system-libvintf-9f78c180ff6c1cff8d0cd5c3a656bed85492685f.tar.gz platform-system-libvintf-9f78c180ff6c1cff8d0cd5c3a656bed85492685f.tar.xz platform-system-libvintf-9f78c180ff6c1cff8d0cd5c3a656bed85492685f.zip |
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
Diffstat (limited to 'VintfObjectRecovery.cpp')
-rw-r--r-- | VintfObjectRecovery.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/VintfObjectRecovery.cpp b/VintfObjectRecovery.cpp index 9d7cab7..9efb318 100644 --- a/VintfObjectRecovery.cpp +++ b/VintfObjectRecovery.cpp | |||
@@ -42,12 +42,14 @@ static FstabMgr defaultFstabMgr() { | |||
42 | 42 | ||
43 | class RecoveryPartitionMounter : public PartitionMounter { | 43 | class RecoveryPartitionMounter : public PartitionMounter { |
44 | public: | 44 | public: |
45 | RecoveryPartitionMounter(PropertyFetcher* propertyFetcher) | ||
46 | : mPropertyFetcher(propertyFetcher) {} | ||
45 | status_t mountSystem() const override { | 47 | status_t mountSystem() const override { |
46 | FstabMgr fstab = defaultFstabMgr(); | 48 | FstabMgr fstab = defaultFstabMgr(); |
47 | if (fstab == NULL) { | 49 | if (fstab == NULL) { |
48 | return UNKNOWN_ERROR; | 50 | return UNKNOWN_ERROR; |
49 | } | 51 | } |
50 | if (getPropertyFetcher().getBoolProperty("ro.build.system_root_image", false)) { | 52 | if (mPropertyFetcher->getBoolProperty("ro.build.system_root_image", false)) { |
51 | return mountAt(fstab, "/", "/system_root"); | 53 | return mountAt(fstab, "/", "/system_root"); |
52 | } else { | 54 | } else { |
53 | return mountAt(fstab, "/system", "/system"); | 55 | return mountAt(fstab, "/system", "/system"); |
@@ -63,7 +65,7 @@ class RecoveryPartitionMounter : public PartitionMounter { | |||
63 | } | 65 | } |
64 | 66 | ||
65 | status_t umountSystem() const override { | 67 | status_t umountSystem() const override { |
66 | if (getPropertyFetcher().getBoolProperty("ro.build.system_root_image", false)) { | 68 | if (mPropertyFetcher->getBoolProperty("ro.build.system_root_image", false)) { |
67 | return umount("/system_root"); | 69 | return umount("/system_root"); |
68 | } else { | 70 | } else { |
69 | return umount("/system"); | 71 | return umount("/system"); |
@@ -73,6 +75,9 @@ class RecoveryPartitionMounter : public PartitionMounter { | |||
73 | status_t umountVendor() const override { | 75 | status_t umountVendor() const override { |
74 | return umount("/vendor"); | 76 | return umount("/vendor"); |
75 | } | 77 | } |
78 | |||
79 | private: | ||
80 | PropertyFetcher* mPropertyFetcher{nullptr}; | ||
76 | }; | 81 | }; |
77 | 82 | ||
78 | } // namespace details | 83 | } // namespace details |
@@ -80,8 +85,12 @@ class RecoveryPartitionMounter : public PartitionMounter { | |||
80 | // static | 85 | // static |
81 | int32_t VintfObjectRecovery::CheckCompatibility( | 86 | int32_t VintfObjectRecovery::CheckCompatibility( |
82 | const std::vector<std::string> &xmls, std::string *error) { | 87 | const std::vector<std::string> &xmls, std::string *error) { |
83 | static details::RecoveryPartitionMounter mounter; | 88 | auto propertyFetcher = std::make_unique<details::PropertyFetcherImpl>(); |
84 | return details::checkCompatibility(xmls, true /* mount */, mounter, error); | 89 | auto mounter = std::make_unique<details::RecoveryPartitionMounter>(propertyFetcher.get()); |
90 | auto vintfObject = std::make_unique<VintfObject>(nullptr /* fileSystem */, std::move(mounter), | ||
91 | nullptr /* runtime info factory */, | ||
92 | std::move(propertyFetcher)); | ||
93 | return vintfObject->checkCompatibility(xmls, true /* mount */, error); | ||
85 | } | 94 | } |
86 | 95 | ||
87 | 96 | ||