!2785 增加数据恢复模式入口

Merge pull request !2785 from 李怡/master
This commit is contained in:
openharmony_ci 2024-05-08 04:07:13 +00:00 committed by Gitee
commit 1ad2131c68
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 20 additions and 0 deletions

View File

@ -83,6 +83,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 InRescueMode(void);
int StringReplaceChr(char *strl, char oldChr, char newChr);
int OpenConsole(void);

View File

@ -41,6 +41,7 @@ int DoJobNow(const char *jobName);
#define INIT_CONFIGURATION_FILE "/etc/init.cfg"
#define OTHER_CFG_PATH "/system/etc/init"
#define OTHER_CHARGE_PATH "/system/etc/charger"
#define INIT_RESCUE_MODE_PATH "/system/etc/rescue"
#define MAX_PATH_ARGS_CNT 20
void ReadConfig(void);

View File

@ -113,6 +113,9 @@ void ReadConfig(void)
} else if (strcmp(buffer, "charger") == 0) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(OTHER_CHARGE_PATH, ".cfg", ParseInitCfg, NULL);
} else if (InRescueMode() == 0) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(INIT_RESCUE_MODE_PATH, ".cfg", ParseInitCfg, NULL);
} else if (InUpdaterMode() == 0) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ParseInitCfgByPriority();

View File

@ -583,6 +583,21 @@ int InUpdaterMode(void)
#endif
}
// Check if in rescue mode.
int InRescueMode(void)
{
#ifdef OHOS_LITE
return 1;
#else
char value[MAX_BUFFER_LEN] = {0};
int ret = GetParameterFromCmdLine("rescue_mode", value, MAX_BUFFER_LEN);
if (ret == 0 && strcmp(value, "true") == 0) {
return 0;
}
return 1;
#endif
}
int StringReplaceChr(char *strl, char oldChr, char newChr)
{
INIT_ERROR_CHECK(strl != NULL, return -1, "Invalid parament");