Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Appspawn Lite
提交
c2b511ca
S
Startup Appspawn Lite
项目概览
OpenHarmony
/
Startup Appspawn Lite
8 个月 前同步成功
通知
4
Star
43
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Appspawn Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c2b511ca
编写于
7月 21, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 21, 2021
浏览文件
操作
浏览文件
下载
差异文件
!18 代码整改
Merge pull request !18 from 熊磊/appspaw3
上级
7a236615
9746c497
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
7 deletion
+22
-7
services/src/appspawn_message.c
services/src/appspawn_message.c
+5
-5
services/src/appspawn_process.c
services/src/appspawn_process.c
+4
-1
services/src/appspawn_service.c
services/src/appspawn_service.c
+7
-1
services/test/unittest/common/message_func_test.cpp
services/test/unittest/common/message_func_test.cpp
+6
-0
未找到文件。
services/src/appspawn_message.c
浏览文件 @
c2b511ca
...
...
@@ -59,7 +59,7 @@ void FreeMessageSt(MessageSt* targetSt)
}
}
static
int
ReadStringItem
(
cJSON
*
strItem
,
char
**
buf
,
size_t
maxLen
,
size_t
minLen
)
static
enum
OHOSLiteErrorCode
ReadStringItem
(
cJSON
*
strItem
,
char
**
buf
,
size_t
maxLen
,
size_t
minLen
)
{
if
(
strItem
==
NULL
||
!
cJSON_IsString
(
strItem
))
{
return
EC_INVALID
;
...
...
@@ -80,7 +80,7 @@ static int ReadStringItem(cJSON* strItem, char** buf, size_t maxLen, size_t minL
return
EC_NOMEMORY
;
}
if
(
strLength
>
0
&&
memcpy_s
(
bufTmp
,
strLength
,
strPtr
,
strLength
)
!=
EOK
)
{
if
(
strLength
>
0
&&
memcpy_s
(
bufTmp
,
strLength
+
1
,
strPtr
,
strLength
)
!=
EOK
)
{
free
(
bufTmp
);
bufTmp
=
NULL
;
return
EC_FAILURE
;
...
...
@@ -117,7 +117,7 @@ static int GetCaps(const cJSON* curItem, MessageSt* msgSt)
}
if
(
capsCnt
>
MAX_CAPABILITY_COUNT
)
{
HILOG_ERROR
(
HILOG_MODULE_HIVIEW
,
"[appspawn] GetCaps, too many caps[cnt %{public}d], max %{public}d"
,
\
HILOG_ERROR
(
HILOG_MODULE_HIVIEW
,
"[appspawn] GetCaps, too many caps[cnt %{public}d], max %{public}d"
,
capsCnt
,
MAX_CAPABILITY_COUNT
);
return
EC_INVALID
;
}
...
...
@@ -167,7 +167,7 @@ int SplitMessage(const char* msg, unsigned int msgLen, MessageSt* msgSt)
}
cJSON
*
bundleNameItem
=
cJSON_GetObjectItem
(
rootJ
,
"bundleName"
);
int
ret
=
ReadStringItem
(
bundleNameItem
,
&
(
msgSt
->
bundleName
),
MAX_BUNDLE_NAME_LEN
,
MIN_BUNDLE_NAME_LEN
);
int
ret
=
(
int
)
ReadStringItem
(
bundleNameItem
,
&
(
msgSt
->
bundleName
),
MAX_BUNDLE_NAME_LEN
,
MIN_BUNDLE_NAME_LEN
);
if
(
ret
!=
EC_SUCCESS
)
{
FreeMessageSt
(
msgSt
);
cJSON_Delete
(
rootJ
);
...
...
@@ -175,7 +175,7 @@ int SplitMessage(const char* msg, unsigned int msgLen, MessageSt* msgSt)
}
cJSON
*
identityIDItem
=
cJSON_GetObjectItem
(
rootJ
,
"identityID"
);
ret
=
ReadStringItem
(
identityIDItem
,
&
(
msgSt
->
identityID
),
MAX_IDENTITY_ID_LEN
,
MIN_IDENTITY_ID_LEN
);
ret
=
(
int
)
ReadStringItem
(
identityIDItem
,
&
(
msgSt
->
identityID
),
MAX_IDENTITY_ID_LEN
,
MIN_IDENTITY_ID_LEN
);
if
(
ret
!=
EC_SUCCESS
)
{
FreeMessageSt
(
msgSt
);
cJSON_Delete
(
rootJ
);
...
...
services/src/appspawn_process.c
浏览文件 @
c2b511ca
...
...
@@ -150,6 +150,9 @@ pid_t CreateProcess(const MessageSt* msgSt)
#endif // OHOS_DEBUG
// set permissions
if
(
msgSt
->
caps
==
NULL
)
{
exit
(
0x7f
);
// 0x7f: user specified
}
if
(
SetPerms
(
msgSt
->
uID
,
msgSt
->
gID
,
msgSt
->
capsCnt
,
msgSt
->
caps
)
!=
0
)
{
HILOG_ERROR
(
HILOG_MODULE_HIVIEW
,
"[appspawn] sub-process %{public}s exit!"
,
msgSt
->
bundleName
);
exit
(
0x7f
);
// 0x7f: user specified
...
...
@@ -164,7 +167,7 @@ pid_t CreateProcess(const MessageSt* msgSt)
getpid
(),
errno
);
}
// 1s = 1000000000ns
long
timeUsed
=
(
tmEnd
.
tv_sec
-
tmStart
.
tv_sec
)
*
1000000000
+
(
tmEnd
.
tv_nsec
-
tmStart
.
tv_nsec
);
long
timeUsed
=
(
tmEnd
.
tv_sec
-
tmStart
.
tv_sec
)
*
(
long
)
1000000000
+
(
tmEnd
.
tv_nsec
-
tmStart
.
tv_nsec
);
HILOG_INFO
(
HILOG_MODULE_HIVIEW
,
"[appspawn] sub-process, pid %{public}d, timeused %ld ns."
,
\
getpid
(),
timeUsed
);
#endif // OHOS_DEBUG
...
...
services/src/appspawn_service.c
浏览文件 @
c2b511ca
...
...
@@ -85,6 +85,9 @@ static TaskConfig GetTaskConfig(Service* service)
#ifdef OHOS_DEBUG
static
void
GetCurTime
(
struct
timespec
*
tmCur
)
{
if
(
tmCur
==
NULL
)
{
return
;
}
if
(
clock_gettime
(
CLOCK_REALTIME
,
tmCur
)
!=
0
)
{
HILOG_ERROR
(
HILOG_MODULE_HIVIEW
,
"[appspawn] invoke, get time failed! err %{public}d"
,
errno
);
}
...
...
@@ -93,6 +96,9 @@ static void GetCurTime(struct timespec* tmCur)
static
int
GetMessageSt
(
MessageSt
*
msgSt
,
IpcIo
*
req
)
{
if
(
msgSt
==
NULL
||
req
==
NULL
)
{
return
EC_FAILURE
;
}
#ifdef __LINUX__
size_t
len
=
0
;
char
*
str
=
IpcIoPopString
(
req
,
&
len
);
...
...
@@ -155,7 +161,7 @@ static int Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, Ip
GetCurTime
(
&
tmEnd
);
// 1s = 1000000000ns
long
timeUsed
=
(
tmEnd
.
tv_sec
-
tmStart
.
tv_sec
)
*
1000000000
+
(
tmEnd
.
tv_nsec
-
tmStart
.
tv_nsec
);
long
timeUsed
=
(
tmEnd
.
tv_sec
-
tmStart
.
tv_sec
)
*
(
long
)
1000000000
+
(
tmEnd
.
tv_nsec
-
tmStart
.
tv_nsec
);
HILOG_INFO
(
HILOG_MODULE_HIVIEW
,
"[appspawn] invoke, reply pid %{public}d, timeused %{public}ld ns."
,
\
newPid
,
timeUsed
);
#else
...
...
services/test/unittest/common/message_func_test.cpp
浏览文件 @
c2b511ca
...
...
@@ -208,6 +208,9 @@ HWTEST_F(StartupAppspawnUTest, msgFuncFreeTest_002, TestSize.Level1)
static
void
GetCurrentTime
(
struct
timespec
*
tmCur
)
{
if
(
tmCur
==
NULL
)
{
return
;
}
if
(
clock_gettime
(
CLOCK_REALTIME
,
tmCur
)
!=
0
)
{
printf
(
"[----------] StartupAppspawnUTest, get time failed! err %d.
\n
"
,
errno
);
}
...
...
@@ -290,11 +293,14 @@ HWTEST_F(StartupAppspawnUTest, msgFuncSplitTest_002, TestSize.Level1)
caps
.
push_back
(
1
);
// 1, test capability
caps
.
push_back
(
5
);
// 5, test capability
EXPECT_NE
(
msgSt
.
bundleName
,
nullptr
);
EXPECT_NE
(
msgSt
.
identityID
,
nullptr
);
EXPECT_EQ
(
strcmp
(
"validName"
,
msgSt
.
bundleName
),
0
);
EXPECT_EQ
(
strcmp
(
"135"
,
msgSt
.
identityID
),
0
);
EXPECT_EQ
(
TEST_UID
,
msgSt
.
uID
);
EXPECT_EQ
(
TEST_GID
,
msgSt
.
gID
);
EXPECT_EQ
(
caps
.
size
(),
msgSt
.
capsCnt
);
EXPECT_NE
(
msgSt
.
caps
,
nullptr
);
for
(
size_t
i
=
0
;
i
<
caps
.
size
();
++
i
)
{
EXPECT_EQ
(
caps
[
i
],
msgSt
.
caps
[
i
]);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录