Merge "healthd: Fix negativity check after cast to unsigned enum" am: 3dad67af05
am: 4734981245
Change-Id: I77ec8aae517e4bd647a7dd6c87cb53152410e7c9
This commit is contained in:
commit
eb066ae098
1 changed files with 3 additions and 3 deletions
|
|
@ -143,7 +143,7 @@ int BatteryMonitor::readFromFile(const String8& path, std::string* buf) {
|
||||||
|
|
||||||
BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String8& path) {
|
BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String8& path) {
|
||||||
std::string buf;
|
std::string buf;
|
||||||
BatteryMonitor::PowerSupplyType ret;
|
int ret;
|
||||||
struct sysfsStringEnumMap supplyTypeMap[] = {
|
struct sysfsStringEnumMap supplyTypeMap[] = {
|
||||||
{ "Unknown", ANDROID_POWER_SUPPLY_TYPE_UNKNOWN },
|
{ "Unknown", ANDROID_POWER_SUPPLY_TYPE_UNKNOWN },
|
||||||
{ "Battery", ANDROID_POWER_SUPPLY_TYPE_BATTERY },
|
{ "Battery", ANDROID_POWER_SUPPLY_TYPE_BATTERY },
|
||||||
|
|
@ -164,13 +164,13 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String
|
||||||
if (readFromFile(path, &buf) <= 0)
|
if (readFromFile(path, &buf) <= 0)
|
||||||
return ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
|
return ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
|
||||||
|
|
||||||
ret = (BatteryMonitor::PowerSupplyType)mapSysfsString(buf.c_str(), supplyTypeMap);
|
ret = mapSysfsString(buf.c_str(), supplyTypeMap);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str());
|
KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str());
|
||||||
ret = ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
|
ret = ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return static_cast<BatteryMonitor::PowerSupplyType>(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatteryMonitor::getBooleanField(const String8& path) {
|
bool BatteryMonitor::getBooleanField(const String8& path) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue