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 SOC_PERF_CLIENT_H 17 #define SOC_PERF_CLIENT_H 18 19 #include "i_socperf_service.h" 20 #include "unistd.h" 21 22 namespace OHOS { 23 namespace SOCPERF { 24 class SocPerfClient { 25 public: 26 void PerfRequest(int cmdId, const std::string& msg); 27 void PerfRequestEx(int cmdId, bool onOffTag, const std::string& msg); 28 void PowerRequest(int cmdId, const std::string& msg); 29 void PowerRequestEx(int cmdId, bool onOffTag, const std::string& msg); 30 void PowerLimitBoost(bool onOffTag, const std::string& msg); 31 void ThermalRequest(int cmdId, const std::string& msg); 32 void ThermalRequestEx(int cmdId, bool onOffTag, const std::string& msg); 33 void ThermalLimitBoost(bool onOffTag, const std::string& msg); 34 static SocPerfClient& GetInstance(); 35 void ResetClient(); 36 37 private: SocPerfClient()38 SocPerfClient() {} ~SocPerfClient()39 ~SocPerfClient() {}; 40 41 private: 42 bool CheckClientValid(); 43 std::string AddPidAndTidInfo(const std::string& msg); 44 45 private: 46 class SocPerfDeathRecipient : public IRemoteObject::DeathRecipient { 47 public: 48 SocPerfDeathRecipient(SocPerfClient &socPerfClient); 49 50 ~SocPerfDeathRecipient(); 51 52 virtual void OnRemoteDied(const wptr<IRemoteObject> &object) override; 53 54 private: 55 SocPerfClient &socPerfClient_; 56 }; 57 58 private: 59 sptr<ISocPerfService> client; 60 sptr<SocPerfDeathRecipient> recipient_; 61 }; 62 } // namespace SOCPERF 63 } // namespace OHOS 64 65 #endif // SOC_PERF_CLIENT_H