Commit ccced1bd authored by Trent Begin's avatar Trent Begin Committed by Commit Bot

DeviceStatusCollector: add ProbeError to TimezoneInfo request

Update cros_healthd telemetry handling code to check for and log errors
from TimezoneInfo request.

Bug: chromium:1041153
Change-Id: I2319094bd80b478c275ee4ceee35faa9e75263f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145925Reviewed-by: default avatarJesse Schettler <jschettler@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Trent Begin <tbegin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758863}
parent ca7d8748
...@@ -893,13 +893,21 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -893,13 +893,21 @@ class DeviceStatusCollectorState : public StatusCollectorState {
} }
} }
const auto& timezone_info = probe_result->timezone_info; // Process TimezoneResult.
if (!timezone_info.is_null()) { const auto& timezone_result = probe_result->timezone_result;
em::TimezoneInfo* const timezone_info_out = if (!timezone_result.is_null()) {
response_params_.device_status->mutable_timezone_info(); if (timezone_result->is_error()) {
timezone_info_out->set_posix(timezone_info->posix); LOG(ERROR) << "cros_healthd: Error getting timezone info: "
timezone_info_out->set_region(timezone_info->region); << timezone_result->get_error()->msg;
} else {
const auto& timezone_info = timezone_result->get_timezone_info();
em::TimezoneInfo* const timezone_info_out =
response_params_.device_status->mutable_timezone_info();
timezone_info_out->set_posix(timezone_info->posix);
timezone_info_out->set_region(timezone_info->region);
}
} }
const auto& memory_info = probe_result->memory_info; const auto& memory_info = probe_result->memory_info;
if (!memory_info.is_null()) { if (!memory_info.is_null()) {
em::MemoryInfo* const memory_info_out = em::MemoryInfo* const memory_info_out =
......
...@@ -480,8 +480,10 @@ void GetFakeCrosHealthdData( ...@@ -480,8 +480,10 @@ void GetFakeCrosHealthdData(
base::Optional<std::vector< base::Optional<std::vector<
chromeos::cros_healthd::mojom::NonRemovableBlockDeviceInfoPtr>> chromeos::cros_healthd::mojom::NonRemovableBlockDeviceInfoPtr>>
block_device_info(std::move(storage_vector)); block_device_info(std::move(storage_vector));
chromeos::cros_healthd::mojom::TimezoneInfo timezone_info(kPosixTimezone, auto timezone_result =
kTimezoneRegion); chromeos::cros_healthd::mojom::TimezoneResult::NewTimezoneInfo(
chromeos::cros_healthd::mojom::TimezoneInfo::New(kPosixTimezone,
kTimezoneRegion));
chromeos::cros_healthd::mojom::MemoryInfo memory_info( chromeos::cros_healthd::mojom::MemoryInfo memory_info(
kFakeTotalMemory, kFakeFreeMemory, kFakeAvailableMemory, kFakePageFaults); kFakeTotalMemory, kFakeFreeMemory, kFakeAvailableMemory, kFakePageFaults);
std::vector<chromeos::cros_healthd::mojom::BacklightInfoPtr> backlight_vector; std::vector<chromeos::cros_healthd::mojom::BacklightInfoPtr> backlight_vector;
...@@ -493,8 +495,9 @@ void GetFakeCrosHealthdData( ...@@ -493,8 +495,9 @@ void GetFakeCrosHealthdData(
fan_vector.push_back(fan_info.Clone()); fan_vector.push_back(fan_info.Clone());
chromeos::cros_healthd::mojom::TelemetryInfo fake_info( chromeos::cros_healthd::mojom::TelemetryInfo fake_info(
battery_info.Clone(), std::move(block_device_info), battery_info.Clone(), std::move(block_device_info),
cached_vpd_info.Clone(), std::move(cpu_result), timezone_info.Clone(), cached_vpd_info.Clone(), std::move(cpu_result),
memory_info.Clone(), std::move(backlight_vector), std::move(fan_vector)); std::move(timezone_result), memory_info.Clone(),
std::move(backlight_vector), std::move(fan_vector));
// Create fake SampledData. // Create fake SampledData.
em::CPUTempInfo fake_cpu_temp_sample; em::CPUTempInfo fake_cpu_temp_sample;
......
...@@ -117,9 +117,9 @@ mojom::CpuResultPtr MakeCpuResult() { ...@@ -117,9 +117,9 @@ mojom::CpuResultPtr MakeCpuResult() {
return mojom::CpuResult::NewCpuInfo(std::move(cpu_info)); return mojom::CpuResult::NewCpuInfo(std::move(cpu_info));
} }
mojom::TimezoneInfoPtr MakeTimezoneInfo() { mojom::TimezoneResultPtr MakeTimezoneResult() {
return mojom::TimezoneInfo::New("MST7MDT,M3.2.0,M11.1.0" /* posix */, return mojom::TimezoneResult::NewTimezoneInfo(mojom::TimezoneInfo::New(
"America/Denver" /* region */); "MST7MDT,M3.2.0,M11.1.0" /* posix */, "America/Denver" /* region */));
} }
mojom::MemoryInfoPtr MakeMemoryInfo() { mojom::MemoryInfoPtr MakeMemoryInfo() {
...@@ -150,7 +150,7 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() { ...@@ -150,7 +150,7 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() {
MakeBatteryInfo() /* battery_info */, MakeBatteryInfo() /* battery_info */,
MakeNonRemovableBlockDeviceInfo() /* block_device_info */, MakeNonRemovableBlockDeviceInfo() /* block_device_info */,
MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */, MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */,
MakeTimezoneInfo() /* timezone_info */, MakeTimezoneResult() /* timezone_result */,
MakeMemoryInfo() /* memory_info */, MakeMemoryInfo() /* memory_info */,
MakeBacklightInfo() /* backlight_info */, MakeFanInfo() /* fan_info */ MakeBacklightInfo() /* backlight_info */, MakeFanInfo() /* fan_info */
); );
......
...@@ -131,6 +131,15 @@ struct CpuInfo { ...@@ -131,6 +131,15 @@ struct CpuInfo {
uint32 max_clock_speed_khz; uint32 max_clock_speed_khz;
}; };
// Timezone probe result. Can either be populated with the TimezoneInfo or an
// error retrieving the information.
union TimezoneResult {
// Valid TimezoneInfo.
TimezoneInfo timezone_info;
// The error that occurred attempting to retrieve the TimezoneInfo.
ProbeError error;
};
// Timezone information. // Timezone information.
struct TimezoneInfo { struct TimezoneInfo {
// The timezone of the device in POSIX standard. // The timezone of the device in POSIX standard.
...@@ -191,7 +200,7 @@ struct TelemetryInfo { ...@@ -191,7 +200,7 @@ struct TelemetryInfo {
CpuResult? cpu_result; CpuResult? cpu_result;
// Information about the device's timezone. Only present when kTimezone was // Information about the device's timezone. Only present when kTimezone was
// included in the categories input to ProbeTelemetryInfo. // included in the categories input to ProbeTelemetryInfo.
TimezoneInfo? timezone_info; TimezoneResult? timezone_result;
// Information about the system's memory. Only present when kMemory was // Information about the system's memory. Only present when kMemory was
// included in the categories input to ProbeTelemetryInfo. // included in the categories input to ProbeTelemetryInfo.
MemoryInfo? memory_info; MemoryInfo? memory_info;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment