!701 合并bootcharge的处理

Merge pull request !701 from Mupceet/bootcharge
This commit is contained in:
openharmony_ci 2022-05-28 00:54:36 +00:00 committed by Gitee
commit 5695fe51d7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 16 additions and 58 deletions

View File

@ -11,10 +11,9 @@
"services": [
"ueventd",
"console",
"watchdog_service",
"hdf_devmgr",
"samgr",
"param_watcher"
"hdcd",
"charger",
"misc"
],
"groups": [
]

View File

@ -1,21 +0,0 @@
{
"jobs": [
"param:sys.usb.config=hdc && param:sys.usb.configfs=1",
"param:sys.usb.ffs.ready=1 && param:sys.usb.config=hdc && param:sys.usb.configfs=1",
"boot && param:persist.sys.usb.config=*",
"param:sys.usb.config=none && param:sys.usb.configfs=0",
"boot && param:const.debuggable=1",
"param:sys.usb.config=none && param:sys.usb.configfs=1",
"load_persist_props_action"
],
"services": [
"ueventd",
"console",
"watchdog_service",
"hdf_devmgr",
"samgr",
"param_watcher"
],
"groups": [
]
}

View File

@ -66,7 +66,6 @@ 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);
int GetMapValue(const char *name, const InitArgInfo *infos, int argNum, int defValue);

View File

@ -299,24 +299,18 @@ int CheckNodeValid(int type, const char *name)
if (type >= NODE_TYPE_GROUPS) {
return -1;
}
#ifndef INIT_TEST
if (g_initWorkspace.groupMode == GROUP_BOOT) {
return 0;
}
HashNode *node = HashMapGet(g_initWorkspace.hashMap[type], name);
if (node != NULL) {
return 0;
}
#else
HashNode *node = HashMapGet(g_initWorkspace.hashMap[type], name);
if (node != NULL) {
INIT_LOGI("Found %s in %s group", name, type == NODE_TYPE_JOBS ? "job" : "service");
return 0;
}
if (g_initWorkspace.groupMode == GROUP_BOOT) {
// for boot start, can not start charger service
if (strcmp(name, "charger") == 0) {
return -1;
}
return 0;
}
#endif
return -1;
}

View File

@ -20,6 +20,7 @@
#include <stdarg.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>
#include "securec.h"
#ifdef OHOS_LITE
@ -45,17 +46,18 @@ void SetInitLogLevel(InitLogLevel logLevel)
#ifdef INIT_FILE
static void LogToFile(const char *logFile, const char *tag, const char *info)
{
time_t second = time(0);
if (second <= 0) {
struct timespec curr;
if (clock_gettime(CLOCK_REALTIME, &curr) != 0) {
return;
}
struct tm *t = localtime(&second);
FILE *outfile = fopen(logFile, "a+");
if (t == NULL || outfile == NULL) {
if (outfile == NULL) {
return;
}
(void)fprintf(outfile, "[%d-%d-%d %d:%d:%d][pid=%d][%s]%s \n",
(t->tm_year + BASE_YEAR), (t->tm_mon + 1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, getpid(), tag, info);
struct tm t;
char dateTime[80]; // 80 data time
strftime(dateTime, sizeof(dateTime), "%Y-%m-%d %H:%M:%S", localtime_r(&curr.tv_sec, &t));
(void)fprintf(outfile, "[%s.%ld][pid=%d %d][%s]%s \n", dateTime, curr.tv_nsec, getpid(), gettid(), tag, info);
(void)fflush(outfile);
fclose(outfile);
return;
@ -116,6 +118,7 @@ void InitLog(InitLogLevel logLevel, unsigned int domain, const char *tag, const
return;
}
va_end(vargs);
#ifdef OHOS_LITE
static LogLevel LOG_LEVEL[] = { LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
(void)HiLogPrint(INIT_LOG_INIT, LOG_LEVEL[logLevel], domain, tag, "%{public}s", tmpFmt);

View File

@ -431,21 +431,6 @@ int InUpdaterMode(void)
}
}
int InChargerMode(void)
{
char *data = ReadFileData(BOOT_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 ,ret=%d\n", value, ret);
free(data);
return ret;
}
int StringReplaceChr(char *strl, char oldChr, char newChr)
{
INIT_ERROR_CHECK(strl != NULL, return -1, "Invalid parament");

View File

@ -70,7 +70,6 @@ HWTEST_F(UtilsUnitTest, TestUtilsApi, TestSize.Level0)
float sec = ConvertMicrosecondToSecond(1000000); // 1000000 microseconds
EXPECT_EQ(sec, 1);
EXPECT_EQ(WriteAll(2, "test", strlen("test")), 4);
EXPECT_EQ(InChargerMode(), 0);
GetRandom();
}
} // namespace init_ut