Commit b4de4a19 authored by Jesse Schettler's avatar Jesse Schettler Committed by Commit Bot

DeviceStatusCollector: Collect and report fan info

Use cros_healthd to collect and report fan info for each of the device's
fans.

Bug: 1035579
Test: DeviceStatusCollector.TestCrosHealthdInfo
Change-Id: I1f458f923e6017d601390bca9b4070b0590d53e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135314Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Jesse Schettler <jschettler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756264}
parent d9ce147e
...@@ -913,6 +913,14 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -913,6 +913,14 @@ class DeviceStatusCollectorState : public StatusCollectorState {
backlight_info_out->set_brightness(backlight->brightness); backlight_info_out->set_brightness(backlight->brightness);
} }
} }
const auto& fan_info = probe_result->fan_info;
if (fan_info.has_value()) {
for (const auto& fan : fan_info.value()) {
em::FanInfo* const fan_info_out =
response_params_.device_status->add_fan_info();
fan_info_out->set_speed_rpm(fan->speed_rpm);
}
}
for (const std::unique_ptr<SampledData>& sample_data : samples) { for (const std::unique_ptr<SampledData>& sample_data : samples) {
auto it = sample_data->battery_samples.find(battery_info->model_name); auto it = sample_data->battery_samples.find(battery_info->model_name);
...@@ -1516,7 +1524,7 @@ void DeviceStatusCollector::FetchCrosHealthdData( ...@@ -1516,7 +1524,7 @@ void DeviceStatusCollector::FetchCrosHealthdData(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::vector<ProbeCategoryEnum> categories_to_probe = { std::vector<ProbeCategoryEnum> categories_to_probe = {
ProbeCategoryEnum::kCachedVpdData}; ProbeCategoryEnum::kCachedVpdData, ProbeCategoryEnum::kFan};
if (report_storage_status_) if (report_storage_status_)
categories_to_probe.push_back(ProbeCategoryEnum::kNonRemovableBlockDevices); categories_to_probe.push_back(ProbeCategoryEnum::kNonRemovableBlockDevices);
if (report_power_status_) if (report_power_status_)
......
...@@ -170,6 +170,8 @@ constexpr uint32_t kFakePageFaults = 896123761; ...@@ -170,6 +170,8 @@ constexpr uint32_t kFakePageFaults = 896123761;
constexpr char kFakeBacklightPath[] = "/sys/class/backlight/fake_backlight"; constexpr char kFakeBacklightPath[] = "/sys/class/backlight/fake_backlight";
constexpr uint32_t kFakeMaxBrightness = 769; constexpr uint32_t kFakeMaxBrightness = 769;
constexpr uint32_t kFakeBrightness = 124; constexpr uint32_t kFakeBrightness = 124;
// Fan test values:
constexpr uint32_t kFakeSpeedRpm = 1225;
// Time delta representing 1 hour time interval. // Time delta representing 1 hour time interval.
constexpr TimeDelta kHour = TimeDelta::FromHours(1); constexpr TimeDelta kHour = TimeDelta::FromHours(1);
...@@ -484,11 +486,13 @@ void GetFakeCrosHealthdData( ...@@ -484,11 +486,13 @@ 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());
std::vector<chromeos::cros_healthd::mojom::FanInfoPtr> fan_vector;
chromeos::cros_healthd::mojom::FanInfo fan_info(kFakeSpeedRpm);
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_vector), timezone_info.Clone(), cached_vpd_info.Clone(), std::move(cpu_vector), timezone_info.Clone(),
memory_info.Clone(), std::move(backlight_vector), memory_info.Clone(), std::move(backlight_vector), std::move(fan_vector));
base::nullopt /* fan_info */);
// Create fake SampledData. // Create fake SampledData.
em::CPUTempInfo fake_cpu_temp_sample; em::CPUTempInfo fake_cpu_temp_sample;
...@@ -2902,6 +2906,7 @@ TEST_F(DeviceStatusCollectorTest, TestCrosHealthdInfo) { ...@@ -2902,6 +2906,7 @@ TEST_F(DeviceStatusCollectorTest, TestCrosHealthdInfo) {
EXPECT_FALSE(device_status_.has_system_status()); EXPECT_FALSE(device_status_.has_system_status());
EXPECT_FALSE(device_status_.has_timezone_info()); EXPECT_FALSE(device_status_.has_timezone_info());
EXPECT_FALSE(device_status_.has_memory_info()); EXPECT_FALSE(device_status_.has_memory_info());
EXPECT_EQ(device_status_.fan_info_size(), 0);
// When all of the relevant policies are set, expect the protobuf to have the // When all of the relevant policies are set, expect the protobuf to have the
// data from cros_healthd. // data from cros_healthd.
...@@ -2989,6 +2994,11 @@ TEST_F(DeviceStatusCollectorTest, TestCrosHealthdInfo) { ...@@ -2989,6 +2994,11 @@ TEST_F(DeviceStatusCollectorTest, TestCrosHealthdInfo) {
EXPECT_EQ(backlight.path(), kFakeBacklightPath); EXPECT_EQ(backlight.path(), kFakeBacklightPath);
EXPECT_EQ(backlight.max_brightness(), kFakeMaxBrightness); EXPECT_EQ(backlight.max_brightness(), kFakeMaxBrightness);
EXPECT_EQ(backlight.brightness(), kFakeBrightness); EXPECT_EQ(backlight.brightness(), kFakeBrightness);
// Verify the fan info.
ASSERT_EQ(device_status_.fan_info_size(), 1);
const auto& fan = device_status_.fan_info(0);
EXPECT_EQ(fan.speed_rpm(), kFakeSpeedRpm);
} }
// Fake device state. // Fake device state.
......
...@@ -1079,6 +1079,12 @@ message BacklightInfo { ...@@ -1079,6 +1079,12 @@ message BacklightInfo {
optional uint32 brightness = 3; optional uint32 brightness = 3;
} }
// Information about the device's fan.
message FanInfo {
// Fan speed in RPM.
optional uint32 speed_rpm = 1;
}
// Report device level status. // Report device level status.
message DeviceStatusReportRequest { message DeviceStatusReportRequest {
reserved 4, 7, 13, 20; reserved 4, 7, 13, 20;
...@@ -1188,6 +1194,9 @@ message DeviceStatusReportRequest { ...@@ -1188,6 +1194,9 @@ message DeviceStatusReportRequest {
// Information about the device's backlights. // Information about the device's backlights.
repeated BacklightInfo backlight_info = 37; repeated BacklightInfo backlight_info = 37;
// Information about the device's fans.
repeated FanInfo fan_info = 38;
} }
message OsUpdateStatus { message OsUpdateStatus {
......
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