Loading healthd/BatteryMonitor.cpp +15 −2 Original line number Diff line number Diff line Loading @@ -73,12 +73,25 @@ static std::optional<T> mapSysfsString(const char* str, SysfsStringEnumMap<T> ma return std::nullopt; } static void initHealthInfo(HealthInfo_2_1* health_info_2_1) { *health_info_2_1 = HealthInfo_2_1{}; // HIDL enum values are zero initialized, so they need to be initialized // properly. health_info_2_1->batteryCapacityLevel = BatteryCapacityLevel::UNKNOWN; auto* props = &health_info_2_1->legacy.legacy; props->batteryStatus = BatteryStatus::UNKNOWN; props->batteryHealth = BatteryHealth::UNKNOWN; } BatteryMonitor::BatteryMonitor() : mHealthdConfig(nullptr), mBatteryDevicePresent(false), mBatteryFixedCapacity(0), mBatteryFixedTemperature(0), mHealthInfo(std::make_unique<HealthInfo_2_1>()) {} mHealthInfo(std::make_unique<HealthInfo_2_1>()) { initHealthInfo(mHealthInfo.get()); } BatteryMonitor::~BatteryMonitor() {} Loading Loading @@ -198,7 +211,7 @@ int BatteryMonitor::getIntField(const String8& path) { } void BatteryMonitor::updateValues(void) { *mHealthInfo = HealthInfo_2_1{}; initHealthInfo(mHealthInfo.get()); HealthInfo_1_0& props = mHealthInfo->legacy.legacy; Loading Loading
healthd/BatteryMonitor.cpp +15 −2 Original line number Diff line number Diff line Loading @@ -73,12 +73,25 @@ static std::optional<T> mapSysfsString(const char* str, SysfsStringEnumMap<T> ma return std::nullopt; } static void initHealthInfo(HealthInfo_2_1* health_info_2_1) { *health_info_2_1 = HealthInfo_2_1{}; // HIDL enum values are zero initialized, so they need to be initialized // properly. health_info_2_1->batteryCapacityLevel = BatteryCapacityLevel::UNKNOWN; auto* props = &health_info_2_1->legacy.legacy; props->batteryStatus = BatteryStatus::UNKNOWN; props->batteryHealth = BatteryHealth::UNKNOWN; } BatteryMonitor::BatteryMonitor() : mHealthdConfig(nullptr), mBatteryDevicePresent(false), mBatteryFixedCapacity(0), mBatteryFixedTemperature(0), mHealthInfo(std::make_unique<HealthInfo_2_1>()) {} mHealthInfo(std::make_unique<HealthInfo_2_1>()) { initHealthInfo(mHealthInfo.get()); } BatteryMonitor::~BatteryMonitor() {} Loading Loading @@ -198,7 +211,7 @@ int BatteryMonitor::getIntField(const String8& path) { } void BatteryMonitor::updateValues(void) { *mHealthInfo = HealthInfo_2_1{}; initHealthInfo(mHealthInfo.get()); HealthInfo_1_0& props = mHealthInfo->legacy.legacy; Loading