Commit 2ae90171 authored by Trent Begin's avatar Trent Begin Committed by Commit Bot

DeviceStatusCollector: fix logic in parsing telemetry probe

Move a brace so that telemetry logic is properly parsed. Previously
multiple telemetry items were only parsed it the battery information is
present.

Bug: none
Change-Id: I0cea4e12c9a8c504bde11917aefd4d0548b77800
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153694
Commit-Queue: Trent Begin <tbegin@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarJesse Schettler <jschettler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762031}
parent 90617fab
...@@ -892,95 +892,95 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -892,95 +892,95 @@ class DeviceStatusCollectorState : public StatusCollectorState {
if (!smart_info.is_null()) if (!smart_info.is_null())
battery_info_out->set_manufacture_date(smart_info->manufacture_date); battery_info_out->set_manufacture_date(smart_info->manufacture_date);
// Process CpuResult. for (const std::unique_ptr<SampledData>& sample_data : samples) {
const auto& cpu_result = probe_result->cpu_result; auto it = sample_data->battery_samples.find(battery_info->model_name);
if (!cpu_result.is_null()) { if (it != sample_data->battery_samples.end())
if (cpu_result->is_error()) { battery_info_out->add_samples()->CheckTypeAndMergeFrom(it->second);
LOG(ERROR) << "cros_healthd: Error getting CPU info: "
<< cpu_result->get_error()->msg;
} else {
for (const auto& cpu : cpu_result->get_cpu_info()) {
em::CpuInfo* const cpu_info_out =
response_params_.device_status->add_cpu_info();
cpu_info_out->set_model_name(cpu->model_name);
cpu_info_out->set_architecture(
em::CpuInfo::Architecture(cpu->architecture));
cpu_info_out->set_max_clock_speed_khz(cpu->max_clock_speed_khz);
}
}
} }
}
// Process TimezoneResult. // Process CpuResult.
const auto& timezone_result = probe_result->timezone_result; const auto& cpu_result = probe_result->cpu_result;
if (!timezone_result.is_null()) { if (!cpu_result.is_null()) {
if (timezone_result->is_error()) { if (cpu_result->is_error()) {
LOG(ERROR) << "cros_healthd: Error getting timezone info: " LOG(ERROR) << "cros_healthd: Error getting CPU info: "
<< timezone_result->get_error()->msg; << cpu_result->get_error()->msg;
} else { } else {
const auto& timezone_info = timezone_result->get_timezone_info(); for (const auto& cpu : cpu_result->get_cpu_info()) {
em::TimezoneInfo* const timezone_info_out = em::CpuInfo* const cpu_info_out =
response_params_.device_status->mutable_timezone_info(); response_params_.device_status->add_cpu_info();
timezone_info_out->set_posix(timezone_info->posix); cpu_info_out->set_model_name(cpu->model_name);
timezone_info_out->set_region(timezone_info->region); cpu_info_out->set_architecture(
em::CpuInfo::Architecture(cpu->architecture));
cpu_info_out->set_max_clock_speed_khz(cpu->max_clock_speed_khz);
} }
} }
}
// Process MemoryResult. // Process TimezoneResult.
const auto& memory_result = probe_result->memory_result; const auto& timezone_result = probe_result->timezone_result;
if (!memory_result.is_null()) { if (!timezone_result.is_null()) {
if (memory_result->is_error()) { if (timezone_result->is_error()) {
LOG(ERROR) << "cros_healthd: Error getting memory info: " LOG(ERROR) << "cros_healthd: Error getting timezone info: "
<< memory_result->get_error()->msg; << timezone_result->get_error()->msg;
} else { } else {
const auto& memory_info = memory_result->get_memory_info(); const auto& timezone_info = timezone_result->get_timezone_info();
em::MemoryInfo* const memory_info_out = em::TimezoneInfo* const timezone_info_out =
response_params_.device_status->mutable_memory_info(); response_params_.device_status->mutable_timezone_info();
memory_info_out->set_total_memory_kib(memory_info->total_memory_kib); timezone_info_out->set_posix(timezone_info->posix);
memory_info_out->set_free_memory_kib(memory_info->free_memory_kib); timezone_info_out->set_region(timezone_info->region);
memory_info_out->set_available_memory_kib(
memory_info->available_memory_kib);
memory_info_out->set_page_faults_since_last_boot(
memory_info->page_faults_since_last_boot);
}
} }
}
// Process BacklightResult. // Process MemoryResult.
const auto& backlight_result = probe_result->backlight_result; const auto& memory_result = probe_result->memory_result;
if (!backlight_result.is_null()) { if (!memory_result.is_null()) {
if (backlight_result->is_error()) { if (memory_result->is_error()) {
LOG(ERROR) << "cros_healthd: Error getting backlight info: " LOG(ERROR) << "cros_healthd: Error getting memory info: "
<< backlight_result->get_error()->msg; << memory_result->get_error()->msg;
} else { } else {
for (const auto& backlight : backlight_result->get_backlight_info()) { const auto& memory_info = memory_result->get_memory_info();
em::BacklightInfo* const backlight_info_out = em::MemoryInfo* const memory_info_out =
response_params_.device_status->add_backlight_info(); response_params_.device_status->mutable_memory_info();
backlight_info_out->set_path(backlight->path); memory_info_out->set_total_memory_kib(memory_info->total_memory_kib);
backlight_info_out->set_max_brightness(backlight->max_brightness); memory_info_out->set_free_memory_kib(memory_info->free_memory_kib);
backlight_info_out->set_brightness(backlight->brightness); memory_info_out->set_available_memory_kib(
} memory_info->available_memory_kib);
} memory_info_out->set_page_faults_since_last_boot(
memory_info->page_faults_since_last_boot);
} }
}
// Process FanResult. // Process BacklightResult.
const auto& fan_result = probe_result->fan_result; const auto& backlight_result = probe_result->backlight_result;
if (!fan_result.is_null()) { if (!backlight_result.is_null()) {
if (fan_result->is_error()) { if (backlight_result->is_error()) {
LOG(ERROR) << "cros_healthd: Error getting fan info: " LOG(ERROR) << "cros_healthd: Error getting backlight info: "
<< fan_result->get_error()->msg; << backlight_result->get_error()->msg;
} else { } else {
const auto& fan_info = fan_result->get_fan_info(); for (const auto& backlight : backlight_result->get_backlight_info()) {
for (const auto& fan : fan_info) { em::BacklightInfo* const backlight_info_out =
em::FanInfo* const fan_info_out = response_params_.device_status->add_backlight_info();
response_params_.device_status->add_fan_info(); backlight_info_out->set_path(backlight->path);
fan_info_out->set_speed_rpm(fan->speed_rpm); backlight_info_out->set_max_brightness(backlight->max_brightness);
} backlight_info_out->set_brightness(backlight->brightness);
} }
} }
}
for (const std::unique_ptr<SampledData>& sample_data : samples) { // Process FanResult.
auto it = sample_data->battery_samples.find(battery_info->model_name); const auto& fan_result = probe_result->fan_result;
if (it != sample_data->battery_samples.end()) if (!fan_result.is_null()) {
battery_info_out->add_samples()->CheckTypeAndMergeFrom(it->second); if (fan_result->is_error()) {
LOG(ERROR) << "cros_healthd: Error getting fan info: "
<< fan_result->get_error()->msg;
} else {
const auto& fan_info = fan_result->get_fan_info();
for (const auto& fan : fan_info) {
em::FanInfo* const fan_info_out =
response_params_.device_status->add_fan_info();
fan_info_out->set_speed_rpm(fan->speed_rpm);
}
} }
} }
} }
......
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