Loading healthd/BatteryMonitor.cpp +23 −6 Original line number Original line Diff line number Diff line Loading @@ -56,6 +56,28 @@ static int mapSysfsString(const char* str, return -1; 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 BatteryMonitor::getBatteryStatus(const char* status) { int ret; int ret; struct sysfsStringEnumMap batteryStatusMap[] = { struct sysfsStringEnumMap batteryStatusMap[] = { Loading Loading @@ -184,12 +206,7 @@ int BatteryMonitor::getIntField(const String8& path) { bool BatteryMonitor::update(void) { bool BatteryMonitor::update(void) { bool logthis; bool logthis; props.chargerAcOnline = false; initBatteryProperties(&props); props.chargerUsbOnline = false; props.chargerWirelessOnline = false; props.batteryStatus = BATTERY_STATUS_UNKNOWN; props.batteryHealth = BATTERY_HEALTH_UNKNOWN; props.maxChargingCurrent = 0; if (!mHealthdConfig->batteryPresentPath.isEmpty()) if (!mHealthdConfig->batteryPresentPath.isEmpty()) props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath); props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath); Loading healthd/BatteryMonitor.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,7 @@ class BatteryMonitor { ANDROID_POWER_SUPPLY_TYPE_BATTERY ANDROID_POWER_SUPPLY_TYPE_BATTERY }; }; BatteryMonitor(); void init(struct healthd_config *hc); void init(struct healthd_config *hc); bool update(void); bool update(void); status_t getProperty(int id, struct BatteryProperty *val); status_t getProperty(int id, struct BatteryProperty *val); Loading Loading
healthd/BatteryMonitor.cpp +23 −6 Original line number Original line Diff line number Diff line Loading @@ -56,6 +56,28 @@ static int mapSysfsString(const char* str, return -1; 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 BatteryMonitor::getBatteryStatus(const char* status) { int ret; int ret; struct sysfsStringEnumMap batteryStatusMap[] = { struct sysfsStringEnumMap batteryStatusMap[] = { Loading Loading @@ -184,12 +206,7 @@ int BatteryMonitor::getIntField(const String8& path) { bool BatteryMonitor::update(void) { bool BatteryMonitor::update(void) { bool logthis; bool logthis; props.chargerAcOnline = false; initBatteryProperties(&props); props.chargerUsbOnline = false; props.chargerWirelessOnline = false; props.batteryStatus = BATTERY_STATUS_UNKNOWN; props.batteryHealth = BATTERY_HEALTH_UNKNOWN; props.maxChargingCurrent = 0; if (!mHealthdConfig->batteryPresentPath.isEmpty()) if (!mHealthdConfig->batteryPresentPath.isEmpty()) props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath); props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath); Loading
healthd/BatteryMonitor.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,7 @@ class BatteryMonitor { ANDROID_POWER_SUPPLY_TYPE_BATTERY ANDROID_POWER_SUPPLY_TYPE_BATTERY }; }; BatteryMonitor(); void init(struct healthd_config *hc); void init(struct healthd_config *hc); bool update(void); bool update(void); status_t getProperty(int id, struct BatteryProperty *val); status_t getProperty(int id, struct BatteryProperty *val); Loading