1 /*
2 * Copyright (c) 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 #include "system_ability_manager_dumper.h"
17
18 #include "accesstoken_kit.h"
19 #include "ffrt_inner.h"
20 #include "file_ex.h"
21 #include "ipc_skeleton.h"
22 #include "system_ability_manager.h"
23 #include "if_local_ability_manager.h"
24 #include "ipc_payload_statistics.h"
25 #include "samgr_err_code.h"
26
27 using namespace std;
28 namespace OHOS {
29 namespace {
30 constexpr const char* HIDUMPER_PROCESS_NAME = "hidumper_service";
31 constexpr const char* ARGS_QUERY_SA = "-sa";
32 constexpr const char* ARGS_QUERY_PROCESS = "-p";
33 constexpr const char* ARGS_QUERY_SA_IN_CURRENT_STATE = "-sm";
34 constexpr const char* ARGS_HELP = "-h";
35 constexpr const char* ARGS_QUERY_ALL = "-l";
36 constexpr const char* ARGS_FFRT_SEPARATOR = "|";
37 constexpr size_t MIN_ARGS_SIZE = 1;
38 constexpr size_t MAX_ARGS_SIZE = 2;
39 constexpr int32_t FFRT_DUMP_PROC_LEN = 2;
40 constexpr int32_t FFRT_DUMP_PIDS_INDEX = 1;
41 constexpr int FFRT_BUFFER_SIZE = 512 * 1024;
42 constexpr int LISTENER_BASE_INDEX = 1;
43
44 constexpr const char* IPC_STAT_STR_START = "--start-stat";
45 constexpr const char* IPC_STAT_STR_STOP = "--stop-stat";
46 constexpr const char* IPC_STAT_STR_GET = "--stat";
47 constexpr const char* IPC_STAT_STR_ALL = "all";
48 constexpr const char* IPC_STAT_STR_SAMGR = "samgr";
49 constexpr const char* IPC_DUMP_SUCCESS = " success\n";
50 constexpr const char* IPC_DUMP_FAIL = " fail\n";
51
52 }
53
ShowListenerHelp(string & result)54 void SystemAbilityManagerDumper::ShowListenerHelp(string& result)
55 {
56 result.append("SystemAbilityManager Listener Dump options:\n")
57 .append(" [-h] [cmd]...\n")
58 .append("cmd maybe one of:\n")
59 .append(" -sa [said]: query sa listener infos.\n")
60 .append(" -p [pid]: query process listener infos.\n")
61 .append(" -l [-sa | -p]: query all sa listener infos by [sa | process].\n");
62 }
63
ListenerDumpProc(map<int32_t,list<SAListener>> & listeners,int32_t fd,const vector<string> & args)64 int32_t SystemAbilityManagerDumper::ListenerDumpProc(map<int32_t, list<SAListener>>& listeners,
65 int32_t fd, const vector<string>& args)
66 {
67 if (!CanDump()) {
68 HILOGE("Dump failed, not allowed");
69 return ERR_PERMISSION_DENIED;
70 }
71 string result;
72 GetListenerDumpProc(listeners, args, result);
73 return SaveDumpResultToFd(fd, result);
74 }
75
GetListenerDumpProc(map<int32_t,list<SAListener>> & listeners,const vector<string> & args,string & result)76 void SystemAbilityManagerDumper::GetListenerDumpProc(map<int32_t, list<SAListener>>& listeners,
77 const vector<string>& args, string& result)
78 {
79 if (args.size() == MIN_ARGS_SIZE + 1) {
80 // -h
81 if (args[LISTENER_BASE_INDEX] == ARGS_HELP) {
82 ShowListenerHelp(result);
83 return;
84 }
85 } else if (args.size() == MAX_ARGS_SIZE + 1) {
86 // -l
87 if (args[LISTENER_BASE_INDEX] == ARGS_QUERY_ALL) {
88 // -sa
89 if (args[LISTENER_BASE_INDEX + 1] == ARGS_QUERY_SA) {
90 ShowAllBySA(listeners, result);
91 return;
92 }
93 // -p
94 if (args[LISTENER_BASE_INDEX + 1] == ARGS_QUERY_PROCESS) {
95 ShowAllByCallingPid(listeners, result);
96 return;
97 }
98 }
99 // -sa said
100 if (args[LISTENER_BASE_INDEX] == ARGS_QUERY_SA) {
101 int said = atoi(args[LISTENER_BASE_INDEX + 1].c_str());
102 ShowCallingPidBySA(listeners, said, result);
103 return;
104 }
105 // -p pid
106 if (args[LISTENER_BASE_INDEX] == ARGS_QUERY_PROCESS) {
107 int callingPid = atoi(args[LISTENER_BASE_INDEX + 1].c_str());
108 ShowSAByCallingPid(listeners, callingPid, result);
109 return;
110 }
111 }
112 IllegalInput(result);
113 }
114
ShowAllBySA(map<int32_t,list<SAListener>> & listeners,string & result)115 void SystemAbilityManagerDumper::ShowAllBySA(map<int32_t, list<SAListener>>& listeners,
116 string& result)
117 {
118 result += "********************************ShowAllBySA********************************";
119 set<sptr<IRemoteObject>> listenerSet;
120 for (auto iter : listeners) {
121 if (iter.second.size() == 0) {
122 continue;
123 }
124 result += "\n\n--------------------------------SA:";
125 result += to_string(iter.first);
126 result += ", SubCnt:";
127 result += to_string(iter.second.size());
128 result += "--------------------------------";
129 map<int32_t, int32_t> pidCnt;
130 for (auto saListener : iter.second) {
131 pidCnt[saListener.callingPid]++;
132 listenerSet.insert(saListener.listener->AsObject());
133 }
134 for (auto iter : pidCnt) {
135 result += "\ncallingPid:";
136 result += to_string(iter.first);
137 result += ", cnt:";
138 result += to_string(iter.second);
139 }
140 }
141 result += "\n--------------------------------TotalListenerCnt:";
142 result += to_string(listenerSet.size());
143 result += "--------------------------------";
144 result += "\n***************************************************************************\n";
145 }
146
ShowAllByCallingPid(map<int32_t,list<SAListener>> & listeners,string & result)147 void SystemAbilityManagerDumper::ShowAllByCallingPid(map<int32_t, list<SAListener>>& listeners,
148 string& result)
149 {
150 result += "********************************ShowAllByCallingPid********************************";
151 map<int32_t, list<pair<int32_t, sptr<ISystemAbilityStatusChange>>>> subscribeMap;
152 map<int32_t, set<sptr<IRemoteObject>>> pidListenerMap;
153 size_t totalSum = 0;
154 for (auto iter : listeners) {
155 int32_t said = iter.first;
156 for (auto saListener : iter.second) {
157 subscribeMap[saListener.callingPid].push_back({said, saListener.listener});
158 pidListenerMap[saListener.callingPid].insert(saListener.listener->AsObject());
159 }
160 }
161 vector<pair<int32_t, set<sptr<IRemoteObject>>>> vec(pidListenerMap.begin(), pidListenerMap.end());
162 auto cmp = [](const pair<int32_t, set<sptr<IRemoteObject>>>& p1,
163 const pair<int32_t, set<sptr<IRemoteObject>>>& p2) {
164 return p1.second.size() > p2.second.size();
165 };
166 sort(vec.begin(), vec.end(), cmp);
167 for (auto iter : vec) {
168 result += "\n\n--------------------------------CallingPid:";
169 result += to_string(iter.first);
170 result += ", ListenerCnt:";
171 result += to_string(iter.second.size());
172 result += "--------------------------------";
173 totalSum += iter.second.size();
174 map<int32_t, int32_t> saCnt;
175 for (auto p : subscribeMap[iter.first]) {
176 saCnt[p.first]++;
177 }
178 for (auto iter : saCnt) {
179 result += "\nSA:";
180 result += to_string(iter.first);
181 result += ", cnt:";
182 result += to_string(iter.second);
183 }
184 }
185 result += "\n--------------------------------TotalListenerCnt:";
186 result += to_string(totalSum);
187 result += "--------------------------------";
188 result += "\n***********************************************************************************\n";
189 }
190
ShowCallingPidBySA(map<int32_t,list<SAListener>> & listeners,int32_t said,string & result)191 void SystemAbilityManagerDumper::ShowCallingPidBySA(map<int32_t, list<SAListener>>& listeners,
192 int32_t said, string& result)
193 {
194 result += "********************************ShowCallingPidBySA********************************";
195 result += "\n--------------------------------SA:";
196 result += to_string(said);
197 result += "--------------------------------";
198 map<int32_t, int32_t> pidCnt;
199 for (auto iter : listeners) {
200 if (iter.first == said) {
201 for (auto saListener : iter.second) {
202 pidCnt[saListener.callingPid]++;
203 }
204 break;
205 }
206 }
207 int32_t totalSum = 0;
208 for (auto iter : pidCnt) {
209 result += "\ncallingPid:";
210 result += to_string(iter.first);
211 result += ", cnt:";
212 result += to_string(iter.second);
213 totalSum += iter.second;
214 }
215 result += "\n--------------------------------TotalSubCnt:";
216 result += to_string(totalSum);
217 result += "--------------------------------";
218 result += "\n**********************************************************************************\n";
219 }
220
ShowSAByCallingPid(map<int32_t,list<SAListener>> & listeners,int32_t callingPid,string & result)221 void SystemAbilityManagerDumper::ShowSAByCallingPid(map<int32_t, list<SAListener>>& listeners,
222 int32_t callingPid, string& result)
223 {
224 result += "********************************ShowSAByCallingPid********************************";
225 result += "\n--------------------------------CallingPid:";
226 result += to_string(callingPid);
227 result += "--------------------------------";
228 map<int32_t, int32_t> saCnt;
229 set<sptr<IRemoteObject>> listenerSet;
230 for (auto iter : listeners) {
231 int32_t said = iter.first;
232 for (auto saListener : iter.second) {
233 if (saListener.callingPid == callingPid) {
234 saCnt[said]++;
235 listenerSet.insert(saListener.listener->AsObject());
236 }
237 }
238 }
239 for (auto iter : saCnt) {
240 result += "\nSA:";
241 result += to_string(iter.first);
242 result += ", cnt:";
243 result += to_string(iter.second);
244 }
245 result += "\n--------------------------------ListenerCnt:";
246 result += to_string(listenerSet.size());
247 result += "--------------------------------";
248 result += "\n**********************************************************************************\n";
249 }
250
FfrtDumpProc(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,int32_t fd,const std::vector<std::string> & args)251 int32_t SystemAbilityManagerDumper::FfrtDumpProc(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,
252 int32_t fd, const std::vector<std::string>& args)
253 {
254 if (!CanDump()) {
255 HILOGE("Dump failed, not allowed");
256 return ERR_PERMISSION_DENIED;
257 }
258 std::string result;
259 GetFfrtDumpInfoProc(abilityStateScheduler, args, result);
260 return SaveDumpResultToFd(fd, result);
261 }
262
GetFfrtDumpInfoProc(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,const std::vector<std::string> & args,std::string & result)263 bool SystemAbilityManagerDumper::GetFfrtDumpInfoProc(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,
264 const std::vector<std::string>& args, std::string& result)
265 {
266 if (args.size() < FFRT_DUMP_PROC_LEN || args[FFRT_DUMP_PIDS_INDEX].empty()) {
267 HILOGE("FfrtDump param pid not exist");
268 IllegalInput(result);
269 return false;
270 }
271 std::string pidStr = args[FFRT_DUMP_PIDS_INDEX];
272 std::vector<int32_t> processIds;
273 SystemAbilityManagerDumper::FfrtDumpParser(processIds, pidStr);
274 if (processIds.empty()) {
275 HILOGE("FfrtDumpParser parse failed, illegal input processIdsStr %{public}s ", pidStr.c_str());
276 IllegalInput(result);
277 return false;
278 }
279 HILOGD("FfrtDumpProc: processIdsSize=%{public}zu", processIds.size());
280 for (const int32_t pid : processIds) {
281 if (pid == getpid()) {
282 GetSAMgrFfrtInfo(result);
283 continue;
284 }
285 std::u16string processName;
286 int32_t queryResult = abilityStateScheduler->GetProcessNameByProcessId(pid, processName);
287 if (queryResult != ERR_OK) {
288 HILOGE("GetProcessNameByProcessId failed, pid %{public}d not exist", pid);
289 result.append("process " + std::to_string(pid) + " not found!\n");
290 continue;
291 }
292 DumpFfrtInfoByProcName(pid, processName, result);
293 }
294 return true;
295 }
296
FfrtDumpParser(std::vector<int32_t> & processIds,const std::string & processIdsStr)297 bool SystemAbilityManagerDumper::FfrtDumpParser(std::vector<int32_t>& processIds, const std::string& processIdsStr)
298 {
299 std::string processIdsVecStr = processIdsStr + ARGS_FFRT_SEPARATOR;
300 std::size_t pos = processIdsVecStr.find(ARGS_FFRT_SEPARATOR);
301 while (pos != std::string::npos) {
302 std::string processIdStr = processIdsVecStr.substr(0, pos);
303 processIdsVecStr = processIdsVecStr.substr(pos + 1, processIdsVecStr.size() - pos - 1);
304 pos = processIdsVecStr.find(ARGS_FFRT_SEPARATOR);
305 int32_t processId = -1;
306 if (!StrToInt(processIdStr, processId)) {
307 HILOGE("StrToInt processIdStr %{public}s error", processIdStr.c_str());
308 continue;
309 }
310 if (processId > 0) {
311 processIds.emplace_back(processId);
312 }
313 }
314 return true;
315 }
316
GetSAMgrFfrtInfo(std::string & result)317 void SystemAbilityManagerDumper::GetSAMgrFfrtInfo(std::string& result)
318 {
319 char* buffer = new char[FFRT_BUFFER_SIZE + 1]();
320 buffer[FFRT_BUFFER_SIZE] = 0;
321 ffrt_dump(ffrt_dump_cmd_t::DUMP_INFO_ALL, buffer, FFRT_BUFFER_SIZE);
322 if (strlen(buffer) == 0) {
323 HILOGE("get samgr FfrtDumperInfo failed");
324 delete[] buffer;
325 return;
326 }
327 std::string ffrtDumpInfoStr(buffer);
328 result.append(ffrtDumpInfoStr + "\n");
329 delete[] buffer;
330 }
331
DumpFfrtInfoByProcName(int32_t pid,const std::u16string processName,std::string & result)332 void SystemAbilityManagerDumper::DumpFfrtInfoByProcName(int32_t pid, const std::u16string processName,
333 std::string& result)
334 {
335 sptr<ILocalAbilityManager> obj =
336 iface_cast<ILocalAbilityManager>(SystemAbilityManager::GetInstance()->GetSystemProcess(processName));
337 if (obj == nullptr) {
338 HILOGE("GetSystemProcess failed, pid:%{public}d processName:%{public}s not exist",
339 pid, Str16ToStr8(processName).c_str());
340 result.append("process " + std::to_string(pid) + " not found!\n");
341 return;
342 }
343 std::string resultForProcess;
344 if (!obj->FfrtDumperProc(resultForProcess)) {
345 HILOGE("safwk FfrtDumperProc execute failed");
346 return;
347 }
348 result.append(resultForProcess + "\n");
349 }
350
SaveDumpResultToFd(int32_t fd,const std::string & result)351 int32_t SystemAbilityManagerDumper::SaveDumpResultToFd(int32_t fd, const std::string& result)
352 {
353 if (!SaveStringToFd(fd, result)) {
354 HILOGE("save to fd failed");
355 return SAVE_FD_FAIL;
356 }
357 HILOGD("save to fd success");
358 return ERR_OK;
359 }
360
StartSamgrIpcStatistics(std::string & result)361 bool SystemAbilityManagerDumper::StartSamgrIpcStatistics(std::string& result)
362 {
363 result = std::string("StartIpcStatistics pid:") + std::to_string(getpid());
364 bool ret = IPCPayloadStatistics::StartStatistics();
365 result += ret ? IPC_DUMP_SUCCESS : IPC_DUMP_FAIL;
366 return ret;
367 }
368
StopSamgrIpcStatistics(std::string & result)369 bool SystemAbilityManagerDumper::StopSamgrIpcStatistics(std::string& result)
370 {
371 result = std::string("StopSamgrIpcStatistics pid:") + std::to_string(getpid());
372 bool ret = IPCPayloadStatistics::StopStatistics();
373 result += ret ? IPC_DUMP_SUCCESS : IPC_DUMP_FAIL;
374 return ret;
375 }
376
GetSamgrIpcStatistics(std::string & result)377 bool SystemAbilityManagerDumper::GetSamgrIpcStatistics(std::string& result)
378 {
379 result += "********************************GlobalStatisticsInfo********************************";
380 result += "\nCurrentPid:";
381 result += std::to_string(getpid());
382 result += "\nTotalCount:";
383 result += std::to_string(IPCPayloadStatistics::GetTotalCount());
384 result += "\nTotalTimeCost:";
385 result += std::to_string(IPCPayloadStatistics::GetTotalCost());
386 std::vector<int32_t> pids;
387 pids = IPCPayloadStatistics::GetPids();
388 for (unsigned int i = 0; i < pids.size(); i++) {
389 result += "\n--------------------------------ProcessStatisticsInfo-------------------------------";
390 result += "\nCallingPid:";
391 result += std::to_string(pids[i]);
392 result += "\nCallingPidTotalCount:";
393 result += std::to_string(IPCPayloadStatistics::GetCount(pids[i]));
394 result += "\nCallingPidTotalTimeCost:";
395 result += std::to_string(IPCPayloadStatistics::GetCost(pids[i]));
396 std::vector<IPCInterfaceInfo> intfs;
397 intfs = IPCPayloadStatistics::GetDescriptorCodes(pids[i]);
398 for (unsigned int j = 0; j < intfs.size(); j++) {
399 result += "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~InterfaceStatisticsInfo~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
400 result += "\nDescriptorCode:";
401 result += Str16ToStr8(intfs[j].desc) + std::string("_") + std::to_string(intfs[j].code);
402 result += "\nDescriptorCodeCount:";
403 result += std::to_string(
404 IPCPayloadStatistics::GetDescriptorCodeCount(pids[i], intfs[j].desc, intfs[j].code));
405 result += "\nDescriptorCodeTimeCost:";
406 result += "\nTotal:";
407 result += std::to_string(
408 IPCPayloadStatistics::GetDescriptorCodeCost(pids[i], intfs[j].desc, intfs[j].code).totalCost);
409 result += " | Max:";
410 result += std::to_string(
411 IPCPayloadStatistics::GetDescriptorCodeCost(pids[i], intfs[j].desc, intfs[j].code).maxCost);
412 result += " | Min:";
413 result += std::to_string(
414 IPCPayloadStatistics::GetDescriptorCodeCost(pids[i], intfs[j].desc, intfs[j].code).minCost);
415 result += " | Avg:";
416 result += std::to_string(
417 IPCPayloadStatistics::GetDescriptorCodeCost(pids[i], intfs[j].desc, intfs[j].code).averCost);
418 result += "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
419 }
420 result += "\n------------------------------------------------------------------------------------";
421 }
422 result += "\n************************************************************************************\n";
423 return true;
424 }
425
IpcDumpIsAllProcess(const std::string & processName)426 bool SystemAbilityManagerDumper::IpcDumpIsAllProcess(const std::string& processName)
427 {
428 return processName == IPC_STAT_STR_ALL;
429 }
430
IpcDumpIsSamgr(const std::string & processName)431 bool SystemAbilityManagerDumper::IpcDumpIsSamgr(const std::string& processName)
432 {
433 return processName == IPC_STAT_STR_SAMGR;
434 }
435
IpcDumpCmdParser(int32_t & cmd,const std::vector<std::string> & args)436 bool SystemAbilityManagerDumper::IpcDumpCmdParser(int32_t& cmd, const std::vector<std::string>& args)
437 {
438 if (!CanDump()) {
439 HILOGE("IPC Dump failed, not allowed");
440 return false;
441 }
442
443 if (args.size() < IPC_STAT_CMD_LEN) {
444 HILOGE("IPC Dump failed, length error");
445 return false;
446 }
447
448 if (args[IPC_STAT_CMD_INDEX] == IPC_STAT_STR_START) {
449 cmd = IPC_STAT_CMD_START;
450 } else if (args[IPC_STAT_CMD_INDEX] == IPC_STAT_STR_STOP) {
451 cmd = IPC_STAT_CMD_STOP;
452 } else if (args[IPC_STAT_CMD_INDEX] == IPC_STAT_STR_GET) {
453 cmd = IPC_STAT_CMD_GET;
454 } else {
455 return false;
456 }
457 return true;
458 }
459
Dump(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,const std::vector<std::string> & args,std::string & result)460 bool SystemAbilityManagerDumper::Dump(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,
461 const std::vector<std::string>& args, std::string& result)
462 {
463 if (!CanDump()) {
464 HILOGE("Dump failed, not allowed");
465 return false;
466 }
467 if (args.size() == MIN_ARGS_SIZE) {
468 // -l
469 if (args[0] == ARGS_QUERY_ALL) {
470 ShowAllSystemAbilityInfo(abilityStateScheduler, result);
471 return true;
472 }
473 // -h
474 if (args[0] == ARGS_HELP) {
475 ShowHelp(result);
476 return true;
477 }
478 }
479 if (args.size() == MAX_ARGS_SIZE) {
480 // -sa said
481 if (args[0] == ARGS_QUERY_SA) {
482 int said = atoi(args[1].c_str());
483 ShowSystemAbilityInfo(said, abilityStateScheduler, result);
484 return true;
485 }
486 // -p processname
487 if (args[0] == ARGS_QUERY_PROCESS) {
488 ShowProcessInfo(args[1], abilityStateScheduler, result);
489 return true;
490 }
491 // -sm state
492 if (args[0] == ARGS_QUERY_SA_IN_CURRENT_STATE) {
493 ShowAllSystemAbilityInfoInState(args[1], abilityStateScheduler, result);
494 return true;
495 }
496 }
497 IllegalInput(result);
498 return false;
499 }
500
CanDump()501 bool SystemAbilityManagerDumper::CanDump()
502 {
503 uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
504 Security::AccessToken::NativeTokenInfo nativeTokenInfo;
505 int32_t result = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo);
506 if (result == ERR_OK && nativeTokenInfo.processName == HIDUMPER_PROCESS_NAME) {
507 return true;
508 }
509 return false;
510 }
511
ShowHelp(std::string & result)512 void SystemAbilityManagerDumper::ShowHelp(std::string& result)
513 {
514 result.append("SystemAbilityManager Dump options:\n")
515 .append(" [-h] [cmd]...\n")
516 .append("cmd maybe one of:\n")
517 .append(" -sa said: query sa state infos.\n")
518 .append(" -p processname: query process state infos.\n")
519 .append(" -sm state: query all sa based on state infos.\n")
520 .append(" -l: query all sa state infos.\n");
521 }
522
ShowAllSystemAbilityInfo(std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,std::string & result)523 void SystemAbilityManagerDumper::ShowAllSystemAbilityInfo(
524 std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler, std::string& result)
525 {
526 if (abilityStateScheduler == nullptr) {
527 HILOGE("abilityStateScheduler is nullptr");
528 return;
529 }
530 abilityStateScheduler->GetAllSystemAbilityInfo(result);
531 }
532
ShowSystemAbilityInfo(int32_t said,std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,std::string & result)533 void SystemAbilityManagerDumper::ShowSystemAbilityInfo(int32_t said,
534 std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler, std::string& result)
535 {
536 if (abilityStateScheduler == nullptr) {
537 HILOGE("abilityStateScheduler is nullptr");
538 return;
539 }
540 abilityStateScheduler->GetSystemAbilityInfo(said, result);
541 }
542
ShowProcessInfo(const std::string & processName,std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,std::string & result)543 void SystemAbilityManagerDumper::ShowProcessInfo(const std::string& processName,
544 std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler, std::string& result)
545 {
546 if (abilityStateScheduler == nullptr) {
547 HILOGE("abilityStateScheduler is nullptr");
548 return;
549 }
550 abilityStateScheduler->GetProcessInfo(processName, result);
551 }
552
ShowAllSystemAbilityInfoInState(const std::string & state,std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler,std::string & result)553 void SystemAbilityManagerDumper::ShowAllSystemAbilityInfoInState(const std::string& state,
554 std::shared_ptr<SystemAbilityStateScheduler> abilityStateScheduler, std::string& result)
555 {
556 if (abilityStateScheduler == nullptr) {
557 HILOGE("abilityStateScheduler is nullptr");
558 return;
559 }
560 abilityStateScheduler->GetAllSystemAbilityInfoByState(state, result);
561 }
562
IllegalInput(std::string & result)563 void SystemAbilityManagerDumper::IllegalInput(std::string& result)
564 {
565 result.append("The arguments are illegal and you can enter '-h' for help.\n");
566 }
567 } // namespace OHOS