1 /* 2 * Copyright (C) 2019 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 HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_THERMAL_UTILS_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_THERMAL_UTILS_H_ 19 20 #include <android/hardware/thermal/2.0/IThermalChangedCallback.h> 21 22 #include "thermal_types.h" 23 24 namespace android { 25 namespace hardware { 26 namespace hidl_thermal_utils { 27 28 using ::android::sp; 29 using ::android::hardware::hidl_string; 30 using ::android::hardware::hidl_vec; 31 using ::android::hardware::Return; 32 using ::android::hardware::Void; 33 using ::android::hardware::thermal::V2_0::IThermalChangedCallback; 34 using ::android::hardware::thermal::V2_0::Temperature; 35 using ::android::hardware::thermal::V2_0::TemperatureType; 36 using ::android::hardware::thermal::V2_0::ThrottlingSeverity; 37 38 // HidlThermalChangedCallback implements the HIDL thermal changed callback 39 // interface, IThermalChangedCallback, to be registered for thermal status 40 // change. 41 class HidlThermalChangedCallback : public IThermalChangedCallback { 42 public: 43 static std::unique_ptr<HidlThermalChangedCallback> Create( 44 google_camera_hal::NotifyThrottlingFunc notify_throttling); 45 virtual ~HidlThermalChangedCallback() = default; 46 47 // Override functions in HidlThermalChangedCallback. 48 Return<void> notifyThrottling(const Temperature& temperature) override; 49 // End of override functions in HidlThermalChangedCallback. 50 51 protected: 52 HidlThermalChangedCallback( 53 google_camera_hal::NotifyThrottlingFunc notify_throttling); 54 55 private: 56 const google_camera_hal::NotifyThrottlingFunc kNotifyThrottling; 57 58 status_t ConvertToHalTemperatureType( 59 const TemperatureType& hidl_temperature_type, 60 google_camera_hal::TemperatureType* hal_temperature_type); 61 62 status_t ConvertToHalThrottlingSeverity( 63 const ThrottlingSeverity& hidl_throttling_severity, 64 google_camera_hal::ThrottlingSeverity* hal_throttling_severity); 65 66 status_t ConvertToHalTemperature( 67 const Temperature& hidl_temperature, 68 google_camera_hal::Temperature* hal_temperature); 69 }; 70 71 status_t ConvertToHidlTemperatureType( 72 const google_camera_hal::TemperatureType& hal_temperature_type, 73 TemperatureType* hidl_temperature_type); 74 75 } // namespace hidl_thermal_utils 76 } // namespace hardware 77 } // namespace android 78 79 #endif // HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_THERMAL_UTILS_H_