AU: Use crossystem hwid to obtain the hardware class.

This is more portable than reading the HWID from the ACPI file and should work
on ARM.

BUG=chromium-os:15255
TEST=unit tests, ran AU on Cr-48, checked the Omaha update check request

Change-Id: I8a2750140da7da99c217a6976f46b1b226696276
Reviewed-on: http://gerrit.chromium.org/gerrit/1078
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Thieu Le <thieule@chromium.org>
diff --git a/utils.cc b/utils.cc
index 9c05a25..bcf34d5 100644
--- a/utils.cc
+++ b/utils.cc
@@ -66,6 +66,23 @@
   return !dev_mode;
 }
 
+string GetHardwareClass() {
+  // TODO(petkov): Convert to a library call once a crossystem library is
+  // available (crosbug.com/13291).
+  int exit_code = 0;
+  vector<string> cmd(1, "/usr/bin/crossystem");
+  cmd.push_back("hwid");
+
+  string hwid;
+  bool success = Subprocess::SynchronousExec(cmd, &exit_code, &hwid);
+  if (success && !exit_code) {
+    TrimWhitespaceASCII(hwid, TRIM_ALL, &hwid);
+    return hwid;
+  }
+  LOG(ERROR) << "Unable to read HWID (" << exit_code << ") " << hwid;
+  return "";
+}
+
 bool WriteFile(const char* path, const char* data, int data_len) {
   DirectFileWriter writer;
   TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path,