Check the enrollment in /home/chronos/Local State in addition to the VPD.

This will allow us to migrate the remaining CfMs to the -cfm flavors of
their board images.

BUG=b:157901191
TEST=unit tests, compared behavior with fizz on a Teemo with and without
requisition in VPD, with and without enrollment in Local State JSON.

Cq-Depend: chromium:2239007
Change-Id: I99b05b8530265d4ef4c81472d0be6ba251f7049c
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2242361
Tested-by: Matthew Ziegelbaum <ziegs@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Matthew Ziegelbaum <ziegs@chromium.org>
diff --git a/hardware_chromeos.cc b/hardware_chromeos.cc
index 916b2e5..5c32648 100644
--- a/hardware_chromeos.cc
+++ b/hardware_chromeos.cc
@@ -38,6 +38,9 @@
 #include "update_engine/common/subprocess.h"
 #include "update_engine/common/utils.h"
 #include "update_engine/dbus_connection.h"
+#if USE_CFM
+#include "update_engine/requisition_util.h"
+#endif
 
 using std::string;
 using std::vector;
@@ -81,31 +84,6 @@
 
 const char* kActivePingKey = "first_active_omaha_ping_sent";
 
-#if USE_CFM
-const char* kOemRequisitionKey = "oem_device_requisition";
-#endif
-
-// 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, error;
-  vector<string> cmd = {"vpd_get_value", key};
-  if (!chromeos_update_engine::Subprocess::SynchronousExec(
-          cmd, &exit_code, &value, &error) ||
-      exit_code) {
-    LOG(ERROR) << "Failed to get vpd key for " << value
-               << " with exit code: " << exit_code << " and error: " << error;
-    return false;
-  } else if (!error.empty()) {
-    LOG(INFO) << "vpd_get_value succeeded but with following errors: " << error;
-  }
-
-  base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value);
-  *result = value;
-  return true;
-}
-
 }  // namespace
 
 namespace chromeos_update_engine {
@@ -217,11 +195,12 @@
 }
 
 string HardwareChromeOS::GetDeviceRequisition() const {
-  string requisition;
 #if USE_CFM
-  GetVpdValue(kOemRequisitionKey, &requisition);
+  const char* kLocalStatePath = "/home/chronos/Local State";
+  return ReadDeviceRequisition(base::FilePath(kLocalStatePath));
+#else
+  return "";
 #endif
-  return requisition;
 }
 
 int HardwareChromeOS::GetMinKernelKeyVersion() const {
@@ -346,7 +325,7 @@
 
 bool HardwareChromeOS::GetFirstActiveOmahaPingSent() const {
   string active_ping_str;
-  if (!GetVpdValue(kActivePingKey, &active_ping_str)) {
+  if (!utils::GetVpdValue(kActivePingKey, &active_ping_str)) {
     return false;
   }