summaryrefslogtreecommitdiffstats
path: root/healthd
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2014-07-10 15:06:21 -0700
committerRuchi Kandoi <kandoiruchi@google.com>2014-07-11 01:19:28 +0000
commita78fc23491f3490bec4e4ac72c4bdc8c6d554fe3 (patch)
tree6a7403d9b681be452ed6203b90c508ca4d302214 /healthd
parent212e97986564060678bb69b756e700e1db85bc39 (diff)
downloadsystem_core-a78fc23491f3490bec4e4ac72c4bdc8c6d554fe3.zip
system_core-a78fc23491f3490bec4e4ac72c4bdc8c6d554fe3.tar.gz
system_core-a78fc23491f3490bec4e4ac72c4bdc8c6d554fe3.tar.bz2
healthd: Reports arbitrary numbers for capacity and temperature when
connected to fake battery. Detects if the device is attached to a fake battery if yes, healthd reports 42% battery charge and 42.2 degrees temperature. Change-Id: I2508fd91c8d3848ea64f57ab59d20be1c2817913
Diffstat (limited to 'healthd')
-rw-r--r--healthd/BatteryMonitor.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 1ee33a1..4a6b702 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -35,6 +35,8 @@
#define POWER_SUPPLY_SUBSYSTEM "power_supply"
#define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM
+#define FAKE_BATTERY_CAPACITY 42
+#define FAKE_BATTERY_TEMPERATURE 424
namespace android {
@@ -530,11 +532,11 @@ void BatteryMonitor::init(struct healthd_config *hc) {
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);
+ if (property_get("ro.boot.fake_battery", pval, NULL) > 0
+ && strtol(pval, NULL, 10) != 0) {
+ mBatteryFixedCapacity = FAKE_BATTERY_CAPACITY;
+ mBatteryFixedTemperature = FAKE_BATTERY_TEMPERATURE;
+ }
}
}; // namespace android