Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8a81c4e authored by Yifan Hong's avatar Yifan Hong Committed by android-build-merger
Browse files

Merge "[REFACTOR] health 2.0: battery monitor returns health info 2.0"

am: d57bd962

Change-Id: I216baf728c401aacb9beeb762df36fc08670d41d
parents 3bc25b4e d57bd962
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -17,11 +17,15 @@
#include <android-base/logging.h>

#include <android-base/file.h>
#include <android/hardware/health/2.0/types.h>
#include <health2/Health.h>

#include <hal_conversion.h>
#include <hidl/HidlTransportSupport.h>

using HealthInfo_1_0 = android::hardware::health::V1_0::HealthInfo;
using android::hardware::health::V1_0::hal_conversion::convertFromHealthInfo;

extern void healthd_battery_update_internal(bool);

namespace android {
@@ -149,7 +153,9 @@ Return<Result> Health::update() {
    // Retrieve all information and call healthd_mode_ops->battery_update, which calls
    // notifyListeners.
    battery_monitor_->updateValues();
    struct BatteryProperties props = getBatteryProperties(battery_monitor_.get());
    const HealthInfo_1_0& health_info = battery_monitor_->getHealthInfo_1_0();
    struct BatteryProperties props;
    convertFromHealthInfo(health_info, &props);
    bool log = healthd_board_battery_update(&props);
    if (log) {
        battery_monitor_->logValues();
@@ -253,10 +259,7 @@ Return<void> Health::getHealthInfo(getHealthInfo_cb _hidl_cb) {
    using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo;

    updateAndNotify(nullptr);
    struct android::BatteryProperties p = getBatteryProperties(battery_monitor_.get());

    V1_0::HealthInfo batteryInfo;
    convertToHealthInfo(&p, batteryInfo);
    HealthInfo healthInfo = battery_monitor_->getHealthInfo_2_0();

    std::vector<StorageInfo> info;
    get_storage_info(info);
@@ -272,8 +275,6 @@ Return<void> Health::getHealthInfo(getHealthInfo_cb _hidl_cb) {
        currentAvg = static_cast<int32_t>(prop.valueInt64);
    }

    V2_0::HealthInfo healthInfo = {};
    healthInfo.legacy = std::move(batteryInfo);
    healthInfo.batteryCurrentAverage = currentAvg;
    healthInfo.diskStats = stats;
    healthInfo.storageInfos = info;