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.cc b/omaha_request_action.cc
index ed3c716..47f3e37 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -574,6 +574,11 @@
<< "powerwash_count is " << powerwash_count;
return false;
}
+ if (system_state_->hardware()->GetFirstActiveOmahaPingSent()) {
+ LOG(INFO) << "Not sending ping with a=-1 r=-1 to omaha because "
+ << "the first_active_omaha_ping_sent is true";
+ return false;
+ }
return true;
}
return ping_active_days_ > 0 || ping_roll_call_days_ > 0;
@@ -988,6 +993,16 @@
LOG_IF(ERROR, !UpdateLastPingDays(&parser_data, system_state_->prefs()))
<< "Failed to update the last ping day preferences!";
+ // Sets first_active_omaha_ping_sent to true (vpd in CrOS). We only do this if
+ // we have got a response from omaha and if its value has never been set to
+ // true before. Failure of this function should be ignored. There should be no
+ // need to check if a=-1 has been sent because older devices have already sent
+ // their a=-1 in the past and we have to set first_active_omaha_ping_sent for
+ // future checks.
+ if (!system_state_->hardware()->GetFirstActiveOmahaPingSent()) {
+ system_state_->hardware()->SetFirstActiveOmahaPingSent();
+ }
+
if (!HasOutputPipe()) {
// Just set success to whether or not the http transfer succeeded,
// which must be true at this point in the code.