blob: 4957d12d60c823ae2e8049c26cd66b7d36a369fc [file] [log] [blame]
Alex Deymo85616652015-10-15 18:48:31 -07001//
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 Hassaniec7bc112020-10-29 16:47:58 -070021#ifndef UPDATE_ENGINE_CROS_IMAGE_PROPERTIES_H_
22#define UPDATE_ENGINE_CROS_IMAGE_PROPERTIES_H_
Alex Deymo85616652015-10-15 18:48:31 -070023
24#include <string>
25
26namespace chromeos_update_engine {
27
28class SystemState;
29
30// The read-only system properties of the running image.
31struct 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
37 // The product version of this image.
38 std::string version;
39
Sen Jiang684c9cd2017-10-17 16:26:45 -070040 // The version of all product components in key values pairs.
41 std::string product_components;
42
Alex Deymoebf6e122017-03-10 16:12:01 -080043 // A unique string that identifies this build. Normally a combination of the
44 // the version, signing keys and build target.
45 std::string build_fingerprint;
46
Sen Jiang1d5d95f2017-05-19 11:33:10 -070047 // The Android build type, should be either 'user', 'userdebug' or 'eng'.
48 // It's empty string on other platform.
49 std::string build_type;
50
Alex Deymo85616652015-10-15 18:48:31 -070051 // The board name this image was built for.
52 std::string board;
53
54 // The release channel this image was obtained from.
55 std::string current_channel;
56
Sen Jiang7f785f52018-01-24 13:31:56 -080057 // Whether we allow arbitrary channels instead of just the ones listed in
58 // kChannelsByStability.
59 bool allow_arbitrary_channels = false;
60
Alex Deymo85616652015-10-15 18:48:31 -070061 // The Omaha URL this image should get updates from.
62 std::string omaha_url;
63};
64
65// The mutable image properties are read-write image properties, initialized
66// with values from the image but can be modified by storing them in the
67// stateful partition.
68struct MutableImageProperties {
69 // The release channel we are tracking.
70 std::string target_channel;
71
72 // Whether powerwash is allowed when downloading an update for the selected
73 // target_channel.
74 bool is_powerwash_allowed{false};
75};
76
77// Loads all the image properties from the running system. In case of error
78// loading any of these properties from the read-only system image a default
79// value may be returned instead.
80ImageProperties LoadImageProperties(SystemState* system_state);
81
Amin Hassaniafd8cea2017-12-04 14:20:00 -080082// Loads the mutable image properties from the stateful partition if found or
83// the system image otherwise.
Alex Deymo85616652015-10-15 18:48:31 -070084MutableImageProperties LoadMutableImageProperties(SystemState* system_state);
85
86// Stores the mutable image properties in the stateful partition. Returns
87// whether the operation succeeded.
88bool StoreMutableImageProperties(SystemState* system_state,
89 const MutableImageProperties& properties);
90
Amin Hassaniafd8cea2017-12-04 14:20:00 -080091// Logs the image properties.
92void LogImageProperties();
93
Alex Deymo85616652015-10-15 18:48:31 -070094// Sets the root_prefix used to load files from during unittests to
Alex Deymo3be05c82015-10-23 11:29:11 -070095// |test_root_prefix|. Passing a nullptr value resets it to the default.
Alex Deymo85616652015-10-15 18:48:31 -070096namespace test {
97void SetImagePropertiesRootPrefix(const char* test_root_prefix);
98} // namespace test
99
100} // namespace chromeos_update_engine
101
Amin Hassaniec7bc112020-10-29 16:47:58 -0700102#endif // UPDATE_ENGINE_CROS_IMAGE_PROPERTIES_H_