提交 30ee3f14 编写于 作者: T toutes

fix animation and battery event

Signed-off-by: Ntoutes <zhaoruiyuan2@huawei.com>
上级 c4bb8408
......@@ -30,6 +30,8 @@ extern "C" {
#define DECIMAL_BASE 10
#define WAIT_MAX_COUNT 10
#define MAX_BUFFER_LEN 256
#define CMDLINE_VALUE_LEN_MAX 512
#define PARAM_CMD_LINE "/proc/cmdline"
#define ARRAY_LENGTH(array) (sizeof((array)) / sizeof((array)[0]))
uid_t DecodeUid(const char *name);
char *ReadFileToBuf(const char *configFile);
......@@ -48,6 +50,7 @@ int ReadFileInDir(const char *dirPath, const char *includeExt,
char **SplitStringExt(char *buffer, const char *del, int *returnCount, int maxItemCount);
void FreeStringVector(char **vector, int count);
int InUpdaterMode(void);
int InChargerMode(void);
int StringReplaceChr(char *strl, char oldChr, char newChr);
#ifdef __cplusplus
......
......@@ -42,6 +42,7 @@ void DumpAllJobs(void);
#define INIT_CONFIGURATION_FILE "/etc/init.without_two_stages.cfg"
#endif
#define OTHER_CFG_PATH "/system/etc/init"
#define OTHER_CHARGE_PATH "/system/etc/charge"
#define MAX_PATH_ARGS_CNT 20
void ReadConfig(void);
......
......@@ -85,7 +85,10 @@ static void ParseAllImports(const cJSON *root)
void ReadConfig(void)
{
// parse cfg
if (InUpdaterMode() == 0) {
if (InChargerMode() == 1) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(OTHER_CHARGE_PATH, ".cfg", ParseInitCfg, NULL);
} else if (InUpdaterMode() == 0) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(OTHER_CFG_PATH, ".cfg", ParseInitCfg, NULL);
} else {
......
......@@ -533,6 +533,7 @@ static int LoadParamFromCmdLine(void)
{
static const char *cmdLines[] = {
OHOS_BOOT"hardware",
OHOS_BOOT"reboot_reason",
#ifdef STARTUP_INIT_TEST
OHOS_BOOT"mem",
OHOS_BOOT"console",
......
......@@ -410,6 +410,21 @@ int InUpdaterMode(void)
}
}
int InChargerMode(void)
{
char *data = ReadFileData(PARAM_CMD_LINE);
char value[CMDLINE_VALUE_LEN_MAX];
int ret = 0;
if ((GetProcCmdlineValue("reboot_reason", data, value, CMDLINE_VALUE_LEN_MAX) == 0) &&
(strcmp(value, "poweroff_charge") == 0)) {
ret = 1;
}
INIT_LOGE("GetProcCmdlineValue():reboot_reason=%s\n", value);
free(data);
return ret;
}
int StringReplaceChr(char *strl, char oldChr, char newChr)
{
INIT_ERROR_CHECK(strl != NULL, return -1, "Invalid parament");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册