Return the daemon error code when update_engine_sideload finishes
When update_engine_sideload exits, it returns 0 on success and 1 if the
error code returned is a value other than
chromeos_update_engine::ErrorCode::kSuccess.
Instead return ErrorCode from ApplyUpdatePayload, so return values can
be mapped to the ErrorCode enum values.
Bug:229758654
Change-Id: I1874f8bf2e1331d7c9128d49e0526465d31972e5
diff --git a/aosp/sideload_main.cc b/aosp/sideload_main.cc
index 4a92ca7..9e7512e 100644
--- a/aosp/sideload_main.cc
+++ b/aosp/sideload_main.cc
@@ -120,7 +120,7 @@
};
// Apply an update payload directly from the given payload URI.
-bool ApplyUpdatePayload(const string& payload,
+ErrorCode ApplyUpdatePayload(const string& payload,
int64_t payload_offset,
int64_t payload_size,
const vector<string>& headers,
@@ -145,13 +145,13 @@
boot_control::CreateBootControl();
if (!boot_control) {
LOG(ERROR) << "Error initializing the BootControlInterface.";
- return false;
+ return ErrorCode::kError;
}
std::unique_ptr<HardwareInterface> hardware = hardware::CreateHardware();
if (!hardware) {
LOG(ERROR) << "Error initializing the HardwareInterface.";
- return false;
+ return ErrorCode::kError;
}
UpdateAttempterAndroid update_attempter(&sideload_daemon_state,
@@ -161,11 +161,13 @@
nullptr);
update_attempter.Init();
- TEST_AND_RETURN_FALSE(update_attempter.ApplyPayload(
- payload, payload_offset, payload_size, headers, nullptr));
+ if (!update_attempter.ApplyPayload(
+ payload, payload_offset, payload_size, headers, nullptr)) {
+ LOG(ERROR) << "Error attempting the ApplyPayload.";
+ }
loop.Run();
- return sideload_daemon_state.status() == UpdateStatus::UPDATED_NEED_REBOOT;
+ return sideload_daemon_state.error_code();
}
} // namespace
@@ -198,9 +200,6 @@
vector<string> headers = base::SplitString(
FLAGS_headers, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
- if (!chromeos_update_engine::ApplyUpdatePayload(
- FLAGS_payload, FLAGS_offset, FLAGS_size, headers, FLAGS_status_fd))
- return 1;
-
- return 0;
+ return static_cast<int>(chromeos_update_engine::ApplyUpdatePayload(
+ FLAGS_payload, FLAGS_offset, FLAGS_size, headers, FLAGS_status_fd));
}