Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2012 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 | // |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 16 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |
| 18 | #define UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 19 | |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 22 | #include <string> |
| 23 | |
Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 24 | #include <base/macros.h> |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 25 | #include <base/time/time.h> |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 26 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 27 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 28 | #include "update_engine/common/platform_constants.h" |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 29 | #include "update_engine/image_properties.h" |
Alex Deymo | ac41a82 | 2015-09-15 20:52:53 -0700 | [diff] [blame] | 30 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 31 | // This gathers local system information and prepares info used by the |
| 32 | // Omaha request action. |
| 33 | |
| 34 | namespace chromeos_update_engine { |
| 35 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 36 | class SystemState; |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 37 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 38 | // This class encapsulates the data Omaha gets for the request, along with |
| 39 | // essential state needed for the processing of the request/response. The |
| 40 | // strings in this struct should not be XML escaped. |
| 41 | // |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 42 | // 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] | 43 | // reflect its lifetime more appropriately. |
| 44 | class OmahaRequestParams { |
| 45 | public: |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 46 | explicit OmahaRequestParams(SystemState* system_state) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 47 | : system_state_(system_state), |
Alex Deymo | ac41a82 | 2015-09-15 20:52:53 -0700 | [diff] [blame] | 48 | os_platform_(constants::kOmahaPlatformName), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 49 | os_version_(kOsVersion), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 50 | delta_okay_(true), |
| 51 | interactive_(false), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 52 | wall_clock_based_wait_enabled_(false), |
| 53 | update_check_count_wait_enabled_(false), |
| 54 | min_update_checks_needed_(kDefaultMinUpdateChecks), |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 55 | max_update_checks_allowed_(kDefaultMaxUpdateChecks) {} |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 56 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 57 | OmahaRequestParams(SystemState* system_state, |
| 58 | const std::string& in_os_platform, |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 59 | const std::string& in_os_version, |
| 60 | const std::string& in_os_sp, |
| 61 | const std::string& in_os_board, |
| 62 | const std::string& in_app_id, |
| 63 | const std::string& in_app_version, |
| 64 | const std::string& in_app_lang, |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 65 | const std::string& in_target_channel, |
| 66 | const std::string& in_hwid, |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 67 | const std::string& in_fw_version, |
| 68 | const std::string& in_ec_version, |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 69 | bool in_delta_okay, |
Gilad Arnold | bbdd490 | 2013-01-10 16:06:30 -0800 | [diff] [blame] | 70 | bool in_interactive, |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 71 | const std::string& in_update_url, |
Gilad Arnold | 74b5f55 | 2014-10-07 08:17:16 -0700 | [diff] [blame] | 72 | const std::string& in_target_version_prefix) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 73 | : system_state_(system_state), |
| 74 | os_platform_(in_os_platform), |
| 75 | os_version_(in_os_version), |
| 76 | os_sp_(in_os_sp), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 77 | app_lang_(in_app_lang), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 78 | hwid_(in_hwid), |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 79 | fw_version_(in_fw_version), |
| 80 | ec_version_(in_ec_version), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 81 | delta_okay_(in_delta_okay), |
| 82 | interactive_(in_interactive), |
| 83 | update_url_(in_update_url), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 84 | target_version_prefix_(in_target_version_prefix), |
| 85 | wall_clock_based_wait_enabled_(false), |
| 86 | update_check_count_wait_enabled_(false), |
| 87 | min_update_checks_needed_(kDefaultMinUpdateChecks), |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 88 | max_update_checks_allowed_(kDefaultMaxUpdateChecks) { |
| 89 | image_props_.board = in_os_board; |
| 90 | image_props_.product_id = in_app_id; |
| 91 | image_props_.canary_product_id = in_app_id; |
| 92 | image_props_.version = in_app_version; |
| 93 | image_props_.current_channel = in_target_channel; |
| 94 | mutable_image_props_.target_channel = in_target_channel; |
| 95 | mutable_image_props_.is_powerwash_allowed = false; |
| 96 | } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 97 | |
Alex Deymo | 3be05c8 | 2015-10-23 11:29:11 -0700 | [diff] [blame] | 98 | virtual ~OmahaRequestParams(); |
Alex Deymo | e894870 | 2014-11-11 21:44:45 -0800 | [diff] [blame] | 99 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 100 | // Setters and getters for the various properties. |
| 101 | inline std::string os_platform() const { return os_platform_; } |
| 102 | inline std::string os_version() const { return os_version_; } |
| 103 | inline std::string os_sp() const { return os_sp_; } |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 104 | inline std::string os_board() const { return image_props_.board; } |
Alex Deymo | ebf6e12 | 2017-03-10 16:12:01 -0800 | [diff] [blame] | 105 | inline std::string os_build_fingerprint() const { |
| 106 | return image_props_.build_fingerprint; |
| 107 | } |
Sen Jiang | 1d5d95f | 2017-05-19 11:33:10 -0700 | [diff] [blame] | 108 | inline std::string os_build_type() const { return image_props_.build_type; } |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 109 | inline std::string board_app_id() const { return image_props_.product_id; } |
| 110 | inline std::string canary_app_id() const { |
| 111 | return image_props_.canary_product_id; |
| 112 | } |
Sen Jiang | 94a4dec | 2017-03-28 18:23:35 -0700 | [diff] [blame] | 113 | inline std::string system_app_id() const { return image_props_.system_id; } |
Aaron Wood | 7dcdedf | 2017-09-06 17:17:41 -0700 | [diff] [blame] | 114 | inline void set_system_app_id(const std::string& system_app_id) { |
| 115 | image_props_.system_id = system_app_id; |
| 116 | } |
Sen Jiang | 297e583 | 2016-03-17 14:45:51 -0700 | [diff] [blame] | 117 | inline void set_app_id(const std::string& app_id) { |
| 118 | image_props_.product_id = app_id; |
| 119 | image_props_.canary_product_id = app_id; |
| 120 | } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 121 | inline std::string app_lang() const { return app_lang_; } |
| 122 | inline std::string hwid() const { return hwid_; } |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 123 | inline std::string fw_version() const { return fw_version_; } |
| 124 | inline std::string ec_version() const { return ec_version_; } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 125 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 126 | inline void set_app_version(const std::string& version) { |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 127 | image_props_.version = version; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 128 | } |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 129 | inline std::string app_version() const { return image_props_.version; } |
Sen Jiang | 94a4dec | 2017-03-28 18:23:35 -0700 | [diff] [blame] | 130 | inline std::string system_version() const { |
| 131 | return image_props_.system_version; |
| 132 | } |
Sen Jiang | 684c9cd | 2017-10-17 16:26:45 -0700 | [diff] [blame] | 133 | inline std::string product_components() const { |
| 134 | return image_props_.product_components; |
| 135 | } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 136 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 137 | inline std::string current_channel() const { |
| 138 | return image_props_.current_channel; |
| 139 | } |
| 140 | inline std::string target_channel() const { |
| 141 | return mutable_image_props_.target_channel; |
| 142 | } |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 143 | inline std::string download_channel() const { return download_channel_; } |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 144 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 145 | // Can client accept a delta ? |
| 146 | inline void set_delta_okay(bool ok) { delta_okay_ = ok; } |
| 147 | inline bool delta_okay() const { return delta_okay_; } |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 148 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 149 | // True if this is a user-initiated update check. |
Chris Sosa | 968d057 | 2013-08-23 14:46:02 -0700 | [diff] [blame] | 150 | inline void set_interactive(bool interactive) { interactive_ = interactive; } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 151 | inline bool interactive() const { return interactive_; } |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 152 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 153 | inline void set_update_url(const std::string& url) { update_url_ = url; } |
| 154 | inline std::string update_url() const { return update_url_; } |
| 155 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 156 | inline void set_target_version_prefix(const std::string& prefix) { |
| 157 | target_version_prefix_ = prefix; |
| 158 | } |
| 159 | |
| 160 | inline std::string target_version_prefix() const { |
| 161 | return target_version_prefix_; |
| 162 | } |
| 163 | |
| 164 | inline void set_wall_clock_based_wait_enabled(bool enabled) { |
| 165 | wall_clock_based_wait_enabled_ = enabled; |
| 166 | } |
| 167 | inline bool wall_clock_based_wait_enabled() const { |
| 168 | return wall_clock_based_wait_enabled_; |
| 169 | } |
| 170 | |
| 171 | inline void set_waiting_period(base::TimeDelta period) { |
| 172 | waiting_period_ = period; |
| 173 | } |
| 174 | base::TimeDelta waiting_period() const { return waiting_period_; } |
| 175 | |
| 176 | inline void set_update_check_count_wait_enabled(bool enabled) { |
| 177 | update_check_count_wait_enabled_ = enabled; |
| 178 | } |
| 179 | |
| 180 | inline bool update_check_count_wait_enabled() const { |
| 181 | return update_check_count_wait_enabled_; |
| 182 | } |
| 183 | |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 184 | inline void set_min_update_checks_needed(int64_t min) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 185 | min_update_checks_needed_ = min; |
| 186 | } |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 187 | inline int64_t min_update_checks_needed() const { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 188 | return min_update_checks_needed_; |
| 189 | } |
| 190 | |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 191 | inline void set_max_update_checks_allowed(int64_t max) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 192 | max_update_checks_allowed_ = max; |
| 193 | } |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 194 | inline int64_t max_update_checks_allowed() const { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 195 | return max_update_checks_allowed_; |
| 196 | } |
| 197 | |
| 198 | // True if we're trying to update to a more stable channel. |
| 199 | // i.e. index(target_channel) > index(current_channel). |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 200 | virtual bool to_more_stable_channel() const; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 201 | |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 202 | // Returns the app id corresponding to the current value of the |
| 203 | // download channel. |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 204 | virtual std::string GetAppId() const; |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 205 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 206 | // Suggested defaults |
David Pursell | 02c1864 | 2014-11-06 11:26:11 -0800 | [diff] [blame] | 207 | static const char kOsVersion[]; |
David Pursell | 02c1864 | 2014-11-06 11:26:11 -0800 | [diff] [blame] | 208 | static const char kIsPowerwashAllowedKey[]; |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 209 | static const int64_t kDefaultMinUpdateChecks = 0; |
| 210 | static const int64_t kDefaultMaxUpdateChecks = 8; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 211 | |
Darin Petkov | 5a7f565 | 2010-07-22 21:40:09 -0700 | [diff] [blame] | 212 | // Initializes all the data in the object. Non-empty |
| 213 | // |in_app_version| or |in_update_url| prevents automatic detection |
| 214 | // of the parameter. Returns true on success, false otherwise. |
| 215 | bool Init(const std::string& in_app_version, |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 216 | const std::string& in_update_url, |
Gilad Arnold | bbdd490 | 2013-01-10 16:06:30 -0800 | [diff] [blame] | 217 | bool in_interactive); |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 218 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 219 | // Permanently changes the release channel to |channel|. Performs a |
| 220 | // powerwash, if required and allowed. |
| 221 | // Returns true on success, false otherwise. Note: This call will fail if |
| 222 | // there's a channel change pending already. This is to serialize all the |
| 223 | // channel changes done by the user in order to avoid having to solve |
| 224 | // numerous edge cases around ensuring the powerwash happens as intended in |
| 225 | // all such cases. |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 226 | virtual bool SetTargetChannel(const std::string& channel, |
Alex Deymo | d942f9d | 2015-11-06 16:11:50 -0800 | [diff] [blame] | 227 | bool is_powerwash_allowed, |
| 228 | std::string* error_message); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 229 | |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 230 | // Updates the download channel for this particular attempt from the current |
| 231 | // value of target channel. This method takes a "snapshot" of the current |
| 232 | // value of target channel and uses it for all subsequent Omaha requests for |
| 233 | // this attempt (i.e. initial request as well as download progress/error |
| 234 | // event requests). The snapshot will be updated only when either this method |
| 235 | // or Init is called again. |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 236 | virtual void UpdateDownloadChannel(); |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 237 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 238 | virtual bool is_powerwash_allowed() const { |
| 239 | return mutable_image_props_.is_powerwash_allowed; |
| 240 | } |
Satoru Takabayashi | 583667b | 2010-10-27 13:09:57 +0900 | [diff] [blame] | 241 | |
David Pursell | 02c1864 | 2014-11-06 11:26:11 -0800 | [diff] [blame] | 242 | // Check if the provided update URL is official, meaning either the default |
| 243 | // autoupdate server or the autoupdate autotest server. |
| 244 | virtual bool IsUpdateUrlOfficial() const; |
| 245 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 246 | // For unit-tests. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 247 | void set_root(const std::string& root); |
Chris Sosa | 28e479c | 2013-07-12 11:39:53 -0700 | [diff] [blame] | 248 | void set_current_channel(const std::string& channel) { |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 249 | image_props_.current_channel = channel; |
Chris Sosa | 28e479c | 2013-07-12 11:39:53 -0700 | [diff] [blame] | 250 | } |
Gilad Arnold | 76b2b48 | 2014-04-01 13:32:43 -0700 | [diff] [blame] | 251 | void set_target_channel(const std::string& channel) { |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 252 | mutable_image_props_.target_channel = channel; |
Gilad Arnold | 76b2b48 | 2014-04-01 13:32:43 -0700 | [diff] [blame] | 253 | } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 254 | |
| 255 | private: |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 256 | FRIEND_TEST(OmahaRequestParamsTest, IsValidChannelTest); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 257 | FRIEND_TEST(OmahaRequestParamsTest, ChannelIndexTest); |
Sen Jiang | 297e583 | 2016-03-17 14:45:51 -0700 | [diff] [blame] | 258 | FRIEND_TEST(OmahaRequestParamsTest, ToMoreStableChannelFlagTest); |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 259 | FRIEND_TEST(OmahaRequestParamsTest, CollectECFWVersionsTest); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 260 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 261 | // Returns true if |channel| is a valid channel, false otherwise. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 262 | bool IsValidChannel(const std::string& channel) const; |
| 263 | |
| 264 | // Returns the index of the given channel. |
| 265 | int GetChannelIndex(const std::string& channel) const; |
| 266 | |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 267 | // Returns True if we should store the fw/ec versions based on our hwid_. |
| 268 | // Compares hwid to a set of whitelisted prefixes. |
| 269 | bool CollectECFWVersions() const; |
| 270 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 271 | // These are individual helper methods to initialize the said properties from |
| 272 | // the LSB value. |
| 273 | void SetTargetChannelFromLsbValue(); |
| 274 | void SetCurrentChannelFromLsbValue(); |
| 275 | void SetIsPowerwashAllowedFromLsbValue(); |
| 276 | |
| 277 | // Initializes the required properties from the LSB value. |
| 278 | void InitFromLsbValue(); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 279 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 280 | // Gets the machine type (e.g. "i686"). |
| 281 | std::string GetMachineType() const; |
| 282 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 283 | // Global system context. |
| 284 | SystemState* system_state_; |
| 285 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 286 | // The system image properties. |
| 287 | ImageProperties image_props_; |
| 288 | MutableImageProperties mutable_image_props_; |
| 289 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 290 | // Basic properties of the OS and Application that go into the Omaha request. |
| 291 | std::string os_platform_; |
| 292 | std::string os_version_; |
| 293 | std::string os_sp_; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 294 | std::string app_lang_; |
| 295 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 296 | // There are three channel values we deal with: |
| 297 | // * The channel we got the image we are running from or "current channel" |
| 298 | // stored in |image_props_.current_channel|. |
| 299 | // |
| 300 | // * The release channel we are tracking, where we should get updates from, |
| 301 | // stored in |mutable_image_props_.target_channel|. This channel is |
| 302 | // normally the same as the current_channel, except when the user changes |
| 303 | // the channel. In that case it'll have the release channel the user |
| 304 | // switched to, regardless of whether we downloaded an update from that |
| 305 | // channel or not, or if we are in the middle of a download from a |
| 306 | // previously selected channel (as opposed to download channel |
| 307 | // which gets updated only at the start of next download). |
| 308 | // |
| 309 | // * The channel from which we're downloading the payload. This should |
| 310 | // normally be the same as target channel. But if the user made another |
| 311 | // channel change after we started the download, then they'd be different, |
| 312 | // in which case, we'd detect elsewhere that the target channel has been |
| 313 | // changed and cancel the current download attempt. |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 314 | std::string download_channel_; |
| 315 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 316 | std::string hwid_; // Hardware Qualification ID of the client |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 317 | std::string fw_version_; // Chrome OS Firmware Version. |
| 318 | std::string ec_version_; // Chrome OS EC Version. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 319 | bool delta_okay_; // If this client can accept a delta |
| 320 | bool interactive_; // Whether this is a user-initiated update check |
| 321 | |
| 322 | // The URL to send the Omaha request to. |
| 323 | std::string update_url_; |
| 324 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 325 | // Prefix of the target OS version that the enterprise wants this device |
| 326 | // to be pinned to. It's empty otherwise. |
| 327 | std::string target_version_prefix_; |
| 328 | |
| 329 | // True if scattering is enabled, in which case waiting_period_ specifies the |
| 330 | // amount of absolute time that we've to wait for before sending a request to |
| 331 | // Omaha. |
| 332 | bool wall_clock_based_wait_enabled_; |
| 333 | base::TimeDelta waiting_period_; |
| 334 | |
| 335 | // True if scattering is enabled to denote the number of update checks |
| 336 | // we've to skip before we can send a request to Omaha. The min and max |
| 337 | // values establish the bounds for a random number to be chosen within that |
| 338 | // range to enable such a wait. |
| 339 | bool update_check_count_wait_enabled_; |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 340 | int64_t min_update_checks_needed_; |
| 341 | int64_t max_update_checks_allowed_; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 342 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 343 | // When reading files, prepend root_ to the paths. Useful for testing. |
| 344 | std::string root_; |
| 345 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 346 | // TODO(jaysri): Uncomment this after fixing unit tests, as part of |
| 347 | // chromium-os:39752 |
| 348 | // DISALLOW_COPY_AND_ASSIGN(OmahaRequestParams); |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 349 | }; |
| 350 | |
| 351 | } // namespace chromeos_update_engine |
| 352 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 353 | #endif // UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |