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> |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 23 | #include <vector> |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 24 | |
Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 25 | #include <base/macros.h> |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 26 | #include <base/time/time.h> |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 27 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 28 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 29 | #include "update_engine/common/platform_constants.h" |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 30 | #include "update_engine/image_properties.h" |
Alex Deymo | ac41a82 | 2015-09-15 20:52:53 -0700 | [diff] [blame] | 31 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 32 | // This gathers local system information and prepares info used by the |
| 33 | // Omaha request action. |
| 34 | |
| 35 | namespace chromeos_update_engine { |
| 36 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 37 | class SystemState; |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 38 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 39 | // This class encapsulates the data Omaha gets for the request, along with |
| 40 | // essential state needed for the processing of the request/response. The |
| 41 | // strings in this struct should not be XML escaped. |
| 42 | // |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 43 | // 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] | 44 | // reflect its lifetime more appropriately. |
| 45 | class OmahaRequestParams { |
| 46 | public: |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 47 | explicit OmahaRequestParams(SystemState* system_state) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 48 | : system_state_(system_state), |
Alex Deymo | ac41a82 | 2015-09-15 20:52:53 -0700 | [diff] [blame] | 49 | os_platform_(constants::kOmahaPlatformName), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 50 | os_version_(kOsVersion), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 51 | delta_okay_(true), |
| 52 | interactive_(false), |
Marton Hunyady | ba51c3f | 2018-04-25 15:18:10 +0200 | [diff] [blame] | 53 | rollback_allowed_(false), |
Zentaro Kavanagh | 28def4f | 2019-01-15 17:15:01 -0800 | [diff] [blame] | 54 | rollback_data_save_requested_(false), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 55 | wall_clock_based_wait_enabled_(false), |
| 56 | update_check_count_wait_enabled_(false), |
| 57 | min_update_checks_needed_(kDefaultMinUpdateChecks), |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 58 | max_update_checks_allowed_(kDefaultMaxUpdateChecks), |
| 59 | is_install_(false) {} |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 60 | |
Alex Deymo | 3be05c8 | 2015-10-23 11:29:11 -0700 | [diff] [blame] | 61 | virtual ~OmahaRequestParams(); |
Alex Deymo | e894870 | 2014-11-11 21:44:45 -0800 | [diff] [blame] | 62 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 63 | // Setters and getters for the various properties. |
| 64 | inline std::string os_platform() const { return os_platform_; } |
| 65 | inline std::string os_version() const { return os_version_; } |
| 66 | inline std::string os_sp() const { return os_sp_; } |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 67 | inline std::string os_board() const { return image_props_.board; } |
Alex Deymo | ebf6e12 | 2017-03-10 16:12:01 -0800 | [diff] [blame] | 68 | inline std::string os_build_fingerprint() const { |
| 69 | return image_props_.build_fingerprint; |
| 70 | } |
Sen Jiang | 1d5d95f | 2017-05-19 11:33:10 -0700 | [diff] [blame] | 71 | inline std::string os_build_type() const { return image_props_.build_type; } |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 72 | inline std::string board_app_id() const { return image_props_.product_id; } |
| 73 | inline std::string canary_app_id() const { |
| 74 | return image_props_.canary_product_id; |
| 75 | } |
Sen Jiang | 94a4dec | 2017-03-28 18:23:35 -0700 | [diff] [blame] | 76 | inline std::string system_app_id() const { return image_props_.system_id; } |
Aaron Wood | 7dcdedf | 2017-09-06 17:17:41 -0700 | [diff] [blame] | 77 | inline void set_system_app_id(const std::string& system_app_id) { |
| 78 | image_props_.system_id = system_app_id; |
| 79 | } |
Sen Jiang | 297e583 | 2016-03-17 14:45:51 -0700 | [diff] [blame] | 80 | inline void set_app_id(const std::string& app_id) { |
| 81 | image_props_.product_id = app_id; |
| 82 | image_props_.canary_product_id = app_id; |
| 83 | } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 84 | inline std::string app_lang() const { return app_lang_; } |
| 85 | inline std::string hwid() const { return hwid_; } |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 86 | inline std::string fw_version() const { return fw_version_; } |
| 87 | inline std::string ec_version() const { return ec_version_; } |
Matt Ziegelbaum | aa8e1a4 | 2019-05-09 21:41:58 -0400 | [diff] [blame] | 88 | inline std::string device_requisition() const { return device_requisition_; } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 89 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 90 | inline void set_app_version(const std::string& version) { |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 91 | image_props_.version = version; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 92 | } |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 93 | inline std::string app_version() const { return image_props_.version; } |
Sen Jiang | 94a4dec | 2017-03-28 18:23:35 -0700 | [diff] [blame] | 94 | inline std::string system_version() const { |
| 95 | return image_props_.system_version; |
| 96 | } |
Sen Jiang | 684c9cd | 2017-10-17 16:26:45 -0700 | [diff] [blame] | 97 | inline std::string product_components() const { |
| 98 | return image_props_.product_components; |
| 99 | } |
Sen Jiang | 8cd4234 | 2018-01-31 12:06:59 -0800 | [diff] [blame] | 100 | inline void set_product_components(const std::string& product_components) { |
| 101 | image_props_.product_components = product_components; |
| 102 | } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 103 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 104 | inline std::string current_channel() const { |
| 105 | return image_props_.current_channel; |
| 106 | } |
| 107 | inline std::string target_channel() const { |
| 108 | return mutable_image_props_.target_channel; |
| 109 | } |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 110 | inline std::string download_channel() const { return download_channel_; } |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 111 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 112 | // Can client accept a delta ? |
| 113 | inline void set_delta_okay(bool ok) { delta_okay_ = ok; } |
| 114 | inline bool delta_okay() const { return delta_okay_; } |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 115 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 116 | // True if this is a user-initiated update check. |
Chris Sosa | 968d057 | 2013-08-23 14:46:02 -0700 | [diff] [blame] | 117 | inline void set_interactive(bool interactive) { interactive_ = interactive; } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 118 | inline bool interactive() const { return interactive_; } |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 119 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 120 | inline void set_update_url(const std::string& url) { update_url_ = url; } |
| 121 | inline std::string update_url() const { return update_url_; } |
| 122 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 123 | inline void set_target_version_prefix(const std::string& prefix) { |
| 124 | target_version_prefix_ = prefix; |
| 125 | } |
| 126 | |
| 127 | inline std::string target_version_prefix() const { |
| 128 | return target_version_prefix_; |
| 129 | } |
| 130 | |
Marton Hunyady | ba51c3f | 2018-04-25 15:18:10 +0200 | [diff] [blame] | 131 | inline void set_rollback_allowed(bool rollback_allowed) { |
| 132 | rollback_allowed_ = rollback_allowed; |
| 133 | } |
| 134 | |
| 135 | inline bool rollback_allowed() const { return rollback_allowed_; } |
| 136 | |
Zentaro Kavanagh | 28def4f | 2019-01-15 17:15:01 -0800 | [diff] [blame] | 137 | inline void set_rollback_data_save_requested( |
| 138 | bool rollback_data_save_requested) { |
| 139 | rollback_data_save_requested_ = rollback_data_save_requested; |
| 140 | } |
| 141 | |
| 142 | inline bool rollback_data_save_requested() const { |
| 143 | return rollback_data_save_requested_; |
| 144 | } |
| 145 | |
Zentaro Kavanagh | 0ef9a2f | 2018-07-02 12:05:07 -0700 | [diff] [blame] | 146 | inline void set_rollback_allowed_milestones(int rollback_allowed_milestones) { |
| 147 | rollback_allowed_milestones_ = rollback_allowed_milestones; |
| 148 | } |
| 149 | |
| 150 | inline int rollback_allowed_milestones() const { |
| 151 | return rollback_allowed_milestones_; |
| 152 | } |
| 153 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 154 | inline void set_wall_clock_based_wait_enabled(bool enabled) { |
| 155 | wall_clock_based_wait_enabled_ = enabled; |
| 156 | } |
| 157 | inline bool wall_clock_based_wait_enabled() const { |
| 158 | return wall_clock_based_wait_enabled_; |
| 159 | } |
| 160 | |
| 161 | inline void set_waiting_period(base::TimeDelta period) { |
| 162 | waiting_period_ = period; |
| 163 | } |
| 164 | base::TimeDelta waiting_period() const { return waiting_period_; } |
| 165 | |
| 166 | inline void set_update_check_count_wait_enabled(bool enabled) { |
| 167 | update_check_count_wait_enabled_ = enabled; |
| 168 | } |
| 169 | |
| 170 | inline bool update_check_count_wait_enabled() const { |
| 171 | return update_check_count_wait_enabled_; |
| 172 | } |
| 173 | |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 174 | inline void set_min_update_checks_needed(int64_t min) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 175 | min_update_checks_needed_ = min; |
| 176 | } |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 177 | inline int64_t min_update_checks_needed() const { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 178 | return min_update_checks_needed_; |
| 179 | } |
| 180 | |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 181 | inline void set_max_update_checks_allowed(int64_t max) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 182 | max_update_checks_allowed_ = max; |
| 183 | } |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 184 | inline int64_t max_update_checks_allowed() const { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 185 | return max_update_checks_allowed_; |
| 186 | } |
Xiaochu Liu | f53a5d3 | 2018-11-26 13:48:59 -0800 | [diff] [blame] | 187 | inline void set_dlc_module_ids( |
| 188 | const std::vector<std::string>& dlc_module_ids) { |
| 189 | dlc_module_ids_ = dlc_module_ids; |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 190 | } |
Xiaochu Liu | f53a5d3 | 2018-11-26 13:48:59 -0800 | [diff] [blame] | 191 | inline std::vector<std::string> dlc_module_ids() const { |
| 192 | return dlc_module_ids_; |
| 193 | } |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 194 | inline void set_is_install(bool is_install) { is_install_ = is_install; } |
| 195 | inline bool is_install() const { return is_install_; } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 196 | |
Askar Aitzhan | 570ca87 | 2019-04-24 11:16:12 +0200 | [diff] [blame] | 197 | inline void set_autoupdate_token(const std::string& token) { |
| 198 | autoupdate_token_ = token; |
| 199 | } |
| 200 | inline const std::string& autoupdate_token() const { |
| 201 | return autoupdate_token_; |
| 202 | } |
| 203 | |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 204 | // Returns the app id corresponding to the current value of the |
| 205 | // download channel. |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 206 | virtual std::string GetAppId() const; |
Jay Srinivasan | db0acdf | 2013-04-02 14:47:45 -0700 | [diff] [blame] | 207 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 208 | // Suggested defaults |
David Pursell | 02c1864 | 2014-11-06 11:26:11 -0800 | [diff] [blame] | 209 | static const char kOsVersion[]; |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 210 | static const int64_t kDefaultMinUpdateChecks = 0; |
| 211 | static const int64_t kDefaultMaxUpdateChecks = 8; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 212 | |
Darin Petkov | 5a7f565 | 2010-07-22 21:40:09 -0700 | [diff] [blame] | 213 | // Initializes all the data in the object. Non-empty |
| 214 | // |in_app_version| or |in_update_url| prevents automatic detection |
| 215 | // of the parameter. Returns true on success, false otherwise. |
| 216 | bool Init(const std::string& in_app_version, |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 217 | const std::string& in_update_url, |
Gilad Arnold | bbdd490 | 2013-01-10 16:06:30 -0800 | [diff] [blame] | 218 | bool in_interactive); |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 219 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 220 | // Permanently changes the release channel to |channel|. Performs a |
| 221 | // powerwash, if required and allowed. |
| 222 | // Returns true on success, false otherwise. Note: This call will fail if |
| 223 | // there's a channel change pending already. This is to serialize all the |
| 224 | // channel changes done by the user in order to avoid having to solve |
| 225 | // numerous edge cases around ensuring the powerwash happens as intended in |
| 226 | // all such cases. |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 227 | virtual bool SetTargetChannel(const std::string& channel, |
Alex Deymo | d942f9d | 2015-11-06 16:11:50 -0800 | [diff] [blame] | 228 | bool is_powerwash_allowed, |
| 229 | std::string* error_message); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 230 | |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 231 | // Updates the download channel for this particular attempt from the current |
| 232 | // value of target channel. This method takes a "snapshot" of the current |
| 233 | // value of target channel and uses it for all subsequent Omaha requests for |
| 234 | // this attempt (i.e. initial request as well as download progress/error |
| 235 | // event requests). The snapshot will be updated only when either this method |
| 236 | // or Init is called again. |
Alex Deymo | 560ae1d | 2014-10-28 02:17:54 -0700 | [diff] [blame] | 237 | virtual void UpdateDownloadChannel(); |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 238 | |
Sen Jiang | 8500d3a | 2018-02-08 12:04:05 -0800 | [diff] [blame] | 239 | // Returns whether we should powerwash for this update. |
| 240 | virtual bool ShouldPowerwash() const; |
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 | } |
Marton Hunyady | 2abda31 | 2018-04-24 18:21:49 +0200 | [diff] [blame] | 254 | void set_os_sp(const std::string& os_sp) { os_sp_ = os_sp; } |
| 255 | void set_os_board(const std::string& os_board) { |
| 256 | image_props_.board = os_board; |
| 257 | } |
| 258 | void set_app_lang(const std::string& app_lang) { app_lang_ = app_lang; } |
| 259 | void set_hwid(const std::string& hwid) { hwid_ = hwid; } |
| 260 | void set_fw_version(const std::string& fw_version) { |
| 261 | fw_version_ = fw_version; |
| 262 | } |
| 263 | void set_ec_version(const std::string& ec_version) { |
| 264 | ec_version_ = ec_version; |
| 265 | } |
| 266 | void set_is_powerwash_allowed(bool powerwash_allowed) { |
| 267 | mutable_image_props_.is_powerwash_allowed = powerwash_allowed; |
| 268 | } |
Matt Ziegelbaum | aa8e1a4 | 2019-05-09 21:41:58 -0400 | [diff] [blame] | 269 | void set_device_requisition(const std::string& requisition) { |
| 270 | device_requisition_ = requisition; |
| 271 | } |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 272 | |
| 273 | private: |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 274 | FRIEND_TEST(OmahaRequestParamsTest, ChannelIndexTest); |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 275 | FRIEND_TEST(OmahaRequestParamsTest, CollectECFWVersionsTest); |
Sen Jiang | 7f785f5 | 2018-01-24 13:31:56 -0800 | [diff] [blame] | 276 | FRIEND_TEST(OmahaRequestParamsTest, IsValidChannelTest); |
Sen Jiang | 8500d3a | 2018-02-08 12:04:05 -0800 | [diff] [blame] | 277 | FRIEND_TEST(OmahaRequestParamsTest, SetIsPowerwashAllowedTest); |
Sen Jiang | 7f785f5 | 2018-01-24 13:31:56 -0800 | [diff] [blame] | 278 | FRIEND_TEST(OmahaRequestParamsTest, SetTargetChannelInvalidTest); |
Sen Jiang | 8500d3a | 2018-02-08 12:04:05 -0800 | [diff] [blame] | 279 | FRIEND_TEST(OmahaRequestParamsTest, SetTargetChannelTest); |
| 280 | FRIEND_TEST(OmahaRequestParamsTest, ShouldPowerwashTest); |
Sen Jiang | 7f785f5 | 2018-01-24 13:31:56 -0800 | [diff] [blame] | 281 | FRIEND_TEST(OmahaRequestParamsTest, ToMoreStableChannelFlagTest); |
Darin Petkov | 49d9132 | 2010-10-25 16:34:58 -0700 | [diff] [blame] | 282 | |
Sen Jiang | ce3f7cf | 2018-01-25 14:07:45 -0800 | [diff] [blame] | 283 | // Returns true if |channel| is a valid channel, otherwise write error to |
| 284 | // |error_message| if passed and return false. |
| 285 | bool IsValidChannel(const std::string& channel, |
| 286 | std::string* error_message) const; |
| 287 | bool IsValidChannel(const std::string& channel) const { |
| 288 | return IsValidChannel(channel, nullptr); |
| 289 | } |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 290 | |
| 291 | // Returns the index of the given channel. |
| 292 | int GetChannelIndex(const std::string& channel) const; |
| 293 | |
Sen Jiang | 8500d3a | 2018-02-08 12:04:05 -0800 | [diff] [blame] | 294 | // True if we're trying to update to a more stable channel. |
| 295 | // i.e. index(target_channel) > index(current_channel). |
| 296 | bool ToMoreStableChannel() const; |
| 297 | |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 298 | // Returns True if we should store the fw/ec versions based on our hwid_. |
| 299 | // Compares hwid to a set of whitelisted prefixes. |
| 300 | bool CollectECFWVersions() const; |
| 301 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 302 | // Gets the machine type (e.g. "i686"). |
| 303 | std::string GetMachineType() const; |
| 304 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 305 | // Global system context. |
| 306 | SystemState* system_state_; |
| 307 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 308 | // The system image properties. |
| 309 | ImageProperties image_props_; |
| 310 | MutableImageProperties mutable_image_props_; |
| 311 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 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_; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 316 | std::string app_lang_; |
| 317 | |
Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 318 | // There are three channel values we deal with: |
| 319 | // * The channel we got the image we are running from or "current channel" |
| 320 | // stored in |image_props_.current_channel|. |
| 321 | // |
| 322 | // * The release channel we are tracking, where we should get updates from, |
| 323 | // stored in |mutable_image_props_.target_channel|. This channel is |
| 324 | // normally the same as the current_channel, except when the user changes |
| 325 | // the channel. In that case it'll have the release channel the user |
| 326 | // switched to, regardless of whether we downloaded an update from that |
| 327 | // channel or not, or if we are in the middle of a download from a |
| 328 | // previously selected channel (as opposed to download channel |
| 329 | // which gets updated only at the start of next download). |
| 330 | // |
| 331 | // * The channel from which we're downloading the payload. This should |
| 332 | // normally be the same as target channel. But if the user made another |
| 333 | // channel change after we started the download, then they'd be different, |
| 334 | // in which case, we'd detect elsewhere that the target channel has been |
| 335 | // changed and cancel the current download attempt. |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 336 | std::string download_channel_; |
| 337 | |
Amin Hassani | 7cc8bb0 | 2019-01-14 16:29:47 -0800 | [diff] [blame] | 338 | std::string hwid_; // Hardware Qualification ID of the client |
Chris Sosa | c197248 | 2013-04-30 22:31:10 -0700 | [diff] [blame] | 339 | std::string fw_version_; // Chrome OS Firmware Version. |
| 340 | std::string ec_version_; // Chrome OS EC Version. |
Matt Ziegelbaum | aa8e1a4 | 2019-05-09 21:41:58 -0400 | [diff] [blame] | 341 | // TODO(b:133324571) tracks removal of this field once it is no longer |
| 342 | // needed in AU requests. Remove by October 1st 2019. |
| 343 | std::string device_requisition_; // Chrome OS Requisition type. |
Amin Hassani | 7cc8bb0 | 2019-01-14 16:29:47 -0800 | [diff] [blame] | 344 | bool delta_okay_; // If this client can accept a delta |
| 345 | bool interactive_; // Whether this is a user-initiated update check |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 346 | |
| 347 | // The URL to send the Omaha request to. |
| 348 | std::string update_url_; |
| 349 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 350 | // Prefix of the target OS version that the enterprise wants this device |
| 351 | // to be pinned to. It's empty otherwise. |
| 352 | std::string target_version_prefix_; |
| 353 | |
Marton Hunyady | ba51c3f | 2018-04-25 15:18:10 +0200 | [diff] [blame] | 354 | // Whether the client is accepting rollback images too. |
| 355 | bool rollback_allowed_; |
| 356 | |
Zentaro Kavanagh | 28def4f | 2019-01-15 17:15:01 -0800 | [diff] [blame] | 357 | // Whether rollbacks should preserve some system state during powerwash. |
| 358 | bool rollback_data_save_requested_; |
| 359 | |
Zentaro Kavanagh | 0ef9a2f | 2018-07-02 12:05:07 -0700 | [diff] [blame] | 360 | // How many milestones the client can rollback to. |
| 361 | int rollback_allowed_milestones_; |
| 362 | |
Adolfo Victoria | 497044c | 2018-07-18 07:51:42 -0700 | [diff] [blame] | 363 | // True if scattering or staging are enabled, in which case waiting_period_ |
| 364 | // specifies the amount of absolute time that we've to wait for before sending |
| 365 | // a request to Omaha. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 366 | bool wall_clock_based_wait_enabled_; |
| 367 | base::TimeDelta waiting_period_; |
| 368 | |
Adolfo Victoria | 497044c | 2018-07-18 07:51:42 -0700 | [diff] [blame] | 369 | // True if scattering or staging are enabled to denote the number of update |
| 370 | // checks we've to skip before we can send a request to Omaha. The min and max |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 371 | // values establish the bounds for a random number to be chosen within that |
| 372 | // range to enable such a wait. |
| 373 | bool update_check_count_wait_enabled_; |
Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 374 | int64_t min_update_checks_needed_; |
| 375 | int64_t max_update_checks_allowed_; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 376 | |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 377 | // When reading files, prepend root_ to the paths. Useful for testing. |
| 378 | std::string root_; |
| 379 | |
Xiaochu Liu | f53a5d3 | 2018-11-26 13:48:59 -0800 | [diff] [blame] | 380 | // A list of DLC module IDs to install. |
| 381 | std::vector<std::string> dlc_module_ids_; |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 382 | |
| 383 | // This variable defines whether the payload is being installed in the current |
Xiaochu Liu | f53a5d3 | 2018-11-26 13:48:59 -0800 | [diff] [blame] | 384 | // partition. At the moment, this is used for installing DLC modules on the |
| 385 | // current active partition instead of the inactive partition. |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 386 | bool is_install_; |
| 387 | |
Askar Aitzhan | 570ca87 | 2019-04-24 11:16:12 +0200 | [diff] [blame] | 388 | // Token used when making an update request for a specific build. |
| 389 | // For example: Token for a Quick Fix Build: |
| 390 | // https://www.chromium.org/administrators/policy-list-3#DeviceQuickFixBuildToken. |
| 391 | std::string autoupdate_token_; |
| 392 | |
Marton Hunyady | 2abda31 | 2018-04-24 18:21:49 +0200 | [diff] [blame] | 393 | DISALLOW_COPY_AND_ASSIGN(OmahaRequestParams); |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | } // namespace chromeos_update_engine |
| 397 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 398 | #endif // UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_ |