Adds check/set for first_active_omaha_ping_sent (from vpd).
first_active_omaha_ping_sent is a boolean in RW_VPD that is checked to
decide whether to send the first active ping (a=-1) to omaha. update_engine
reads its value and sets it to "true" after first active ping is sent or
if the first ping has been sent already and it does not exits in the vpd
(to capture the same feature for older devices).
BUG=chromium:717788
TEST=cros_workon_make --test; Deployed on a device and made sure the
flag is read and writen properly.
CQ-DEPEND=CL:469126
Change-Id: I867d16de1d5d2da4d7a7e1f26aa8e951d90b68f2
Reviewed-on: https://chromium-review.googlesource.com/469107
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index cb3ef71..8c92d00 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -2145,6 +2145,35 @@
EXPECT_EQ(string::npos, post_str.find("<ping"));
}
+// Checks that the initial ping with a=-1 r=-1 is not send when the device
+// first_active_omaha_ping_sent is set.
+TEST_F(OmahaRequestActionTest, PingWhenFirstActiveOmahaPingIsSent) {
+ fake_prefs_.SetString(kPrefsPreviousVersion, "");
+
+ // Flag that the device was not powerwashed in the past.
+ fake_system_state_.fake_hardware()->SetPowerwashCount(0);
+
+ // Flag that the device has sent first active ping in the past.
+ fake_system_state_.fake_hardware()->SetFirstActiveOmahaPingSent();
+
+ 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));
+ // We shouldn't send a ping in this case since
+ // first_active_omaha_ping_sent=true
+ string post_str(post_data.begin(), post_data.end());
+ 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.