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
(cherry picked from commit ac5a0d316be22bc5e99b63c2c792a77afaeb2031)
diff --git a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
index 74fe4fb..6e13a98 100644
--- a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
+++ b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
@@ -257,15 +257,21 @@
     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;
 }