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 "reboot_adp.h"
17 #include "init_cmdexecutor.h"
18 #include "init_log.h"
19 #include "init_group_manager.h"
20 #include "init_modulemgr.h"
21
ExecReboot(const char * value)22 void ExecReboot(const char *value)
23 {
24 INIT_LOGI("ExecReboot %s", value);
25 #ifndef STARTUP_INIT_TEST
26 // install module
27 ModuleMgrScan("init/reboot");
28 if (strstr(value, "reboot") != NULL) {
29 PluginExecCmdByName("reboot", value);
30 } else {
31 PluginExecCmdByName(value, value);
32 }
33 #endif
34 return;
35 }
36
clearMisc(void)37 void clearMisc(void)
38 {
39 (void)UpdateMiscMessage(NULL, "reboot", NULL, NULL);
40 }
41
GetBootModeFromMisc(void)42 int GetBootModeFromMisc(void)
43 {
44 char cmd[32] = {0}; // 32 cmd length
45 (void)GetRebootReasonFromMisc(cmd, sizeof(cmd));
46 if (memcmp(cmd, "boot_charge", strlen("boot_charge")) == 0) {
47 return GROUP_CHARGE;
48 }
49 return 0;
50 }