From 3bbb20f557790c015e44098098375eb6cc376a42 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 27 Feb 2018 15:56:11 -0800 Subject: Add a singleton CacheLocation to replace the hard coded locations This class allows us to set the following locations dynamically: cache_temp_source, last_command_file, stash_directory_base. In the updater's main function, we reset the values of these variables to their default locations in /cache; while we can set them to temp files in unit tests or host simulation. Test: unit tests pass Change-Id: I528652650caa41373617ab055d41b1f1a4ec0f87 --- updater/updater.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'updater/updater.cpp') diff --git a/updater/updater.cpp b/updater/updater.cpp index f55a0d3bd..f063e5fa1 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -34,6 +34,7 @@ #include "otafault/config.h" #include "otautil/DirUtil.h" #include "otautil/SysUtil.h" +#include "otautil/cache_location.h" #include "otautil/error_code.h" #include "updater/blockimg.h" #include "updater/install.h" @@ -168,6 +169,10 @@ int main(int argc, char** argv) { } ota_io_init(za, state.is_retry); + // Initialize the cache_temp_source, last_command_file and stash_directory_base to their default + // locations. + CacheLocation::location().ResetLocations(); + std::string result; bool status = Evaluate(&state, root, &result); -- cgit v1.2.3