1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef THERMAL_KERNEL_SERVICE_H 17 #define THERMAL_KERNEL_SERVICE_H 18 19 #include <memory> 20 #include "thermal_kernel_policy.h" 21 #include "thermal_sensor_provision.h" 22 #include "thermal_device_control.h" 23 #include "thermal_protector_timer.h" 24 25 namespace OHOS { 26 namespace PowerMgr { 27 class ThermalKernelService { 28 public: ThermalKernelService()29 ThermalKernelService() {}; 30 ~ThermalKernelService() = default; 31 ThermalKernelService(const ThermalKernelService&) = delete; 32 ThermalKernelService& operator=(const ThermalKernelService&) = delete; GetInstance()33 static ThermalKernelService &GetInstance() 34 { 35 static ThermalKernelService instance; 36 return instance; 37 } 38 39 void OnStart(); 40 void OnStop(); 41 GetPolicy()42 std::shared_ptr<ThermalKernelPolicy> GetPolicy() const 43 { 44 return policy_; 45 } 46 GetProvision()47 std::shared_ptr<ThermalSensorProvision> GetProvision() const 48 { 49 return provision_; 50 } 51 GetControl()52 std::shared_ptr<ThermalDeviceControl> GetControl() const 53 { 54 return control_; 55 } 56 GetTimer()57 std::shared_ptr<ThermalProtectorTimer> GetTimer() const 58 { 59 return timer_; 60 } 61 private: 62 bool Init(); 63 std::shared_ptr<ThermalKernelPolicy> policy_ {nullptr}; 64 std::shared_ptr<ThermalSensorProvision> provision_ {nullptr}; 65 std::shared_ptr<ThermalDeviceControl> control_ {nullptr}; 66 std::shared_ptr<ThermalProtectorTimer> timer_ {nullptr}; 67 }; 68 } // namespace PowerMgr 69 } // namespace OHOS 70 #endif 71