Tao Bao | 641fa97 | 2018-04-25 18:59:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | #ifndef _OTAUTIL_PATHS_H_ |
| 18 | #define _OTAUTIL_PATHS_H_ |
| 19 | |
| 20 | #include <string> |
| 21 | |
| 22 | #include <android-base/macros.h> |
| 23 | |
| 24 | // A singleton class to maintain the update related paths. The paths should be only set once at the |
| 25 | // start of the program. |
| 26 | class Paths { |
| 27 | public: |
| 28 | static Paths& Get(); |
| 29 | |
| 30 | std::string cache_log_directory() const { |
| 31 | return cache_log_directory_; |
| 32 | } |
| 33 | void set_cache_log_directory(const std::string& log_dir) { |
| 34 | cache_log_directory_ = log_dir; |
| 35 | } |
| 36 | |
| 37 | std::string cache_temp_source() const { |
| 38 | return cache_temp_source_; |
| 39 | } |
| 40 | void set_cache_temp_source(const std::string& temp_source) { |
| 41 | cache_temp_source_ = temp_source; |
| 42 | } |
| 43 | |
| 44 | std::string last_command_file() const { |
| 45 | return last_command_file_; |
| 46 | } |
| 47 | void set_last_command_file(const std::string& last_command_file) { |
| 48 | last_command_file_ = last_command_file; |
| 49 | } |
| 50 | |
| 51 | std::string stash_directory_base() const { |
| 52 | return stash_directory_base_; |
| 53 | } |
| 54 | void set_stash_directory_base(const std::string& base) { |
| 55 | stash_directory_base_ = base; |
| 56 | } |
| 57 | |
| 58 | std::string temporary_install_file() const { |
| 59 | return temporary_install_file_; |
| 60 | } |
| 61 | void set_temporary_install_file(const std::string& install_file) { |
| 62 | temporary_install_file_ = install_file; |
| 63 | } |
| 64 | |
| 65 | std::string temporary_log_file() const { |
| 66 | return temporary_log_file_; |
| 67 | } |
| 68 | void set_temporary_log_file(const std::string& log_file) { |
| 69 | temporary_log_file_ = log_file; |
| 70 | } |
| 71 | |
| 72 | private: |
| 73 | Paths(); |
| 74 | DISALLOW_COPY_AND_ASSIGN(Paths); |
| 75 | |
| 76 | // Path to the directory that contains last_log and last_kmsg log files. |
| 77 | std::string cache_log_directory_; |
| 78 | |
| 79 | // Path to the temporary source file on /cache. When there isn't enough room on the target |
| 80 | // filesystem to hold the patched version of the file, we copy the original here and delete it to |
| 81 | // free up space. If the expected source file doesn't exist, or is corrupted, we look to see if |
| 82 | // the cached file contains the bits we want and use it as the source instead. |
| 83 | std::string cache_temp_source_; |
| 84 | |
| 85 | // Path to the last command file. |
| 86 | std::string last_command_file_; |
| 87 | |
| 88 | // Path to the base directory to write stashes during update. |
| 89 | std::string stash_directory_base_; |
| 90 | |
| 91 | // Path to the temporary file that contains the install result. |
| 92 | std::string temporary_install_file_; |
| 93 | |
| 94 | // Path to the temporary log file while under recovery. |
| 95 | std::string temporary_log_file_; |
| 96 | }; |
| 97 | |
| 98 | #endif // _OTAUTIL_PATHS_H_ |