summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2018-04-06 17:41:05 -0500
committerYifan Hong2018-04-10 14:20:17 -0500
commit10d862283d70ab48941b2dbd1226f139480ed27c (patch)
tree57c914e500bad374a316f2bac054828968b01774 /VintfObject.cpp
parent00611d5483de8ddee95c1b251f126c704f5270f7 (diff)
downloadplatform-system-libvintf-10d862283d70ab48941b2dbd1226f139480ed27c.tar.gz
platform-system-libvintf-10d862283d70ab48941b2dbd1226f139480ed27c.tar.xz
platform-system-libvintf-10d862283d70ab48941b2dbd1226f139480ed27c.zip
Cleanup global FileFetcherandroid-o-mr1-iot-preview-8
This global instance is modifiable everywhere and is hard to maintain. It also contains references as out-variables, which is not the standard. Clean it up by refactoring it into a public (i.e. not in details namespace) class, FileSystem. Introduce VintfObject::InitFileSystem that allows the behavior to be changed before any files are read. Bug: 37999212 Test: host and target libvintf_test, vintf_object_test Change-Id: I1c64b31fd37119450be89dfd1d2bfe76a71ccf3d Merged-In: I1c64b31fd37119450be89dfd1d2bfe76a71ccf3d
Diffstat (limited to 'VintfObject.cpp')
-rw-r--r--VintfObject.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 38ef0df..0e757ca 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -165,7 +165,7 @@ status_t VintfObject::GetCombinedFrameworkMatrix(
165status_t VintfObject::AddDirectoryManifests(const std::string& directory, HalManifest* manifest, 165status_t VintfObject::AddDirectoryManifests(const std::string& directory, HalManifest* manifest,
166 std::string* error) { 166 std::string* error) {
167 std::vector<std::string> fileNames; 167 std::vector<std::string> fileNames;
168 status_t err = details::gFetcher->listFiles(directory, &fileNames, error); 168 status_t err = details::getFileSystem().listFiles(directory, &fileNames, error);
169 // if the directory isn't there, that's okay 169 // if the directory isn't there, that's okay
170 if (err == NAME_NOT_FOUND) return OK; 170 if (err == NAME_NOT_FOUND) return OK;
171 if (err != OK) return err; 171 if (err != OK) return err;
@@ -304,7 +304,7 @@ std::vector<Named<CompatibilityMatrix>> VintfObject::GetAllFrameworkMatrixLevels
304 std::vector<std::string> fileNames; 304 std::vector<std::string> fileNames;
305 std::vector<Named<CompatibilityMatrix>> results; 305 std::vector<Named<CompatibilityMatrix>> results;
306 306
307 if (details::gFetcher->listFiles(kSystemVintfDir, &fileNames, error) != OK) { 307 if (details::getFileSystem().listFiles(kSystemVintfDir, &fileNames, error) != OK) {
308 return {}; 308 return {};
309 } 309 }
310 for (const std::string& fileName : fileNames) { 310 for (const std::string& fileName : fileNames) {
@@ -312,7 +312,7 @@ std::vector<Named<CompatibilityMatrix>> VintfObject::GetAllFrameworkMatrixLevels
312 312
313 std::string content; 313 std::string content;
314 std::string fetchError; 314 std::string fetchError;
315 status_t status = details::gFetcher->fetch(path, content, &fetchError); 315 status_t status = details::getFileSystem().fetch(path, &content, &fetchError);
316 if (status != OK) { 316 if (status != OK) {
317 if (error) { 317 if (error) {
318 *error += "Framework Matrix: Ignore file " + path + ": " + fetchError + "\n"; 318 *error += "Framework Matrix: Ignore file " + path + ": " + fetchError + "\n";
@@ -753,5 +753,9 @@ int32_t VintfObject::CheckDeprecation(std::string* error) {
753 return CheckDeprecation(inManifest, error); 753 return CheckDeprecation(inManifest, error);
754} 754}
755 755
756bool VintfObject::InitFileSystem(std::unique_ptr<FileSystem>&& fileSystem) {
757 return details::initFileSystem(std::move(fileSystem));
758}
759
756} // namespace vintf 760} // namespace vintf
757} // namespace android 761} // namespace android