AU: Provide a reboot_if_needed D-Bus API.
This will reboot if the current state is UPDATED_REBOOT_NEEDED.
Also add -reboot option to the update_engine_client.
BUG=4250
TEST=unit tests,gmerged on device and tried reboot requests
Review URL: http://codereview.chromium.org/3034026
diff --git a/update_attempter.cc b/update_attempter.cc
index 014f822..939e074 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -221,6 +221,16 @@
Update(app_version, omaha_url);
}
+bool UpdateAttempter::RebootIfNeeded() {
+ if (status_ != UPDATE_STATUS_UPDATED_NEED_REBOOT) {
+ LOG(INFO) << "Reboot requested, but status is "
+ << UpdateStatusToString(status_) << ", so not rebooting.";
+ return false;
+ }
+ TEST_AND_RETURN_FALSE(utils::Reboot());
+ return true;
+}
+
// Delegate methods:
void UpdateAttempter::ProcessingDone(const ActionProcessor* processor,
ActionExitCode code) {