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

Commit 257b978d authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "BatteryMonitor: Add helper of logValues()" am: 23a13485

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1580979

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I969341ee25378ef43a8bf5d0cb052b776c062024
parents f0f96830 23a13485
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -349,9 +349,14 @@ void BatteryMonitor::updateValues(void) {
}

void BatteryMonitor::logValues(void) {
    logValues(*mHealthInfo, *mHealthdConfig);
}

void BatteryMonitor::logValues(const android::hardware::health::V2_1::HealthInfo& health_info,
                               const struct healthd_config& healthd_config) {
    char dmesgline[256];
    size_t len;
    const HealthInfo_1_0& props = mHealthInfo->legacy.legacy;
    const HealthInfo_1_0& props = health_info.legacy.legacy;
    if (props.batteryPresent) {
        snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d",
                 props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "",
@@ -359,17 +364,17 @@ void BatteryMonitor::logValues(void) {
                 props.batteryHealth, props.batteryStatus);

        len = strlen(dmesgline);
        if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
        if (!healthd_config.batteryCurrentNowPath.isEmpty()) {
            len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d",
                            props.batteryCurrent);
        }

        if (!mHealthdConfig->batteryFullChargePath.isEmpty()) {
        if (!healthd_config.batteryFullChargePath.isEmpty()) {
            len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d",
                            props.batteryFullCharge);
        }

        if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) {
        if (!healthd_config.batteryCycleCountPath.isEmpty()) {
            len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d",
                            props.batteryCycleCount);
        }
+3 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@ class BatteryMonitor {
    void logValues(void);
    bool isChargerOnline();

    static void logValues(const android::hardware::health::V2_1::HealthInfo& health_info,
                          const struct healthd_config& healthd_config);

  private:
    struct healthd_config *mHealthdConfig;
    Vector<String8> mChargerNames;