1
2 /*
3 * Copyright (c) 2022 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "init_hook.h"
18 #include "init_utils.h"
19 #include "plugin_adapter.h"
20 #include "securec.h"
21
22 /**
23 系统参数转化规则
24 1,ohos.ctl.start.{start|stop} = servicename
25 转化后系统参数,用来进行dac/mac校验
26 ohos.servicectrl.{servicename}
27 对应的处理命令
28 start
29 2,ohos.startup.powerctrl = reboot,[bootcharge | shutdown | flashd | updater]
30 转化后系统参数,用来进行dac/mac校验
31 ohos.servicectrl.reboot.[bootcharge | shutdown | flashd | updater]
32 对应的处理命令
33 reboot.[bootcharge | shutdown | flashd | updater]
34 3,ohos.servicectrl.{cmdName} = {arg}
35 转化后系统参数,用来进行dac/mac校验
36 ohos.servicectrl.{cmd}
37 对应的处理命令
38 cmd
39 4,普通系统参数,根据定义的ParamCmdInfo进行处理
40 {xxxx.xxxx.xxxx, xxxx.xxxx.xxxx, cmdname}
41 例如:
42 xxxx.xxxx.xxxx = {args}
43 转化后系统参数,用来进行dac/mac校验
44 xxxx.xxxx.xxxx.{args}
45 对应的处理命令
46 cmdname
47 命令输入参数(跳过replace部分的剩余值)
48 xxxx.xxxx.xxxx.{args} + strlen(name)
49 */
50
GetServiceStartCtrl(size_t * size)51 const ParamCmdInfo *GetServiceStartCtrl(size_t *size)
52 {
53 static const ParamCmdInfo ctrlParam[] = {
54 {"ohos.ctl.start", "start", "start "},
55 {"ohos.ctl.stop", "stop", "stop "},
56 };
57 *size = ARRAY_LENGTH(ctrlParam);
58 return ctrlParam;
59 }
60
GetServiceCtl(size_t * size)61 const ParamCmdInfo *GetServiceCtl(size_t *size)
62 {
63 static const ParamCmdInfo installParam[] = {
64 {"ohos.servicectrl.install", "install", "install" },
65 {"ohos.servicectrl.uninstall", "uninstall", "uninstall" },
66 {"ohos.servicectrl.clear", "clear", "clear" },
67 {"ohos.servicectrl.bootchart", "bootchart", "bootchart" },
68 {"ohos.servicectrl.init_trace", "init_trace", "init_trace" },
69 {"ohos.servicectrl.timer_start", "timer_start", "timer_start " },
70 {"ohos.servicectrl.timer_stop", "timer_stop", "timer_stop" },
71 {"ohos.servicectrl.cmd", "cmd", "initcmd"},
72 };
73 *size = ARRAY_LENGTH(installParam);
74 return installParam;
75 }
76
77 #ifdef OHOS_LITE
GetStartupPowerCtl(size_t * size)78 const ParamCmdInfo *GetStartupPowerCtl(size_t *size)
79 {
80 static const ParamCmdInfo powerCtrlArg[] = {
81 {"reboot,shutdown", "reboot.shutdown", "reboot.shutdown"},
82 {"reboot,updater", "reboot.updater", "reboot.updater"},
83 {"reboot,flashd", "reboot.flashd", "reboot.flashd"},
84 {"reboot,charge", "reboot.charge", "reboot.charge"},
85 {"reboot", "reboot", "reboot"},
86 };
87 *size = ARRAY_LENGTH(powerCtrlArg);
88 return powerCtrlArg;
89 }
90 #endif
91
GetOtherSpecial(size_t * size)92 const ParamCmdInfo *GetOtherSpecial(size_t *size)
93 {
94 static const ParamCmdInfo other[] = {
95 {"bootevent.", "bootevent.", "bootevent"},
96 {"persist.init.debug.", "persist.init.debug.", "setloglevel"},
97 // for hitrace start, need interrupt init trace
98 {"debug.hitrace.enable.state", "debug.hitrace.enable.state.", "init_trace"},
99 };
100 *size = ARRAY_LENGTH(other);
101 return other;
102 }
103