ThermalHAL: add BCL to temperature type

Bug: 116540200
Test: VTS test passed
Change-Id: I7cdf64a8ee55a9e14a9df673edaf25a5cd3a90d2
diff --git a/thermal/2.0/IThermal.hal b/thermal/2.0/IThermal.hal
index 548ac9d..f890694 100644
--- a/thermal/2.0/IThermal.hal
+++ b/thermal/2.0/IThermal.hal
@@ -42,7 +42,7 @@
         generates (ThermalStatus status, vec<Temperature> temperatures);
 
     /**
-     * Retrieves temperature thresholds in Celsius.
+     * Retrieves static temperature thresholds in Celsius.
      *
      * @param filterType whether to filter the result for a given type.
      * @param type the TemperatureType such as battery or skin.
@@ -54,7 +54,11 @@
      *    devices (such as CPUs, GPUs and etc.) in the list must be kept
      *    the same regardless of the number of calls to this method even if
      *    they go offline, if these devices exist on boot. The method
-     *    always returns and never removes such temperatures.
+     *    always returns and never removes such temperatures. The thresholds
+     *    are returned as static values and must not change across calls. The actual
+     *    throttling state is determined in driver and HAL and must not be simply
+     *    compared with these thresholds. To get accurate throttling status, use
+     *    getCurrentTemperatures or registerThermalChangedCallback and listen.
      */
     getTemperatureThresholds(bool filterType, TemperatureType type)
         generates (ThermalStatus status, vec<TemperatureThreshold> temperatureThresholds);
diff --git a/thermal/2.0/default/android.hardware.thermal@2.0-service.xml b/thermal/2.0/default/android.hardware.thermal@2.0-service.xml
index c4c7d4d..bcd6344 100644
--- a/thermal/2.0/default/android.hardware.thermal@2.0-service.xml
+++ b/thermal/2.0/default/android.hardware.thermal@2.0-service.xml
@@ -2,6 +2,7 @@
     <hal format="hidl">
         <name>android.hardware.thermal</name>
         <transport>hwbinder</transport>
+        <version>1.0</version>
         <version>2.0</version>
         <interface>
             <name>IThermal</name>
diff --git a/thermal/2.0/types.hal b/thermal/2.0/types.hal
index 7b60d00..4929e44 100644
--- a/thermal/2.0/types.hal
+++ b/thermal/2.0/types.hal
@@ -22,6 +22,12 @@
 enum TemperatureType : @1.0::TemperatureType {
     USB_PORT = 4,
     POWER_AMPLIFIER = 5,
+    /**
+     * Battery Charge Limit - virtual thermal sensors
+     */
+    BCL_VOLTAGE = 6,
+    BCL_CURRENT = 7,
+    BCL_PERCENTAGE = 8,
 };
 
 
@@ -88,6 +94,7 @@
      * Hot throttling temperature constant for this temperature sensor in
      * level defined in ThrottlingSeverity including shutdown. Throttling
      * happens when temperature >= threshold. If not available, set to NAN.
+     * Unit is same as Temperature's value.
      */
     float[ThrottlingSeverityCount:NUM_THROTTLING_LEVELS] hotThrottlingThresholds;
 
@@ -95,13 +102,14 @@
      * Cold throttling temperature constant for this temperature sensor in
      * level defined in ThrottlingSeverity including shutdown. Throttling
      * happens when temperature <= threshold. If not available, set to NAN.
+     * Unit is same as Temperature's value.
      */
     float[ThrottlingSeverityCount:NUM_THROTTLING_LEVELS] coldThrottlingThresholds;
 
     /**
      * Threshold temperature above which the VR mode clockrate minimums cannot
-     * be maintained for this device.
-     * If not available, set by HAL to NAN.
+     * be maintained for this device. If not available, set by HAL to NAN.
+     * Unit is same as Temperature's value.
      */
     float vrThrottlingThreshold;
 };
@@ -121,7 +129,10 @@
     string name;
 
     /**
-     * Current temperature in Celsius. If not available set by HAL to NAN.
+     * For BCL, this is the current reading of the virtual sensor and the unit is
+     * millivolt, milliamp, percentage for BCL_VOLTAGE, BCL_CURRENT and BCL_PERCENTAGE
+     * respectively. For everything else, this is the current temperature in Celsius.
+     * If not available set by HAL to NAN.
      */
     float value;
 
diff --git a/thermal/2.0/vts/functional/VtsHalThermalV2_0TargetTest.cpp b/thermal/2.0/vts/functional/VtsHalThermalV2_0TargetTest.cpp
index 535f618..cf1956d 100644
--- a/thermal/2.0/vts/functional/VtsHalThermalV2_0TargetTest.cpp
+++ b/thermal/2.0/vts/functional/VtsHalThermalV2_0TargetTest.cpp
@@ -23,6 +23,7 @@
 #include <VtsHalHidlTargetTestEnvBase.h>
 
 using ::android::sp;
+using ::android::hardware::hidl_enum_range;
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
@@ -183,9 +184,8 @@
                                              EXPECT_NE(ThermalStatusCode::SUCCESS, status.code);
                                          }
                                      });
-    for (int i = static_cast<int>(TemperatureType::UNKNOWN);
-         i <= static_cast<int>(TemperatureType::POWER_AMPLIFIER); ++i) {
-        auto type = static_cast<TemperatureType>(i);
+    auto types = hidl_enum_range<TemperatureType>();
+    for (const auto& type : types) {
         mThermal->getCurrentTemperatures(
             true, type, [&type](ThermalStatus status, hidl_vec<Temperature> temperatures) {
                 if (temperatures.size()) {