/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef THERMAL_SERVICE_H #define THERMAL_SERVICE_H #include #include "delayed_sp_singleton.h" #include "system_ability.h" #include "iremote_object.h" #include "action_popup.h" #include "thermal_srv_stub.h" #include "ithermal_level_callback.h" #include "ithermal_temp_callback.h" #include "thermal_srv_sensor_info.h" #include "thermalsrv_event_handler.h" #include "thermal_observer.h" #include "thermal_sensor_info.h" #include "thermal_service_subscriber.h" #include "thermal_policy.h" #include "state_machine.h" #include "thermal_action_manager.h" #include "thermal_config_base_info.h" #include "thermal_config_sensor_cluster.h" #include "thermal_callback_impl.h" #include "thermal_types.h" #include "hdf_service_status_listener.h" #include "v1_0/thermal_interface_proxy.h" namespace OHOS { namespace PowerMgr { using TypeTempMap = std::map; using namespace OHOS::HDI::Thermal::V1_0; using namespace OHOS::HDI::ServiceManager::V1_0; class ThermalService final : public SystemAbility, public ThermalSrvStub { DECLARE_SYSTEM_ABILITY(ThermalService); DECLARE_DELAYED_SP_SINGLETON(ThermalService); public: virtual void OnStart() override; virtual void OnStop() override; void SubscribeThermalTempCallback(const std::vector &typeList, const sptr &callback) override; void UnSubscribeThermalTempCallback(const sptr &callback) override; void SubscribeThermalLevelCallback(const sptr &callback) override; void UnSubscribeThermalLevelCallback(const sptr &callback) override; bool GetThermalSrvSensorInfo(const SensorType &type, ThermalSrvSensorInfo& sensorInfo) override; void GetThermalLevel(ThermalLevel& level) override; virtual std::string ShellDump(const std::vector& args, uint32_t argc) override; void HandleEvent(int event); void SendEvent(int32_t event, int64_t param, int64_t delayTime); void RemoveEvent(int32_t event); int32_t HandleThermalCallbackEvent(const HdfThermalCallbackInfo& event); void SetFlag(bool flag) { flag_ = flag; } bool GetFlag() { return flag_; } bool IsServiceReady() const { return ready_; } std::shared_ptr GetHandler() const { return handler_; } std::shared_ptr GetEventRunner() const { return eventRunner_; } std::shared_ptr GetBaseinfoObj() const { return baseInfo_; } std::shared_ptr GetStateMachineObj() const { return state_; } std::shared_ptr GetActionManagerObj() const { return actionMgr_; } std::shared_ptr GetPolicy() const { return policy_; } std::shared_ptr GetObserver() const { return observer_; } std::shared_ptr GetSensorInfo() const { return info_; } std::shared_ptr GetSubscriber() const { return serviceSubscriber_; } std::shared_ptr GetSensorCluster() const { return cluster_; } std::shared_ptr GetActionPopup() const { return popup_; } sptr GetThermalInterface() const { return thermalInterface_; } private: bool Init(); bool InitThermalDriver(); bool InitThermalObserver(); bool InitThermalAction(); bool InitThermalPolicy(); bool InitBaseInfo(); bool InitSensorCluser(); bool InitActionManager(); bool InitStateMachine(); bool InitModules(); bool CreateConfigModule(); bool RigisterHdfStatusListener(); bool ready_ {false}; std::mutex mutex_; std::shared_ptr eventRunner_ {nullptr}; std::shared_ptr handler_ {nullptr}; std::shared_ptr serviceSubscriber_ {nullptr}; std::shared_ptr observer_ {nullptr} ; std::shared_ptr info_ {nullptr}; std::shared_ptr policy_ {nullptr}; std::shared_ptr baseInfo_ {nullptr}; std::shared_ptr state_ {nullptr}; std::shared_ptr actionMgr_ {nullptr}; std::shared_ptr cluster_ {nullptr}; bool flag_ {false}; sptr thermalInterface_ {nullptr}; sptr servmgr_ {nullptr}; sptr hdfListener_ {nullptr}; std::shared_ptr popup_; }; } // namespace PowerMgr } // namespace OHOS #endif // THERMAL_SERVICE_H