Report build_type to Omaha.

Send additional os_build_type <app> attribute to distinguish between
user and userdebug images.

Bug: 36491462
Test: check omaha request xml
Change-Id: I519e85293db9a2194e0cd015a3a944adc723c3dd
(cherry picked from commit eba2297072914582aed5008ad5f99374124ae4d7)
diff --git a/image_properties.h b/image_properties.h
index ac6d474..4f94eeb 100644
--- a/image_properties.h
+++ b/image_properties.h
@@ -45,6 +45,10 @@
   // the version, signing keys and build target.
   std::string build_fingerprint;
 
+  // The Android build type, should be either 'user', 'userdebug' or 'eng'.
+  // It's empty string on other platform.
+  std::string build_type;
+
   // The board name this image was built for.
   std::string board;
 
diff --git a/image_properties_android.cc b/image_properties_android.cc
index 0e6385d..e815dbf 100644
--- a/image_properties_android.cc
+++ b/image_properties_android.cc
@@ -45,6 +45,7 @@
 // System properties that identifies the "board".
 const char kPropProductName[] = "ro.product.name";
 const char kPropBuildFingerprint[] = "ro.build.fingerprint";
+const char kPropBuildType[] = "ro.build.type";
 
 std::string GetStringWithDefault(const brillo::OsReleaseReader& osrelease,
                                  const std::string& key,
@@ -87,6 +88,9 @@
   property_get(kPropBuildFingerprint, prop, "none");
   result.build_fingerprint = prop;
 
+  property_get(kPropBuildType, prop, "");
+  result.build_type = prop;
+
   // Brillo images don't have a channel assigned. We stored the name of the
   // channel where we got the image from in prefs at the time of the update, so
   // we use that as the current channel if available. During provisioning, there
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 0026ad5..473f138 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -270,12 +270,19 @@
         "fingerprint=\"" + XmlEncodeWithDefault(params->os_build_fingerprint(), "") + "\" ";
   }
 
+  string buildtype_arg;
+  if (!params->os_build_type().empty()) {
+    buildtype_arg = "os_build_type=\"" +
+                    XmlEncodeWithDefault(params->os_build_type(), "") + "\" ";
+  }
+
   string app_xml = "    <app "
       "appid=\"" + XmlEncodeWithDefault(app_data.id, "") + "\" " +
       app_cohort_args +
       app_versions +
       app_channels +
       fingerprint_arg +
+      buildtype_arg +
       "lang=\"" + XmlEncodeWithDefault(params->app_lang(), "en-US") + "\" " +
       "board=\"" + XmlEncodeWithDefault(params->os_board(), "") + "\" " +
       "hardware_class=\"" + XmlEncodeWithDefault(params->hwid(), "") + "\" " +
diff --git a/omaha_request_params.h b/omaha_request_params.h
index cdc5f38..f8e9438 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -105,6 +105,7 @@
   inline std::string os_build_fingerprint() const {
     return image_props_.build_fingerprint;
   }
+  inline std::string os_build_type() const { return image_props_.build_type; }
   inline std::string board_app_id() const { return image_props_.product_id; }
   inline std::string canary_app_id() const {
     return image_props_.canary_product_id;