Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2404)

Unified Diff: chromeos/system/statistics_provider.cc

Issue 2774673004: Add stub implementations for state keys and VPD (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/system/statistics_provider.cc
diff --git a/chromeos/system/statistics_provider.cc b/chromeos/system/statistics_provider.cc
index 26fb751b78f404002cd4db7393515a4b70dda4a5..287fdb0fe76560aa2bc31e4c910e4dbdd7d34122 100644
--- a/chromeos/system/statistics_provider.cc
+++ b/chromeos/system/statistics_provider.cc
@@ -61,8 +61,7 @@ const char kEchoCouponFile[] = "/var/cache/echo/vpd_echo.txt";
const char kEchoCouponEq[] = "=";
const char kEchoCouponDelim[] = "\n";
-// File to get VPD info from, and key/value delimiters of the file.
-const char kVpdFile[] = "/var/log/vpd_2.0.txt";
+// Key/value delimiters for VPD file.
const char kVpdEq[] = "=";
const char kVpdDelim[] = "\n";
@@ -471,23 +470,32 @@ void StatisticsProviderImpl::LoadMachineStatistics(bool load_oem_manifest) {
std::string stub_contents =
"\"serial_number\"=\"stub_" +
base::Int64ToString(base::Time::Now().ToJavaTime()) + "\"\n";
- int bytes_written = base::WriteFile(machine_info_path,
- stub_contents.c_str(),
- stub_contents.size());
- // static_cast<int> is fine because stub_contents is small.
+ int bytes_written = base::WriteFile(
+ machine_info_path, stub_contents.c_str(), stub_contents.size());
if (bytes_written < static_cast<int>(stub_contents.size())) {
LOG(ERROR) << "Error writing machine info stub: "
Daniel Erat 2017/03/23 23:35:23 nit: PLOG(ERROR) will include errno
Thiemo Nagel 2017/04/11 15:29:32 Done.
<< machine_info_path.value();
}
}
+ base::FilePath vpd_path;
+ PathService::Get(chromeos::FILE_VPD, &vpd_path);
+ if (!base::SysInfo::IsRunningOnChromeOS() && !base::PathExists(vpd_path)) {
+ std::string stub_contents = "\"ActivateDate\"=\"2000-01\"\n";
+ int bytes_written =
+ base::WriteFile(vpd_path, stub_contents.c_str(), stub_contents.size());
+ if (bytes_written < static_cast<int>(stub_contents.size())) {
+ LOG(ERROR) << "Error writing vpd stub: " << vpd_path.value();
Daniel Erat 2017/03/23 23:35:23 PLOG(ERROR) here as well
Thiemo Nagel 2017/04/11 15:29:32 Done.
+ }
+ }
+
parser.GetNameValuePairsFromFile(machine_info_path,
kMachineHardwareInfoEq,
kMachineHardwareInfoDelim);
parser.GetNameValuePairsFromFile(base::FilePath(kEchoCouponFile),
kEchoCouponEq,
kEchoCouponDelim);
- parser.GetNameValuePairsFromFile(base::FilePath(kVpdFile),
+ parser.GetNameValuePairsFromFile(vpd_path,
kVpdEq,
kVpdDelim);
« chromeos/dbus/session_manager_client.cc ('K') | « chromeos/dbus/session_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698