Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
18080436
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看板
未验证
提交
18080436
编写于
5月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!643 增加sa服务动态拉起 测试用例源码
Merge pull request !643 from Mupceet/init519_1
上级
26739f8a
418f9793
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
95 addition
and
0 deletion
+95
-0
test/exec_test/BUILD.gn
test/exec_test/BUILD.gn
+16
-0
test/exec_test/sa_service_ondemand_test.cpp
test/exec_test/sa_service_ondemand_test.cpp
+79
-0
未找到文件。
test/exec_test/BUILD.gn
浏览文件 @
18080436
...
...
@@ -69,12 +69,28 @@ ohos_executable("server") {
part_name = "init"
}
ohos_executable("ondemandTest") {
sources = [ "sa_service_ondemand_test.cpp" ]
external_deps = [
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
"utils_base:utils",
]
install_images = [ "system" ]
install_enable = true
part_name = "init"
}
group("exectest") {
if (control_test) {
deps = [
":client",
":fd_holder_test",
":fd_holder_test.cfg",
":ondemandTest",
":server",
]
}
...
...
test/exec_test/sa_service_ondemand_test.cpp
0 → 100644
浏览文件 @
18080436
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cstdlib>
#include <iostream>
#include <string>
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "system_ability_load_callback_stub.h"
using
namespace
OHOS
;
using
namespace
std
;
class
OnDemandLoadCallback
:
public
SystemAbilityLoadCallbackStub
{
public:
void
OnLoadSystemAbilitySuccess
(
int32_t
systemAbilityId
,
const
sptr
<
IRemoteObject
>&
remoteObject
)
override
;
void
OnLoadSystemAbilityFail
(
int32_t
systemAbilityId
)
override
;
};
void
OnDemandLoadCallback
::
OnLoadSystemAbilitySuccess
(
int32_t
systemAbilityId
,
const
sptr
<
IRemoteObject
>&
remoteObject
)
{
cout
<<
"OnLoadSystemAbilitySuccess systemAbilityId:"
<<
systemAbilityId
<<
" IRemoteObject result:"
<<
((
remoteObject
!=
nullptr
)
?
"succeed"
:
"failed"
)
<<
endl
;
}
void
OnDemandLoadCallback
::
OnLoadSystemAbilityFail
(
int32_t
systemAbilityId
)
{
cout
<<
"OnLoadSystemAbilityFail systemAbilityId:"
<<
systemAbilityId
<<
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
map
<
string
,
int
>
saService
=
{
{
"updater_sa"
,
UPDATE_DISTRIBUTED_SERVICE_ID
},
{
"softbus_server"
,
SOFTBUS_SERVER_SA_ID
},
};
int
parameterNum
=
2
;
if
((
argc
!=
parameterNum
)
||
(
argv
[
1
]
==
nullptr
))
{
cout
<<
"Invaild parameter"
<<
endl
;
}
const
string
name
=
argv
[
1
];
int
abilityId
=
0
;
std
::
map
<
string
,
int
>::
iterator
item
=
saService
.
find
(
name
);
if
(
item
!=
saService
.
end
())
{
cout
<<
"sa service name "
<<
item
->
first
<<
"ability id "
<<
item
->
second
<<
endl
;
abilityId
=
item
->
second
;
}
else
{
cout
<<
"Invaild sa service name"
<<
endl
;
return
0
;
}
sptr
<
OnDemandLoadCallback
>
loadCallback_
=
new
OnDemandLoadCallback
();
sptr
<
ISystemAbilityManager
>
sm
=
SystemAbilityManagerClient
::
GetInstance
().
GetSystemAbilityManager
();
if
(
sm
==
nullptr
)
{
cout
<<
"GetSystemAbilityManager samgr object null!"
<<
endl
;
return
0
;
}
int32_t
result
=
sm
->
LoadSystemAbility
(
abilityId
,
loadCallback_
);
if
(
result
!=
ERR_OK
)
{
cout
<<
"systemAbilityId:"
<<
abilityId
<<
" load failed, result code:"
<<
result
<<
endl
;
return
0
;
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录