diff options
author | Todd Poynor <toddpoynor@google.com> | 2013-08-27 18:11:49 -0700 |
---|---|---|
committer | Todd Poynor <toddpoynor@google.com> | 2013-09-04 17:41:57 -0700 |
commit | bc102111845a48f79a4cf6ea058a0ca334cd613c (patch) | |
tree | 2bd7646ebeca335e1b801fefa283b7983163289d /healthd | |
parent | 2d0c5d168fe0ecae2063f901610db597e6c53a88 (diff) | |
download | system_core-bc102111845a48f79a4cf6ea058a0ca334cd613c.zip system_core-bc102111845a48f79a4cf6ea058a0ca334cd613c.tar.gz system_core-bc102111845a48f79a4cf6ea058a0ca334cd613c.tar.bz2 |
healthd: Add average current property
Change-Id: Ibc901fe1b550c0d72095ef5590e2db8962d1a7b2
Diffstat (limited to 'healthd')
-rw-r--r-- | healthd/BatteryMonitor.cpp | 18 | ||||
-rw-r--r-- | healthd/healthd.cpp | 1 | ||||
-rw-r--r-- | healthd/healthd.h | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index a2da3ee..5b3cac6 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -297,6 +297,16 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { } break; + case BATTERY_PROP_CURRENT_AVG: + if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) { + val->valueInt = + getIntField(mHealthdConfig->batteryCurrentAvgPath); + ret = NO_ERROR; + } else { + ret = NAME_NOT_FOUND; + } + break; + default: break; } @@ -393,6 +403,14 @@ void BatteryMonitor::init(struct healthd_config *hc, bool nosvcmgr) { mHealthdConfig->batteryCurrentNowPath = path; } + if (mHealthdConfig->batteryCurrentAvgPath.isEmpty()) { + path.clear(); + path.appendFormat("%s/%s/current_avg", + POWER_SUPPLY_SYSFS_PATH, name); + if (access(path, R_OK) == 0) + mHealthdConfig->batteryCurrentAvgPath = path; + } + if (mHealthdConfig->batteryChargeCounterPath.isEmpty()) { path.clear(); path.appendFormat("%s/%s/charge_counter", diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp index 1719c22..f7c79c4 100644 --- a/healthd/healthd.cpp +++ b/healthd/healthd.cpp @@ -49,6 +49,7 @@ static struct healthd_config healthd_config = { .batteryTemperaturePath = String8(String8::kEmptyString), .batteryTechnologyPath = String8(String8::kEmptyString), .batteryCurrentNowPath = String8(String8::kEmptyString), + .batteryCurrentAvgPath = String8(String8::kEmptyString), .batteryChargeCounterPath = String8(String8::kEmptyString), }; diff --git a/healthd/healthd.h b/healthd/healthd.h index 5374fb1..5a1ad18 100644 --- a/healthd/healthd.h +++ b/healthd/healthd.h @@ -61,6 +61,7 @@ struct healthd_config { android::String8 batteryTemperaturePath; android::String8 batteryTechnologyPath; android::String8 batteryCurrentNowPath; + android::String8 batteryCurrentAvgPath; android::String8 batteryChargeCounterPath; }; |