Merge "Add UNSUPPORTED to health HAL 2.1 values" am: 9d261c3fed

Change-Id: I18dc62b92725d3061772d5069558af688a99573b
This commit is contained in:
Treehugger Robot 2020-02-18 21:12:32 +00:00
commit 5c2dc9c222

View file

@ -55,6 +55,7 @@ using HealthInfo_2_1 = android::hardware::health::V2_1::HealthInfo;
using android::hardware::health::V1_0::BatteryHealth;
using android::hardware::health::V1_0::BatteryStatus;
using android::hardware::health::V2_1::BatteryCapacityLevel;
using android::hardware::health::V2_1::Constants;
namespace android {
@ -79,6 +80,8 @@ static void initHealthInfo(HealthInfo_2_1* health_info_2_1) {
// HIDL enum values are zero initialized, so they need to be initialized
// properly.
health_info_2_1->batteryCapacityLevel = BatteryCapacityLevel::UNKNOWN;
health_info_2_1->batteryChargeTimeToFullNowSeconds =
(int64_t)Constants::BATTERY_CHARGE_TIME_TO_FULL_NOW_SECONDS_UNSUPPORTED;
auto* props = &health_info_2_1->legacy.legacy;
props->batteryStatus = BatteryStatus::UNKNOWN;
props->batteryHealth = BatteryHealth::UNKNOWN;
@ -134,13 +137,13 @@ BatteryCapacityLevel getBatteryCapacityLevel(const char* capacityLevel) {
{"Normal", BatteryCapacityLevel::NORMAL},
{"High", BatteryCapacityLevel::HIGH},
{"Full", BatteryCapacityLevel::FULL},
{NULL, BatteryCapacityLevel::UNKNOWN},
{NULL, BatteryCapacityLevel::UNSUPPORTED},
};
auto ret = mapSysfsString(capacityLevel, batteryCapacityLevelMap);
if (!ret) {
KLOG_WARNING(LOG_TAG, "Unknown battery capacity level '%s'\n", capacityLevel);
*ret = BatteryCapacityLevel::UNKNOWN;
KLOG_WARNING(LOG_TAG, "Unsupported battery capacity level '%s'\n", capacityLevel);
*ret = BatteryCapacityLevel::UNSUPPORTED;
}
return *ret;