1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package android.hardware.thermal@2.0;
17
18import android.hardware.thermal@1.0::IThermal;
19import android.hardware.thermal@1.0::ThermalStatus;
20import IThermalChangedCallback;
21
22interface IThermal extends @1.0::IThermal {
23
24    /**
25     * Retrieves temperatures in Celsius.
26     *
27     * @param filterType whether to filter the result for a given type.
28     * @param type the TemperatureType such as battery or skin.
29     *
30     * @return status Status of the operation. If status code is FAILURE,
31     *    the status.debugMessage must be populated with a human-readable
32     *    error message.
33     *
34     * @return temperatures If status code is SUCCESS, it's filled with the
35     *    current temperatures. The order of temperatures of built-in
36     *    devices (such as CPUs, GPUs and etc.) in the list must be kept
37     *    the same regardless of the number of calls to this method even if
38     *    they go offline, if these devices exist on boot. The method
39     *    always returns and never removes such temperatures.
40     */
41    getCurrentTemperatures(bool filterType, TemperatureType type)
42        generates (ThermalStatus status, vec<Temperature> temperatures);
43
44    /**
45     * Retrieves static temperature thresholds in Celsius.
46     *
47     * @param filterType whether to filter the result for a given type.
48     * @param type the TemperatureType such as battery or skin.
49     *
50     * @return status Status of the operation. If status code is FAILURE,
51     *    the status.debugMessage must be populated with a human-readable error message.
52     * @return temperatureThresholds If status code is SUCCESS, it's filled with the
53     *    temperatures thresholds. The order of temperatures of built-in
54     *    devices (such as CPUs, GPUs and etc.) in the list must be kept
55     *    the same regardless of the number of calls to this method even if
56     *    they go offline, if these devices exist on boot. The method
57     *    always returns and never removes such temperatures. The thresholds
58     *    are returned as static values and must not change across calls. The actual
59     *    throttling state is determined in device thermal mitigation policy/agorithm
60     *    which might not be simple thresholds so these values Thermal HAL provided
61     *    may not be accurate to detemin the throttling status. To get accurate
62     *    throttling status, use getCurrentTemperatures or registerThermalChangedCallback
63     *    and listen to the callback.
64     */
65    getTemperatureThresholds(bool filterType, TemperatureType type)
66        generates (ThermalStatus status, vec<TemperatureThreshold> temperatureThresholds);
67
68   /**
69    * Register an IThermalChangedCallback, used by the Thermal HAL
70    * to receive thermal events when thermal mitigation status changed.
71    * Multiple registrations with different IThermalChangedCallback must be allowed.
72    * Multiple registrations with same IThermalChangedCallback is not allowed, client
73    * should unregister the given IThermalChangedCallback first.
74    *
75    * @param callback the IThermalChangedCallback to use for receiving
76    *    thermal events (nullptr callback will lead to failure with status code FAILURE).
77    * @param filterType if filter for given sensor type.
78    * @param type the type to be filtered.
79    *
80    * @return status Status of the operation. If status code is FAILURE,
81    *    the status.debugMessage must be populated with a human-readable error message.
82    */
83   registerThermalChangedCallback(IThermalChangedCallback callback,
84                                  bool filterType,
85                                  TemperatureType type)
86       generates (ThermalStatus status);
87
88   /**
89    * Unregister an IThermalChangedCallback, used by the Thermal HAL
90    * to receive thermal events when thermal mitigation status changed.
91    *
92    * @param callback the IThermalChangedCallback used for receiving
93    *    thermal events (nullptr callback will lead to failure with status code FAILURE).
94    *
95    * @return status Status of the operation. If status code is FAILURE,
96    *    the status.debugMessage must be populated with a human-readable error message.
97    */
98   unregisterThermalChangedCallback(IThermalChangedCallback callback)
99       generates (ThermalStatus status);
100
101    /**
102     * Retrieves the cooling devices information.
103     *
104     * @param filterType whether to filter the result for a given type.
105     * @param type the CoolingDevice such as CPU/GPU.
106     *
107     * @return status Status of the operation. If status code is FAILURE,
108     *    the status.debugMessage must be populated with the human-readable
109     *    error message.
110     * @return devices If status code is SUCCESS, it's filled with the current
111     *    cooling device information. The order of built-in cooling
112     *    devices in the list must be kept the same regardless of the number
113     *    of calls to this method even if they go offline, if these devices
114     *    exist on boot. The method always returns and never removes from
115     *    the list such cooling devices.
116     */
117   getCurrentCoolingDevices(bool filterType, CoolingType type)
118       generates (ThermalStatus status, vec<CoolingDevice> devices);
119};
120