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 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 16 | |
Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_CROS_OMAHA_REQUEST_ACTION_H_ |
| 18 | #define UPDATE_ENGINE_CROS_OMAHA_REQUEST_ACTION_H_ |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 19 | |
Alex Vakulenko | 44cab30 | 2014-07-23 13:12:15 -0700 | [diff] [blame] | 20 | #include <fcntl.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 21 | #include <sys/stat.h> |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 22 | #include <sys/types.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 23 | |
Alex Deymo | b3fa53b | 2016-04-18 19:57:58 -0700 | [diff] [blame] | 24 | #include <map> |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 25 | #include <memory> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 26 | #include <string> |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 27 | #include <vector> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 28 | |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 29 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 30 | |
Jae Hoon Kim | e2cac61 | 2020-11-02 18:30:29 -0800 | [diff] [blame] | 31 | #include <base/optional.h> |
Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 32 | #include <brillo/secure_blob.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 33 | #include <curl/curl.h> |
| 34 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 35 | #include "update_engine/common/action.h" |
| 36 | #include "update_engine/common/http_fetcher.h" |
Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 37 | #include "update_engine/cros/omaha_request_builder_xml.h" |
| 38 | #include "update_engine/cros/omaha_response.h" |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 39 | |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 40 | // The Omaha Request action makes a request to Omaha and can output |
| 41 | // the response on the output ActionPipe. |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 42 | |
Zentaro Kavanagh | 1f899d5 | 2018-02-27 15:02:47 -0800 | [diff] [blame] | 43 | namespace policy { |
| 44 | class PolicyProvider; |
| 45 | } |
| 46 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 47 | namespace chromeos_update_engine { |
| 48 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 49 | class NoneType; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 50 | class OmahaRequestAction; |
Yunlian Jiang | a178e5e | 2013-04-05 14:41:56 -0700 | [diff] [blame] | 51 | class OmahaRequestParams; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 52 | |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 53 | // This struct is declared in the .cc file. |
| 54 | struct OmahaParserData; |
| 55 | |
Amin Hassani | 7cc8bb0 | 2019-01-14 16:29:47 -0800 | [diff] [blame] | 56 | template <> |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 57 | class ActionTraits<OmahaRequestAction> { |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 58 | public: |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 59 | // Takes parameters on the input pipe. |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 60 | typedef NoneType InputObjectType; |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 61 | // On UpdateCheck success, puts the Omaha response on output. Event |
| 62 | // requests do not have an output pipe. |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 63 | typedef OmahaResponse OutputObjectType; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 66 | class OmahaRequestAction : public Action<OmahaRequestAction>, |
| 67 | public HttpFetcherDelegate { |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 68 | public: |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 69 | static const int kPingTimeJump = -2; |
Jae Hoon Kim | a3210e6 | 2020-05-07 11:32:44 -0700 | [diff] [blame] | 70 | // We choose this value of 3 as a heuristic for a work day in trying |
Jay Srinivasan | 2b5a0f0 | 2012-12-19 17:25:56 -0800 | [diff] [blame] | 71 | // each URL, assuming we check roughly every 45 mins. This is a good time to |
Jae Hoon Kim | a3210e6 | 2020-05-07 11:32:44 -0700 | [diff] [blame] | 72 | // wait so we don't give up the preferred URLs, but allow using the URL that |
| 73 | // appears earlier in list for every payload before resorting to the fallback |
| 74 | // URLs in the candiate URL list. |
| 75 | static const int kDefaultMaxFailureCountPerUrl = 3; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 76 | |
Adolfo Victoria | 497044c | 2018-07-18 07:51:42 -0700 | [diff] [blame] | 77 | // If staging is enabled, set the maximum wait time to 28 days, since that is |
| 78 | // the predetermined wait time for staging. |
| 79 | static const int kMaxWaitTimeStagingInDays = 28; |
| 80 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 81 | // These are the possible outcome upon checking whether we satisfied |
| 82 | // the wall-clock-based-wait. |
| 83 | enum WallClockWaitResult { |
| 84 | kWallClockWaitNotSatisfied, |
| 85 | kWallClockWaitDoneButUpdateCheckWaitRequired, |
| 86 | kWallClockWaitDoneAndUpdateCheckWaitNotRequired, |
| 87 | }; |
| 88 | |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 89 | // The ctor takes in all the parameters that will be used for making |
| 90 | // the request to Omaha. For some of them we have constants that |
| 91 | // should be used. |
| 92 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 93 | // Takes ownership of the passed in HttpFetcher. Useful for testing. |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 94 | // |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 95 | // Takes ownership of the passed in OmahaEvent. If |event| is null, |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 96 | // this is an UpdateCheck request, otherwise it's an Event request. |
| 97 | // Event requests always succeed. |
| 98 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 99 | // A good calling pattern is: |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 100 | // OmahaRequestAction(..., new OmahaEvent(...), new WhateverHttpFetcher); |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 101 | // or |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 102 | // OmahaRequestAction(..., nullptr, new WhateverHttpFetcher); |
Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 103 | OmahaRequestAction(OmahaEvent* event, |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 104 | std::unique_ptr<HttpFetcher> http_fetcher, |
Jae Hoon Kim | edb6550 | 2019-06-14 11:52:17 -0700 | [diff] [blame] | 105 | bool ping_only, |
| 106 | const std::string& session_id); |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 107 | ~OmahaRequestAction() override; |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 108 | typedef ActionTraits<OmahaRequestAction>::InputObjectType InputObjectType; |
| 109 | typedef ActionTraits<OmahaRequestAction>::OutputObjectType OutputObjectType; |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 110 | void PerformAction() override; |
| 111 | void TerminateProcessing() override; |
| 112 | void ActionCompleted(ErrorCode code) override; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 113 | |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 114 | int GetHTTPResponseCode() { return http_fetcher_->http_response_code(); } |
| 115 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 116 | // Debugging/logging |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 117 | static std::string StaticType() { return "OmahaRequestAction"; } |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 118 | std::string Type() const override { return StaticType(); } |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 119 | |
| 120 | // Delegate methods (see http_fetcher.h) |
Amin Hassani | 0cd9d77 | 2018-07-31 23:55:43 -0700 | [diff] [blame] | 121 | bool ReceivedBytes(HttpFetcher* fetcher, |
| 122 | const void* bytes, |
| 123 | size_t length) override; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 124 | |
Amin Hassani | 7cc8bb0 | 2019-01-14 16:29:47 -0800 | [diff] [blame] | 125 | void TransferComplete(HttpFetcher* fetcher, bool successful) override; |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 126 | |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 127 | // Returns true if this is an Event request, false if it's an UpdateCheck. |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 128 | bool IsEvent() const { return event_.get() != nullptr; } |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 129 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 130 | private: |
Zentaro Kavanagh | 1f899d5 | 2018-02-27 15:02:47 -0800 | [diff] [blame] | 131 | friend class OmahaRequestActionTest; |
Amin Hassani | d3f4bea | 2018-04-30 14:52:40 -0700 | [diff] [blame] | 132 | friend class OmahaRequestActionTestProcessorDelegate; |
Alex Deymo | e1e3afe | 2014-10-30 13:02:49 -0700 | [diff] [blame] | 133 | FRIEND_TEST(OmahaRequestActionTest, GetInstallDateWhenNoPrefsNorOOBE); |
| 134 | FRIEND_TEST(OmahaRequestActionTest, |
| 135 | GetInstallDateWhenOOBECompletedWithInvalidDate); |
| 136 | FRIEND_TEST(OmahaRequestActionTest, |
| 137 | GetInstallDateWhenOOBECompletedWithValidDate); |
| 138 | FRIEND_TEST(OmahaRequestActionTest, |
| 139 | GetInstallDateWhenOOBECompletedDateChanges); |
Jae Hoon Kim | edb6550 | 2019-06-14 11:52:17 -0700 | [diff] [blame] | 140 | friend class UpdateAttempterTest; |
| 141 | FRIEND_TEST(UpdateAttempterTest, SessionIdTestEnforceEmptyStrPingOmaha); |
| 142 | FRIEND_TEST(UpdateAttempterTest, SessionIdTestConsistencyInUpdateFlow); |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 143 | |
| 144 | // Enumeration used in PersistInstallDate(). |
| 145 | enum InstallDateProvisioningSource { |
| 146 | kProvisionedFromOmahaResponse, |
| 147 | kProvisionedFromOOBEMarker, |
| 148 | |
| 149 | // kProvisionedMax is the count of the number of enums above. Add |
| 150 | // any new enums above this line only. |
| 151 | kProvisionedMax |
| 152 | }; |
| 153 | |
| 154 | // Gets the install date, expressed as the number of PST8PDT |
| 155 | // calendar weeks since January 1st 2007, times seven. Returns -1 if |
| 156 | // unknown. See http://crbug.com/336838 for details about this value. |
Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 157 | static int GetInstallDate(); |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 158 | |
| 159 | // Parses the Omaha Response in |doc| and sets the |
| 160 | // |install_date_days| field of |output_object| to the value of the |
| 161 | // elapsed_days attribute of the daystart element. Returns True if |
| 162 | // the value was set, False if it wasn't found. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 163 | static bool ParseInstallDate(OmahaParserData* parser_data, |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 164 | OmahaResponse* output_object); |
| 165 | |
| 166 | // Returns True if the kPrefsInstallDateDays state variable is set, |
| 167 | // False otherwise. |
Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 168 | static bool HasInstallDate(); |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 169 | |
| 170 | // Writes |install_date_days| into the kPrefsInstallDateDays state |
| 171 | // variable and emits an UMA stat for the |source| used. Returns |
| 172 | // True if the value was written, False if an error occurred. |
Amin Hassani | 538bd59 | 2020-11-04 20:46:08 -0800 | [diff] [blame] | 173 | static bool PersistInstallDate(int install_date_days, |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 174 | InstallDateProvisioningSource source); |
| 175 | |
Jae Hoon Kim | e2cac61 | 2020-11-02 18:30:29 -0800 | [diff] [blame] | 176 | // Persist the new cohort value received in the XML file in the |prefs_key| |
| 177 | // preference file. If the |new_value| is empty, do nothing. If the |
| 178 | // |new_value| stores and empty value, the currently stored value will be |
| 179 | // deleted. Don't call this function with an empty |new_value| if the value |
| 180 | // was not set in the XML, since that would delete the stored value. |
| 181 | void PersistCohortData(const std::string& prefs_key, |
| 182 | const base::Optional<std::string>& new_value); |
| 183 | |
| 184 | // Parses and persists the cohorts sent back in the updatecheck tag |
| 185 | // attributes. |
| 186 | void PersistCohorts(const OmahaParserData& parser_data); |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 187 | |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 188 | // If this is an update check request, initializes |
| 189 | // |ping_active_days_| and |ping_roll_call_days_| to values that may |
| 190 | // be sent as pings to Omaha. |
| 191 | void InitPingDays(); |
| 192 | |
Darin Petkov | 84c763c | 2010-07-29 16:27:58 -0700 | [diff] [blame] | 193 | // Based on the persistent preference store values, calculates the |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 194 | // number of days since the last ping sent for |key|. |
| 195 | int CalculatePingDays(const std::string& key); |
| 196 | |
Alex Deymo | ebbe7ef | 2014-10-30 13:02:49 -0700 | [diff] [blame] | 197 | // Returns whether we have "active_days" or "roll_call_days" ping values to |
| 198 | // send to Omaha and thus we should include them in the response. |
| 199 | bool ShouldPing() const; |
| 200 | |
Andrew | e045aef | 2020-01-08 16:29:22 -0800 | [diff] [blame] | 201 | // Process Omaha's response to a ping request and store the results in the DLC |
| 202 | // metadata directory. |
| 203 | void StorePingReply(const OmahaParserData& parser_data) const; |
| 204 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 205 | // Returns true if the download of a new update should be deferred. |
| 206 | // False if the update can be downloaded. |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 207 | bool ShouldDeferDownload(OmahaResponse* output_object); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 208 | |
| 209 | // Returns true if the basic wall-clock-based waiting period has been |
| 210 | // satisfied based on the scattering policy setting. False otherwise. |
| 211 | // If true, it also indicates whether the additional update-check-count-based |
| 212 | // waiting period also needs to be satisfied before the download can begin. |
| 213 | WallClockWaitResult IsWallClockBasedWaitingSatisfied( |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 214 | OmahaResponse* output_object); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 215 | |
| 216 | // Returns true if the update-check-count-based waiting period has been |
| 217 | // satisfied. False otherwise. |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 218 | bool IsUpdateCheckCountBasedWaitingSatisfied(); |
| 219 | |
| 220 | // Parses the response from Omaha that's available in |doc| using the other |
| 221 | // helper methods below and populates the |output_object| with the relevant |
| 222 | // values. Returns true if we should continue the parsing. False otherwise, |
| 223 | // in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 224 | bool ParseResponse(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 225 | OmahaResponse* output_object, |
| 226 | ScopedActionCompleter* completer); |
| 227 | |
| 228 | // Parses the status property in the given update_check_node and populates |
| 229 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 230 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 231 | bool ParseStatus(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 232 | OmahaResponse* output_object, |
| 233 | ScopedActionCompleter* completer); |
| 234 | |
| 235 | // Parses the URL nodes in the given XML document and populates |
| 236 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 237 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 238 | bool ParseUrls(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 239 | OmahaResponse* output_object, |
| 240 | ScopedActionCompleter* completer); |
| 241 | |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 242 | // Parses the other parameters in the given XML document and populates |
| 243 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 244 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 245 | bool ParseParams(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 246 | OmahaResponse* output_object, |
| 247 | ScopedActionCompleter* completer); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 248 | |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 249 | // Called by TransferComplete() to complete processing, either |
| 250 | // asynchronously after looking up resources via p2p or directly. |
| 251 | void CompleteProcessing(); |
| 252 | |
| 253 | // Helper to asynchronously look up payload on the LAN. |
| 254 | void LookupPayloadViaP2P(const OmahaResponse& response); |
| 255 | |
| 256 | // Callback used by LookupPayloadViaP2P(). |
| 257 | void OnLookupPayloadViaP2PCompleted(const std::string& url); |
| 258 | |
Chris Sosa | 77f79e8 | 2014-06-02 18:16:24 -0700 | [diff] [blame] | 259 | // Returns true if the current update should be ignored. |
Toni Barzic | 61544e6 | 2018-10-11 14:37:30 -0700 | [diff] [blame] | 260 | bool ShouldIgnoreUpdate(const OmahaResponse& response, |
| 261 | ErrorCode* error) const; |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 262 | |
| 263 | // Return true if updates are allowed by user preferences. |
| 264 | bool IsUpdateAllowedOverCellularByPrefs(const OmahaResponse& response) const; |
Chris Sosa | 77f79e8 | 2014-06-02 18:16:24 -0700 | [diff] [blame] | 265 | |
| 266 | // Returns true if updates are allowed over the current type of connection. |
| 267 | // False otherwise. |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 268 | bool IsUpdateAllowedOverCurrentConnection( |
| 269 | ErrorCode* error, const OmahaResponse& response) const; |
Chris Sosa | 77f79e8 | 2014-06-02 18:16:24 -0700 | [diff] [blame] | 270 | |
Zentaro Kavanagh | 1f899d5 | 2018-02-27 15:02:47 -0800 | [diff] [blame] | 271 | // Returns true if rollback is enabled. Always returns false for consumer |
| 272 | // devices. |
| 273 | bool IsRollbackEnabled() const; |
| 274 | |
| 275 | // Sets the appropriate max kernel key version based on whether rollback is |
| 276 | // enabled. |
| 277 | void SetMaxKernelKeyVersionForRollback() const; |
| 278 | |
May Lippert | 60aa3ca | 2018-08-15 16:55:29 -0700 | [diff] [blame] | 279 | // Reads and returns the kPrefsUpdateFirstSeenAt pref if the pref currently |
| 280 | // exists. Otherwise saves the current wallclock time to the |
| 281 | // kPrefsUpdateFirstSeenAt pref and returns it as a base::Time object. |
| 282 | base::Time LoadOrPersistUpdateFirstSeenAtPref() const; |
| 283 | |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 284 | // Pointer to the OmahaEvent info. This is an UpdateCheck request if null. |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 285 | std::unique_ptr<OmahaEvent> event_; |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 286 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 287 | // pointer to the HttpFetcher that does the http work |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 288 | std::unique_ptr<HttpFetcher> http_fetcher_; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 289 | |
Zentaro Kavanagh | 1f899d5 | 2018-02-27 15:02:47 -0800 | [diff] [blame] | 290 | // Used for fetching information about the device policy. |
| 291 | std::unique_ptr<policy::PolicyProvider> policy_provider_; |
| 292 | |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 293 | // If true, only include the <ping> element in the request. |
| 294 | bool ping_only_; |
| 295 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 296 | // Stores the response from the omaha server |
Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 297 | brillo::Blob response_buffer_; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 298 | |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 299 | // Initialized by InitPingDays to values that may be sent to Omaha |
| 300 | // as part of a ping message. Note that only positive values and -1 |
| 301 | // are sent to Omaha. |
| 302 | int ping_active_days_; |
| 303 | int ping_roll_call_days_; |
| 304 | |
Jae Hoon Kim | edb6550 | 2019-06-14 11:52:17 -0700 | [diff] [blame] | 305 | std::string session_id_; |
| 306 | |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 307 | DISALLOW_COPY_AND_ASSIGN(OmahaRequestAction); |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | } // namespace chromeos_update_engine |
| 311 | |
Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 312 | #endif // UPDATE_ENGINE_CROS_OMAHA_REQUEST_ACTION_H_ |