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_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,