Loading healthd/BatteryMonitor.cpp +32 −40 Original line number Diff line number Diff line Loading @@ -200,9 +200,7 @@ int BatteryMonitor::getIntField(const String8& path) { return value; } bool BatteryMonitor::update(void) { bool logthis; void BatteryMonitor::updateValues(void) { initBatteryProperties(&props); if (!mHealthdConfig->batteryPresentPath.isEmpty()) Loading Loading @@ -289,50 +287,44 @@ bool BatteryMonitor::update(void) { } } } } logthis = !healthd_board_battery_update(&props); if (logthis) { void BatteryMonitor::logValues(void) { char dmesgline[256]; size_t len; if (props.batteryPresent) { snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d", props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "", abs(props.batteryTemperature / 10), abs(props.batteryTemperature % 10), props.batteryHealth, props.batteryStatus); snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d", props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "", abs(props.batteryTemperature / 10), abs(props.batteryTemperature % 10), props.batteryHealth, props.batteryStatus); len = strlen(dmesgline); if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) { len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d", props.batteryCurrent); len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d", props.batteryCurrent); } if (!mHealthdConfig->batteryFullChargePath.isEmpty()) { len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d", props.batteryFullCharge); len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d", props.batteryFullCharge); } if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) { len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d", props.batteryCycleCount); len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d", props.batteryCycleCount); } } else { len = snprintf(dmesgline, sizeof(dmesgline), "battery none"); len = snprintf(dmesgline, sizeof(dmesgline), "battery none"); } snprintf(dmesgline + len, sizeof(dmesgline) - len, " chg=%s%s%s", props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "", props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "", props.chargerWirelessOnline ? "w" : ""); KLOG_WARNING(LOG_TAG, "%s\n", dmesgline); } healthd_mode_ops->battery_update(&props); bool BatteryMonitor::isChargerOnline() { return props.chargerAcOnline | props.chargerUsbOnline | props.chargerWirelessOnline; } Loading healthd/include/healthd/BatteryMonitor.h +4 −1 Original line number Diff line number Diff line Loading @@ -38,12 +38,15 @@ class BatteryMonitor { BatteryMonitor(); void init(struct healthd_config *hc); bool update(void); int getChargeStatus(); status_t getProperty(int id, struct BatteryProperty *val); void dumpState(int fd); friend struct BatteryProperties getBatteryProperties(BatteryMonitor* batteryMonitor); void updateValues(void); void logValues(void); bool isChargerOnline(); private: struct healthd_config *mHealthdConfig; Vector<String8> mChargerNames; Loading Loading
healthd/BatteryMonitor.cpp +32 −40 Original line number Diff line number Diff line Loading @@ -200,9 +200,7 @@ int BatteryMonitor::getIntField(const String8& path) { return value; } bool BatteryMonitor::update(void) { bool logthis; void BatteryMonitor::updateValues(void) { initBatteryProperties(&props); if (!mHealthdConfig->batteryPresentPath.isEmpty()) Loading Loading @@ -289,50 +287,44 @@ bool BatteryMonitor::update(void) { } } } } logthis = !healthd_board_battery_update(&props); if (logthis) { void BatteryMonitor::logValues(void) { char dmesgline[256]; size_t len; if (props.batteryPresent) { snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d", props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "", abs(props.batteryTemperature / 10), abs(props.batteryTemperature % 10), props.batteryHealth, props.batteryStatus); snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d", props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "", abs(props.batteryTemperature / 10), abs(props.batteryTemperature % 10), props.batteryHealth, props.batteryStatus); len = strlen(dmesgline); if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) { len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d", props.batteryCurrent); len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d", props.batteryCurrent); } if (!mHealthdConfig->batteryFullChargePath.isEmpty()) { len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d", props.batteryFullCharge); len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d", props.batteryFullCharge); } if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) { len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d", props.batteryCycleCount); len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d", props.batteryCycleCount); } } else { len = snprintf(dmesgline, sizeof(dmesgline), "battery none"); len = snprintf(dmesgline, sizeof(dmesgline), "battery none"); } snprintf(dmesgline + len, sizeof(dmesgline) - len, " chg=%s%s%s", props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "", props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "", props.chargerWirelessOnline ? "w" : ""); KLOG_WARNING(LOG_TAG, "%s\n", dmesgline); } healthd_mode_ops->battery_update(&props); bool BatteryMonitor::isChargerOnline() { return props.chargerAcOnline | props.chargerUsbOnline | props.chargerWirelessOnline; } Loading
healthd/include/healthd/BatteryMonitor.h +4 −1 Original line number Diff line number Diff line Loading @@ -38,12 +38,15 @@ class BatteryMonitor { BatteryMonitor(); void init(struct healthd_config *hc); bool update(void); int getChargeStatus(); status_t getProperty(int id, struct BatteryProperty *val); void dumpState(int fd); friend struct BatteryProperties getBatteryProperties(BatteryMonitor* batteryMonitor); void updateValues(void); void logValues(void); bool isChargerOnline(); private: struct healthd_config *mHealthdConfig; Vector<String8> mChargerNames; Loading