未验证 提交 2d2b459b 编写于 作者: O openharmony_ci 提交者: Gitee

!22149 新增BundleInstaller.updateBundleForSelf接口文档

Merge pull request !22149 from xsz233/master
......@@ -21,6 +21,7 @@ import installer from '@ohos.bundle.installer';
| ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE | system_core | 允许在企业设备上安装企业NORMAL应用包。 |
| ohos.permission.UNINSTALL_BUNDLE | system_core | 允许应用卸载应用。 |
| ohos.permission.RECOVER_BUNDLE | system_core | 允许应用恢复预置应用。 |
| ohos.permission.INSTALL_SELF_BUNDLE | system_core | 允许企业MDM应用在企业设备上自升级。|
权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)
......@@ -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&lt;string&gt; | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,安装应用成功,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&lt;string&gt; | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,安装应用成功,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&lt;string&gt; | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放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
应用程序安装卸载哈希参数信息。
......
......@@ -646,6 +646,19 @@ Failed to install the HAP because the code signature verification is failed.
2. 检查提供的代码签名文件的路径是否合法。
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 企业设备校验失败
**错误信息**<br/>
Failed to install the HAP because enterprise normal/MDM bundle cannot be installed on non-enterprise device.
......@@ -659,3 +672,16 @@ Failed to install the HAP because enterprise normal/MDM bundle cannot be install
**处理步骤**<br/>
1. 检查安装设备是否为企业设备。
2. 检查设备参数const.bms.allowenterprisebundle是否为true
## 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.
先完成此消息的编辑!
想要评论请 注册