Add thermal HAL 2.0
Bug: 116540200
Test: add default ThermalHAL 2.0 and VtsHalThermalV2_0TargetTest pass
Change-Id: Ib12634459d9ed5071230adf353b9737f5c90e771
diff --git a/thermal/2.0/IThermal.hal b/thermal/2.0/IThermal.hal
new file mode 100644
index 0000000..548ac9d
--- /dev/null
+++ b/thermal/2.0/IThermal.hal
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.thermal@2.0;
+
+import android.hardware.thermal@1.0::IThermal;
+import android.hardware.thermal@1.0::ThermalStatus;
+import IThermalChangedCallback;
+
+interface IThermal extends @1.0::IThermal {
+
+ /**
+ * Retrieves temperatures in Celsius.
+ *
+ * @param filterType whether to filter the result for a given type.
+ * @param type the TemperatureType such as battery or skin.
+ *
+ * @return status Status of the operation. If status code is FAILURE,
+ * the status.debugMessage must be populated with a human-readable
+ * error message.
+ *
+ * @return temperatures If status code is SUCCESS, it's filled with the
+ * current temperatures. The order of temperatures of built-in
+ * 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.
+ */
+ getCurrentTemperatures(bool filterType, TemperatureType type)
+ generates (ThermalStatus status, vec<Temperature> temperatures);
+
+ /**
+ * Retrieves temperature thresholds in Celsius.
+ *
+ * @param filterType whether to filter the result for a given type.
+ * @param type the TemperatureType such as battery or skin.
+ *
+ * @return status Status of the operation. If status code is FAILURE,
+ * the status.debugMessage must be populated with a human-readable error message.
+ * @return temperatureThresholds If status code is SUCCESS, it's filled with the
+ * temperatures thresholds. The order of temperatures of built-in
+ * 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.
+ */
+ getTemperatureThresholds(bool filterType, TemperatureType type)
+ generates (ThermalStatus status, vec<TemperatureThreshold> temperatureThresholds);
+
+ /**
+ * Register an IThermalChangedCallback, used by the Thermal HAL
+ * to send thermal events when thermal mitigation status changed.
+ * Multiple registrations with different IThermalChangedCallback must be allowed.
+ * Multiple registrations with same IThermalChangedCallback is not allowed, client
+ * should unregister the given IThermalChangedCallback first.
+ *
+ * @param callback the IThermalChangedCallback to use for sending
+ * thermal events (cannot be nullptr).
+ * @param filterType if filter for given sensor type.
+ * @param type the type to be filtered.
+ *
+ * @return status Status of the operation. If status code is FAILURE,
+ * the status.debugMessage must be populated with a human-readable error message.
+ */
+ registerThermalChangedCallback(IThermalChangedCallback callback,
+ bool filterType,
+ TemperatureType type)
+ generates (ThermalStatus status);
+
+ /**
+ * Register an IThermalChangedCallback, used by the Thermal HAL
+ * to send thermal events when thermal mitigation status changed.
+ *
+ * @param callback the IThermalChangedCallback to use for sending
+ * thermal events, or nullptr to set no callback.
+ *
+ * @return status Status of the operation. If status code is FAILURE,
+ * the status.debugMessage must be populated with a human-readable error message.
+ */
+ unregisterThermalChangedCallback(IThermalChangedCallback callback)
+ generates (ThermalStatus status);
+
+ /**
+ * Retrieves the cooling devices information.
+ *
+ * @param filterType whether to filter the result for a given type.
+ * @param type the CoolingDevice such as CPU/GPU.
+ *
+ * @return status Status of the operation. If status code is FAILURE,
+ * the status.debugMessage must be populated with the human-readable
+ * error message.
+ * @return devices If status code is SUCCESS, it's filled with the current
+ * cooling device information. The order of built-in cooling
+ * devices 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 from
+ * the list such cooling devices.
+ */
+ getCurrentCoolingDevices(bool filterType, CoolingType type)
+ generates (ThermalStatus status, vec<CoolingDevice> devices);
+};