Add UNSUPPORTED to health HAL 2.1 values

Bug: 149429835
Test: lshal debug android.hardware.health@2.1::IHealth/default
Change-Id: Ibbcd89f38ed9ec2966b31854ab1cbe218c8e19cb
This commit is contained in:
Stephane Lee 2020-02-12 17:00:24 -08:00
parent 71fcaf5726
commit 06846044fe

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;