Support in update_engine for script for UI jank investigation.
We need to update image_to_live.sh to run in a loop to help investigate
the kernel behavior during AU. Since update_engine doesn't allow a
new update to be applied unless the device is rebooted after the previous
update, this CL adds an option to reset the state for testing purposes.
This CL does not cause any change in product code, since
update_engine_client will never be invoked with this option in product.
BUG=chromium-os:27954
TEST=Tested on ZGB.
Change-Id: I561e58893818a1b4990fdc131cd3bb64e473155e
Reviewed-on: https://gerrit.chromium.org/gerrit/29907
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 4422e4c..6bef755 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -14,6 +14,7 @@
#include <tr1/memory>
#include <vector>
+#include <base/file_util.h>
#include <base/rand_util.h>
#include <glib.h>
#include <metrics/metrics_library.h>
@@ -717,6 +718,32 @@
}
}
+bool UpdateAttempter::ResetStatus() {
+ LOG(INFO) << "Attempting to reset state from "
+ << UpdateStatusToString(status_) << " to UPDATE_STATUS_IDLE";
+
+ switch (status_) {
+ case UPDATE_STATUS_IDLE:
+ // no-op.
+ return true;
+
+ case UPDATE_STATUS_UPDATED_NEED_REBOOT: {
+ status_ = UPDATE_STATUS_IDLE;
+ LOG(INFO) << "Reset Successful";
+
+ // also remove the reboot marker so that if the machine is rebooted
+ // after resetting to idle state, it doesn't go back to
+ // UPDATE_STATUS_UPDATED_NEED_REBOOT state.
+ const FilePath kUpdateCompletedMarkerPath(kUpdateCompletedMarker);
+ return file_util::Delete(kUpdateCompletedMarkerPath, false);
+ }
+
+ default:
+ LOG(ERROR) << "Reset not allowed in this state.";
+ return false;
+ }
+}
+
bool UpdateAttempter::GetStatus(int64_t* last_checked_time,
double* progress,
string* current_operation,