summaryrefslogtreecommitdiffstats
path: root/healthd
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-02-17 18:37:53 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-02-17 18:37:53 +0000
commit7e84cbd999625c28f261be1382ab3637547e1c37 (patch)
treeef5a11c67a18e6dc12ba2f12bbe4828e525fceb8 /healthd
parent7b3b490fe209fb074175ad9077a86a1d66f2498c (diff)
parent2773d4f96a8e9f06710e36f7c33459eeaa5cb23a (diff)
downloadsystem_core-7e84cbd999625c28f261be1382ab3637547e1c37.tar.gz
system_core-7e84cbd999625c28f261be1382ab3637547e1c37.tar.bz2
system_core-7e84cbd999625c28f261be1382ab3637547e1c37.zip
Merge "healthd: init members of BatteryMonitor."
am: 2773d4f96a * commit '2773d4f96a8e9f06710e36f7c33459eeaa5cb23a': healthd: init members of BatteryMonitor.
Diffstat (limited to 'healthd')
-rw-r--r--healthd/BatteryMonitor.cpp29
-rw-r--r--healthd/BatteryMonitor.h1
2 files changed, 24 insertions, 6 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 6aa360bdb..11ddd3e8a 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -56,6 +56,28 @@ static int mapSysfsString(const char* str,
return -1;
}
+static void initBatteryProperties(BatteryProperties* props) {
+ props->chargerAcOnline = false;
+ props->chargerUsbOnline = false;
+ props->chargerWirelessOnline = false;
+ props->maxChargingCurrent = 0;
+ props->batteryStatus = BATTERY_STATUS_UNKNOWN;
+ props->batteryHealth = BATTERY_HEALTH_UNKNOWN;
+ props->batteryPresent = false;
+ props->batteryLevel = 0;
+ props->batteryVoltage = 0;
+ props->batteryTemperature = 0;
+ props->batteryCurrent = 0;
+ props->batteryCycleCount = 0;
+ props->batteryFullCharge = 0;
+ props->batteryTechnology.clear();
+}
+
+BatteryMonitor::BatteryMonitor() : mHealthdConfig(nullptr), mBatteryDevicePresent(false),
+ mAlwaysPluggedDevice(false), mBatteryFixedCapacity(0), mBatteryFixedTemperature(0) {
+ initBatteryProperties(&props);
+}
+
int BatteryMonitor::getBatteryStatus(const char* status) {
int ret;
struct sysfsStringEnumMap batteryStatusMap[] = {
@@ -184,12 +206,7 @@ int BatteryMonitor::getIntField(const String8& path) {
bool BatteryMonitor::update(void) {
bool logthis;
- props.chargerAcOnline = false;
- props.chargerUsbOnline = false;
- props.chargerWirelessOnline = false;
- props.batteryStatus = BATTERY_STATUS_UNKNOWN;
- props.batteryHealth = BATTERY_HEALTH_UNKNOWN;
- props.maxChargingCurrent = 0;
+ initBatteryProperties(&props);
if (!mHealthdConfig->batteryPresentPath.isEmpty())
props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath);
diff --git a/healthd/BatteryMonitor.h b/healthd/BatteryMonitor.h
index a61171fc6..600107308 100644
--- a/healthd/BatteryMonitor.h
+++ b/healthd/BatteryMonitor.h
@@ -37,6 +37,7 @@ class BatteryMonitor {
ANDROID_POWER_SUPPLY_TYPE_BATTERY
};
+ BatteryMonitor();
void init(struct healthd_config *hc);
bool update(void);
status_t getProperty(int id, struct BatteryProperty *val);