aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2015-10-30 21:56:55 -0700
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-11-02 23:24:52 +0000
commit87c08866cfc596234a1484147d3943d109418e7e (patch)
treee194769a239e4e2249b06a059c6fefa8960b315f
parent4cf1402b6245f1606788b1850b1a9c3571b0d27b (diff)
downloadupdate_engine-87c08866cfc596234a1484147d3943d109418e7e.tar.gz
Send "success reboot" only after an update.
The <event> message sent to omaha after we reboot into a new version was originally sent only on the first updatecheck after rebooting into the new installed version, and included the old version number. A bug introduced in 2013 removed the check for the empty previous version making the update_engine send this message on *every* updatecheck. This patch inserts back the check for the empty previous version to send the "success reboot" event only after. While there are still discussions about what's the right event message to send on that case, this fixes the regression. Bug: 24867646 Test: FEATURES=test emerge-link update_engine; second <updatecheck> didn't include the <event> Change-Id: Icd00364aae15c8bf420f1f89ae7b526999b3a124
-rw-r--r--omaha_request_action.cc25
-rw-r--r--update_attempter.cc6
2 files changed, 21 insertions, 10 deletions
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 89677627..8f405e8d 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -123,20 +123,25 @@ string GetAppBody(const OmahaEvent* event,
// generated with a previous version of 0.0.0.0 -- this is relevant for
// older clients or new installs. The previous version event is not sent
// for ping-only requests because they come before the client has
- // rebooted.
+ // rebooted. The previous version event is also not sent if it was already
+ // sent for this new version with a previous updatecheck.
string prev_version;
if (!prefs->GetString(kPrefsPreviousVersion, &prev_version)) {
prev_version = "0.0.0.0";
}
-
- app_body += base::StringPrintf(
- " <event eventtype=\"%d\" eventresult=\"%d\" "
- "previousversion=\"%s\"></event>\n",
- OmahaEvent::kTypeUpdateComplete,
- OmahaEvent::kResultSuccessReboot,
- XmlEncodeWithDefault(prev_version, "0.0.0.0").c_str());
- LOG_IF(WARNING, !prefs->SetString(kPrefsPreviousVersion, ""))
- << "Unable to reset the previous version.";
+ // We only store a non-empty previous version value after a successful
+ // update in the previous boot. After reporting it back to the server,
+ // we clear the previous version value so it doesn't get reported again.
+ if (!prev_version.empty()) {
+ app_body += base::StringPrintf(
+ " <event eventtype=\"%d\" eventresult=\"%d\" "
+ "previousversion=\"%s\"></event>\n",
+ OmahaEvent::kTypeUpdateComplete,
+ OmahaEvent::kResultSuccessReboot,
+ XmlEncodeWithDefault(prev_version, "0.0.0.0").c_str());
+ LOG_IF(WARNING, !prefs->SetString(kPrefsPreviousVersion, ""))
+ << "Unable to reset the previous version.";
+ }
}
} else {
// The error code is an optional attribute so append it only if the result
diff --git a/update_attempter.cc b/update_attempter.cc
index 1610ec46..09dd108b 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1083,6 +1083,12 @@ bool UpdateAttempter::ResetStatus() {
// Notify the PayloadState that the successful payload was canceled.
system_state_->payload_state()->ResetUpdateStatus();
+ // The previous version is used to report back to omaha after reboot that
+ // we actually rebooted into the new version from this "prev-version". We
+ // need to clear out this value now to prevent it being sent on the next
+ // updatecheck request.
+ ret_value = prefs_->SetString(kPrefsPreviousVersion, "") && ret_value;
+
LOG(INFO) << "Reset status " << (ret_value ? "successful" : "failed");
return ret_value;
}