Peiyong Lin | 5696075 | 2022-09-30 21:52:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | #include "Thermal.h" |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | |
| 21 | namespace aidl::android::hardware::thermal::impl::example { |
| 22 | |
| 23 | using ndk::ScopedAStatus; |
| 24 | |
| 25 | ScopedAStatus Thermal::getCoolingDevices(std::vector<CoolingDevice>* /* out_devices */) { |
| 26 | LOG(VERBOSE) << __func__; |
| 27 | return ScopedAStatus::ok(); |
| 28 | } |
| 29 | |
| 30 | ScopedAStatus Thermal::getCoolingDevicesWithType(CoolingType in_type, |
| 31 | std::vector<CoolingDevice>* /* out_devices */) { |
| 32 | LOG(VERBOSE) << __func__ << " CoolingType: " << static_cast<int32_t>(in_type); |
| 33 | return ScopedAStatus::ok(); |
| 34 | } |
| 35 | |
| 36 | ScopedAStatus Thermal::getTemperatures(std::vector<Temperature>* /* out_temperatures */) { |
| 37 | LOG(VERBOSE) << __func__; |
| 38 | return ScopedAStatus::ok(); |
| 39 | } |
| 40 | |
| 41 | ScopedAStatus Thermal::getTemperaturesWithType(TemperatureType in_type, |
| 42 | std::vector<Temperature>* /* out_temperatures */) { |
| 43 | LOG(VERBOSE) << __func__ << " TemperatureType: " << static_cast<int32_t>(in_type); |
| 44 | return ScopedAStatus::ok(); |
| 45 | } |
| 46 | |
| 47 | ScopedAStatus Thermal::getTemperatureThresholds( |
| 48 | std::vector<TemperatureThreshold>* /* out_temperatureThresholds */) { |
| 49 | LOG(VERBOSE) << __func__; |
| 50 | return ScopedAStatus::ok(); |
| 51 | } |
| 52 | |
| 53 | ScopedAStatus Thermal::getTemperatureThresholdsWithType( |
| 54 | TemperatureType in_type, |
| 55 | std::vector<TemperatureThreshold>* /* out_temperatureThresholds */) { |
| 56 | LOG(VERBOSE) << __func__ << " TemperatureType: " << static_cast<int32_t>(in_type); |
| 57 | return ScopedAStatus::ok(); |
| 58 | } |
| 59 | |
| 60 | ScopedAStatus Thermal::registerThermalChangedCallback( |
| 61 | const std::shared_ptr<IThermalChangedCallback>& in_callback) { |
| 62 | LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback; |
| 63 | if (in_callback == nullptr) { |
| 64 | return ScopedAStatus::fromStatus(STATUS_BAD_VALUE); |
| 65 | } |
| 66 | if (mCallbacks.find(in_callback) != mCallbacks.end()) { |
| 67 | return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION); |
| 68 | } |
| 69 | mCallbacks.insert(in_callback); |
| 70 | return ScopedAStatus::ok(); |
| 71 | } |
| 72 | |
| 73 | ScopedAStatus Thermal::registerThermalChangedCallbackWithType( |
| 74 | const std::shared_ptr<IThermalChangedCallback>& in_callback, TemperatureType in_type) { |
| 75 | LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback |
| 76 | << ", TemperatureType: " << static_cast<int32_t>(in_type); |
| 77 | if (in_callback == nullptr) { |
| 78 | return ScopedAStatus::fromStatus(STATUS_BAD_VALUE); |
| 79 | } |
| 80 | if (mCallbacks.find(in_callback) != mCallbacks.end()) { |
| 81 | return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION); |
| 82 | } |
| 83 | mCallbacks.insert(in_callback); |
| 84 | return ScopedAStatus::ok(); |
| 85 | } |
| 86 | |
| 87 | ScopedAStatus Thermal::unregisterThermalChangedCallback( |
| 88 | const std::shared_ptr<IThermalChangedCallback>& in_callback) { |
| 89 | LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback; |
| 90 | bool found = false; |
| 91 | if (in_callback == nullptr) { |
| 92 | return ScopedAStatus::fromStatus(STATUS_BAD_VALUE); |
| 93 | } |
| 94 | if (mCallbacks.find(in_callback) == mCallbacks.end()) { |
| 95 | return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION); |
| 96 | } |
| 97 | mCallbacks.erase(in_callback); |
| 98 | return ScopedAStatus::ok(); |
| 99 | } |
| 100 | |
| 101 | } // namespace aidl::android::hardware::thermal::impl::example |