• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #ifndef UPDATE_ENGINE_IMAGE_PROPERTIES_H_
22 #define UPDATE_ENGINE_IMAGE_PROPERTIES_H_
23 
24 #include <string>
25 
26 namespace chromeos_update_engine {
27 
28 class SystemState;
29 
30 // The read-only system properties of the running image.
31 struct ImageProperties {
32   // The product id of the image used for all channels, except canary.
33   std::string product_id;
34   // The canary-channel product id.
35   std::string canary_product_id;
36   // The system id for the Android Things SoM, empty for Chrome OS.
37   std::string system_id;
38 
39   // The product version of this image.
40   std::string version;
41   // The system version of this image.
42   std::string system_version;
43 
44   // The version of all product components in key values pairs.
45   std::string product_components;
46 
47   // A unique string that identifies this build. Normally a combination of the
48   // the version, signing keys and build target.
49   std::string build_fingerprint;
50 
51   // The Android build type, should be either 'user', 'userdebug' or 'eng'.
52   // It's empty string on other platform.
53   std::string build_type;
54 
55   // The board name this image was built for.
56   std::string board;
57 
58   // The release channel this image was obtained from.
59   std::string current_channel;
60 
61   // Whether we allow arbitrary channels instead of just the ones listed in
62   // kChannelsByStability.
63   bool allow_arbitrary_channels = false;
64 
65   // The Omaha URL this image should get updates from.
66   std::string omaha_url;
67 };
68 
69 // The mutable image properties are read-write image properties, initialized
70 // with values from the image but can be modified by storing them in the
71 // stateful partition.
72 struct MutableImageProperties {
73   // The release channel we are tracking.
74   std::string target_channel;
75 
76   // Whether powerwash is allowed when downloading an update for the selected
77   // target_channel.
78   bool is_powerwash_allowed{false};
79 };
80 
81 // Loads all the image properties from the running system. In case of error
82 // loading any of these properties from the read-only system image a default
83 // value may be returned instead.
84 ImageProperties LoadImageProperties(SystemState* system_state);
85 
86 // Loads the mutable image properties from the stateful partition if found or
87 // the system image otherwise.
88 MutableImageProperties LoadMutableImageProperties(SystemState* system_state);
89 
90 // Stores the mutable image properties in the stateful partition. Returns
91 // whether the operation succeeded.
92 bool StoreMutableImageProperties(SystemState* system_state,
93                                  const MutableImageProperties& properties);
94 
95 // Logs the image properties.
96 void LogImageProperties();
97 
98 // Sets the root_prefix used to load files from during unittests to
99 // |test_root_prefix|. Passing a nullptr value resets it to the default.
100 namespace test {
101 void SetImagePropertiesRootPrefix(const char* test_root_prefix);
102 }  // namespace test
103 
104 }  // namespace chromeos_update_engine
105 
106 #endif  // UPDATE_ENGINE_IMAGE_PROPERTIES_H_
107