• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "socperf_client.h"
17 
18 const int PARAMETERS_NUM_MIN        = 2;
19 const int PARAMETERS_NUM_WITHOUT_EX = 3;
20 const int PARAMETERS_NUM_WITH_EX    = 4;
21 
PerfRequest(int argc,char * argv[])22 static void PerfRequest(int argc, char *argv[])
23 {
24     if (argc == PARAMETERS_NUM_WITHOUT_EX) {
25         char* cmdId = argv[2];
26         if (cmdId) {
27             OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(atoi(cmdId), "");
28         }
29     }
30 }
31 
PerfRequestEx(int argc,char * argv[])32 static void PerfRequestEx(int argc, char *argv[])
33 {
34     if (argc == PARAMETERS_NUM_WITH_EX) {
35         char* cmdId = argv[2];
36         char* onOffTag = argv[3];
37         if (cmdId && onOffTag) {
38             if (strcmp(onOffTag, "true") == 0) {
39                 OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(atoi(cmdId), true, "");
40             } else if (strcmp(onOffTag, "false") == 0) {
41                 OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(atoi(cmdId), false, "");
42             }
43         }
44     }
45 }
46 
PowerRequest(int argc,char * argv[])47 static void PowerRequest(int argc, char *argv[])
48 {
49     if (argc == PARAMETERS_NUM_WITHOUT_EX) {
50         char* cmdId = argv[2];
51         if (cmdId) {
52             OHOS::SOCPERF::SocPerfClient::GetInstance().PowerRequest(atoi(cmdId), "");
53         }
54     }
55 }
56 
PowerRequestEx(int argc,char * argv[])57 static void PowerRequestEx(int argc, char *argv[])
58 {
59     if (argc == PARAMETERS_NUM_WITH_EX) {
60         char* cmdId = argv[2];
61         char* onOffTag = argv[3];
62         if (cmdId && onOffTag) {
63             if (strcmp(onOffTag, "true") == 0) {
64                 OHOS::SOCPERF::SocPerfClient::GetInstance().PowerRequestEx(atoi(cmdId), true, "");
65             } else if (strcmp(onOffTag, "false") == 0) {
66                 OHOS::SOCPERF::SocPerfClient::GetInstance().PowerRequestEx(atoi(cmdId), false, "");
67             }
68         }
69     }
70 }
71 
PowerLimitBoost(int argc,char * argv[])72 static void PowerLimitBoost(int argc, char *argv[])
73 {
74     if (argc == PARAMETERS_NUM_WITHOUT_EX) {
75         char* onOffTag = argv[2];
76         if (onOffTag) {
77             if (strcmp(onOffTag, "true") == 0) {
78                 OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(true, "");
79             } else if (strcmp(onOffTag, "false") == 0) {
80                 OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(false, "");
81             }
82         }
83     }
84 }
85 
ThermalRequest(int argc,char * argv[])86 static void ThermalRequest(int argc, char *argv[])
87 {
88     if (argc == PARAMETERS_NUM_WITHOUT_EX) {
89         char* cmdId = argv[2];
90         if (cmdId) {
91             OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalRequest(atoi(cmdId), "");
92         }
93     }
94 }
95 
ThermalRequestEx(int argc,char * argv[])96 static void ThermalRequestEx(int argc, char *argv[])
97 {
98     if (argc == PARAMETERS_NUM_WITH_EX) {
99         char* cmdId = argv[2];
100         char* onOffTag = argv[3];
101         if (cmdId && onOffTag) {
102             if (strcmp(onOffTag, "true") == 0) {
103                 OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalRequestEx(atoi(cmdId), true, "");
104             } else if (strcmp(onOffTag, "false") == 0) {
105                 OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalRequestEx(atoi(cmdId), false, "");
106             }
107         }
108     }
109 }
110 
ThermalLimitBoost(int argc,char * argv[])111 static void ThermalLimitBoost(int argc, char *argv[])
112 {
113     if (argc == PARAMETERS_NUM_WITHOUT_EX) {
114         char* onOffTag = argv[2];
115         if (onOffTag) {
116             if (strcmp(onOffTag, "true") == 0) {
117                 OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(true, "");
118             } else if (strcmp(onOffTag, "false") == 0) {
119                 OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(false, "");
120             }
121         }
122     }
123 }
124 
main(int argc,char * argv[])125 int main(int argc, char *argv[])
126 {
127     if (argc >= PARAMETERS_NUM_MIN && argv) {
128         char* function = argv[1];
129         if (strcmp(function, "PerfRequest") == 0) {
130             PerfRequest(argc, argv);
131         } else if (strcmp(function, "PerfRequestEx") == 0) {
132             PerfRequestEx(argc, argv);
133         } else if (strcmp(function, "PowerRequest") == 0) {
134             PowerRequest(argc, argv);
135         } else if (strcmp(function, "PowerRequestEx") == 0) {
136             PowerRequestEx(argc, argv);
137         } else if (strcmp(function, "PowerLimitBoost") == 0) {
138             PowerLimitBoost(argc, argv);
139         } else if (strcmp(function, "ThermalRequest") == 0) {
140             ThermalRequest(argc, argv);
141         } else if (strcmp(function, "ThermalRequestEx") == 0) {
142             ThermalRequestEx(argc, argv);
143         } else if (strcmp(function, "ThermalLimitBoost") == 0) {
144             ThermalLimitBoost(argc, argv);
145         }
146     }
147     return 0;
148 }