health VTS: Status::UNKNOWN is OK if not present

Documentation: https://source.android.com/devices/tech/power/batteryless

If a battery device is not detected, the following battery-related
defaults are used on Android 9 and higher:

* Present:              false
* Status:               unknown
* Remaining capacity:   0
* Health:               unknown
* AC charger online:    not modified

The previous version of the test failed devices if the vendor HAL
reported BatteryStatus::UNKNOWN. However, the tests were skipped if the
default HAL was the one being used, so this has not come up before for
other batteryless devices.

Bug: 142081126
Test: vts-tradefed run vts -m VtsHalHealthV2_0
Change-Id: I8ca758677478b47511e24990fee545fafa6c7f83
This commit is contained in:
Robin Lee
2019-10-09 15:48:17 +02:00
parent b6fd785ec5
commit ac5a0d316b

View File

@@ -257,15 +257,21 @@ bool verifyHealthInfo(const HealthInfo& health_info) {
using V1_0::BatteryStatus;
using V1_0::BatteryHealth;
if (!((health_info.legacy.batteryChargeCounter > 0) &&
(health_info.legacy.batteryCurrent != INT32_MIN) &&
if (!((health_info.legacy.batteryCurrent != INT32_MIN) &&
(0 <= health_info.legacy.batteryLevel && health_info.legacy.batteryLevel <= 100) &&
verifyEnum<BatteryHealth>(health_info.legacy.batteryHealth) &&
(health_info.legacy.batteryStatus != BatteryStatus::UNKNOWN) &&
verifyEnum<BatteryStatus>(health_info.legacy.batteryStatus))) {
return false;
}
if (health_info.legacy.batteryPresent) {
// If a battery is present, the battery status must be known.
if (!((health_info.legacy.batteryChargeCounter > 0) &&
(health_info.legacy.batteryStatus != BatteryStatus::UNKNOWN))) {
return false;
}
}
return true;
}