AU: Always run setgoodkernel, unless we abort within 45 seconds of launch.
This addresses a bug in the updater. Previously, we ran setgoodkernel
within 45 seconds of boot, unless an update was running or completed
successfully (thus requiring us to reboot). This change keeps the
indended behavior of running within 45 seconds of boot, but prevents
updating from interfering.
BUG=chromium-os:14280
TEST=tested on device
Change-Id: Ib6a8978835a68440d671785577abccdc5856ef1d
Review URL: http://codereview.chromium.org/6881037
diff --git a/update_attempter.cc b/update_attempter.cc
index f56c0d1..e1ab0b1 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -28,6 +28,7 @@
#include "update_engine/omaha_response_handler_action.h"
#include "update_engine/postinstall_runner_action.h"
#include "update_engine/prefs_interface.h"
+#include "update_engine/subprocess.h"
#include "update_engine/update_check_scheduler.h"
using base::TimeDelta;
@@ -114,7 +115,8 @@
is_full_update_(false),
proxy_manual_checks_(0),
obeying_proxies_(true),
- chrome_proxy_resolver_(dbus_iface) {
+ chrome_proxy_resolver_(dbus_iface),
+ updated_boot_flags_(false) {
if (utils::FileExists(kUpdateCompletedMarker))
status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT;
}
@@ -127,6 +129,7 @@
const std::string& omaha_url,
bool obey_proxies) {
chrome_proxy_resolver_.Init();
+ UpdateBootFlags(); // Just in case we didn't do this yet.
if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) {
LOG(INFO) << "Not updating b/c we already updated and we're waiting for "
<< "reboot";
@@ -451,6 +454,19 @@
return true;
}
+void UpdateAttempter::UpdateBootFlags() {
+ if (updated_boot_flags_) {
+ LOG(INFO) << "Already updated boot flags. Skipping.";
+ return;
+ }
+ // This is purely best effort. Failures should be logged by Subprocess.
+ int unused = 0;
+ vector<string> cmd(1, "/usr/sbin/chromeos-setgoodkernel");
+ Subprocess::SynchronousExec(cmd, &unused);
+ updated_boot_flags_ = true;
+ return;
+}
+
void UpdateAttempter::SetStatusAndNotify(UpdateStatus status) {
status_ = status;
if (update_check_scheduler_) {