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

DeviceStatusCollector: add ProbeError to BacklightInfo request

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

Bug: chromium:1041153
Change-Id: I445a014fad10b452b393d61c022561dede092005
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148126Reviewed-by: default avatarPaul Moy <pmoy@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@{#759311}
parent 2c9fdda7
...@@ -927,9 +927,14 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -927,9 +927,14 @@ class DeviceStatusCollectorState : public StatusCollectorState {
} }
} }
const auto& backlight_info = probe_result->backlight_info; // Process BacklightResult.
if (backlight_info.has_value()) { const auto& backlight_result = probe_result->backlight_result;
for (const auto& backlight : backlight_info.value()) { if (!backlight_result.is_null()) {
if (backlight_result->is_error()) {
LOG(ERROR) << "cros_healthd: Error getting backlight info: "
<< backlight_result->get_error()->msg;
} else {
for (const auto& backlight : backlight_result->get_backlight_info()) {
em::BacklightInfo* const backlight_info_out = em::BacklightInfo* const backlight_info_out =
response_params_.device_status->add_backlight_info(); response_params_.device_status->add_backlight_info();
backlight_info_out->set_path(backlight->path); backlight_info_out->set_path(backlight->path);
...@@ -937,6 +942,7 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -937,6 +942,7 @@ class DeviceStatusCollectorState : public StatusCollectorState {
backlight_info_out->set_brightness(backlight->brightness); backlight_info_out->set_brightness(backlight->brightness);
} }
} }
}
// Process FanResult. // Process FanResult.
const auto& fan_result = probe_result->fan_result; const auto& fan_result = probe_result->fan_result;
......
...@@ -493,6 +493,9 @@ void GetFakeCrosHealthdData( ...@@ -493,6 +493,9 @@ void GetFakeCrosHealthdData(
chromeos::cros_healthd::mojom::BacklightInfo backlight_info( chromeos::cros_healthd::mojom::BacklightInfo backlight_info(
kFakeBacklightPath, kFakeMaxBrightness, kFakeBrightness); kFakeBacklightPath, kFakeMaxBrightness, kFakeBrightness);
backlight_vector.push_back(backlight_info.Clone()); backlight_vector.push_back(backlight_info.Clone());
auto backlight_result =
chromeos::cros_healthd::mojom::BacklightResult::NewBacklightInfo(
std::move(backlight_vector));
std::vector<chromeos::cros_healthd::mojom::FanInfoPtr> fan_vector; std::vector<chromeos::cros_healthd::mojom::FanInfoPtr> fan_vector;
chromeos::cros_healthd::mojom::FanInfo fan_info(kFakeSpeedRpm); chromeos::cros_healthd::mojom::FanInfo fan_info(kFakeSpeedRpm);
fan_vector.push_back(fan_info.Clone()); fan_vector.push_back(fan_info.Clone());
...@@ -502,7 +505,7 @@ void GetFakeCrosHealthdData( ...@@ -502,7 +505,7 @@ void GetFakeCrosHealthdData(
battery_info.Clone(), std::move(block_device_info), battery_info.Clone(), std::move(block_device_info),
cached_vpd_info.Clone(), std::move(cpu_result), cached_vpd_info.Clone(), std::move(cpu_result),
std::move(timezone_result), std::move(memory_result), std::move(timezone_result), std::move(memory_result),
std::move(backlight_vector), std::move(fan_result)); std::move(backlight_result), std::move(fan_result));
// Create fake SampledData. // Create fake SampledData.
em::CPUTempInfo fake_cpu_temp_sample; em::CPUTempInfo fake_cpu_temp_sample;
......
...@@ -129,13 +129,13 @@ mojom::MemoryResultPtr MakeMemoryResult() { ...@@ -129,13 +129,13 @@ mojom::MemoryResultPtr MakeMemoryResult() {
43264 /* page_faults_since_last_boot */)); 43264 /* page_faults_since_last_boot */));
} }
base::Optional<std::vector<mojom::BacklightInfoPtr>> MakeBacklightInfo() { mojom::BacklightResultPtr MakeBacklightResult() {
std::vector<mojom::BacklightInfoPtr> backlight_info; std::vector<mojom::BacklightInfoPtr> backlight_info;
backlight_info.push_back(mojom::BacklightInfo::New( backlight_info.push_back(mojom::BacklightInfo::New(
"path_1" /* path */, 6537 /* max_brightness */, 987 /* brightness */)); "path_1" /* path */, 6537 /* max_brightness */, 987 /* brightness */));
backlight_info.push_back(mojom::BacklightInfo::New( backlight_info.push_back(mojom::BacklightInfo::New(
"path_2" /* path */, 3242 /* max_brightness */, 65 /* brightness */)); "path_2" /* path */, 3242 /* max_brightness */, 65 /* brightness */));
return backlight_info; return mojom::BacklightResult::NewBacklightInfo(std::move(backlight_info));
} }
mojom::FanResultPtr MakeFanResult() { mojom::FanResultPtr MakeFanResult() {
...@@ -152,7 +152,8 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() { ...@@ -152,7 +152,8 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() {
MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */, MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */,
MakeTimezoneResult() /* timezone_result */, MakeTimezoneResult() /* timezone_result */,
MakeMemoryResult() /* memory_result */, MakeMemoryResult() /* memory_result */,
MakeBacklightInfo() /* backlight_info */, MakeFanResult() /* fan_result */ MakeBacklightResult() /* backlight_result */,
MakeFanResult() /* fan_result */
); );
} }
......
...@@ -171,6 +171,15 @@ struct MemoryInfo { ...@@ -171,6 +171,15 @@ struct MemoryInfo {
uint32 page_faults_since_last_boot; uint32 page_faults_since_last_boot;
}; };
// Backlight probe result. Can either be populated with the BacklightInfo or an
// error retrieving the information.
union BacklightResult {
// Valid BacklightInfo.
array<BacklightInfo> backlight_info;
// The error that occurred attempting to retrieve the BacklightInfo.
ProbeError error;
};
// Backlight information. // Backlight information.
struct BacklightInfo { struct BacklightInfo {
// Path to this backlight on the system. Useful if the caller needs to // Path to this backlight on the system. Useful if the caller needs to
...@@ -226,7 +235,7 @@ struct TelemetryInfo { ...@@ -226,7 +235,7 @@ struct TelemetryInfo {
MemoryResult? memory_result; MemoryResult? memory_result;
// Information about all of the device's backlights. Only present when // Information about all of the device's backlights. Only present when
// kBacklight was included in the categories input to ProbeTelemetryInfo. // kBacklight was included in the categories input to ProbeTelemetryInfo.
array<BacklightInfo>? backlight_info; BacklightResult? backlight_result;
// Information about each of the device's fans. Only present when kFan was // Information about each of the device's fans. Only present when kFan was
// included in the categories input to ProbeTelemetryInfo. // included in the categories input to ProbeTelemetryInfo.
FanResult? fan_result; FanResult? fan_result;
......
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