Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac5a0d31 authored by Robin Lee's avatar Robin Lee
Browse files

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
parent b6fd785e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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;
}