Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
157c8054
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
157c8054
编写于
3月 12, 2022
作者:
X
xlei1030
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加appspawnw文档
Signed-off-by:
N
xlei1030
<
xionglei6@huawei.com
>
上级
a047fb88
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
166 addition
and
0 deletion
+166
-0
zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md
zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md
+166
-0
未找到文件。
zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md
0 → 100644
浏览文件 @
157c8054
# appspawn标准系统应用孵化组件<a name="ZH-CN_TOPIC_0000001063680582"></a>
-
[
概述
](
#section56901555910
)
-
[
功能简介
](
#section56901555911
)
-
[
基本概念
](
#section56901555912
)
-
[
开发指导
](
#section56901555913
)
-
[
接口说明
](
#section56901555914
)
-
[
开发实例
](
#section56901555915
)
-
[
常见问题
](
#section56901555916
)
-
[
冷启动失败
](
#section56901555917
)
## 概述<a name="section56901555910"></a>
appspawn被init启动后,等待接收进程间消息,根据消息内容启动应用服务并赋予其对应权限。
### 功能简介<a name="section56901555911"></a>
-
安全控制
-
支持为app设置SELinux标签
-
应用进程控制
-
支持为app设置AccessToken
-
支持重启前,appspawn停止后,可同时停止所有已孵化的app进程
-
冷启动
-
支持应用通过aa命令冷启动应用
```
param set appspawn.cold.boot true // 打开冷启动状态
aa start -d 12345 -a $name -b $package -C
参考:
aa start -d 12345 -a ohos.acts.startup.sysparam.function.MainAbility -b ohos.acts.startup.sysparam.function -C
### 基本概念<a name="section56901555912"></a>
appspawn注册的服务名称为“appspawn”, appspawn 通过监听本地socket,接收来自客户端的请求消息,消息格式定义如下:
**表 1** 字段说明
<table><thead align="left"><tr id="row6650142913713"><th class="cellrowborder" valign="top" width="39.489999999999995%" id="mcps1.2.3.1.1"><p id="p17650112914379"><a name="p17650112914379"></a><a name="p17650112914379"></a>字段名</p>
</th>
<th class="cellrowborder" valign="top" width="60.51%" id="mcps1.2.3.1.2"><p id="p865032916376"><a name="p865032916376"></a><a name="p865032916376"></a>说明</p>
</th>
</tr>
</thead>
<tbody><tr id="row36506298373"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p76501029113715"><a name="p76501029113715"></a><a name="p76501029113715"></a>processName</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p2650329183715"><a name="p2650329183715"></a><a name="p2650329183715"></a>即将启动的应用服务进程名,最大256字节。</p>
</td>
</tr>
<tr id="row36506298373"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p76501029113715"><a name="p76501029113715"></a><a name="p76501029113715"></a>bundleName</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p2650329183715"><a name="p2650329183715"></a><a name="p2650329183715"></a>即将启动的应用程序包名,最大256字节。</p>
</td>
</tr>
<tr id="row86501129183712"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p2065010298379"><a name="p2065010298379"></a><a name="p2065010298379"></a>soPath</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p13650192963715"><a name="p13650192963715"></a><a name="p13650192963715"></a>应用程序指定的动态库的路径,最大256字节。</p>
</td>
</tr>
<tr id="row13650329103719"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p16501292377"><a name="p16501292377"></a><a name="p16501292377"></a>uid</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p186503291371"><a name="p186503291371"></a><a name="p186503291371"></a>即将启动的应用进程的uid,必须为正值。</p>
</td>
</tr>
<tr id="row187625816314"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p188771758833"><a name="p188771758833"></a><a name="p188771758833"></a>gid</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p187716587310"><a name="p187716587310"></a><a name="p187716587310"></a>即将启动的应用进程的gid,必须为正值。</p>
</td>
</tr>
<tr id="row187625816314"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p188771758833"><a name="p188771758833"></a><a name="p188771758833"></a>gidTable</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p187716587310"><a name="p187716587310"></a><a name="p187716587310"></a>即将启动的应用进程组信息,长度由gidCount指定,最大支持64个进程组,必须为正值。</p>
</td>
</tr>
<tr id="row187625816314"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p188771758833"><a name="p188771758833"></a><a name="p188771758833"></a>gidCount</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p187716587310"><a name="p187716587310"></a><a name="p187716587310"></a>即将启动的应用进程组个数。</p>
</td>
</tr>
<tr id="row106508294373"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p16501829183715"><a name="p16501829183715"></a><a name="p16501829183715"></a>accessTokenId</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p11650182953717"><a name="p11650182953717"></a><a name="p11650182953717"></a>应用进程权限控制的token id。</p>
</td>
</tr>
<tr id="row106508294373"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p16501829183715"><a name="p16501829183715"></a><a name="p16501829183715"></a>apl</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p11650182953717"><a name="p11650182953717"></a><a name="p11650182953717"></a>应用进程权限控制的apl,最大32字节。</p>
</td>
</tr>
</tbody>
</table>
## 开发指导<a name="section56901555913"></a>
通过 “base/startup/appspawn_standard/interfaces/innerkits/include/client_socket.h“ 头文件查看
### 接口说明<a name="section56901555914"></a>
**表 2** 字段说明
<table><thead align="left"><tr id="row6650142913713"><th class="cellrowborder" valign="top" width="39.489999999999995%" id="mcps1.2.3.1.1"><p id="p17650112914379"><a name="p17650112914379"></a><a name="p17650112914379"></a>字段名</p>
</th>
<th class="cellrowborder" valign="top" width="60.51%" id="mcps1.2.3.1.2"><p id="p865032916376"><a name="p865032916376"></a><a name="p865032916376"></a>说明</p>
</th>
</tr>
</thead>
<tbody><tr id="row36506298373"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p76501029113715"><a name="p76501029113715"></a><a name="p76501029113715"></a>CreateClient</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p2650329183715"><a name="p2650329183715"></a><a name="p2650329183715"></a>创建client。</p>
</td>
</tr>
<tr id="row36506298373"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p76501029113715"><a name="p76501029113715"></a><a name="p76501029113715"></a>CloseClient</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p2650329183715"><a name="p2650329183715"></a><a name="p2650329183715"></a>关闭client。</p>
</td>
</tr>
<tr id="row86501129183712"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p2065010298379"><a name="p2065010298379"></a><a name="p2065010298379"></a>ConnectSocket</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p13650192963715"><a name="p13650192963715"></a><a name="p13650192963715"></a>向appspawn服务发起连接请求。</p>
</td>
</tr>
<tr id="row13650329103719"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p16501292377"><a name="p16501292377"></a><a name="p16501292377"></a>WriteSocketMessage</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p186503291371"><a name="p186503291371"></a><a name="p186503291371"></a>发送消息到appspawn服务。</p>
</td>
</tr>
<tr id="row187625816314"><td class="cellrowborder" valign="top" width="39.489999999999995%" headers="mcps1.2.3.1.1 "><p id="p188771758833"><a name="p188771758833"></a><a name="p188771758833"></a>ReadSocketMessage</p>
</td>
<td class="cellrowborder" valign="top" width="60.51%" headers="mcps1.2.3.1.2 "><p id="p187716587310"><a name="p187716587310"></a><a name="p187716587310"></a>接收来自appspawn服务的消息。</p>
</td>
</tr>
</tbody>
</table>
### 开发实例<a name="section56901555915"></a>
```
std::shared_ptr
<AppSpawn::ClientSocket>
clientSocket = std::make_unique
<AppSpawn::ClientSocket>
("AppSpawn");
if (clientSocket == nullptr) {
return -1;
}
if (clientSocket->CreateClient() != ERR_OK) {
return -1;
}
if (clientSocket->ConnectSocket() != ERR_OK) {
return -1;;
}
// property 构造AppProperty
clientSocket->WriteSocketMessage((void
*
)&property, sizeof(AppSpawn::AppProperty));
// 读结果
int pid;
clientSocket->ReadSocketMessage((void
*
)&pid, sizeof(pid));
// 如果失败,返回pid如果小于等于0,则错误,否则返回应用的进程id
```
## 常见问题<a name="section56901555916"></a>
### 冷启动失败<a name="section56901555917"></a>
- **现象描述**
通过命令冷启动应用失败
- **解决方法**
1. 确认是否打开冷启动设置
2. 确认冷启动命令是否正确
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录