• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "distributed_sched_dumper.h"
17 
18 #include "distributed_sched_service.h"
19 #include "dtbschedmgr_log.h"
20 #include "ipc_skeleton.h"
21 
22 namespace OHOS {
23 namespace DistributedSchedule {
24 namespace {
25 constexpr size_t MIN_ARGS_SIZE = 1;
26 const std::string ARGS_CONNECT_REMOTE_ABILITY = "-connect";
27 const std::string TAG = "DistributedSchedDumper";
28 }
29 
DumpDefault(std::string & result)30 bool DistributedSchedDumper::DumpDefault(std::string& result)
31 {
32     result.append("DistributedSched Dump\n");
33     result.append("\n");
34     ShowConnectRemoteAbility(result);
35     return true;
36 }
37 
Dump(const std::vector<std::string> & args,std::string & result)38 bool DistributedSchedDumper::Dump(const std::vector<std::string>& args, std::string& result)
39 {
40     result.clear();
41     if (args.size() < MIN_ARGS_SIZE) {
42         return DumpDefault(result);
43     }
44 
45     if (args.size() == MIN_ARGS_SIZE) {
46         // -connect
47         if (args[0] == ARGS_CONNECT_REMOTE_ABILITY) {
48             ShowConnectRemoteAbility(result);
49             return true;
50         }
51     }
52     return false;
53 }
54 
55 
ShowConnectRemoteAbility(std::string & result)56 void DistributedSchedDumper::ShowConnectRemoteAbility(std::string& result)
57 {
58     DistributedSchedService::GetInstance().DumpConnectInfo(result);
59 }
60 } // namespace DistributedSchedule
61 } // namespace OHOS