update_engine: add chrome os device requisition to the omaha request

Requisition type is not currently sent to Omaha and is thus unavailable
for AU rules. This adds a requisition attribute to the <app> if the
device has a requisition type. Currently, the types may be one of
remora, shark, or rialto.

TEST=unittest
BUG=b:132014633,b:133324571

Change-Id: I0e53d3a5749da4cbb95ce73cff35191066339009
Reviewed-on: https://chromium-review.googlesource.com/1604218
Commit-Ready: Matthew Ziegelbaum <ziegs@chromium.org>
Tested-by: Matthew Ziegelbaum <ziegs@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/hardware_chromeos.cc b/hardware_chromeos.cc
index 60583e1..dd21c1b 100644
--- a/hardware_chromeos.cc
+++ b/hardware_chromeos.cc
@@ -81,6 +81,27 @@
 
 const char* kActivePingKey = "first_active_omaha_ping_sent";
 
+const char* kOemRequisitionKey = "oem_device_requisition";
+
+// Gets a string value from the vpd for a given key using the `vpd_get_value`
+// shell command. Returns true on success.
+int GetVpdValue(string key, string* result) {
+  int exit_code = 0;
+  string value;
+  vector<string> cmd = {"vpd_get_value", key};
+  if (!chromeos_update_engine::Subprocess::SynchronousExec(
+          cmd, &exit_code, &value) ||
+      exit_code) {
+    LOG(ERROR) << "Failed to get vpd key for " << value
+               << " with exit code: " << exit_code;
+    return false;
+  }
+
+  base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value);
+  *result = value;
+  return true;
+}
+
 }  // namespace
 
 namespace chromeos_update_engine {
@@ -190,6 +211,11 @@
   return utils::ParseECVersion(input_line);
 }
 
+string HardwareChromeOS::GetDeviceRequisition() const {
+  string requisition;
+  return GetVpdValue(kOemRequisitionKey, &requisition) ? requisition : "";
+}
+
 int HardwareChromeOS::GetMinKernelKeyVersion() const {
   return VbGetSystemPropertyInt("tpm_kernver");
 }
@@ -311,17 +337,11 @@
 }
 
 bool HardwareChromeOS::GetFirstActiveOmahaPingSent() const {
-  int exit_code = 0;
   string active_ping_str;
-  vector<string> cmd = {"vpd_get_value", kActivePingKey};
-  if (!Subprocess::SynchronousExec(cmd, &exit_code, &active_ping_str) ||
-      exit_code) {
-    LOG(ERROR) << "Failed to get vpd key for " << kActivePingKey
-               << " with exit code: " << exit_code;
+  if (!GetVpdValue(kActivePingKey, &active_ping_str)) {
     return false;
   }
 
-  base::TrimWhitespaceASCII(active_ping_str, base::TRIM_ALL, &active_ping_str);
   int active_ping;
   if (active_ping_str.empty() ||
       !base::StringToInt(active_ping_str, &active_ping)) {