summaryrefslogtreecommitdiffstats
path: root/healthd/BatteryMonitor.cpp
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2014-05-21 16:28:13 -0700
committerTodd Poynor <toddpoynor@google.com>2014-05-22 01:56:15 +0000
commit3db03a5ab0cb7713529c298531be6da7c2193525 (patch)
tree8f48bf7e8a704a142bd73390c522c46d4d997fe3 /healthd/BatteryMonitor.cpp
parentacc13d7b27aa7046b4cc705e08947e19091a41cd (diff)
downloadsystem_core-3db03a5ab0cb7713529c298531be6da7c2193525.tar.gz
system_core-3db03a5ab0cb7713529c298531be6da7c2193525.tar.bz2
system_core-3db03a5ab0cb7713529c298531be6da7c2193525.zip
healthd: Set fixed battery level and temperature via properties
setprop persist.sys.battery.capacity 77 setprop persist.sys.battery.temperature 123 and reboot to cause a fixed battery level of 77% and temperature of 12.3C to be reported to Android. Typically used on power evaluation boards without batteries connected. Bug: 14839868 Change-Id: Ibae5e16429d05891cb0787d74a2fe93b07013699
Diffstat (limited to 'healthd/BatteryMonitor.cpp')
-rw-r--r--healthd/BatteryMonitor.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 4ee6249b9..1ee33a187 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <batteryservice/BatteryService.h>
#include <cutils/klog.h>
+#include <cutils/properties.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/String8.h>
@@ -184,10 +185,14 @@ bool BatteryMonitor::update(void) {
else
props.batteryPresent = mBatteryDevicePresent;
- props.batteryLevel = getIntField(mHealthdConfig->batteryCapacityPath);
+ props.batteryLevel = mBatteryFixedCapacity ?
+ mBatteryFixedCapacity :
+ getIntField(mHealthdConfig->batteryCapacityPath);
props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
- props.batteryTemperature = getIntField(mHealthdConfig->batteryTemperaturePath);
+ props.batteryTemperature = mBatteryFixedTemperature ?
+ mBatteryFixedTemperature :
+ getIntField(mHealthdConfig->batteryTemperaturePath);
const int SIZE = 128;
char buf[SIZE];
@@ -367,6 +372,7 @@ void BatteryMonitor::dumpState(int fd) {
void BatteryMonitor::init(struct healthd_config *hc) {
String8 path;
+ char pval[PROPERTY_VALUE_MAX];
mHealthdConfig = hc;
DIR* dir = opendir(POWER_SUPPLY_SYSFS_PATH);
@@ -523,6 +529,12 @@ void BatteryMonitor::init(struct healthd_config *hc) {
if (mHealthdConfig->batteryTechnologyPath.isEmpty())
KLOG_WARNING(LOG_TAG, "BatteryTechnologyPath not found\n");
}
+
+ if (property_get("persist.sys.battery.capacity", pval, NULL) > 0)
+ mBatteryFixedCapacity = (int) strtol(pval, NULL, 10);
+
+ if (property_get("persist.sys.battery.temperature", pval, NULL) > 0)
+ mBatteryFixedTemperature = (int) strtol(pval, NULL, 10);
}
}; // namespace android