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

Commit e14b37eb authored by Todd Poynor's avatar Todd Poynor
Browse files

healthd: Add hooks for ENERGY_COUNTER property

Bug: 10118565
Change-Id: Ibabae2a78a600ae37ce9b91da0f5980ee94b05c2
parent b65208d1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <batteryservice/BatteryService.h>
#include <cutils/klog.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -315,7 +316,11 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
        break;

    case BATTERY_PROP_ENERGY_COUNTER:
        if (mHealthdConfig->energyCounter) {
            ret = mHealthdConfig->energyCounter(&val->valueInt64);
        } else {
            ret = NAME_NOT_FOUND;
        }
        break;

    default:
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ static struct healthd_config healthd_config = {
    .batteryCurrentNowPath = String8(String8::kEmptyString),
    .batteryCurrentAvgPath = String8(String8::kEmptyString),
    .batteryChargeCounterPath = String8(String8::kEmptyString),
    .energyCounter = NULL,
};

static int eventct;
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define _HEALTHD_H_

#include <batteryservice/BatteryService.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/String8.h>

@@ -64,6 +65,8 @@ struct healthd_config {
    android::String8 batteryCurrentNowPath;
    android::String8 batteryCurrentAvgPath;
    android::String8 batteryChargeCounterPath;

    int (*energyCounter)(int64_t *);
};

// Global helper functions