Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2d2b459b
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看板
未验证
提交
2d2b459b
编写于
8月 14, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 14, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22149 新增BundleInstaller.updateBundleForSelf接口文档
Merge pull request !22149 from xsz233/master
上级
fcdeac2a
05bce7c4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
242 addition
and
1 deletion
+242
-1
zh-cn/application-dev/reference/apis/js-apis-installer.md
zh-cn/application-dev/reference/apis/js-apis-installer.md
+215
-0
zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md
.../application-dev/reference/errorcodes/errorcode-bundle.md
+27
-1
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-installer.md
浏览文件 @
2d2b459b
...
@@ -21,6 +21,7 @@ import installer from '@ohos.bundle.installer';
...
@@ -21,6 +21,7 @@ import installer from '@ohos.bundle.installer';
| ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE | system_core | 允许在企业设备上安装企业NORMAL应用包。 |
| ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE | system_core | 允许在企业设备上安装企业NORMAL应用包。 |
| ohos.permission.UNINSTALL_BUNDLE | system_core | 允许应用卸载应用。 |
| ohos.permission.UNINSTALL_BUNDLE | system_core | 允许应用卸载应用。 |
| ohos.permission.RECOVER_BUNDLE | system_core | 允许应用恢复预置应用。 |
| ohos.permission.RECOVER_BUNDLE | system_core | 允许应用恢复预置应用。 |
| ohos.permission.INSTALL_SELF_BUNDLE | system_core | 允许企业MDM应用在企业设备上自升级。|
权限等级参考
[
权限等级说明
](
../../security/accesstoken-overview.md#权限等级说明
)
权限等级参考
[
权限等级说明
](
../../security/accesstoken-overview.md#权限等级说明
)
...
@@ -786,6 +787,220 @@ try {
...
@@ -786,6 +787,220 @@ try {
}
}
```
```
## BundleInstaller.updateBundleForSelf<sup>10+</sup>
updateBundleForSelf(hapFilePaths: Array
<string>
, installParam: InstallParam, callback: AsyncCallback
<void>
): void;
以异步方法更新当前应用,仅限企业设备上的企业MDM应用调用,且传入的hapFilePaths中的hap必须都属于当前应用,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_SELF_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array
<
string
>
| 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| installParam |
[
InstallParam
](
#installparam
)
| 是 | 指定安装所需的其他参数。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,安装应用成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700004 | The specified user ID is not found. |
| 17700010 | Failed to install the HAP because the HAP fails to be parsed. |
| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. |
| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. |
| 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700018 | Failed to install because the dependent module does not exist. |
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. |
| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). |
| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. |
| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. |
| 17700048 | Failed to install the HAP because the code signature verification is failed. |
| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. |
| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. |
| 17700051 | Failed to install the HAP because the distribution type of caller application is not enterprise_mdm. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
installParam
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
updateBundleForSelf failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
updateBundleForSelf successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## BundleInstaller.updateBundleForSelf<sup>10+</sup>
updateBundleForSelf(hapFilePaths: Array
<string>
, callback: AsyncCallback
<void>
): void;
以异步方法更新当前应用,仅限企业设备上的企业MDM应用调用,且传入的hapFilePaths中的hap必须都属于当前应用,使用callback形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_SELF_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array
<
string
>
| 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,安装应用成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700004 | The specified user ID is not found. |
| 17700010 | Failed to install the HAP because the HAP fails to be parsed. |
| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. |
| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. |
| 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700018 | Failed to install because the dependent module does not exist. |
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. |
| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). |
| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. |
| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. |
| 17700048 | Failed to install the HAP because the code signature verification is failed. |
| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. |
| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. |
| 17700051 | Failed to install the HAP because the distribution type of caller application is not enterprise_mdm. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
err
=>
{
if
(
err
)
{
console
.
error
(
'
updateBundleForSelf failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
updateBundleForSelf successfully.
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## BundleInstaller.updateBundleForSelf<sup>10+</sup>
updateBundleForSelf(hapFilePaths: Array
<string>
, installParam?: InstallParam): Promise
<void>
;
以异步方法更新当前应用,仅限企业设备上的企业MDM应用调用,且传入的hapFilePaths中的hap必须都属于当前应用,使用promise形式返回结果。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.INSTALL_SELF_BUNDLE
**系统能力:**
SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array
<
string
>
| 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| installParam |
[
InstallParam
](
#installparam
)
| 否 | 指定安装所需的其他参数,默认值:参照
[
InstallParam
](
#installparam
)
的默认值。 |
**错误码:**
以下错误码的详细介绍请参见
[
ohos.bundle错误码
](
../errorcodes/errorcode-bundle.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700004 | The specified user ID is not found. |
| 17700010 | Failed to install the HAP because the HAP fails to be parsed. |
| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. |
| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. |
| 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700018 | Failed to install because the dependent module does not exist. |
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. |
| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). |
| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. |
| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. |
| 17700048 | Failed to install the HAP because the code signature verification is failed. |
| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. |
| 17700050 | Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device. |
| 17700051 | Failed to install the HAP because the distribution type of caller application is not enterprise_mdm. |
**示例:**
```
ts
import
installer
from
'
@ohos.bundle.installer
'
;
let
hapFilePaths
=
[
'
/data/storage/el2/base/haps/entry/files/
'
];
let
installParam
=
{
userId
:
100
,
isKeepData
:
false
,
installFlag
:
1
,
};
try
{
installer
.
getBundleInstaller
().
then
(
data
=>
{
data
.
updateBundleForSelf
(
hapFilePaths
,
installParam
)
.
then
((
data
)
=>
{
console
.
info
(
'
updateBundleForSelf successfully:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
updateBundleForSelf failed:
'
+
error
.
message
);
});
}).
catch
(
error
=>
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getBundleInstaller failed. Cause:
'
+
error
.
message
);
}
```
## HashParam
## HashParam
应用程序安装卸载哈希参数信息。
应用程序安装卸载哈希参数信息。
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md
浏览文件 @
2d2b459b
...
@@ -646,6 +646,19 @@ Failed to install the HAP because the code signature verification is failed.
...
@@ -646,6 +646,19 @@ Failed to install the HAP because the code signature verification is failed.
2.
检查提供的代码签名文件的路径是否合法。
2.
检查提供的代码签名文件的路径是否合法。
3.
使用和安装包匹配的代码签名文件。
3.
使用和安装包匹配的代码签名文件。
## 17700049 应用自升级时安装的应用与调用方包名不同
**错误信息**
<br/>
Failed to install the HAP because the bundleName is different from the bundleName of the caller application.
**错误描述**
<br/>
企业mdm应用自升级时,安装的应用与调用方包名不同。
**可能原因**
<br/>
1.
要安装的hap或hsp不属于当前应用。
**处理步骤**
<br/>
1.
检查要安装的hap或hsp是否属于当前应用。
## 17700050 企业设备校验失败
## 17700050 企业设备校验失败
**错误信息**
<br/>
**错误信息**
<br/>
Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device.
Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device.
...
@@ -658,4 +671,17 @@ Failed to install the HAP because enterprise normal/MDM bundle cannot be install
...
@@ -658,4 +671,17 @@ Failed to install the HAP because enterprise normal/MDM bundle cannot be install
**处理步骤**
<br/>
**处理步骤**
<br/>
1.
检查安装设备是否为企业设备。
1.
检查安装设备是否为企业设备。
2.
检查设备参数const.bms.allowenterprisebundle是否为true
2.
检查设备参数const.bms.allowenterprisebundle是否为true
\ No newline at end of file
## 17700051 应用自升级时安装的应用与调用方包名不同
**错误信息**
<br/>
Failed to install the HAP because the distribution type of caller application is not enterprise_mdm.
**错误描述**
<br/>
企业mdm应用自升级时,调用方的分发类型不是企业mdm。
**可能原因**
<br/>
1.
调用方的分发类型不是企业mdm。
**处理步骤**
<br/>
1.
检查应用的签名文件是否正确配置。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录