• 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 #ifndef FOUNDATION_AAFWK_STANDARD_TOOLS_AA_INCLUDE_ABILITY_COMMAND_H
17 #define FOUNDATION_AAFWK_STANDARD_TOOLS_AA_INCLUDE_ABILITY_COMMAND_H
18 
19 #include "shell_command.h"
20 #include "ability_manager_interface.h"
21 
22 namespace OHOS {
23 namespace AAFwk {
24 namespace {
25 const std::string TOOL_NAME = "aa";
26 
27 const std::string HELP_MSG = "usage: aa <command> <options>\n"
28                              "These are common aa commands list:\n"
29                              "  help                 list available commands\n"
30                              "  start                start ability with options\n"
31                              "  stop-service         stop service with options\n"
32                              "  dump                 dump the ability stack info\n";
33 
34 const std::string HELP_MSG_SCREEN =
35     "usage: aa screen <options>\n"
36     "options list:\n"
37     "  -h, --help                                               list available commands\n"
38     "  -p, --power <state>                                      power on or off with a state name\n";
39 
40 const std::string HELP_MSG_START =
41     "usage: aa start <options>\n"
42     "options list:\n"
43     "  -h, --help                                               list available commands\n"
44     "  [-d <device-id>] -a <ability-name> -b <bundle-name>      start ability with an element name\n";
45 
46 const std::string HELP_MSG_STOP_SERVICE =
47     "usage: aa stop-service <options>\n"
48     "options list:\n"
49     "  -h, --help                                               list available commands\n"
50     "  [-d <device-id>] -a <ability-name> -b <bundle-name>      stop service with an element name\n";
51 
52 const std::string HELP_MSG_DUMP = "usage: aa dump <options>\n"
53                                   "options list:\n"
54                                   "  -h, --help                   list available commands\n"
55                                   "  -a, --all                    dump all abilities\n"
56                                   "  -s, --stack <number>         dump the ability info of a specificed stack\n"
57                                   "  -m, --mission <number>       dump the ability info of a specificed mission\n"
58                                   "  -l, --stack-list             dump the mission list of every stack\n"
59                                   "  -u, --ui                     dump the ability list of system ui stack\n"
60                                   "  -e, --serv                   dump the service abilities\n"
61                                   "  -d, --data                   dump the data abilities\n";
62 
63 const std::string HELP_MSG_NO_ABILITY_NAME_OPTION = "error: -a <ability-name> is expected";
64 const std::string HELP_MSG_NO_BUNDLE_NAME_OPTION = "error: -b <bundle-name> is expected";
65 
66 const std::string STRING_START_ABILITY_OK = "start ability successfully.";
67 const std::string STRING_START_ABILITY_NG = "error: failed to start ability.";
68 
69 const std::string STRING_STOP_SERVICE_ABILITY_OK = "stop service ability successfully.";
70 const std::string STRING_STOP_SERVICE_ABILITY_NG = "error: failed to stop service ability.";
71 
72 const std::string STRING_SCREEN_POWER_ON = "on";
73 
74 const std::string STRING_SCREEN_POWER_ON_OK = "power on screen successfully.";
75 const std::string STRING_SCREEN_POWER_ON_NG = "error: failed to power on screen.";
76 const std::string STRING_SCREEN_POWER_OFF_OK = "power off screen successfully.";
77 const std::string STRING_SCREEN_POWER_OFF_NG = "error: failed to power off screen.";
78 }  // namespace
79 
80 class AbilityManagerShellCommand : public ShellCommand {
81 public:
82     AbilityManagerShellCommand(int argc, char *argv[]);
~AbilityManagerShellCommand()83     ~AbilityManagerShellCommand() override
84     {}
85 
86 private:
87     ErrCode CreateCommandMap() override;
88     ErrCode CreateMessageMap() override;
89     ErrCode init() override;
90 
91     ErrCode RunAsHelpCommand();
92     ErrCode RunAsScreenCommand();
93     ErrCode RunAsStartAbility();
94     ErrCode RunAsStopService();
95     ErrCode RunAsDumpCommand();
96 
97     ErrCode RunAsDumpCommandOptopt();
98     ErrCode MakeWantFromCmd(Want &want, std::string &windowMode);
99 };
100 
101 }  // namespace AAFwk
102 }  // namespace OHOS
103 
104 #endif  // FOUNDATION_AAFWK_STANDARD_TOOLS_AA_INCLUDE_ABILITY_COMMAND_H
105