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