| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2015 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 | // This module abstracts the properties tied to the current running image. These | 
|  | 18 | // properties are meant to be constant during the life of this daemon, but can | 
|  | 19 | // be modified in dev-move or non-official builds. | 
|  | 20 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 21 | #ifndef UPDATE_ENGINE_CROS_IMAGE_PROPERTIES_H_ | 
|  | 22 | #define UPDATE_ENGINE_CROS_IMAGE_PROPERTIES_H_ | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 23 |  | 
|  | 24 | #include <string> | 
|  | 25 |  | 
|  | 26 | namespace chromeos_update_engine { | 
|  | 27 |  | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 28 | // The read-only system properties of the running image. | 
|  | 29 | struct ImageProperties { | 
|  | 30 | // The product id of the image used for all channels, except canary. | 
|  | 31 | std::string product_id; | 
|  | 32 | // The canary-channel product id. | 
|  | 33 | std::string canary_product_id; | 
|  | 34 |  | 
|  | 35 | // The product version of this image. | 
|  | 36 | std::string version; | 
|  | 37 |  | 
| Sen Jiang | 684c9cd | 2017-10-17 16:26:45 -0700 | [diff] [blame] | 38 | // The version of all product components in key values pairs. | 
|  | 39 | std::string product_components; | 
|  | 40 |  | 
| Alex Deymo | ebf6e12 | 2017-03-10 16:12:01 -0800 | [diff] [blame] | 41 | // A unique string that identifies this build. Normally a combination of the | 
|  | 42 | // the version, signing keys and build target. | 
|  | 43 | std::string build_fingerprint; | 
|  | 44 |  | 
| Sen Jiang | 1d5d95f | 2017-05-19 11:33:10 -0700 | [diff] [blame] | 45 | // The Android build type, should be either 'user', 'userdebug' or 'eng'. | 
|  | 46 | // It's empty string on other platform. | 
|  | 47 | std::string build_type; | 
|  | 48 |  | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 49 | // The board name this image was built for. | 
|  | 50 | std::string board; | 
|  | 51 |  | 
|  | 52 | // The release channel this image was obtained from. | 
|  | 53 | std::string current_channel; | 
|  | 54 |  | 
| Sen Jiang | 7f785f5 | 2018-01-24 13:31:56 -0800 | [diff] [blame] | 55 | // Whether we allow arbitrary channels instead of just the ones listed in | 
|  | 56 | // kChannelsByStability. | 
|  | 57 | bool allow_arbitrary_channels = false; | 
|  | 58 |  | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 59 | // The Omaha URL this image should get updates from. | 
|  | 60 | std::string omaha_url; | 
|  | 61 | }; | 
|  | 62 |  | 
|  | 63 | // The mutable image properties are read-write image properties, initialized | 
|  | 64 | // with values from the image but can be modified by storing them in the | 
|  | 65 | // stateful partition. | 
|  | 66 | struct MutableImageProperties { | 
|  | 67 | // The release channel we are tracking. | 
|  | 68 | std::string target_channel; | 
|  | 69 |  | 
|  | 70 | // Whether powerwash is allowed when downloading an update for the selected | 
|  | 71 | // target_channel. | 
|  | 72 | bool is_powerwash_allowed{false}; | 
|  | 73 | }; | 
|  | 74 |  | 
|  | 75 | // Loads all the image properties from the running system. In case of error | 
|  | 76 | // loading any of these properties from the read-only system image a default | 
|  | 77 | // value may be returned instead. | 
| Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 78 | ImageProperties LoadImageProperties(); | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 79 |  | 
| Amin Hassani | afd8cea | 2017-12-04 14:20:00 -0800 | [diff] [blame] | 80 | // Loads the mutable image properties from the stateful partition if found or | 
|  | 81 | // the system image otherwise. | 
| Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 82 | MutableImageProperties LoadMutableImageProperties(); | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 83 |  | 
|  | 84 | // Stores the mutable image properties in the stateful partition. Returns | 
|  | 85 | // whether the operation succeeded. | 
| Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 86 | bool StoreMutableImageProperties(const MutableImageProperties& properties); | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 87 |  | 
| Amin Hassani | afd8cea | 2017-12-04 14:20:00 -0800 | [diff] [blame] | 88 | // Logs the image properties. | 
|  | 89 | void LogImageProperties(); | 
|  | 90 |  | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 91 | // Sets the root_prefix used to load files from during unittests to | 
| Alex Deymo | 3be05c8 | 2015-10-23 11:29:11 -0700 | [diff] [blame] | 92 | // |test_root_prefix|. Passing a nullptr value resets it to the default. | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 93 | namespace test { | 
|  | 94 | void SetImagePropertiesRootPrefix(const char* test_root_prefix); | 
|  | 95 | }  // namespace test | 
|  | 96 |  | 
|  | 97 | }  // namespace chromeos_update_engine | 
|  | 98 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 99 | #endif  // UPDATE_ENGINE_CROS_IMAGE_PROPERTIES_H_ |