1 /* 2 * Copyright (c) 2022 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 MOCK_THERMAL_SERVICE_CLIENT_H 17 #define MOCK_THERMAL_SERVICE_CLIENT_H 18 19 #include <string> 20 #include <singleton.h> 21 #include "ithermal_srv.h" 22 #include "thermal_srv_sensor_info.h" 23 24 namespace OHOS { 25 namespace PowerMgr { 26 class MockThermalMgrClient final : public DelayedRefSingleton<MockThermalMgrClient> { 27 DECLARE_DELAYED_REF_SINGLETON(MockThermalMgrClient) 28 29 public: 30 DISALLOW_COPY_AND_MOVE(MockThermalMgrClient); 31 32 bool GetThermalInfo(); 33 private: 34 class ThermalMgrDeathRecipient : public IRemoteObject::DeathRecipient { 35 public: 36 ThermalMgrDeathRecipient() = default; 37 ~ThermalMgrDeathRecipient() = default; 38 void OnRemoteDied(const wptr<IRemoteObject>& remote); 39 private: 40 DISALLOW_COPY_AND_MOVE(ThermalMgrDeathRecipient); 41 }; 42 43 private: 44 ErrCode Connect(); 45 private: 46 sptr<IThermalSrv> thermalSrv_ {nullptr}; 47 sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr}; 48 void ResetProxy(const wptr<IRemoteObject>& remote); 49 std::mutex mutex_; 50 }; 51 } // namespace PowerMgr 52 } // namespace OHOS 53 #endif // MOCK_THERMAL_SERVICE_CLIENT_H 54