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/common/utils.cc b/common/utils.cc
index 644493d..50b45fa 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -910,6 +910,25 @@
return true;
}
+bool 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;
+}
+
bool GetBootId(string* boot_id) {
TEST_AND_RETURN_FALSE(
base::ReadFileToString(base::FilePath(kBootIdPath), boot_id));