Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [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 | // |
| 16 | |
| 17 | #include "update_engine/common_service.h" |
| 18 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 19 | #include <string> |
| 20 | |
Hidehiko Abe | 2b9d241 | 2017-12-13 18:56:18 +0900 | [diff] [blame] | 21 | #include <base/bind.h> |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 22 | #include <base/location.h> |
| 23 | #include <base/logging.h> |
| 24 | #include <base/strings/stringprintf.h> |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 25 | #include <brillo/message_loops/message_loop.h> |
| 26 | #include <brillo/strings/string_utils.h> |
| 27 | #include <policy/device_policy.h> |
| 28 | |
| 29 | #include "update_engine/common/clock_interface.h" |
| 30 | #include "update_engine/common/hardware_interface.h" |
| 31 | #include "update_engine/common/prefs.h" |
| 32 | #include "update_engine/common/utils.h" |
| 33 | #include "update_engine/connection_manager_interface.h" |
| 34 | #include "update_engine/omaha_request_params.h" |
Alex Deymo | b3fa53b | 2016-04-18 19:57:58 -0700 | [diff] [blame] | 35 | #include "update_engine/omaha_utils.h" |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 36 | #include "update_engine/p2p_manager.h" |
Shuqian Zhao | 2997173 | 2016-02-05 11:29:32 -0800 | [diff] [blame] | 37 | #include "update_engine/payload_state_interface.h" |
Alex Deymo | b3fa53b | 2016-04-18 19:57:58 -0700 | [diff] [blame] | 38 | #include "update_engine/update_attempter.h" |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 39 | |
| 40 | using base::StringPrintf; |
| 41 | using brillo::ErrorPtr; |
| 42 | using brillo::string_utils::ToString; |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 43 | using std::string; |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 44 | using std::vector; |
Aaron Wood | bf5a252 | 2017-10-04 10:58:36 -0700 | [diff] [blame] | 45 | using update_engine::UpdateAttemptFlags; |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame] | 46 | using update_engine::UpdateEngineStatus; |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 47 | |
| 48 | namespace chromeos_update_engine { |
| 49 | |
| 50 | namespace { |
| 51 | // Log and set the error on the passed ErrorPtr. |
| 52 | void LogAndSetError(ErrorPtr* error, |
Jakub Pawlowski | 7e1dcf7 | 2018-07-26 00:29:42 -0700 | [diff] [blame] | 53 | const base::Location& location, |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 54 | const string& reason) { |
| 55 | brillo::Error::AddTo(error, |
| 56 | location, |
| 57 | UpdateEngineService::kErrorDomain, |
| 58 | UpdateEngineService::kErrorFailed, |
| 59 | reason); |
| 60 | LOG(ERROR) << "Sending Update Engine Failure: " << location.ToString() << ": " |
| 61 | << reason; |
| 62 | } |
| 63 | } // namespace |
| 64 | |
| 65 | const char* const UpdateEngineService::kErrorDomain = "update_engine"; |
| 66 | const char* const UpdateEngineService::kErrorFailed = |
| 67 | "org.chromium.UpdateEngine.Error.Failed"; |
| 68 | |
| 69 | UpdateEngineService::UpdateEngineService(SystemState* system_state) |
Amin Hassani | 7cc8bb0 | 2019-01-14 16:29:47 -0800 | [diff] [blame] | 70 | : system_state_(system_state) {} |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 71 | |
| 72 | // org::chromium::UpdateEngineInterfaceInterface methods implementation. |
| 73 | |
Aaron Wood | bf5a252 | 2017-10-04 10:58:36 -0700 | [diff] [blame] | 74 | bool UpdateEngineService::SetUpdateAttemptFlags(ErrorPtr* /* error */, |
| 75 | int32_t in_flags_as_int) { |
| 76 | auto flags = static_cast<UpdateAttemptFlags>(in_flags_as_int); |
| 77 | LOG(INFO) << "Setting Update Attempt Flags: " |
| 78 | << "flags=0x" << std::hex << flags << " " |
| 79 | << "RestrictDownload=" |
| 80 | << ((flags & UpdateAttemptFlags::kFlagRestrictDownload) ? "yes" |
| 81 | : "no"); |
| 82 | system_state_->update_attempter()->SetUpdateAttemptFlags(flags); |
| 83 | return true; |
| 84 | } |
| 85 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 86 | bool UpdateEngineService::AttemptUpdate(ErrorPtr* /* error */, |
| 87 | const string& in_app_version, |
| 88 | const string& in_omaha_url, |
Aaron Wood | 081c023 | 2017-10-19 17:14:58 -0700 | [diff] [blame] | 89 | int32_t in_flags_as_int, |
| 90 | bool* out_result) { |
Aaron Wood | bf5a252 | 2017-10-04 10:58:36 -0700 | [diff] [blame] | 91 | auto flags = static_cast<UpdateAttemptFlags>(in_flags_as_int); |
| 92 | bool interactive = !(flags & UpdateAttemptFlags::kFlagNonInteractive); |
Aaron Wood | 081c023 | 2017-10-19 17:14:58 -0700 | [diff] [blame] | 93 | bool restrict_downloads = (flags & UpdateAttemptFlags::kFlagRestrictDownload); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 94 | |
| 95 | LOG(INFO) << "Attempt update: app_version=\"" << in_app_version << "\" " |
| 96 | << "omaha_url=\"" << in_omaha_url << "\" " |
| 97 | << "flags=0x" << std::hex << flags << " " |
Aaron Wood | 081c023 | 2017-10-19 17:14:58 -0700 | [diff] [blame] | 98 | << "interactive=" << (interactive ? "yes " : "no ") |
| 99 | << "RestrictDownload=" << (restrict_downloads ? "yes " : "no "); |
| 100 | |
| 101 | *out_result = system_state_->update_attempter()->CheckForUpdate( |
| 102 | in_app_version, in_omaha_url, flags); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 103 | return true; |
| 104 | } |
| 105 | |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 106 | bool UpdateEngineService::AttemptInstall(brillo::ErrorPtr* error, |
| 107 | const string& omaha_url, |
Amin Hassani | 2b68e6b | 2020-04-17 10:49:12 -0700 | [diff] [blame] | 108 | const vector<string>& dlc_ids) { |
| 109 | if (!system_state_->update_attempter()->CheckForInstall(dlc_ids, omaha_url)) { |
Xiaochu Liu | 88d9038 | 2018-08-29 16:09:11 -0700 | [diff] [blame] | 110 | // TODO(xiaochu): support more detailed error messages. |
| 111 | LogAndSetError(error, FROM_HERE, "Could not schedule install operation."); |
| 112 | return false; |
| 113 | } |
| 114 | return true; |
| 115 | } |
| 116 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 117 | bool UpdateEngineService::AttemptRollback(ErrorPtr* error, bool in_powerwash) { |
| 118 | LOG(INFO) << "Attempting rollback to non-active partitions."; |
| 119 | |
| 120 | if (!system_state_->update_attempter()->Rollback(in_powerwash)) { |
| 121 | // TODO(dgarrett): Give a more specific error code/reason. |
| 122 | LogAndSetError(error, FROM_HERE, "Rollback attempt failed."); |
| 123 | return false; |
| 124 | } |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | bool UpdateEngineService::CanRollback(ErrorPtr* /* error */, |
| 129 | bool* out_can_rollback) { |
| 130 | bool can_rollback = system_state_->update_attempter()->CanRollback(); |
| 131 | LOG(INFO) << "Checking to see if we can rollback . Result: " << can_rollback; |
| 132 | *out_can_rollback = can_rollback; |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | bool UpdateEngineService::ResetStatus(ErrorPtr* error) { |
| 137 | if (!system_state_->update_attempter()->ResetStatus()) { |
| 138 | // TODO(dgarrett): Give a more specific error code/reason. |
| 139 | LogAndSetError(error, FROM_HERE, "ResetStatus failed."); |
| 140 | return false; |
| 141 | } |
| 142 | return true; |
| 143 | } |
| 144 | |
Andrew | a8d7df3 | 2020-03-15 20:10:01 -0700 | [diff] [blame] | 145 | bool UpdateEngineService::SetDlcActiveValue(brillo::ErrorPtr* error, |
| 146 | bool is_active, |
| 147 | const string& dlc_id) { |
| 148 | if (!system_state_->update_attempter()->SetDlcActiveValue(is_active, |
| 149 | dlc_id)) { |
| 150 | LogAndSetError(error, FROM_HERE, "SetDlcActiveValue failed."); |
| 151 | return false; |
| 152 | } |
| 153 | return true; |
| 154 | } |
| 155 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 156 | bool UpdateEngineService::GetStatus(ErrorPtr* error, |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame] | 157 | UpdateEngineStatus* out_status) { |
| 158 | if (!system_state_->update_attempter()->GetStatus(out_status)) { |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 159 | LogAndSetError(error, FROM_HERE, "GetStatus failed."); |
| 160 | return false; |
| 161 | } |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | bool UpdateEngineService::RebootIfNeeded(ErrorPtr* error) { |
| 166 | if (!system_state_->update_attempter()->RebootIfNeeded()) { |
| 167 | // TODO(dgarrett): Give a more specific error code/reason. |
| 168 | LogAndSetError(error, FROM_HERE, "Reboot not needed, or attempt failed."); |
| 169 | return false; |
| 170 | } |
| 171 | return true; |
| 172 | } |
| 173 | |
| 174 | bool UpdateEngineService::SetChannel(ErrorPtr* error, |
| 175 | const string& in_target_channel, |
| 176 | bool in_is_powerwash_allowed) { |
| 177 | const policy::DevicePolicy* device_policy = system_state_->device_policy(); |
| 178 | |
| 179 | // The device_policy is loaded in a lazy way before an update check. Load it |
| 180 | // now from the libbrillo cache if it wasn't already loaded. |
| 181 | if (!device_policy) { |
| 182 | UpdateAttempter* update_attempter = system_state_->update_attempter(); |
| 183 | if (update_attempter) { |
| 184 | update_attempter->RefreshDevicePolicy(); |
| 185 | device_policy = system_state_->device_policy(); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | bool delegated = false; |
| 190 | if (device_policy && device_policy->GetReleaseChannelDelegated(&delegated) && |
| 191 | !delegated) { |
| 192 | LogAndSetError(error, |
| 193 | FROM_HERE, |
| 194 | "Cannot set target channel explicitly when channel " |
| 195 | "policy/settings is not delegated"); |
| 196 | return false; |
| 197 | } |
| 198 | |
| 199 | LOG(INFO) << "Setting destination channel to: " << in_target_channel; |
| 200 | string error_message; |
| 201 | if (!system_state_->request_params()->SetTargetChannel( |
| 202 | in_target_channel, in_is_powerwash_allowed, &error_message)) { |
| 203 | LogAndSetError(error, FROM_HERE, error_message); |
| 204 | return false; |
| 205 | } |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 206 | return true; |
| 207 | } |
| 208 | |
| 209 | bool UpdateEngineService::GetChannel(ErrorPtr* /* error */, |
| 210 | bool in_get_current_channel, |
| 211 | string* out_channel) { |
| 212 | OmahaRequestParams* rp = system_state_->request_params(); |
| 213 | *out_channel = |
| 214 | (in_get_current_channel ? rp->current_channel() : rp->target_channel()); |
| 215 | return true; |
| 216 | } |
| 217 | |
Alex Deymo | 5b5fa8b | 2016-10-06 15:40:49 -0700 | [diff] [blame] | 218 | bool UpdateEngineService::SetCohortHint(ErrorPtr* error, |
Andrew | 9d5a61d | 2020-03-26 13:40:37 -0700 | [diff] [blame] | 219 | const string& in_cohort_hint) { |
Alex Deymo | 5b5fa8b | 2016-10-06 15:40:49 -0700 | [diff] [blame] | 220 | PrefsInterface* prefs = system_state_->prefs(); |
| 221 | |
| 222 | // It is ok to override the cohort hint with an invalid value since it is |
| 223 | // stored in stateful partition. The code reading it should sanitize it |
| 224 | // anyway. |
| 225 | if (!prefs->SetString(kPrefsOmahaCohortHint, in_cohort_hint)) { |
| 226 | LogAndSetError( |
| 227 | error, |
| 228 | FROM_HERE, |
| 229 | StringPrintf("Error setting the cohort hint value to \"%s\".", |
| 230 | in_cohort_hint.c_str())); |
| 231 | return false; |
| 232 | } |
| 233 | return true; |
| 234 | } |
| 235 | |
| 236 | bool UpdateEngineService::GetCohortHint(ErrorPtr* error, |
| 237 | string* out_cohort_hint) { |
| 238 | PrefsInterface* prefs = system_state_->prefs(); |
| 239 | |
| 240 | *out_cohort_hint = ""; |
| 241 | if (prefs->Exists(kPrefsOmahaCohortHint) && |
| 242 | !prefs->GetString(kPrefsOmahaCohortHint, out_cohort_hint)) { |
| 243 | LogAndSetError(error, FROM_HERE, "Error getting the cohort hint."); |
| 244 | return false; |
| 245 | } |
| 246 | return true; |
| 247 | } |
| 248 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 249 | bool UpdateEngineService::SetP2PUpdatePermission(ErrorPtr* error, |
| 250 | bool in_enabled) { |
| 251 | PrefsInterface* prefs = system_state_->prefs(); |
| 252 | |
| 253 | if (!prefs->SetBoolean(kPrefsP2PEnabled, in_enabled)) { |
| 254 | LogAndSetError( |
| 255 | error, |
| 256 | FROM_HERE, |
| 257 | StringPrintf("Error setting the update via p2p permission to %s.", |
| 258 | ToString(in_enabled).c_str())); |
| 259 | return false; |
| 260 | } |
| 261 | return true; |
| 262 | } |
| 263 | |
| 264 | bool UpdateEngineService::GetP2PUpdatePermission(ErrorPtr* error, |
| 265 | bool* out_enabled) { |
| 266 | PrefsInterface* prefs = system_state_->prefs(); |
| 267 | |
| 268 | bool p2p_pref = false; // Default if no setting is present. |
| 269 | if (prefs->Exists(kPrefsP2PEnabled) && |
| 270 | !prefs->GetBoolean(kPrefsP2PEnabled, &p2p_pref)) { |
| 271 | LogAndSetError(error, FROM_HERE, "Error getting the P2PEnabled setting."); |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | *out_enabled = p2p_pref; |
| 276 | return true; |
| 277 | } |
| 278 | |
| 279 | bool UpdateEngineService::SetUpdateOverCellularPermission(ErrorPtr* error, |
| 280 | bool in_allowed) { |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 281 | ConnectionManagerInterface* connection_manager = |
| 282 | system_state_->connection_manager(); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 283 | |
| 284 | // Check if this setting is allowed by the device policy. |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 285 | if (connection_manager->IsAllowedConnectionTypesForUpdateSet()) { |
Tao Bao | 5688d16 | 2017-06-06 13:09:06 -0700 | [diff] [blame] | 286 | LogAndSetError(error, |
| 287 | FROM_HERE, |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 288 | "Ignoring the update over cellular setting since there's " |
| 289 | "a device policy enforcing this setting."); |
| 290 | return false; |
| 291 | } |
| 292 | |
| 293 | // If the policy wasn't loaded yet, then it is still OK to change the local |
| 294 | // setting because the policy will be checked again during the update check. |
| 295 | |
| 296 | PrefsInterface* prefs = system_state_->prefs(); |
| 297 | |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 298 | if (!prefs || |
| 299 | !prefs->SetBoolean(kPrefsUpdateOverCellularPermission, in_allowed)) { |
Tao Bao | 5688d16 | 2017-06-06 13:09:06 -0700 | [diff] [blame] | 300 | LogAndSetError(error, |
| 301 | FROM_HERE, |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 302 | string("Error setting the update over cellular to ") + |
| 303 | (in_allowed ? "true" : "false")); |
| 304 | return false; |
| 305 | } |
| 306 | return true; |
| 307 | } |
| 308 | |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 309 | bool UpdateEngineService::SetUpdateOverCellularTarget( |
| 310 | brillo::ErrorPtr* error, |
| 311 | const std::string& target_version, |
| 312 | int64_t target_size) { |
| 313 | ConnectionManagerInterface* connection_manager = |
| 314 | system_state_->connection_manager(); |
Weidong Guo | 4b0d603 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 315 | |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 316 | // Check if this setting is allowed by the device policy. |
| 317 | if (connection_manager->IsAllowedConnectionTypesForUpdateSet()) { |
| 318 | LogAndSetError(error, |
| 319 | FROM_HERE, |
| 320 | "Ignoring the update over cellular setting since there's " |
| 321 | "a device policy enforcing this setting."); |
| 322 | return false; |
Weidong Guo | 4b0d603 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 323 | } |
Tao Bao | 5688d16 | 2017-06-06 13:09:06 -0700 | [diff] [blame] | 324 | |
Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 325 | // If the policy wasn't loaded yet, then it is still OK to change the local |
| 326 | // setting because the policy will be checked again during the update check. |
| 327 | |
| 328 | PrefsInterface* prefs = system_state_->prefs(); |
| 329 | |
| 330 | if (!prefs || |
| 331 | !prefs->SetString(kPrefsUpdateOverCellularTargetVersion, |
| 332 | target_version) || |
| 333 | !prefs->SetInt64(kPrefsUpdateOverCellularTargetSize, target_size)) { |
| 334 | LogAndSetError( |
| 335 | error, FROM_HERE, "Error setting the target for update over cellular."); |
| 336 | return false; |
| 337 | } |
| 338 | return true; |
| 339 | } |
| 340 | |
| 341 | bool UpdateEngineService::GetUpdateOverCellularPermission(ErrorPtr* error, |
| 342 | bool* out_allowed) { |
| 343 | ConnectionManagerInterface* connection_manager = |
| 344 | system_state_->connection_manager(); |
| 345 | |
| 346 | if (connection_manager->IsAllowedConnectionTypesForUpdateSet()) { |
| 347 | // We have device policy, so ignore the user preferences. |
| 348 | *out_allowed = connection_manager->IsUpdateAllowedOver( |
| 349 | ConnectionType::kCellular, ConnectionTethering::kUnknown); |
| 350 | } else { |
| 351 | PrefsInterface* prefs = system_state_->prefs(); |
| 352 | |
| 353 | if (!prefs || !prefs->Exists(kPrefsUpdateOverCellularPermission)) { |
| 354 | // Update is not allowed as user preference is not set or not available. |
| 355 | *out_allowed = false; |
| 356 | return true; |
| 357 | } |
| 358 | |
| 359 | bool is_allowed; |
| 360 | |
| 361 | if (!prefs->GetBoolean(kPrefsUpdateOverCellularPermission, &is_allowed)) { |
| 362 | LogAndSetError(error, |
| 363 | FROM_HERE, |
| 364 | "Error getting the update over cellular preference."); |
| 365 | return false; |
| 366 | } |
| 367 | *out_allowed = is_allowed; |
| 368 | } |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 369 | return true; |
| 370 | } |
| 371 | |
| 372 | bool UpdateEngineService::GetDurationSinceUpdate(ErrorPtr* error, |
| 373 | int64_t* out_usec_wallclock) { |
| 374 | base::Time time; |
| 375 | if (!system_state_->update_attempter()->GetBootTimeAtUpdate(&time)) { |
| 376 | LogAndSetError(error, FROM_HERE, "No pending update."); |
| 377 | return false; |
| 378 | } |
| 379 | |
| 380 | ClockInterface* clock = system_state_->clock(); |
| 381 | *out_usec_wallclock = (clock->GetBootTime() - time).InMicroseconds(); |
| 382 | return true; |
| 383 | } |
| 384 | |
| 385 | bool UpdateEngineService::GetPrevVersion(ErrorPtr* /* error */, |
| 386 | string* out_prev_version) { |
| 387 | *out_prev_version = system_state_->update_attempter()->GetPrevVersion(); |
| 388 | return true; |
| 389 | } |
| 390 | |
| 391 | bool UpdateEngineService::GetRollbackPartition( |
| 392 | ErrorPtr* /* error */, string* out_rollback_partition_name) { |
| 393 | BootControlInterface::Slot rollback_slot = |
| 394 | system_state_->update_attempter()->GetRollbackSlot(); |
| 395 | |
| 396 | if (rollback_slot == BootControlInterface::kInvalidSlot) { |
| 397 | out_rollback_partition_name->clear(); |
| 398 | return true; |
| 399 | } |
| 400 | |
| 401 | string name; |
| 402 | if (!system_state_->boot_control()->GetPartitionDevice( |
| 403 | "KERNEL", rollback_slot, &name)) { |
| 404 | LOG(ERROR) << "Invalid rollback device"; |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | LOG(INFO) << "Getting rollback partition name. Result: " << name; |
| 409 | *out_rollback_partition_name = name; |
| 410 | return true; |
| 411 | } |
| 412 | |
Shuqian Zhao | 2997173 | 2016-02-05 11:29:32 -0800 | [diff] [blame] | 413 | bool UpdateEngineService::GetLastAttemptError(ErrorPtr* /* error */, |
| 414 | int32_t* out_last_attempt_error) { |
Sen Jiang | 3978ddd | 2018-03-22 18:05:44 -0700 | [diff] [blame] | 415 | ErrorCode error_code = |
| 416 | system_state_->update_attempter()->GetAttemptErrorCode(); |
Shuqian Zhao | 2997173 | 2016-02-05 11:29:32 -0800 | [diff] [blame] | 417 | *out_last_attempt_error = static_cast<int>(error_code); |
| 418 | return true; |
| 419 | } |
Alex Deymo | b3fa53b | 2016-04-18 19:57:58 -0700 | [diff] [blame] | 420 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 421 | } // namespace chromeos_update_engine |