• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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_INCLUDE_CLIENT_SOCPERF_CLIENT_H
17 #define SOC_PERF_INCLUDE_CLIENT_SOCPERF_CLIENT_H
18 
19 #include <cstdint>             // for int32_t
20 #include <iosfwd>               // for string
21 #include <vector>               // for vector
22 #include "i_socperf_service.h"  // for ISocPerfService
23 
24 namespace OHOS {
25 namespace SOCPERF {
26 class SocPerfClient {
27 public:
28     void PerfRequest(int32_t cmdId, const std::string& msg);
29     void PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg);
30     void PowerLimitBoost(bool onOffTag, const std::string& msg);
31     void ThermalLimitBoost(bool onOffTag, const std::string& msg);
32     void LimitRequest(int32_t clientId,
33         const std::vector<int32_t>& tags, const std::vector<int64_t>& configs, 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         explicit SocPerfDeathRecipient(SocPerfClient &socPerfClient);
49 
50         ~SocPerfDeathRecipient();
51 
52         void OnRemoteDied(const wptr<IRemoteObject> &object) override;
53 
54     private:
55         SocPerfClient &socPerfClient_;
56     };
57 
58 private:
59     std::mutex mutex_;
60     sptr<ISocPerfService> client;
61     sptr<SocPerfDeathRecipient> recipient_;
62 };
63 } // namespace SOCPERF
64 } // namespace OHOS
65 
66 #endif // SOC_PERF_INCLUDE_CLIENT_SOCPERF_CLIENT_H
67