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,14 +927,20 @@ class DeviceStatusCollectorState : public StatusCollectorState {
}
}
const auto& backlight_info = probe_result->backlight_info;
if (backlight_info.has_value()) {
for (const auto& backlight : backlight_info.value()) {
em::BacklightInfo* const backlight_info_out =
response_params_.device_status->add_backlight_info();
backlight_info_out->set_path(backlight->path);
backlight_info_out->set_max_brightness(backlight->max_brightness);
backlight_info_out->set_brightness(backlight->brightness);
// Process BacklightResult.
const auto& backlight_result = probe_result->backlight_result;
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 =
response_params_.device_status->add_backlight_info();
backlight_info_out->set_path(backlight->path);
backlight_info_out->set_max_brightness(backlight->max_brightness);
backlight_info_out->set_brightness(backlight->brightness);
}
}
}
......
......@@ -493,6 +493,9 @@ void GetFakeCrosHealthdData(
chromeos::cros_healthd::mojom::BacklightInfo backlight_info(
kFakeBacklightPath, kFakeMaxBrightness, kFakeBrightness);
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;
chromeos::cros_healthd::mojom::FanInfo fan_info(kFakeSpeedRpm);
fan_vector.push_back(fan_info.Clone());
......@@ -502,7 +505,7 @@ void GetFakeCrosHealthdData(
battery_info.Clone(), std::move(block_device_info),
cached_vpd_info.Clone(), std::move(cpu_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.
em::CPUTempInfo fake_cpu_temp_sample;
......
......@@ -129,13 +129,13 @@ mojom::MemoryResultPtr MakeMemoryResult() {
43264 /* page_faults_since_last_boot */));
}
base::Optional<std::vector<mojom::BacklightInfoPtr>> MakeBacklightInfo() {
mojom::BacklightResultPtr MakeBacklightResult() {
std::vector<mojom::BacklightInfoPtr> backlight_info;
backlight_info.push_back(mojom::BacklightInfo::New(
"path_1" /* path */, 6537 /* max_brightness */, 987 /* brightness */));
backlight_info.push_back(mojom::BacklightInfo::New(
"path_2" /* path */, 3242 /* max_brightness */, 65 /* brightness */));
return backlight_info;
return mojom::BacklightResult::NewBacklightInfo(std::move(backlight_info));
}
mojom::FanResultPtr MakeFanResult() {
......@@ -152,7 +152,8 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() {
MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */,
MakeTimezoneResult() /* timezone_result */,
MakeMemoryResult() /* memory_result */,
MakeBacklightInfo() /* backlight_info */, MakeFanResult() /* fan_result */
MakeBacklightResult() /* backlight_result */,
MakeFanResult() /* fan_result */
);
}
......
......@@ -171,6 +171,15 @@ struct MemoryInfo {
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.
struct BacklightInfo {
// Path to this backlight on the system. Useful if the caller needs to
......@@ -226,7 +235,7 @@ struct TelemetryInfo {
MemoryResult? memory_result;
// Information about all of the device's backlights. Only present when
// 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
// included in the categories input to ProbeTelemetryInfo.
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