Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame^] | 5 | #ifndef UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |
| 6 | #define UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 10 | #include <base/basictypes.h> |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 11 | #include <base/time/time.h> |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 12 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 13 | |
| 14 | // This gathers local system information and prepares info used by the |
| 15 | // Omaha request action. |
| 16 | |
| 17 | namespace chromeos_update_engine { |
| 18 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 19 | // The default "official" Omaha update URL. |
| 20 | extern const char* const kProductionOmahaUrl; |
| 21 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 22 | class SystemState; |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 23 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 24 | // This class encapsulates the data Omaha gets for the request, along with |
| 25 | // essential state needed for the processing of the request/response. The |
| 26 | // strings in this struct should not be XML escaped. |
| 27 | // |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 28 | // TODO(jaysri): chromium-os:39752 tracks the need to rename this class to |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 29 | // reflect its lifetime more appropriately. |
| 30 | class OmahaRequestParams { |
| 31 | public: |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 32 | explicit OmahaRequestParams(SystemState* system_state) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 33 | : system_state_(system_state), |
| 34 | os_platform_(kOsPlatform), |
| 35 | os_version_(kOsVersion), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 36 | board_app_id_(kAppId), |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 37 | canary_app_id_(kAppId), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 38 | delta_okay_(true), |
| 39 | interactive_(false), |
| 40 | update_disabled_(false), |
| 41 | wall_clock_based_wait_enabled_(false), |
| 42 | update_check_count_wait_enabled_(false), |
| 43 | min_update_checks_needed_(kDefaultMinUpdateChecks), |
| 44 | max_update_checks_allowed_(kDefaultMaxUpdateChecks), |
| 45 | is_powerwash_allowed_(false), |
| 46 | force_lock_down_(false), |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 47 | forced_lock_down_(false), |
| 48 | use_p2p_for_downloading_(false), |
| 49 | use_p2p_for_sharing_(false) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 50 | InitFromLsbValue(); |
| 51 | } |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 52 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 53 | OmahaRequestParams(SystemState* system_state, |
| 54 | const std::string& in_os_platform, |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 55 | const std::string& in_os_version, |
| 56 | const std::string& in_os_sp, |
| 57 | const std::string& in_os_board, |
| 58 | const std::string& in_app_id, |
| 59 | const std::string& in_app_version, |
| 60 | const std::string& in_app_lang, |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 61 | const std::string& in_target_channel, |
| 62 | const std::string& in_hwid, |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 63 | const std::string& in_fw_version, |
| 64 | const std::string& in_ec_version, |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 65 | bool in_delta_okay, |
Gilad Arnold | bbdd490 | 2013-01-10 16:06:30 -0800 | [diff] [blame] | 66 | bool in_interactive, |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 67 | const std::string& in_update_url, |
| 68 | bool in_update_disabled, |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 69 | const std::string& in_target_version_prefix, |
| 70 | bool in_use_p2p_for_downloading, |
| 71 | bool in_use_p2p_for_sharing) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 72 | : system_state_(system_state), |
| 73 | os_platform_(in_os_platform), |
| 74 | os_version_(in_os_version), |
| 75 | os_sp_(in_os_sp), |
| 76 | os_board_(in_os_board), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 77 | board_app_id_(in_app_id), |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 78 | canary_app_id_(in_app_id), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 79 | app_version_(in_app_version), |
| 80 | app_lang_(in_app_lang), |
| 81 | current_channel_(in_target_channel), |
| 82 | target_channel_(in_target_channel), |
| 83 | hwid_(in_hwid), |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 84 | fw_version_(in_fw_version), |
| 85 | ec_version_(in_ec_version), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 86 | delta_okay_(in_delta_okay), |
| 87 | interactive_(in_interactive), |
| 88 | update_url_(in_update_url), |
| 89 | update_disabled_(in_update_disabled), |
| 90 | target_version_prefix_(in_target_version_prefix), |
| 91 | wall_clock_based_wait_enabled_(false), |
| 92 | update_check_count_wait_enabled_(false), |
| 93 | min_update_checks_needed_(kDefaultMinUpdateChecks), |
| 94 | max_update_checks_allowed_(kDefaultMaxUpdateChecks), |
| 95 | is_powerwash_allowed_(false), |
| 96 | force_lock_down_(false), |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 97 | forced_lock_down_(false), |
| 98 | use_p2p_for_downloading_(in_use_p2p_for_downloading), |
| 99 | use_p2p_for_sharing_(in_use_p2p_for_sharing) {} |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 100 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 101 | // Setters and getters for the various properties. |
| 102 | inline std::string os_platform() const { return os_platform_; } |
| 103 | inline std::string os_version() const { return os_version_; } |
| 104 | inline std::string os_sp() const { return os_sp_; } |
| 105 | inline std::string os_board() const { return os_board_; } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 106 | inline std::string board_app_id() const { return board_app_id_; } |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 107 | inline std::string canary_app_id() const { return canary_app_id_; } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 108 | inline std::string app_lang() const { return app_lang_; } |
| 109 | inline std::string hwid() const { return hwid_; } |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 110 | inline std::string fw_version() const { return fw_version_; } |
| 111 | inline std::string ec_version() const { return ec_version_; } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 112 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 113 | inline void set_app_version(const std::string& version) { |
| 114 | app_version_ = version; |
| 115 | } |
| 116 | inline std::string app_version() const { return app_version_; } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 117 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 118 | inline std::string current_channel() const { return current_channel_; } |
| 119 | inline std::string target_channel() const { return target_channel_; } |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 120 | inline std::string download_channel() const { return download_channel_; } |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 121 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 122 | // Can client accept a delta ? |
| 123 | inline void set_delta_okay(bool ok) { delta_okay_ = ok; } |
| 124 | inline bool delta_okay() const { return delta_okay_; } |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 125 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 126 | // True if this is a user-initiated update check. |
Chris Sosa | 968d057 | 2013-08-23 14:46:02 -0700 | [diff] [blame] | 127 | inline void set_interactive(bool interactive) { interactive_ = interactive; } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 128 | inline bool interactive() const { return interactive_; } |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 129 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 130 | inline void set_update_url(const std::string& url) { update_url_ = url; } |
| 131 | inline std::string update_url() const { return update_url_; } |
| 132 | |
| 133 | inline void set_update_disabled(bool disabled) { |
| 134 | update_disabled_ = disabled; |
| 135 | } |
| 136 | inline bool update_disabled() const { return update_disabled_; } |
| 137 | |
| 138 | inline void set_target_version_prefix(const std::string& prefix) { |
| 139 | target_version_prefix_ = prefix; |
| 140 | } |
| 141 | |
| 142 | inline std::string target_version_prefix() const { |
| 143 | return target_version_prefix_; |
| 144 | } |
| 145 | |
| 146 | inline void set_wall_clock_based_wait_enabled(bool enabled) { |
| 147 | wall_clock_based_wait_enabled_ = enabled; |
| 148 | } |
| 149 | inline bool wall_clock_based_wait_enabled() const { |
| 150 | return wall_clock_based_wait_enabled_; |
| 151 | } |
| 152 | |
| 153 | inline void set_waiting_period(base::TimeDelta period) { |
| 154 | waiting_period_ = period; |
| 155 | } |
| 156 | base::TimeDelta waiting_period() const { return waiting_period_; } |
| 157 | |
| 158 | inline void set_update_check_count_wait_enabled(bool enabled) { |
| 159 | update_check_count_wait_enabled_ = enabled; |
| 160 | } |
| 161 | |
| 162 | inline bool update_check_count_wait_enabled() const { |
| 163 | return update_check_count_wait_enabled_; |
| 164 | } |
| 165 | |
| 166 | inline void set_min_update_checks_needed(int64 min) { |
| 167 | min_update_checks_needed_ = min; |
| 168 | } |
| 169 | inline int64 min_update_checks_needed() const { |
| 170 | return min_update_checks_needed_; |
| 171 | } |
| 172 | |
| 173 | inline void set_max_update_checks_allowed(int64 max) { |
| 174 | max_update_checks_allowed_ = max; |
| 175 | } |
| 176 | inline int64 max_update_checks_allowed() const { |
| 177 | return max_update_checks_allowed_; |
| 178 | } |
| 179 | |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 180 | inline void set_use_p2p_for_downloading(bool value) { |
| 181 | use_p2p_for_downloading_ = value; |
| 182 | } |
| 183 | inline bool use_p2p_for_downloading() const { |
| 184 | return use_p2p_for_downloading_; |
| 185 | } |
| 186 | |
| 187 | inline void set_use_p2p_for_sharing(bool value) { |
| 188 | use_p2p_for_sharing_ = value; |
| 189 | } |
| 190 | inline bool use_p2p_for_sharing() const { |
| 191 | return use_p2p_for_sharing_; |
| 192 | } |
| 193 | |
| 194 | inline void set_p2p_url(const std::string& value) { |
| 195 | p2p_url_ = value; |
| 196 | } |
| 197 | inline std::string p2p_url() const { |
| 198 | return p2p_url_; |
| 199 | } |
| 200 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 201 | // True if we're trying to update to a more stable channel. |
| 202 | // i.e. index(target_channel) > index(current_channel). |
| 203 | bool to_more_stable_channel() const; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 204 | |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 205 | // Returns the app id corresponding to the current value of the |
| 206 | // download channel. |
| 207 | std::string GetAppId() const; |
| 208 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 209 | // Suggested defaults |
| 210 | static const char* const kAppId; |
| 211 | static const char* const kOsPlatform; |
| 212 | static const char* const kOsVersion; |
| 213 | static const char* const kUpdateUrl; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 214 | static const char* const kUpdateChannelKey; |
| 215 | static const char* const kIsPowerwashAllowedKey; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 216 | static const int64 kDefaultMinUpdateChecks = 0; |
| 217 | static const int64 kDefaultMaxUpdateChecks = 8; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 218 | |
Darin Petkov | 5a7f565 | 2010-07-22 21:40:09 -0700 | [diff] [blame] | 219 | // Initializes all the data in the object. Non-empty |
| 220 | // |in_app_version| or |in_update_url| prevents automatic detection |
| 221 | // of the parameter. Returns true on success, false otherwise. |
| 222 | bool Init(const std::string& in_app_version, |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 223 | const std::string& in_update_url, |
Gilad Arnold | bbdd490 | 2013-01-10 16:06:30 -0800 | [diff] [blame] | 224 | bool in_interactive); |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 225 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 226 | // Permanently changes the release channel to |channel|. Performs a |
| 227 | // powerwash, if required and allowed. |
| 228 | // Returns true on success, false otherwise. Note: This call will fail if |
| 229 | // there's a channel change pending already. This is to serialize all the |
| 230 | // channel changes done by the user in order to avoid having to solve |
| 231 | // numerous edge cases around ensuring the powerwash happens as intended in |
| 232 | // all such cases. |
| 233 | bool SetTargetChannel(const std::string& channel, bool is_powerwash_allowed); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 234 | |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 235 | // Updates the download channel for this particular attempt from the current |
| 236 | // value of target channel. This method takes a "snapshot" of the current |
| 237 | // value of target channel and uses it for all subsequent Omaha requests for |
| 238 | // this attempt (i.e. initial request as well as download progress/error |
| 239 | // event requests). The snapshot will be updated only when either this method |
| 240 | // or Init is called again. |
| 241 | void UpdateDownloadChannel(); |
| 242 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 243 | bool is_powerwash_allowed() const { return is_powerwash_allowed_; } |
Satoru Takabayashi | 583667b | 2010-10-27 13:09:57 +0900 | [diff] [blame] | 244 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 245 | // For unit-tests. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 246 | void set_root(const std::string& root); |
Chris Sosa | 28e479c | 2013-07-12 11:39:53 -0700 | [diff] [blame] | 247 | void set_current_channel(const std::string& channel) { |
| 248 | current_channel_ = channel; |
| 249 | } |
Gilad Arnold | 76b2b48 | 2014-04-01 13:32:43 -0700 | [diff] [blame] | 250 | void set_target_channel(const std::string& channel) { |
| 251 | target_channel_ = channel; |
| 252 | } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 253 | |
Darin Petkov | 10d02dd | 2011-01-10 14:57:39 -0800 | [diff] [blame] | 254 | // Enforce security mode for testing purposes. |
| 255 | void SetLockDown(bool lock); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 256 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 257 | private: |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 258 | FRIEND_TEST(OmahaRequestParamsTest, IsValidChannelTest); |
| 259 | FRIEND_TEST(OmahaRequestParamsTest, ShouldLockDownTest); |
| 260 | FRIEND_TEST(OmahaRequestParamsTest, ChannelIndexTest); |
| 261 | FRIEND_TEST(OmahaRequestParamsTest, LsbPreserveTest); |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 262 | FRIEND_TEST(OmahaRequestParamsTest, CollectECFWVersionsTest); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 263 | |
| 264 | // Use a validator that is a non-static member of this class so that its |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 265 | // inputs can be mocked in unit tests (e.g., build type for IsValidChannel). |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame^] | 266 | typedef bool( |
| 267 | OmahaRequestParams::*ValueValidator)( // NOLINT(readability/casting) |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 268 | const std::string&) const; |
| 269 | |
Darin Petkov | 10d02dd | 2011-01-10 14:57:39 -0800 | [diff] [blame] | 270 | // Returns true if parameter values should be locked down for security |
| 271 | // reasons. If this is an official build running in normal boot mode, all |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 272 | // values except the release channel are parsed only from the read-only rootfs |
| 273 | // partition and the channel values are restricted to a pre-approved set. |
Darin Petkov | 10d02dd | 2011-01-10 14:57:39 -0800 | [diff] [blame] | 274 | bool ShouldLockDown() const; |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 275 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 276 | // Returns true if |channel| is a valid channel, false otherwise. This method |
| 277 | // restricts the channel value only if the image is official (see |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 278 | // IsOfficialBuild). |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 279 | bool IsValidChannel(const std::string& channel) const; |
| 280 | |
| 281 | // Returns the index of the given channel. |
| 282 | int GetChannelIndex(const std::string& channel) const; |
| 283 | |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 284 | // Returns True if we should store the fw/ec versions based on our hwid_. |
| 285 | // Compares hwid to a set of whitelisted prefixes. |
| 286 | bool CollectECFWVersions() const; |
| 287 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 288 | // These are individual helper methods to initialize the said properties from |
| 289 | // the LSB value. |
| 290 | void SetTargetChannelFromLsbValue(); |
| 291 | void SetCurrentChannelFromLsbValue(); |
| 292 | void SetIsPowerwashAllowedFromLsbValue(); |
| 293 | |
| 294 | // Initializes the required properties from the LSB value. |
| 295 | void InitFromLsbValue(); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 296 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 297 | // Fetches the value for a given key from |
Darin Petkov | a3df55b | 2010-11-15 13:33:55 -0800 | [diff] [blame] | 298 | // /mnt/stateful_partition/etc/lsb-release if possible and |stateful_override| |
| 299 | // is true. Failing that, it looks for the key in /etc/lsb-release. If |
| 300 | // |validator| is non-NULL, uses it to validate and ignore invalid valies. |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 301 | std::string GetLsbValue(const std::string& key, |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 302 | const std::string& default_value, |
Darin Petkov | a3df55b | 2010-11-15 13:33:55 -0800 | [diff] [blame] | 303 | ValueValidator validator, |
| 304 | bool stateful_override) const; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 305 | |
| 306 | // Gets the machine type (e.g. "i686"). |
| 307 | std::string GetMachineType() const; |
| 308 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 309 | // Global system context. |
| 310 | SystemState* system_state_; |
| 311 | |
| 312 | // Basic properties of the OS and Application that go into the Omaha request. |
| 313 | std::string os_platform_; |
| 314 | std::string os_version_; |
| 315 | std::string os_sp_; |
| 316 | std::string os_board_; |
| 317 | |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 318 | // The board app id identifies the app id for the board irrespective of the |
| 319 | // channel that we're on. The canary app id identifies the app id to be used |
| 320 | // iff we're in the canary-channel. These values could be different depending |
| 321 | // on how the release tools are implemented. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 322 | std::string board_app_id_; |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 323 | std::string canary_app_id_; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 324 | |
| 325 | std::string app_version_; |
| 326 | std::string app_lang_; |
| 327 | |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 328 | // The three channel values we deal with. |
| 329 | // Current channel: is always the channel from /etc/lsb-release. It never |
| 330 | // changes. It's just read in during initialization. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 331 | std::string current_channel_; |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 332 | |
| 333 | // Target channel: It starts off with the value of current channel. But if |
| 334 | // the user changes the channel, then it'll have a different value. If the |
| 335 | // user changes multiple times, target channel will always contain the most |
| 336 | // recent change and is updated immediately to the user-selected value even |
| 337 | // if we're in the middle of a download (as opposed to download channel |
| 338 | // which gets updated only at the start of next download) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 339 | std::string target_channel_; |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 340 | |
| 341 | // The channel from which we're downloading the payload. This should normally |
| 342 | // be the same as target channel. But if the user made another channel change |
| 343 | // we started the download, then they'd be different, in which case, we'd |
| 344 | // detect elsewhere that the target channel has been changed and cancel the |
| 345 | // current download attempt. |
| 346 | std::string download_channel_; |
| 347 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 348 | std::string hwid_; // Hardware Qualification ID of the client |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 349 | std::string fw_version_; // Chrome OS Firmware Version. |
| 350 | std::string ec_version_; // Chrome OS EC Version. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 351 | bool delta_okay_; // If this client can accept a delta |
| 352 | bool interactive_; // Whether this is a user-initiated update check |
| 353 | |
| 354 | // The URL to send the Omaha request to. |
| 355 | std::string update_url_; |
| 356 | |
| 357 | // True if we've been told to block updates per enterprise policy. |
| 358 | bool update_disabled_; |
| 359 | |
| 360 | // Prefix of the target OS version that the enterprise wants this device |
| 361 | // to be pinned to. It's empty otherwise. |
| 362 | std::string target_version_prefix_; |
| 363 | |
| 364 | // True if scattering is enabled, in which case waiting_period_ specifies the |
| 365 | // amount of absolute time that we've to wait for before sending a request to |
| 366 | // Omaha. |
| 367 | bool wall_clock_based_wait_enabled_; |
| 368 | base::TimeDelta waiting_period_; |
| 369 | |
| 370 | // True if scattering is enabled to denote the number of update checks |
| 371 | // we've to skip before we can send a request to Omaha. The min and max |
| 372 | // values establish the bounds for a random number to be chosen within that |
| 373 | // range to enable such a wait. |
| 374 | bool update_check_count_wait_enabled_; |
| 375 | int64 min_update_checks_needed_; |
| 376 | int64 max_update_checks_allowed_; |
| 377 | |
| 378 | // True if we are allowed to do powerwash, if required, on a channel change. |
| 379 | bool is_powerwash_allowed_; |
| 380 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 381 | // When reading files, prepend root_ to the paths. Useful for testing. |
| 382 | std::string root_; |
| 383 | |
Darin Petkov | 10d02dd | 2011-01-10 14:57:39 -0800 | [diff] [blame] | 384 | // Force security lock down for testing purposes. |
| 385 | bool force_lock_down_; |
| 386 | bool forced_lock_down_; |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 387 | |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 388 | // True if we may use p2p to download. This is based on owner |
| 389 | // preferences and policy. |
| 390 | bool use_p2p_for_downloading_; |
| 391 | |
| 392 | // True if we may use p2p to share. This is based on owner |
| 393 | // preferences and policy. |
| 394 | bool use_p2p_for_sharing_; |
| 395 | |
| 396 | // An URL to a local peer serving the requested payload or "" if no |
| 397 | // such peer is available. |
| 398 | std::string p2p_url_; |
| 399 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 400 | // TODO(jaysri): Uncomment this after fixing unit tests, as part of |
| 401 | // chromium-os:39752 |
| 402 | // DISALLOW_COPY_AND_ASSIGN(OmahaRequestParams); |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | } // namespace chromeos_update_engine |
| 406 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame^] | 407 | #endif // UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |