Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
726c2794
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
大约 1 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
726c2794
编写于
9月 07, 2022
作者:
C
cheng_jinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
使用独立的job启动服务
Signed-off-by:
N
cheng_jinsong
<
chengjinsong2@huawei.com
>
上级
2f868912
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
131 addition
and
93 deletion
+131
-93
interfaces/innerkits/BUILD.gn
interfaces/innerkits/BUILD.gn
+1
-1
services/etc/param/ohos.para.dac
services/etc/param/ohos.para.dac
+5
-3
services/include/param/init_param.h
services/include/param/init_param.h
+1
-1
services/init/include/init_service_manager.h
services/init/include/init_service_manager.h
+0
-1
services/init/init_service_manager.c
services/init/init_service_manager.c
+1
-26
services/init/standard/init.c
services/init/standard/init.c
+70
-24
services/loopevent/task/le_asynctask.c
services/loopevent/task/le_asynctask.c
+27
-17
services/param/include/trigger_manager.h
services/param/include/trigger_manager.h
+1
-1
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+1
-1
services/param/trigger/trigger_manager.c
services/param/trigger/trigger_manager.c
+3
-1
services/param/trigger/trigger_processor.c
services/param/trigger/trigger_processor.c
+20
-15
test/unittest/init/group_unittest.cpp
test/unittest/init/group_unittest.cpp
+0
-1
test/unittest/param/trigger_unittest.cpp
test/unittest/param/trigger_unittest.cpp
+1
-1
未找到文件。
interfaces/innerkits/BUILD.gn
浏览文件 @
726c2794
...
...
@@ -253,7 +253,7 @@ if (defined(ohos_lite)) {
external_deps = [
"c_utils:utils",
"hilog_native:libhilog_base",
"ipc:ipc_
cor
e",
"ipc:ipc_
singl
e",
"samgr:samgr_proxy",
]
public_configs = [ ":exported_header_files" ]
...
...
services/etc/param/ohos.para.dac
浏览文件 @
726c2794
...
...
@@ -24,9 +24,11 @@ const.build. = root:root:0775
const.SystemCapability. = root:root:0775
const.product. = root:root:0775
persist.init. = root:root:0775
appspawn. = root:root:0750
startup.uevent. = root:root:0775
ohos.dev. = ueventd:ueventd:0775
startup.appspawn. = root:root:0750
startup.uevent. = ueventd:ueventd:0775
persist.init.debug. = root:root:0775:int
persist.appspawn. = root:root:0775
#udid and sn, only read
ohos.boot.sn = root:deviceprivate:0750
...
...
services/include/param/init_param.h
浏览文件 @
726c2794
...
...
@@ -139,7 +139,7 @@ void DoJobExecNow(const char *triggerName);
*/
int
AddCompleteJob
(
const
char
*
name
,
const
char
*
condition
,
const
char
*
cmdContent
);
void
RegisterBootStateChange
(
void
(
*
bootStateChange
)(
const
char
*
));
void
RegisterBootStateChange
(
void
(
*
bootStateChange
)(
int
start
,
const
char
*
));
/**
* 对外接口
...
...
services/init/include/init_service_manager.h
浏览文件 @
726c2794
...
...
@@ -58,7 +58,6 @@ void StopAllServices(int flags, const char **exclude, int size,
int
(
*
filter
)(
const
Service
*
service
,
const
char
**
exclude
,
int
size
));
void
ParseAllServices
(
const
cJSON
*
fileRoot
);
void
ReleaseService
(
Service
*
service
);
void
StartAllServices
(
int
startMode
);
void
LoadAccessTokenId
(
void
);
Service
*
AddService
(
const
char
*
name
);
void
DumpServiceHookExecute
(
const
char
*
name
,
const
char
*
info
);
...
...
services/init/init_service_manager.c
浏览文件 @
726c2794
...
...
@@ -997,7 +997,7 @@ void StopAllServices(int flags, const char **exclude, int size,
int
(
*
filter
)(
const
Service
*
service
,
const
char
**
exclude
,
int
size
))
{
Service
*
service
=
GetServiceByName
(
"appspawn"
);
if
(
service
!=
NULL
&&
service
->
pid
!=
-
1
)
{
// notify appspawn stop
if
(
service
!=
NULL
&&
service
->
pid
>
0
)
{
// notify appspawn stop
#ifndef STARTUP_INIT_TEST
kill
(
service
->
pid
,
SIGTERM
);
waitpid
(
service
->
pid
,
0
,
0
);
...
...
@@ -1049,31 +1049,6 @@ Service *GetServiceByName(const char *servName)
return
NULL
;
}
void
StartAllServices
(
int
startMode
)
{
INIT_LOGI
(
"StartAllServices %d"
,
startMode
);
InitGroupNode
*
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
NULL
);
while
(
node
!=
NULL
)
{
Service
*
service
=
node
->
data
.
service
;
if
(
service
==
NULL
||
service
->
startMode
!=
startMode
)
{
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
continue
;
}
if
(
IsOnDemandService
(
service
))
{
if
(
CreateServiceSocket
(
service
)
!=
0
)
{
INIT_LOGE
(
"service %s exit! create socket failed!"
,
service
->
name
);
}
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
continue
;
}
if
(
ServiceStart
(
service
)
!=
SERVICE_SUCCESS
)
{
INIT_LOGE
(
"Service %s start failed!"
,
service
->
name
);
}
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
}
INIT_LOGI
(
"StartAllServices %d finish"
,
startMode
);
}
void
LoadAccessTokenId
(
void
)
{
GetAccessToken
();
...
...
services/init/standard/init.c
浏览文件 @
726c2794
...
...
@@ -16,6 +16,7 @@
#include <errno.h>
#include <poll.h>
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
...
...
@@ -47,6 +48,10 @@
#include "bootstage.h"
static
bool
g_enableSandbox
;
typedef
struct
HOOK_TIMING_STAT
{
struct
timespec
startTime
;
struct
timespec
endTime
;
}
HOOK_TIMING_STAT
;
static
int
FdHolderSockInit
(
void
)
{
...
...
@@ -246,16 +251,27 @@ HOOK_MGR *GetBootStageHookMgr()
return
bootStageHookMgr
;
}
static
void
BootStateChange
(
const
char
*
content
)
HOOK_TIMING_STAT
g_bootJob
=
{
0
};
static
long
long
InitDiffTime
(
HOOK_TIMING_STAT
*
stat
)
{
INIT_LOGI
(
"boot start %s finish."
,
content
);
if
(
strcmp
(
"init"
,
content
)
==
0
)
{
StartAllServices
(
START_MODE_BOOT
);
return
;
long
long
diff
=
(
long
long
)((
stat
->
endTime
.
tv_sec
-
stat
->
startTime
.
tv_sec
)
*
1000000
);
// 1000000 1000ms
if
(
stat
->
endTime
.
tv_nsec
>
stat
->
startTime
.
tv_nsec
)
{
diff
+=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
/
1000
;
// 1000 ms
}
else
{
diff
-=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
/
1000
;
// 1000 ms
}
if
(
strcmp
(
"post-init"
,
content
)
==
0
)
{
StartAllServices
(
START_MODE_NORMAL
);
return
;
return
diff
;
}
static
void
BootStateChange
(
int
start
,
const
char
*
content
)
{
if
(
start
==
0
)
{
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
g_bootJob
.
startTime
));
INIT_LOGI
(
"boot job %s start."
,
content
);
}
else
{
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
g_bootJob
.
endTime
));
long
long
diff
=
InitDiffTime
(
&
g_bootJob
);
INIT_LOGI
(
"boot job %s finish diff %lld us."
,
content
,
diff
);
}
}
...
...
@@ -296,11 +312,6 @@ static void InitLoadParamFiles(void)
FreeCfgFiles
(
files
);
}
typedef
struct
HOOK_TIMING_STAT
{
struct
timespec
startTime
;
struct
timespec
endTime
;
}
HOOK_TIMING_STAT
;
static
void
InitPreHook
(
const
HOOK_INFO
*
hookInfo
,
void
*
executionContext
)
{
HOOK_TIMING_STAT
*
stat
=
(
HOOK_TIMING_STAT
*
)
executionContext
;
...
...
@@ -309,20 +320,51 @@ static void InitPreHook(const HOOK_INFO *hookInfo, void *executionContext)
static
void
InitPostHook
(
const
HOOK_INFO
*
hookInfo
,
void
*
executionContext
,
int
executionRetVal
)
{
long
long
diff
;
const
long
long
baseTime
=
1000
;
HOOK_TIMING_STAT
*
stat
=
(
HOOK_TIMING_STAT
*
)
executionContext
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
stat
->
endTime
));
long
long
diff
=
InitDiffTime
(
stat
);
INIT_LOGI
(
"Executing hook [%d:%d:%p] cost [%lld]us, return %d."
,
hookInfo
->
stage
,
hookInfo
->
prio
,
hookInfo
->
hook
,
diff
,
executionRetVal
);
}
diff
=
(
long
long
)((
stat
->
endTime
.
tv_sec
-
stat
->
startTime
.
tv_sec
)
/
baseTime
);
if
(
stat
->
endTime
.
tv_nsec
>
stat
->
startTime
.
tv_nsec
)
{
diff
+=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
*
baseTime
;
}
else
{
diff
-=
(
stat
->
endTime
.
tv_nsec
-
stat
->
startTime
.
tv_nsec
)
*
baseTime
;
static
void
TriggerServices
(
int
startMode
)
{
int
index
=
0
;
int
jobNum
=
0
;
char
jobName
[
64
]
=
{
0
};
// 64 job name
char
cmd
[
64
]
=
{
0
};
// 64 job name
const
int
maxServiceInJob
=
4
;
// 4 service in job
InitGroupNode
*
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
NULL
);
while
(
node
!=
NULL
)
{
Service
*
service
=
node
->
data
.
service
;
if
(
service
==
NULL
||
service
->
startMode
!=
startMode
)
{
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
continue
;
}
if
(
IsOnDemandService
(
service
))
{
if
(
CreateServiceSocket
(
service
)
!=
0
)
{
INIT_LOGE
(
"service %s exit! create socket failed!"
,
service
->
name
);
}
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
continue
;
}
if
(
index
==
0
)
{
sprintf_s
(
jobName
,
sizeof
(
jobName
),
"boot-service:service-%d-%03d"
,
startMode
,
jobNum
);
jobNum
++
;
}
index
++
;
sprintf_s
(
cmd
,
sizeof
(
cmd
),
"start %s"
,
service
->
name
);
AddCompleteJob
(
jobName
,
NULL
,
cmd
);
INIT_LOGV
(
"Add %s to job %s"
,
service
->
name
,
jobName
);
if
(
index
==
maxServiceInJob
)
{
PostTrigger
(
EVENT_TRIGGER_BOOT
,
jobName
,
strlen
(
jobName
));
index
=
0
;
}
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
}
if
(
index
>
0
)
{
PostTrigger
(
EVENT_TRIGGER_BOOT
,
jobName
,
strlen
(
jobName
));
}
INIT_LOGV
(
"Executing hook [%d:%d:%p] cost [%lld]ms, return %d."
,
hookInfo
->
stage
,
hookInfo
->
prio
,
hookInfo
->
hook
,
diff
,
executionRetVal
);
}
void
SystemConfig
(
void
)
...
...
@@ -342,6 +384,7 @@ void SystemConfig(void)
InitParseGroupCfg
();
RegisterBootStateChange
(
BootStateChange
);
INIT_LOGI
(
"boot init finish."
);
// load SELinux context and policy
// Do not move position!
PluginExecCmdByName
(
"loadSelinuxPolicy"
,
""
);
...
...
@@ -354,14 +397,17 @@ void SystemConfig(void)
// read config
HookMgrExecute
(
GetBootStageHookMgr
(),
INIT_PRE_CFG_LOAD
,
(
void
*
)
&
timingStat
,
(
void
*
)
&
options
);
ReadConfig
();
INIT_LOGI
(
"
Parse init
config file done."
);
INIT_LOGI
(
"
boot parse
config file done."
);
HookMgrExecute
(
GetBootStageHookMgr
(),
INIT_POST_CFG_LOAD
,
(
void
*
)
&
timingStat
,
(
void
*
)
&
options
);
IsEnableSandbox
();
// execute init
PostTrigger
(
EVENT_TRIGGER_BOOT
,
"pre-init"
,
strlen
(
"pre-init"
));
PostTrigger
(
EVENT_TRIGGER_BOOT
,
"init"
,
strlen
(
"init"
));
TriggerServices
(
START_MODE_BOOT
);
PostTrigger
(
EVENT_TRIGGER_BOOT
,
"post-init"
,
strlen
(
"post-init"
));
TriggerServices
(
START_MODE_NORMAL
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
g_bootJob
.
startTime
));
}
void
SystemRun
(
void
)
...
...
services/loopevent/task/le_asynctask.c
浏览文件 @
726c2794
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "le_task.h"
#include <time.h>
#include <sys/eventfd.h>
#include "le_loop.h"
...
...
@@ -21,19 +21,15 @@
static
void
DoAsyncEvent_
(
const
LoopHandle
loopHandle
,
AsyncEventTask
*
asyncTask
)
{
LE_CHECK
(
loopHandle
!=
NULL
&&
asyncTask
!=
NULL
,
return
,
"Invalid parameters"
);
ListNode
tmpHdr
;
OH_ListInit
(
&
tmpHdr
);
#ifdef LOOP_DEBUG
struct
timespec
startTime
;
struct
timespec
endTime
;
long
long
diff
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
startTime
));
#endif
StreamTask
*
task
=
&
asyncTask
->
stream
;
LoopMutexLock
(
&
task
->
mutex
);
tmpHdr
.
next
=
task
->
buffHead
.
next
;
tmpHdr
.
prev
=
task
->
buffHead
.
prev
;
task
->
buffHead
.
next
->
prev
=
&
tmpHdr
;
task
->
buffHead
.
prev
->
next
=
&
tmpHdr
;
OH_ListInit
(
&
task
->
buffHead
);
LoopMutexUnlock
(
&
task
->
mutex
);
ListNode
*
node
=
tmpHdr
.
next
;
while
(
node
!=
&
tmpHdr
)
{
ListNode
*
node
=
task
->
buffHead
.
next
;
while
(
node
!=
&
task
->
buffHead
)
{
LE_Buffer
*
buffer
=
ListEntry
(
node
,
LE_Buffer
,
node
);
uint64_t
eventId
=
*
(
uint64_t
*
)(
buffer
->
data
);
if
(
asyncTask
->
processAsyncEvent
)
{
...
...
@@ -42,13 +38,27 @@ static void DoAsyncEvent_(const LoopHandle loopHandle, AsyncEventTask *asyncTask
}
OH_ListRemove
(
&
buffer
->
node
);
free
(
buffer
);
node
=
tmpHdr
.
next
;
#ifdef LOOP_DEBUG
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
endTime
));
diff
=
(
long
long
)((
endTime
.
tv_sec
-
startTime
.
tv_sec
)
*
1000000
);
if
(
endTime
.
tv_nsec
>
startTime
.
tv_nsec
)
{
diff
+=
(
endTime
.
tv_nsec
-
startTime
.
tv_nsec
)
/
1000
;
// 1000 ms
}
else
{
diff
-=
(
endTime
.
tv_nsec
-
startTime
.
tv_nsec
)
/
1000
;
// 1000 ms
}
LE_LOGI
(
"DoAsyncEvent_ diff %ld"
,
diff
);
#endif
break
;
}
}
#ifdef STARTUP_INIT_TEST
void
LE_DoAsyncEvent
(
const
LoopHandle
loopHandle
,
const
TaskHandle
taskHandle
)
{
DoAsyncEvent_
(
loopHandle
,
(
AsyncEventTask
*
)
taskHandle
);
AsyncEventTask
*
asyncTask
=
(
AsyncEventTask
*
)
taskHandle
;
while
(
!
IsBufferEmpty
(
&
asyncTask
->
stream
))
{
DoAsyncEvent_
(
loopHandle
,
(
AsyncEventTask
*
)
taskHandle
);
}
}
#endif
static
LE_STATUS
HandleAsyncEvent_
(
const
LoopHandle
loopHandle
,
const
TaskHandle
taskHandle
,
uint32_t
oper
)
...
...
@@ -61,8 +71,8 @@ static LE_STATUS HandleAsyncEvent_(const LoopHandle loopHandle, const TaskHandle
int
ret
=
read
(
GetSocketFd
(
taskHandle
),
&
eventId
,
sizeof
(
eventId
));
LE_LOGV
(
"HandleAsyncEvent_ read fd:%d ret: %d eventId %llu"
,
GetSocketFd
(
taskHandle
),
ret
,
eventId
);
DoAsyncEvent_
(
loopHandle
,
asyncTask
);
if
(
IsBufferEmpty
(
&
asyncTask
->
stream
))
{
loop
->
modEvent
(
loop
,
(
const
BaseTask
*
)
taskHandle
,
Event_
Read
);
if
(
!
IsBufferEmpty
(
&
asyncTask
->
stream
))
{
loop
->
modEvent
(
loop
,
(
const
BaseTask
*
)
taskHandle
,
Event_
Write
);
return
LE_SUCCESS
;
}
}
else
{
...
...
services/param/include/trigger_manager.h
浏览文件 @
726c2794
...
...
@@ -160,7 +160,7 @@ typedef struct TriggerWorkSpace_ {
TriggerHeader
triggerHead
[
TRIGGER_MAX
];
HashMapHandle
hashMap
;
ParamTaskPtr
eventHandle
;
void
(
*
bootStateChange
)(
const
char
*
);
void
(
*
bootStateChange
)(
int
start
,
const
char
*
);
char
cache
[
PARAM_NAME_LEN_MAX
+
PARAM_CONST_VALUE_LEN_MAX
];
}
TriggerWorkSpace
;
...
...
services/param/manager/param_manager.c
浏览文件 @
726c2794
...
...
@@ -330,7 +330,7 @@ INIT_LOCAL_API int CheckParameterSet(const char *name,
}
#if !(defined __LITEOS_A__ || defined __LITEOS_M__)
// do hook cmd
PARAM_LOG
I
(
"CheckParameterSet realKey %s cmd: '%s' value: %s"
,
PARAM_LOG
V
(
"CheckParameterSet realKey %s cmd: '%s' value: %s"
,
serviceInfo
->
realKey
,
serviceInfo
->
cmdName
,
(
char
*
)
serviceInfo
->
realKey
+
serviceInfo
->
valueOffset
);
DoCmdByName
(
serviceInfo
->
cmdName
,
(
char
*
)
serviceInfo
->
realKey
+
serviceInfo
->
valueOffset
);
#endif
...
...
services/param/trigger/trigger_manager.c
浏览文件 @
726c2794
...
...
@@ -123,7 +123,9 @@ static TriggerNode *AddJobTrigger_(const TriggerWorkSpace *workSpace,
return
NULL
,
"Failed to add hash node"
);
if
(
extInfo
->
type
==
TRIGGER_BOOT
)
{
TRIGGER_SET_FLAG
(
node
,
TRIGGER_FLAGS_ONCE
);
TRIGGER_SET_FLAG
(
node
,
TRIGGER_FLAGS_SUBTRIGGER
);
if
(
strncmp
(
"boot-service:"
,
extInfo
->
info
.
name
,
strlen
(
"boot-service:"
))
!=
0
)
{
TRIGGER_SET_FLAG
(
node
,
TRIGGER_FLAGS_SUBTRIGGER
);
}
}
return
node
;
}
...
...
services/param/trigger/trigger_processor.c
浏览文件 @
726c2794
...
...
@@ -44,7 +44,7 @@ static int DoTriggerExecute_(const TriggerNode *trigger, const char *content, ui
return
0
;
}
static
int
DoTiggerCheckResult
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
static
int
DoT
r
iggerCheckResult
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
{
UNUSED
(
content
);
UNUSED
(
size
);
...
...
@@ -58,10 +58,10 @@ static int DoTiggerCheckResult(TriggerNode *trigger, const char *content, uint32
return
0
;
}
static
int
ExecuteTiggerImmediately
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
static
int
ExecuteT
r
iggerImmediately
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
{
PARAM_CHECK
(
trigger
!=
NULL
,
return
-
1
,
"Invalid trigger"
);
PARAM_LOGV
(
"ExecuteTiggerImmediately trigger %s"
,
GetTriggerName
(
trigger
));
PARAM_LOGV
(
"ExecuteT
r
iggerImmediately trigger %s"
,
GetTriggerName
(
trigger
));
TriggerHeader
*
triggerHead
=
GetTriggerHeader
(
&
g_triggerWorkSpace
,
trigger
->
type
);
if
(
triggerHead
!=
NULL
)
{
triggerHead
->
executeTrigger
(
trigger
,
content
,
size
);
...
...
@@ -74,17 +74,17 @@ static int ExecuteTiggerImmediately(TriggerNode *trigger, const char *content, u
return
0
;
}
static
void
StartTiggerExecute_
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
static
void
StartT
r
iggerExecute_
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
{
TriggerHeader
*
triggerHead
=
GetTriggerHeader
(
&
g_triggerWorkSpace
,
trigger
->
type
);
if
(
triggerHead
!=
NULL
)
{
PARAM_LOGV
(
"StartTiggerExecute_ trigger %s flags:0x%04x"
,
PARAM_LOGV
(
"StartT
r
iggerExecute_ trigger %s flags:0x%04x"
,
GetTriggerName
(
trigger
),
trigger
->
flags
);
triggerHead
->
executeTrigger
(
trigger
,
content
,
size
);
TRIGGER_CLEAR_FLAG
(
trigger
,
TRIGGER_FLAGS_QUEUE
);
if
(
TRIGGER_TEST_FLAG
(
trigger
,
TRIGGER_FLAGS_SUBTRIGGER
))
{
// boot && xxx=xxx trigger
const
char
*
condition
=
triggerHead
->
getCondition
(
trigger
);
CheckTrigger
(
&
g_triggerWorkSpace
,
TRIGGER_UNKNOW
,
condition
,
strlen
(
condition
),
ExecuteTiggerImmediately
);
CheckTrigger
(
&
g_triggerWorkSpace
,
TRIGGER_UNKNOW
,
condition
,
strlen
(
condition
),
ExecuteT
r
iggerImmediately
);
}
if
(
TRIGGER_TEST_FLAG
(
trigger
,
TRIGGER_FLAGS_ONCE
))
{
FreeTrigger
(
&
g_triggerWorkSpace
,
trigger
);
...
...
@@ -97,7 +97,7 @@ static void ExecuteQueueWork(uint32_t maxCount)
uint32_t
executeCount
=
0
;
TriggerNode
*
trigger
=
ExecuteQueuePop
(
&
g_triggerWorkSpace
);
while
(
trigger
!=
NULL
)
{
StartTiggerExecute_
(
trigger
,
NULL
,
0
);
StartT
r
iggerExecute_
(
trigger
,
NULL
,
0
);
executeCount
++
;
if
(
executeCount
>
maxCount
)
{
break
;
...
...
@@ -113,27 +113,30 @@ PARAM_STATIC void ProcessBeforeEvent(const ParamTaskPtr stream,
switch
(
eventId
)
{
case
EVENT_TRIGGER_PARAM
:
{
CheckTrigger
(
&
g_triggerWorkSpace
,
TRIGGER_PARAM
,
(
const
char
*
)
content
,
size
,
DoTiggerCheckResult
);
(
const
char
*
)
content
,
size
,
DoT
r
iggerCheckResult
);
ExecuteQueueWork
(
MAX_TRIGGER_COUNT_RUN_ONCE
);
break
;
}
case
EVENT_TRIGGER_BOOT
:
{
if
(
g_triggerWorkSpace
.
bootStateChange
!=
NULL
)
{
g_triggerWorkSpace
.
bootStateChange
(
0
,
(
const
char
*
)
content
);
}
CheckTrigger
(
&
g_triggerWorkSpace
,
TRIGGER_BOOT
,
(
const
char
*
)
content
,
size
,
DoTiggerCheckResult
);
(
const
char
*
)
content
,
size
,
DoT
r
iggerCheckResult
);
ExecuteQueueWork
(
MAX_TRIGGER_COUNT_RUN_ONCE
);
if
(
g_triggerWorkSpace
.
bootStateChange
!=
NULL
)
{
g_triggerWorkSpace
.
bootStateChange
((
const
char
*
)
content
);
g_triggerWorkSpace
.
bootStateChange
(
1
,
(
const
char
*
)
content
);
}
break
;
}
case
EVENT_TRIGGER_PARAM_WAIT
:
{
CheckTrigger
(
&
g_triggerWorkSpace
,
TRIGGER_PARAM_WAIT
,
(
const
char
*
)
content
,
size
,
ExecuteTiggerImmediately
);
(
const
char
*
)
content
,
size
,
ExecuteT
r
iggerImmediately
);
break
;
}
case
EVENT_TRIGGER_PARAM_WATCH
:
{
CheckTrigger
(
&
g_triggerWorkSpace
,
TRIGGER_PARAM_WATCH
,
(
const
char
*
)
content
,
size
,
ExecuteTiggerImmediately
);
(
const
char
*
)
content
,
size
,
ExecuteT
r
iggerImmediately
);
break
;
}
default:
...
...
@@ -174,6 +177,9 @@ static int GetTriggerType(const char *type)
if
(
strncmp
(
"param:"
,
type
,
strlen
(
"param:"
))
==
0
)
{
return
TRIGGER_PARAM
;
}
if
(
strncmp
(
"boot-service:"
,
type
,
strlen
(
"boot-service:"
))
==
0
)
{
return
TRIGGER_BOOT
;
}
const
char
*
triggerTypeStr
[]
=
{
"pre-init"
,
"boot"
,
"early-init"
,
"init"
,
"early-init"
,
"late-init"
,
"post-init"
,
"fs"
,
"early-fs"
,
"post-fs"
,
"late-fs"
,
"early-boot"
,
"post-fs-data"
,
"reboot"
,
"suspend"
...
...
@@ -375,14 +381,13 @@ void DoJobExecNow(const char *triggerName)
PARAM_CHECK
(
triggerName
!=
NULL
,
return
,
"Invalid param"
);
JobNode
*
trigger
=
GetTriggerByName
(
&
g_triggerWorkSpace
,
triggerName
);
if
(
trigger
!=
NULL
)
{
StartTiggerExecute_
((
TriggerNode
*
)
trigger
,
NULL
,
0
);
StartT
r
iggerExecute_
((
TriggerNode
*
)
trigger
,
NULL
,
0
);
}
}
int
AddCompleteJob
(
const
char
*
name
,
const
char
*
condition
,
const
char
*
cmdContent
)
{
PARAM_CHECK
(
name
!=
NULL
,
return
-
1
,
"Invalid name"
);
PARAM_CHECK
(
condition
!=
NULL
,
return
-
1
,
"Invalid condition"
);
PARAM_CHECK
(
cmdContent
!=
NULL
,
return
-
1
,
"Invalid cmdContent"
);
int
type
=
GetTriggerType
(
name
);
PARAM_CHECK
(
type
<=
TRIGGER_UNKNOW
,
return
-
1
,
"Failed to get trigger index"
);
...
...
@@ -402,7 +407,7 @@ int AddCompleteJob(const char *name, const char *condition, const char *cmdConte
return
0
;
}
void
RegisterBootStateChange
(
void
(
*
bootStateChange
)(
const
char
*
))
void
RegisterBootStateChange
(
void
(
*
bootStateChange
)(
int
,
const
char
*
))
{
if
(
bootStateChange
!=
NULL
)
{
g_triggerWorkSpace
.
bootStateChange
=
bootStateChange
;
...
...
test/unittest/init/group_unittest.cpp
浏览文件 @
726c2794
...
...
@@ -169,7 +169,6 @@ HWTEST_F(InitGroupManagerUnitTest, TestInitGroupMgrInit, TestSize.Level1)
EXPECT_EQ
(
1
,
0
);
}
// test read cfgfile
int
ret
=
InitParseGroupCfg
();
StartAllServices
(
GROUP_CHARGE
);
EXPECT_EQ
(
ret
,
0
);
}
...
...
test/unittest/param/trigger_unittest.cpp
浏览文件 @
726c2794
...
...
@@ -34,7 +34,7 @@ static const int triggerBuffer = 512;
static
uint32_t
g_execCmdId
=
0
;
static
int
g_matchTrigger
=
0
;
static
char
g_matchTriggerName
[
triggerBuffer
]
=
{
0
};
static
void
BootStateChange
(
const
char
*
content
)
static
void
BootStateChange
(
int
start
,
const
char
*
content
)
{
UNUSED
(
content
);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录