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_SERVICE_CLIENT_H 17 #define THERMAL_SERVICE_CLIENT_H 18 19 #include "ithermal_srv.h" 20 #include "thermal_srv_sensor_info.h" 21 #include <singleton.h> 22 #include <string> 23 24 namespace OHOS { 25 namespace PowerMgr { 26 class ThermalMgrClient final : public DelayedRefSingleton<ThermalMgrClient> { 27 DECLARE_DELAYED_REF_SINGLETON(ThermalMgrClient) 28 29 public: 30 DISALLOW_COPY_AND_MOVE(ThermalMgrClient); 31 32 bool SubscribeThermalTempCallback( 33 const std::vector<std::string>& typeList, const sptr<IThermalTempCallback>& callback); 34 bool UnSubscribeThermalTempCallback(const sptr<IThermalTempCallback>& callback); 35 bool SubscribeThermalLevelCallback(const sptr<IThermalLevelCallback>& callback); 36 bool UnSubscribeThermalLevelCallback(const sptr<IThermalLevelCallback>& callback); 37 bool SubscribeThermalActionCallback(const std::vector<std::string>& actionList, const std::string& desc, 38 const sptr<IThermalActionCallback>& callback); 39 bool UnSubscribeThermalActionCallback(const sptr<IThermalActionCallback>& callback); 40 int32_t GetThermalSensorTemp(const SensorType type); 41 ThermalLevel GetThermalLevel(); 42 bool SetScene(const std::string& scene); 43 std::string Dump(const std::vector<std::string>& args); 44 45 #ifndef THERMAL_SERVICE_DEATH_UT 46 private: 47 #endif 48 class ThermalMgrDeathRecipient : public IRemoteObject::DeathRecipient { 49 public: 50 ThermalMgrDeathRecipient() = default; 51 ~ThermalMgrDeathRecipient() = default; 52 void OnRemoteDied(const wptr<IRemoteObject>& remote); 53 54 private: 55 DISALLOW_COPY_AND_MOVE(ThermalMgrDeathRecipient); 56 }; 57 58 ErrCode Connect(); 59 void GetLevel(ThermalLevel& level); 60 bool GetThermalSrvSensorInfo(const SensorType& type, ThermalSrvSensorInfo& sensorInfo); 61 sptr<IThermalSrv> thermalSrv_ {nullptr}; 62 sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr}; 63 void ResetProxy(const wptr<IRemoteObject>& remote); 64 std::mutex mutex_; 65 }; 66 } // namespace PowerMgr 67 } // namespace OHOS 68 #endif // THERMAL_SERVICE_CLIENT_H 69