提交 86996ca1 编写于 作者: Z zhaogan

Issue: #I631GP

Description: 包管理API整改资料修改
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Feature
Binary Source: No
Signed-off-by: Nzhaogan <zhaogan2@huawei.com>
上级 4f3acce5
......@@ -8,7 +8,7 @@
## 导入模块
```javascript
```ts
import bundleMonitor from '@ohos.bundle.bundleMonitor';
```
......@@ -28,8 +28,8 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor';
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------- | ------ | ---- | ---- | -------------------------- |
| bundleName | string | 是 | 否 | 应用状态发生变化的应用包名 |
| userId | number | 是 | 否 | 应用状态发生变化的用户id |
| bundleName | string | 是 | 否 | 应用状态发生变化的应用包名 |
| userId | number | 是 | 否 | 应用状态发生变化的用户id |
## bundleMonitor.on
......@@ -47,19 +47,16 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
| 参数名 | 类型 | 必填 | 说明 |
| ---------------------------- | -------- | ---- | ------------------ |
| BundleChangedEvent | string | 是 | 注册监听的事件类型 |
| Callback\<BundleChangedInfo> | callback | 是 | 注册监听的回调函数 |
| BundleChangedEvent | string | 是 | 注册监听的事件类型 |
| Callback\<BundleChangedInfo> | callback | 是 | 注册监听的回调函数 |
**相关错误码**
**错误码:**
| 错误码ID | 错误信息 |
| -------- | --------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:**
```js
```ts
import bundleMonitor from '@ohos.bundle.bundleMonitor';
try {
......@@ -87,19 +84,16 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
| 参数名 | 类型 | 必填 | 说明 |
| ---------------------------- | -------- | ---- | ---------------------------------------------------------- |
| BundleChangedEvent | string | 是 | 注销监听的事件类型 |
| Callback\<BundleChangedInfo> | callback | 否 | 注销监听的回调函数,当为空时表示注销当前事件的所有callback |
| BundleChangedEvent | string | 是 | 注销监听的事件类型 |
| Callback\<BundleChangedInfo> | callback | 是 | 注销监听的回调函数,当为空时表示注销当前事件的所有callback。 |
**相关错误码**
**错误码:**
| 错误码ID | 错误信息 |
| -------- | --------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:**
```js
```ts
import bundleMonitor from '@ohos.bundle.bundleMonitor';
try {
......
......@@ -11,6 +11,16 @@
```
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
```
## 权限列表
| 权限 | 权限等级 | 描述 |
| --------------------------------------- | ----------- | ---------------- |
| ohos.permission.GET_DEFAULT_APPLICATION | system_core | 默认应用相关权限。 |
权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E)
## defaultAppMgr.ApplicationType
应用类型
......@@ -48,9 +58,14 @@ isDefaultApplication(type: string): Promise\<boolean>
| ------------------------- | ------------------ |
| Promise\<boolean> | Promise形式返回当前应用是否是默认应用,true表示是默认应用,false表示不是默认应用。 |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:**
```js
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER)
.then((data) => {
......@@ -75,6 +90,10 @@ isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void
| type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值。 |
| callback | AsyncCallback\<boolean> | 是 | 程序启动作为入参的回调函数,返回当前应用是否是默认应用,true表示是默认应用,false表示不是默认应用。 |
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:**
```js
......@@ -115,6 +134,8 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo>
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -164,6 +185,8 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -213,6 +236,8 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -273,6 +298,8 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -338,6 +365,8 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -396,6 +425,8 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -404,7 +435,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
**示例:**
```js
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.test.app",
......@@ -452,6 +483,8 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -501,6 +534,8 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -549,6 +584,8 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 17700004 | The specified user id is not found. |
......@@ -556,7 +593,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
**示例:**
```js
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => {
if (err) {
......
......@@ -22,7 +22,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
| 权限 | 权限等级 | 说明 |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)
......@@ -50,18 +50,15 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAb
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|--------------------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
......@@ -109,18 +106,15 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>;
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
......@@ -153,7 +147,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 |
| callback | AsyncCallback\<Array\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)>> | 是 | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo数组对象;否则返回错误对象。 |
**错误码:**
......@@ -161,18 +155,15 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
......@@ -214,7 +205,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10。 |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息最大数组长度为10。 |
**返回值:**
......@@ -227,18 +218,15 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
......@@ -279,7 +267,7 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | 是 | ElementName信息。 |
| locale | string |是 | 语言地区 |
| locale | string |是 | 语言地区 |
| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | 是 | 回调函数,操作成功返回err为null,data为RemoteAbilityInfo对象;否则为错误对象。 |
**错误码:**
......@@ -287,18 +275,15 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
......@@ -334,7 +319,7 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | -------------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | 是 | ElementName信息。 |
| locale | string |是 | 语言地区 |
| locale | string |是 | 语言地区 |
**返回值:**
......@@ -347,18 +332,15 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
......@@ -391,8 +373,8 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 |
| locale | string |是 | 语言地区 |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 |
| locale | string |是 | 语言地区 |
| callback | AsyncCallback\<Array\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)>> | 是 | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo数组对象;否则返回错误对象。 |
**错误码:**
......@@ -401,17 +383,14 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
......@@ -454,7 +433,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10。 |
| locale | string |是 | 语言地区 |
| locale | string |是 | 语言地区 |
**返回值:**
......@@ -467,18 +446,15 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. |
| 17700027 | The distributed service is not running. |
**示例:**
```js
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
......
......@@ -18,8 +18,8 @@ import freeInstall from '@ohos.bundle.freeInstall';
| 权限 | 权限等级 | 描述 |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)
## UpgradeFlag
......@@ -29,10 +29,10 @@ import freeInstall from '@ohos.bundle.freeInstall';
**系统能力:** SystemCapability.BundleManager.BundleFramework.FreeInstall
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ---------------- |
| NOT_UPGRADE | 0 | 模块无需升级 |
| SINGLE_UPGRADE | 1 | 单个模块需要升级 |
| RELATION_UPGRADE | 2 | 关系模块需要升级 |
| ---------------- | ---- | ---------------- |
| NOT_UPGRADE | 0 | 模块无需升级 |
| SINGLE_UPGRADE | 1 | 单个模块需要升级 |
| RELATION_UPGRADE | 2 | 关系模块需要升级 |
## BundlePackFlag
......@@ -66,18 +66,15 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位 |
| callback | AsyncCallback\<void> | 是 | 回调函数。当函数调用成功,err为null,否则为错误对象 |
| callback | AsyncCallback\<void> | 是 | 回调函数。当函数调用成功,err为null,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|---------------------------------------- |
| 17700001 | The specified bundle name is not found. |
| 17700002 | The specified module name is not found. |
**示例:**
......@@ -118,24 +115,21 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg
| ----------- | --------------------------- | ---- | ---------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| moduleName | string | 是 | 应用程序模块名称。 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位 |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | 仅供内部系统使用标志位|
**返回值:**
| 类型 | 说明 |
| ------------- | ------------------------------------ |
| Promise\<void> | Promise对象。无返回结果的Promise对象 |
| Promise\<void> | Promise对象。无返回结果的Promise对象 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|----------------------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700002 | The specified module name is not found. |
**示例:**
......@@ -181,11 +175,8 @@ isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCall
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|----------------------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700002 | The specified module name is not found. |
**示例:**
......@@ -237,11 +228,8 @@ isHapModuleRemovable(bundleName: string, moduleName: string): Promise\<boolean>;
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|----------------------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700002 | The specified module name is not found. |
**示例:**
......@@ -278,7 +266,7 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback:
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 应用程序包名称。 |
| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 |
| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 |
| callback | AsyncCallback<[BundlePackInfo](js-apis-bundleManager-packInfo.md)> | 是 | 回调函数。当函数调用成功,err为null,data为获取到的BundlePackInfo信息。否则为错误对象。 |
**错误码:**
......@@ -286,11 +274,8 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback:
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|----------------------------------------|
| 17700001 | The specified bundle name is not found. |
**示例:**
......@@ -327,7 +312,7 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | --------------------------------- | ---- | ---------------------- |
| bundleName | string | 是 | 应用程序包名称。 |
| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 |
| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志|
**返回值:**
......@@ -340,11 +325,8 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 401 | The parameter check failed. |
| 801 | Capability not supported. |
| 17700001 | The specified bundle name is not found |
|----------|----------------------------------------|
| 17700001 | The specified bundle name is not found. |
**示例:**
......@@ -383,12 +365,7 @@ getDispatchInfo(callback: AsyncCallback\<DispatchInfo>): void;
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 801 | Capability not supported. |
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:**
......@@ -427,12 +404,7 @@ getDispatchInfo(): Promise\<DispatchInfo>;
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
|---------------|-------------------------|
| 201 | Permission denied.|
| 801 | Capability not supported. |
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:**
......
......@@ -15,7 +15,7 @@ import installer from '@ohos.bundle.installer';
| 权限 | 权限等级 | 描述 |
| ------------------------------ | ----------- | ---------------- |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E)
......@@ -33,7 +33,7 @@ getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | 是 | 回调函数,获取BundleInstaller对象,err为undefined,data为获取到的BundleInstaller对象;否则为错误对象 |
| callback | AsyncCallback\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | 是 | 回调函数,获取BundleInstaller对象,err为undefined,data为获取到的BundleInstaller对象;否则为错误对象 |
**错误码:**
......@@ -70,7 +70,7 @@ getBundleInstaller(): Promise\<BundleInstaller>;
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ------------------------------------ |
| Promise\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | Promise对象,返回BundleInstaller对象 |
| Promise\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | Promise对象,返回BundleInstaller对象 |
**错误码:**
......@@ -107,9 +107,9 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array&lt;string&gt; | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP包的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP包,且这些HAP包的签名需要保持一致 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,安装应用成功,err为undefined,否则为错误对象 |
| hapFilePaths | Array&lt;string&gt; | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP包的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP包,且这些HAP包的签名需要保持一致 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,安装应用成功,err为undefined,否则为错误对象 |
**错误码:**
......@@ -117,15 +117,15 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------ |
| 17700004 | The specified userId is not existed |
| 17700010 | To parse file of config.json or module.json failed |
| 17700011 | To verify signature failed |
| 17700012 | Invalid hap file path or too large file size |
| 17700015 | Multiple haps have inconsistent configured information |
| 17700016 | No disk space left for installation |
| 17700017 | Downgrade installation is prohibited |
| 17700101 | The system service is excepted |
| 17700103 | I/O operation is failed |
| 17700004 | The specified userId is not existed. |
| 17700010 | To parse file of config.json or module.json failed. |
| 17700011 | To verify signature failed. |
| 17700012 | Invalid hap file path or too large file size. |
| 17700015 | Multiple haps have inconsistent configured information. |
| 17700016 | No disk space left for installation. |
| 17700017 | Downgrade installation is prohibited. |
| 17700101 | The system service is excepted. |
| 17700103 | I/O operation is failed. |
**示例:**
......@@ -171,9 +171,9 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 包名 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象 |
| bundleName | string | 是 | 待卸载应用的包名。 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,卸载应用成功,err为undefined,否则为错误对象 |
**错误码:**
......@@ -181,9 +181,9 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700004 | The specified userId is not existed |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled |
| 17700101 | The system service is excepted |
| 17700004 | The specified userId is not existed. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700101 | The system service is excepted. |
**示例:**
......@@ -229,9 +229,9 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 包名 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,回滚应用成功,err为undefined,否则为错误对象 |
| bundleName | string | 是 | 待恢复应用的包名。 |
| installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,回滚应用成功,err为undefined,否则为错误对象 |
**错误码:**
......@@ -239,7 +239,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 17700004 | The specified userId is not existed |
| 17700004 | The specified userId is not existed. |
**示例:**
......@@ -271,7 +271,7 @@ try {
## HashParam
应用程序安装卸载信息
应用程序安装卸载哈希参数信息。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
......@@ -279,12 +279,12 @@ try {
| 参数名 | 类型 | 说明 |
| ---------- | ------ | ---------------- |
| moduleName | string | 应用程序模块名称 |
| hashValue | string | 哈希值 |
| moduleName | string | 应用程序模块名称 |
| hashValue | string | 哈希值 |
## InstallParam
应用程序安装卸载信息
应用程序安装、卸载或恢复需指定的参数信息。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
......@@ -292,8 +292,8 @@ try {
| 参数名 | 类型 | 说明 |
| ------------------------------ | ------------------------------ | ------------------ |
| userId | number | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9)获取当前进程所在用户 |
| installFlag | number | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装 |
| isKeepData | boolean | 卸载时是否保留数据目录 |
| hashParams | Array<[HashParam](#hashparam)> | 哈希值参数 |
| crowdtestDeadline| number | 测试包的被杀死时间 |
\ No newline at end of file
| userId | number | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9)获取当前进程所在用户。 |
| installFlag | number | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装。 |
| isKeepData | boolean | 卸载时是否保留数据目录。 |
| hashParams | Array<[HashParam](#hashparam)> | 哈希值参数。 |
| crowdtestDeadline| number |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 |
\ No newline at end of file
......@@ -8,12 +8,12 @@
## 导入模块
```typescript
```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
```
## launcherBundlemanager.**getLauncherAbilityInfo<sup>9+</sup>**
## launcherBundlemanager.getLauncherAbilityInfo<sup>9+</sup>
getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallback<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>>) : void;
......@@ -36,18 +36,20 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba
| 类型 | 说明 |
| ----------------------------------- | --------------------------------------------------- |
| AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | callback形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息 |
| AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | callback形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息。 |
**错误码:**
**相关错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) |
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17700001 | The specified bundle name is not found. |
| 17700004 | The specified user id is not found. |
| 17700004 | The specified userId is not found. |
**示例:**
```typescript
```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try {
......@@ -62,6 +64,8 @@ try {
}
```
## launcherBundlemanager.getLauncherAbilityInfo<sup>9+</sup>
getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>>;
查询指定bundleName及用户的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
......@@ -76,21 +80,23 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau
| 参数名 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | -------------- |
| bundleName | string | 是 | 应用程序包名称 。|
| bundleName | string | 是 | 应用程序包名称。|
| userId | number | 是 | 被查询的用户id。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------- | -------------------------------------------------- |
| Promise\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | Promise形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息 |
| Promise\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | Promise形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息。 |
**错误码:**
**相关错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) |
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17700001 | The specified bundle name is not found. |
| 17700004 | The specified user id is not found. |
| 17700004 | The specified userId is not found. |
**示例:**
......@@ -130,17 +136,19 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch
| 类型 | 说明 |
| ----------------------------------- | ------------------------------------------------------- |
| AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | callback形式返回指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) |
| AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | callback形式返回指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) |
**相关错误码**
**错误码:**
| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) |
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17700004 | The specified user id is not found. |
| 17700004 | The specified userId is not found. |
示例:
```typescript
```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try {
......@@ -149,11 +157,12 @@ try {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
}
console.log("data is " + JSON.stringify(data));
})
});
} catch (errData) {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
}
```
## launcherBundlemanager.getAllLauncherAbilityInfo<sup>9+</sup>
getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>>;
......@@ -175,11 +184,19 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo]
| 类型 | 说明 |
| ----------------------------- | ------------------------------------------------------ |
| Promise\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | Promise形式返回指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) |
| Promise\<Array<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>> | Promise形式返回指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) |
示例:
**错误码:**
```typescript
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17700004 | The specified userId is not found. |
**示例:**
```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try {
......@@ -187,7 +204,7 @@ try {
console.log("data is " + JSON.stringify(data));
}).catch (errData => {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
})
});
} catch (errData) {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
}
......@@ -197,7 +214,7 @@ try {
getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>>) : void;
查询当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)
查询当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
......@@ -213,11 +230,19 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo
| 类型 | 说明 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| AsyncCallback\<Array<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>> | callback形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) |
| AsyncCallback\<Array<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>> | callback形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) |
示例:
**错误码:**
```typescript
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17700001 | The specified bundle name is not found. |
**示例:**
```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try {
......@@ -226,14 +251,18 @@ try {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
}
console.log("data is " + JSON.stringify(data));
})
});
} catch (errData) {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
}
```
## launcherBundlemanager.getShortcutInfo<sup>9+</sup>
getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>>;
查询当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统接口:** 此接口为系统接口
......@@ -248,11 +277,19 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun
| 类型 | 说明 |
| ---------------------- | ----------------------------------------------- |
| Promise\<Array<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>> | Promise形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) |
| Promise\<Array<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>> | Promise形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) |
示例:
**错误码:**
```typescript
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17700001 | The specified bundle name is not found. |
**示例:**
```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try {
......@@ -260,7 +297,7 @@ try {
console.log("data is " + JSON.stringify(data));
}).catch (errData => {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
})
});
} catch (errData) {
console.log(`errData is errCode:${errData.code} message:${errData.message}`);
}
......
......@@ -25,9 +25,9 @@ zipFile(inFile: string, outFile: string, options: Options): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[Stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip) |
| options | [Options](#options) | 否 | 压缩的可选参数 |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[Stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip) |
| options | [Options](#options) | 否 | 压缩的可选参数 |
**返回值:**
......@@ -89,9 +89,9 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压文件路径 |
| options | [Options](#options) | 否 | 解压的可选参数 |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压文件路径 |
| options | [Options](#options) | 否 | 解压的可选参数 |
**返回值:**
......@@ -131,16 +131,16 @@ compressFile(inFile: string, outFile: string, options: Options, callback: AsyncC
| 参数名 | 类型 | 必填 | 说明 |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压文件路径 |
| options | [Options](#options) | 是 | 压缩的配置参数 |
| AsyncCallback<**void**> | callback | 否 | 压缩时的回调函数 |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压文件路径 |
| options | [Options](#options) | 是 | 压缩的配置参数 |
| AsyncCallback<**void**> | callback | 否 | 压缩时的回调函数 |
**相关错误码**
以下错误码的详细介绍请参见[ohos.zlib错误码](../errorcodes/errorcode-zlib.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 401 | wrong param type |
| -------- | --------------------------------------|
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
......@@ -179,15 +179,16 @@ compressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压文件路径 |
| options | [Options](#options) | 是 | 压缩的配置参数 |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压文件路径 |
| options | [Options](#options) | 是 | 压缩的配置参数 |
**相关错误码**
以下错误码的详细介绍请参见[ohos.zlib错误码](../errorcodes/errorcode-zlib.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 401 | wrong param type |
| -------- | ------------------------------------- |
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
......@@ -228,16 +229,17 @@ decompressFile(inFile: string, outFile: string, options: Options, callback: Asyn
| 参数名 | 类型 | 必填 | 说明 |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压后的目录路径 |
| options | [Options](#options) | 是 | 解压的配置参数 |
| AsyncCallback<**void**> | callback | 否 | 解压是的回调函数 |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压后的目录路径 |
| options | [Options](#options) | 是 | 解压的配置参数 |
| AsyncCallback<**void**> | callback | 否 | 解压是的回调函数 |
**相关错误码**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 401 | wrong param type |
以下错误码的详细介绍请参见[ohos.zlib错误码](../errorcodes/errorcode-zlib.md)
| 错误码ID | 错误信息
| -------- | --------------------------------------|
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
......@@ -276,15 +278,16 @@ decompressFile(inFile: string, outFile: string, options: Options): Promise\<void
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压后的目录路径 |
| options | [Options](#options) | 是 | 解压时的配置参数 |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md) |
| outFile | string | 是 | 指定的解压后的目录路径 |
| options | [Options](#options) | 是 | 解压时的配置参数 |
**相关错误码**
| 错误码 | 错误信息 |
| ------ | -------------------------------------- |
| 401 | wrong param type |
以下错误码的详细介绍请参见[ohos.zlib错误码](../errorcodes/errorcode-zlib.md)
| 错误码ID | 错误信息 |
| ------ | ------------------------------------- |
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
......@@ -317,9 +320,9 @@ try {
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------- | ---- | --------------------------------------------------------- |
| level | CompressLeve | 否 | 参考[zip.CompressLevel枚举定义](#zipcompresslevel) |
| memLevel | MemLevel | 否 | 参考[zip.MemLevel枚举定义](#zipmemlevel) |
| strategy | CompressStrategy | 否 | 参考[zip.CompressStrategy枚举定义](#zipcompressstrategy) |
| level | CompressLeve | 否 | 参考[zip.CompressLevel枚举定义](#zipcompresslevel) |
| memLevel | MemLevel | 否 | 参考[zip.MemLevel枚举定义](#zipmemlevel) |
| strategy | CompressStrategy | 否 | 参考[zip.CompressStrategy枚举定义](#zipcompressstrategy) |
## zip.CompressLevel
......@@ -327,10 +330,10 @@ try {
| 名称 | 值 | 说明 |
| ---------------------------------- | ---- | ----------------- |
| COMPRESS_LEVEL_NO_COMPRESSION | 0 | 压缩率为0压缩等级 |
| COMPRESS_LEVEL_BEST_SPEED | 1 | 最佳速度压缩等级 |
| COMPRESS_LEVEL_BEST_COMPRESSION | 9 | 最佳压缩等级 |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | 默认压缩等级 |
| COMPRESS_LEVEL_NO_COMPRESSION | 0 | 压缩率为0压缩等级 |
| COMPRESS_LEVEL_BEST_SPEED | 1 | 最佳速度压缩等级 |
| COMPRESS_LEVEL_BEST_COMPRESSION | 9 | 最佳压缩等级 |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | 默认压缩等级 |
## zip.MemLevel
......@@ -338,9 +341,9 @@ try {
| 名称 | 值 | 说明 |
| ----------------- | ---- | -------------------------------- |
| MEM_LEVEL_MIN | 1 | zip 接口在压缩过程中最小使用内存 |
| MEM_LEVEL_MAX | 9 | zip 接口在压缩过程中最大使用内存 |
| MEM_LEVEL_DEFAULT | 8 | zip 接口在压缩过程中默认使用内存 |
| MEM_LEVEL_MIN | 1 | zip 接口在压缩过程中最小使用内存 |
| MEM_LEVEL_MAX | 9 | zip 接口在压缩过程中最大使用内存 |
| MEM_LEVEL_DEFAULT | 8 | zip 接口在压缩过程中默认使用内存 |
## zip.CompressStrategy
......@@ -348,11 +351,11 @@ try {
| 名称 | 值 | 说明 |
| ---------------------------------- | ---- | ------------------------ |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY | 0 | 常规数据策略 |
| COMPRESS_STRATEGY_FILTERED | 1 | 过滤器产生的数据压缩策略 |
| COMPRESS_STRATEGY_HUFFMAN_ONLY | 2 | 霍夫曼编码格式压缩策略 |
| COMPRESS_STRATEGY_RLE | 3 | 游标编码压缩策略 |
| COMPRESS_STRATEGY_FIXED | 4 | 固定的压缩策略 |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY | 0 | 常规数据策略 |
| COMPRESS_STRATEGY_FILTERED | 1 | 过滤器产生的数据压缩策略 |
| COMPRESS_STRATEGY_HUFFMAN_ONLY | 2 | 霍夫曼编码格式压缩策略 |
| COMPRESS_STRATEGY_RLE | 3 | 游标编码压缩策略 |
| COMPRESS_STRATEGY_FIXED | 4 | 固定的压缩策略 |
## zip.ErrorCode
......@@ -360,5 +363,5 @@ try {
| 名称 | 值 | 说明 |
| ---------------- | ---- | ------------ |
| ERROR_CODE_OK | 0 | 函数调用成功 |
| ERROR_CODE_ERRNO | -1 | 函数调用失败 |
| ERROR_CODE_OK | 0 | 函数调用成功 |
| ERROR_CODE_ERRNO | -1 | 函数调用失败 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册