blob: 5fa1abd9f59994277b66b72635d4213a0fc0e5a3 [file] [log] [blame]
Wei Wang84ce54e2018-10-18 13:56:03 -07001/*
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 */
16
17#ifndef ANDROID_HARDWARE_THERMAL_V2_0_THERMAL_H
18#define ANDROID_HARDWARE_THERMAL_V2_0_THERMAL_H
19
20#include <android/hardware/thermal/2.0/IThermal.h>
21#include <hidl/MQDescriptor.h>
22#include <hidl/Status.h>
23
24namespace android {
25namespace hardware {
26namespace thermal {
27namespace V2_0 {
28namespace implementation {
29
30using ::android::sp;
31using ::android::hardware::hidl_array;
32using ::android::hardware::hidl_memory;
33using ::android::hardware::hidl_string;
34using ::android::hardware::hidl_vec;
35using ::android::hardware::Return;
36using ::android::hardware::Void;
37using ::android::hardware::thermal::V1_0::CpuUsage;
38using ::android::hardware::thermal::V2_0::CoolingType;
39using ::android::hardware::thermal::V2_0::IThermal;
40using CoolingDevice_1_0 = ::android::hardware::thermal::V1_0::CoolingDevice;
41using CoolingDevice_2_0 = ::android::hardware::thermal::V2_0::CoolingDevice;
42using Temperature_1_0 = ::android::hardware::thermal::V1_0::Temperature;
43using Temperature_2_0 = ::android::hardware::thermal::V2_0::Temperature;
44using ::android::hardware::thermal::V2_0::IThermalChangedCallback;
45using ::android::hardware::thermal::V2_0::TemperatureThreshold;
46using ::android::hardware::thermal::V2_0::TemperatureType;
47
48struct CallbackSetting {
49 CallbackSetting(sp<IThermalChangedCallback> callback, bool is_filter_type, TemperatureType type)
50 : callback(callback), is_filter_type(is_filter_type), type(type) {}
51 sp<IThermalChangedCallback> callback;
52 bool is_filter_type;
53 TemperatureType type;
54};
55
56class Thermal : public IThermal {
57 public:
58 // Methods from ::android::hardware::thermal::V1_0::IThermal follow.
59 Return<void> getTemperatures(getTemperatures_cb _hidl_cb) override;
60 Return<void> getCpuUsages(getCpuUsages_cb _hidl_cb) override;
61 Return<void> getCoolingDevices(getCoolingDevices_cb _hidl_cb) override;
62
63 // Methods from ::android::hardware::thermal::V2_0::IThermal follow.
64 Return<void> getCurrentTemperatures(bool filterType, TemperatureType type,
65 getCurrentTemperatures_cb _hidl_cb) override;
66 Return<void> getTemperatureThresholds(bool filterType, TemperatureType type,
67 getTemperatureThresholds_cb _hidl_cb) override;
68 Return<void> registerThermalChangedCallback(
69 const sp<IThermalChangedCallback>& callback, bool filterType, TemperatureType type,
70 registerThermalChangedCallback_cb _hidl_cb) override;
71 Return<void> unregisterThermalChangedCallback(
72 const sp<IThermalChangedCallback>& callback,
73 unregisterThermalChangedCallback_cb _hidl_cb) override;
74 Return<void> getCurrentCoolingDevices(bool filterType, CoolingType type,
75 getCurrentCoolingDevices_cb _hidl_cb) override;
76
77 private:
78 std::mutex thermal_callback_mutex_;
79 std::vector<CallbackSetting> callbacks_;
80};
81
82} // namespace implementation
83} // namespace V2_0
84} // namespace thermal
85} // namespace hardware
86} // namespace android
87
88#endif // ANDROID_HARDWARE_THERMAL_V2_0_THERMAL_H