From 06846044fe5dc4e99a107b2e92e3584afff4438e Mon Sep 17 00:00:00 2001 From: Stephane Lee Date: Wed, 12 Feb 2020 17:00:24 -0800 Subject: [PATCH] Add UNSUPPORTED to health HAL 2.1 values Bug: 149429835 Test: lshal debug android.hardware.health@2.1::IHealth/default Change-Id: Ibbcd89f38ed9ec2966b31854ab1cbe218c8e19cb --- healthd/BatteryMonitor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index b85f23f6f..8e9e074ab 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -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;