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

Commit ae455dbc authored by YiKai Peng's avatar YiKai Peng
Browse files

healthd: add annotations for dumpsys diagnostics



Bug: 396734648
Test: adb shell dumpsys android.hardware.health.IHealth/default
Change-Id: I3024fee9b2297abe488037988d463c42f0f5d472
Signed-off-by: default avatarYiKai Peng <kenpeng@google.com>
parent 43fdd9c1
Loading
Loading
Loading
Loading
+21 −16
Original line number Diff line number Diff line
@@ -715,6 +715,8 @@ void BatteryMonitor::dumpState(int fd) {
    char vs[128];
    const HealthInfo& props = *mHealthInfo;

    snprintf(vs, sizeof(vs), "Cached HealthInfo:\n");
    write(fd, vs, strlen(vs));
    snprintf(vs, sizeof(vs),
             "  ac: %d usb: %d wireless: %d dock: %d current_max: %d voltage_max: %d\n",
             props.chargerAcOnline, props.chargerUsbOnline, props.chargerWirelessOnline,
@@ -729,35 +731,38 @@ void BatteryMonitor::dumpState(int fd) {
    write(fd, vs, strlen(vs));

    if (!mHealthdConfig->batteryCurrentNowPath.empty()) {
        v = getIntField(mHealthdConfig->batteryCurrentNowPath);
        snprintf(vs, sizeof(vs), "current now: %d\n", v);
        snprintf(vs, sizeof(vs), "  current now: %d\n", props.batteryCurrentMicroamps);
        write(fd, vs, strlen(vs));
    }

    if (!mHealthdConfig->batteryCurrentAvgPath.empty()) {
        v = getIntField(mHealthdConfig->batteryCurrentAvgPath);
        snprintf(vs, sizeof(vs), "current avg: %d\n", v);
    if (!mHealthdConfig->batteryCycleCountPath.empty()) {
        snprintf(vs, sizeof(vs), "  cycle count: %d\n", props.batteryCycleCount);
        write(fd, vs, strlen(vs));
    }

    if (!mHealthdConfig->batteryChargeCounterPath.empty()) {
        v = getIntField(mHealthdConfig->batteryChargeCounterPath);
        snprintf(vs, sizeof(vs), "charge counter: %d\n", v);
    if (!mHealthdConfig->batteryFullChargePath.empty()) {
        snprintf(vs, sizeof(vs), "  Full charge: %d\n", props.batteryFullChargeUah);
        write(fd, vs, strlen(vs));
    }

    snprintf(vs, sizeof(vs), "Real-time Values:\n");
    write(fd, vs, strlen(vs));

    if (!mHealthdConfig->batteryCurrentNowPath.empty()) {
        snprintf(vs, sizeof(vs), "current now: %d\n", props.batteryCurrentMicroamps);
        v = getIntField(mHealthdConfig->batteryCurrentNowPath);
        snprintf(vs, sizeof(vs), "  current now: %d\n", v);
        write(fd, vs, strlen(vs));
    }

    if (!mHealthdConfig->batteryCycleCountPath.empty()) {
        snprintf(vs, sizeof(vs), "cycle count: %d\n", props.batteryCycleCount);
    if (!mHealthdConfig->batteryCurrentAvgPath.empty()) {
        v = getIntField(mHealthdConfig->batteryCurrentAvgPath);
        snprintf(vs, sizeof(vs), "  current avg: %d\n", v);
        write(fd, vs, strlen(vs));
    }

    if (!mHealthdConfig->batteryFullChargePath.empty()) {
        snprintf(vs, sizeof(vs), "Full charge: %d\n", props.batteryFullChargeUah);
    if (!mHealthdConfig->batteryChargeCounterPath.empty()) {
        v = getIntField(mHealthdConfig->batteryChargeCounterPath);
        snprintf(vs, sizeof(vs), "  charge counter: %d\n", v);
        write(fd, vs, strlen(vs));
    }
}