Send Omaha event_type 54 after reboot to new update.
When rebooting to a new version, we were sending an Omaha event_type 3
to flag a "success reboot". Nevertheless, the server expect us to send
only one event_type 3 for every <updatecheck> response with a payload
but we were sending one event_type 3 upon payload application and
another one after reboot.
This patch changes the event_type sent after reboot to 54, a value
reserved from Chromium OS clients.
Bug: None
Test: Added unittest.
Change-Id: I199a2b00c702175762f2c154ca2f45b3f6ad768c
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 8f405e8..cc762c8 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -136,8 +136,8 @@
app_body += base::StringPrintf(
" <event eventtype=\"%d\" eventresult=\"%d\" "
"previousversion=\"%s\"></event>\n",
- OmahaEvent::kTypeUpdateComplete,
- OmahaEvent::kResultSuccessReboot,
+ OmahaEvent::kTypeRebootedAfterUpdate,
+ OmahaEvent::kResultSuccess,
XmlEncodeWithDefault(prev_version, "0.0.0.0").c_str());
LOG_IF(WARNING, !prefs->SetString(kPrefsPreviousVersion, ""))
<< "Unable to reset the previous version.";
diff --git a/omaha_request_action.h b/omaha_request_action.h
index f1b81ec..57ef250 100644
--- a/omaha_request_action.h
+++ b/omaha_request_action.h
@@ -59,13 +59,15 @@
kTypeUpdateComplete = 3,
kTypeUpdateDownloadStarted = 13,
kTypeUpdateDownloadFinished = 14,
+ // Chromium OS reserved type sent after the first reboot following an update
+ // completed.
+ kTypeRebootedAfterUpdate = 54,
};
// The Result values correspond to EVENT_RESULT values of Omaha.
enum Result {
kResultError = 0,
kResultSuccess = 1,
- kResultSuccessReboot = 2,
kResultUpdateDeferred = 9, // When we ignore/defer updates due to policy.
};
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 1ee2151..aa62271 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -1877,6 +1877,40 @@
EXPECT_EQ(string::npos, post_str.find("<ping"));
}
+// Checks that the event 54 is sent on a reboot to a new update.
+TEST_F(OmahaRequestActionTest, RebootAfterUpdateEvent) {
+ // Flag that the device was updated in a previous boot.
+ fake_prefs_.SetString(kPrefsPreviousVersion, "1.2.3.4");
+
+ brillo::Blob post_data;
+ ASSERT_TRUE(
+ TestUpdateCheck(nullptr, // request_params
+ fake_update_response_.GetNoUpdateResponse(),
+ -1,
+ false, // ping_only
+ ErrorCode::kSuccess,
+ metrics::CheckResult::kNoUpdateAvailable,
+ metrics::CheckReaction::kUnset,
+ metrics::DownloadErrorCode::kUnset,
+ nullptr,
+ &post_data));
+ string post_str(post_data.begin(), post_data.end());
+
+ // An event 54 is included and has the right version.
+ EXPECT_NE(string::npos,
+ post_str.find(base::StringPrintf(
+ "<event eventtype=\"%d\"",
+ OmahaEvent::kTypeRebootedAfterUpdate)));
+ EXPECT_NE(string::npos,
+ post_str.find("previousversion=\"1.2.3.4\"></event>"));
+
+ // The previous version flag should have been removed.
+ EXPECT_TRUE(fake_prefs_.Exists(kPrefsPreviousVersion));
+ string prev_version;
+ EXPECT_TRUE(fake_prefs_.GetString(kPrefsPreviousVersion, &prev_version));
+ EXPECT_TRUE(prev_version.empty());
+}
+
void OmahaRequestActionTest::P2PTest(
bool initial_allow_p2p_for_downloading,
bool initial_allow_p2p_for_sharing,