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

Unified Diff: chromeos/system/statistics_provider.cc

Issue 2774673004: Add stub implementations for state keys and VPD (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « chromeos/dbus/session_manager_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/system/statistics_provider.cc
diff --git a/chromeos/system/statistics_provider.cc b/chromeos/system/statistics_provider.cc
index 26fb751b78f404002cd4db7393515a4b70dda4a5..3273aa96c0e43e3602e8af11146e831a7e586e40 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,13 +470,22 @@ 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: "
- << machine_info_path.value();
+ PLOG(ERROR) << "Error writing machine info stub "
+ << 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())) {
+ PLOG(ERROR) << "Error writing vpd stub " << vpd_path.value();
}
}
@@ -487,7 +495,7 @@ void StatisticsProviderImpl::LoadMachineStatistics(bool load_oem_manifest) {
parser.GetNameValuePairsFromFile(base::FilePath(kEchoCouponFile),
kEchoCouponEq,
kEchoCouponDelim);
- parser.GetNameValuePairsFromFile(base::FilePath(kVpdFile),
+ parser.GetNameValuePairsFromFile(vpd_path,
kVpdEq,
kVpdDelim);
« no previous file with comments | « chromeos/dbus/session_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698