update_engine: Add ping for DLCs in update_engine

Send ping to omaha with the metadata values 'active','date_last_active'
and 'date_last_rollcall'. Update engine resets the 'active' flag after
succesfully sending a ping to Omaha. The 'date_last_active' value is
sent and updated only when the DLC was active since the previous ping.
'date_last_rollcall' is sent on every ping.

BUG=chromium:912666
TEST=unittests
TEST=Test on DUT using Nebraska and forcing ping values by changing the
metadata files in /var/lib/dlc/dummy-dlc/.
Installed dlc using:dlcservice_util --dlc_ids="dummy-dlc" --install
Trigger the pings by calling: update_engine_client --check_for_update
Change-Id: I47eff8c7923f5b3a7e892c281933c9a12b619ee7
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2001095
Tested-by: Andrew Lassalle <andrewlassalle@chromium.org>
Commit-Queue: Andrew Lassalle <andrewlassalle@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_builder_xml.h b/omaha_request_builder_xml.h
index d7a81d3..50c708d 100644
--- a/omaha_request_builder_xml.h
+++ b/omaha_request_builder_xml.h
@@ -33,13 +33,17 @@
 
 #include "update_engine/common/action.h"
 #include "update_engine/common/http_fetcher.h"
+#include "update_engine/omaha_request_params.h"
 #include "update_engine/omaha_response.h"
 #include "update_engine/system_state.h"
 
 namespace chromeos_update_engine {
 
-extern const int kNeverPinged;
 extern const char kNoVersion[];
+extern const int kPingNeverPinged;
+extern const int kPingUnknownValue;
+extern const int kPingActiveValue;
+extern const int kPingInactiveValue;
 
 // This struct encapsulates the Omaha event information. For a
 // complete list of defined event types and results, see
@@ -87,6 +91,7 @@
   std::string product_components;
   bool skip_update;
   bool is_dlc;
+  OmahaRequestParams::AppParams app_params;
 };
 
 // Encodes XML entities in a given string. Input must be ASCII-7 valid. If
@@ -158,9 +163,7 @@
 
   // Returns an XML that goes into the body of the <app> element of the Omaha
   // request based on the given parameters.
-  // The skip_updatecheck argument if set to true will omit the emission of
-  // the updatecheck xml tag in the body of the <app> element.
-  std::string GetAppBody(bool skip_updatecheck) const;
+  std::string GetAppBody(const OmahaAppData& app_data) const;
 
   // Returns the cohort* argument to include in the <app> tag for the passed
   // |arg_name| and |prefs_key|, if any. The return value is suitable to
@@ -173,6 +176,11 @@
   // sent, or an empty string otherwise.
   std::string GetPing() const;
 
+  // Returns an XML ping element if any of the elapsed days need to be
+  // sent, or an empty string otherwise.
+  std::string GetPingDateBased(
+      const OmahaRequestParams::AppParams& app_params) const;
+
   const OmahaEvent* event_;
   OmahaRequestParams* params_;
   bool ping_only_;