From d5cacc656437e348a7371e36020413e0d144f2fe Mon Sep 17 00:00:00 2001 From: lijiaying <1640106564@qq.com> Date: Wed, 23 Mar 2022 17:28:29 +0800 Subject: [PATCH] =?UTF-8?q?api=20=E6=96=87=E6=A1=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijiaying <1640106564@qq.com> --- .../reference/apis/js-apis-Bundle.md | 207 +++++------------- 1 file changed, 60 insertions(+), 147 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index b9ea2509fc..e042623c8f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -461,7 +461,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { ## bundle.getAllApplicationInfo -function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; +getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; 获取指定用户下所有已安装的应用信息,使用callback形式返回结果。 @@ -535,8 +535,7 @@ bundle.getAbilityInfo(bundleName, abilityName) ## bundle.getAbilityInfo -getAbilityInfo(bundleName: string, abilityName: string): callback : -AsyncCallback\: void +getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\): void; 以异步方法根据给定的意图获取Ability信息,使用callback形式返回结果。 @@ -882,7 +881,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { ## bundle.queryAbilityByWant -queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void +queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void; 以异步方法根据给定的意图获取Ability信息,使用callback形式返回结果。 @@ -915,91 +914,6 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { }) ``` -## bundle.getBundleInstaller - -getBundleInstaller(): Promise\ - -以异步方法获取BundleInstaller,使用Promise形式返回结果。 - -**需要权限:** - -ohos.permission.INSTALL_BUNDLE - -**系统能力:** - -SystemCapability.BundleManager.BundleFramework - -**返回值:** - -| 类型 | 说明 | -| ------------------------ | --------------------------------------------------- | -| Promise\ | 返回值为Promise对象,Promise中包含BundleInstaller。 | - -**示例:** - -```js -let bundleFilePaths = ['/data/test.hap']; -let param = { - userId : 100, - installFlag : 1, - isKeepData : false -}; -bundle.getBundleInstaller() -.then((installerObject) => { - console.info('Operation successful. '); - installerObject.install(bundleFilePaths, param) - .then((data) => { - console.info('Operation successful. Data:' + JSON.stringify(data)); - }).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); - }) -}).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); -}) -``` - -## bundle.getBundleInstaller - -getBundleInstaller(callback: AsyncCallback\): void; - -以异步方法获取BundleInstaller,使用callback形式返回结果。 - -**需要权限:** - -ohos.permission.INSTALL_BUNDLE - -**系统能力:** - -SystemCapability.BundleManager.BundleFramework - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| -------- | ------------------------------ | ---- | ------------------------------------------------- | -| callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回BundleInstaller。 | - -**示例:** - -```js -let bundleFilePaths = ['/data/test.hap']; -let param = { - userId : 100, - installFlag : 1, - isKeepData : false -}; -bundle.getBundleInstaller((err, installerObject) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - } - console.info('Operation successful. Data:' + JSON.stringify(installerObject)); - installerObject.install(bundleFilePaths, param, (err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - } - console.info('Operation successful. Data:' + JSON.stringify(data)); - }) -}) -``` ## bundle.getLaunchWantForBundle @@ -1109,7 +1023,7 @@ bundle.getNameForUid(uid) ## bundle.getNameForUid8+ -getNameForUid(uid: number, callback: AsyncCallback\): void; +getNameForUid(uid: number, callback: AsyncCallback\) : void 以异步方法通过uid获取对应的包名,使用callback形式返回结果。 @@ -1140,7 +1054,7 @@ bundle.getNameForUid(uid, (err, data) => { ## bundle.getAbilityIcon8+ -getAbilityIcon(bundleName: string, abilityName: string): Promise\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>; +getAbilityIcon(bundleName: string, abilityName: string): Promise\; 以异步方法通过bundleName和abilityName获取对应Icon的[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md),使用Promise形式返回结果。 @@ -1154,15 +1068,15 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | ------ | ---- | -------- | -| bundleName | string | 是 | 要查询的bundleName。 | -| abilityName | string | 是 | 要查询的abilityName。 | +| 名称 | 类型 | 必填 | 描述 | +| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | +| bundleName | string | 是 | 要查询的bundleName。 | +| abilityName | string | 是 | 要查询的abilityName。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------------------------------------------ | -| Promise\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)> | 返回值为<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>。 | +| Promise\ | 返回值为[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)。 | **示例:** @@ -1179,7 +1093,7 @@ bundle.getAbilityIcon(bundleName, abilityName) ## bundle.getAbilityIcon8+ -getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>): void; +getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\): void; 以异步方法通过bundleName和abilityName获取对应的[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md),使用callback形式返回结果。 @@ -1193,11 +1107,11 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | ------ | ---- | -------- | -| bundleName | string | 是 | 要查询的bundleName。 | -| abilityName | string | 是 | 要查询的abilityName。 | -| callback | AsyncCallback\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)> | 是 | 程序启动作为入参的回调函数,返回指定<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>。 | +| 名称 | 类型 | 必填 | 描述 | +| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | +| bundleName | string | 是 | 要查询的bundleName。 | +| abilityName | string | 是 | 要查询的abilityName。 | +| callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回指定[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)。 | **示例:** @@ -1451,31 +1365,30 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ------ | ------ | ------ | -| name | string | 是 | 否 | 应用程序的名称 | -| description | string | 是 | 否 | 应用程序的描述 | -| descriptionId | number | 是 | 否 | 应用程序的描述id | -| systemApp | boolean | 是 | 否 | 判断是否为系统应用程序,默认为false | -| enabled | boolean | 是 | 否 | 判断应用程序是否可以使用,默认为true | -| label | string | 是 | 否 | 应用程序的标签 | -| labelId | string | 是 | 否 | 应用程序的标签id | -| icon | string | 是 | 否 | 应用程序的图标 | -| iconId | string | 是 | 否 | 应用程序的图标id | -| process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称 | -| supportedModes | number | 是 | 否 | 应用程序支持的运行模式 | -| moduleSourceDirs | Array\ | 是 | 否 | 应用程序的资源存放的相对路径 | -| permissions | Array\ | 是 | 否 | 访问应用程序所需的权限 | -| moduleInfos | Array\ | 是 | 否 | 应用程序的模块信息 | -| entryDir | string | 是 | 否 | 应用程序的文件保存路径 | -| customizeData | Map> | 是 | 是 | 应用程序的自定义数据 | -| codePath8+ | string | 是 | 否 | 应用程序的安装目录 | -| metaData8+ | Map> | 是 | 否 | 应用程序的自定义元信息 | -| metaData9+ | Map> | 是 | 否 | 应用程序的元信息 | -| removable8+ | boolean | 是 | 否 | 应用程序是否可以被移除 | -| accessTokenId8+ | number | 是 | 否 | 应用程序的accessTokenId | -| uid8+ | number | 是 | 否 | 应用程序的uid | -| entityType9+ | string | 是 | 否 | 应用程序的实体类型 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------------------- | ---------------------------------- | ---- | ---- | --------------------- | +| name | string | 是 | 否 | 应用程序的名称 | +| description | string | 是 | 否 | 应用程序的描述 | +| descriptionId | number | 是 | 否 | 应用程序的描述id | +| systemApp | boolean | 是 | 否 | 判断是否为系统应用程序,默认为false | +| enabled | boolean | 是 | 否 | 判断应用程序是否可以使用,默认为true | +| label | string | 是 | 否 | 应用程序的标签 | +| labelId | string | 是 | 否 | 应用程序的标签id | +| icon | string | 是 | 否 | 应用程序的图标 | +| iconId | string | 是 | 否 | 应用程序的图标id | +| process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称 | +| supportedModes | number | 是 | 否 | 应用程序支持的运行模式 | +| moduleSourceDirs | Array\ | 是 | 否 | 应用程序的资源存放的相对路径 | +| permissions | Array\ | 是 | 否 | 访问应用程序所需的权限 | +| moduleInfos | Array\ | 是 | 否 | 应用程序的模块信息 | +| entryDir | string | 是 | 否 | 应用程序的文件保存路径 | +| codePath8+ | string | 是 | 否 | 应用程序的安装目录 | +| metaData8+ | Map> | 是 | 否 | 应用程序的自定义元信息 | +| metaData9+ | Map> | 是 | 否 | 应用程序的元信息 | +| removable8+ | boolean | 是 | 否 | 应用程序是否可以被移除 | +| accessTokenId8+ | number | 是 | 否 | 应用程序的accessTokenId | +| uid8+ | number | 是 | 否 | 应用程序的uid | +| entityType9+ | string | 是 | 否 | 应用程序的实体类型 | ## ModuleInfo @@ -1507,26 +1420,26 @@ Hap模块信息 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ------ | ------ | ------ | -| name | string | 是 | 否 | 模块名称 | -| description | string | 是 | 否 | 模块描述信息 | -| descriptionId | number | 是 | 否 | 描述信息ID | -| icon | string | 是 | 否 | 模块图标 | -| label | string | 是 | 否 | 模块标签 | -| labelId | number | 是 | 否 | 模块标签ID | -| iconId | number | 是 | 否 | 模块图标ID | -| backgroundImg | string | 是 | 否 | 模块背景图片 | -| supportedModes | number | 是 | 否 | 模块支持的模式 | -| reqCapabilities | Array\ | 是 | 否 | 模块运行需要的能力 | -| deviceTypes | Array\ | 是 | 否 | 支持运行的设备类型 | -| abilityInfo | Array\ | 是 | 否 | Ability信息 | -| moduleName | string | 是 | 否 | 模块名 | -| mainAbilityName | string | 是 | 否 | 入口Ability名称 | -| installationFree | boolean | 是 | 否 | 是否支持免安装 | -| mainElementName8+ | string | 是 | 否 | 入口ability信息 | -| extensionAbilityInfo9+ | Array\ | 是 | 否 | extensionAbility信息 | -| metadata9+ | Array\ | 是 | 否 | Ability的元信息 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------------------------- | ---------------------------- | ---- | ---- | ------------------ | +| name | string | 是 | 否 | 模块名称 | +| description | string | 是 | 否 | 模块描述信息 | +| descriptionId | number | 是 | 否 | 描述信息ID | +| icon | string | 是 | 否 | 模块图标 | +| label | string | 是 | 否 | 模块标签 | +| labelId | number | 是 | 否 | 模块标签ID | +| iconId | number | 是 | 否 | 模块图标ID | +| backgroundImg | string | 是 | 否 | 模块背景图片 | +| supportedModes | number | 是 | 否 | 模块支持的模式 | +| reqCapabilities | Array\ | 是 | 否 | 模块运行需要的能力 | +| deviceTypes | Array\ | 是 | 否 | 支持运行的设备类型 | +| abilityInfo | Array\ | 是 | 否 | Ability信息 | +| moduleName | string | 是 | 否 | 模块名 | +| mainAbilityName | string | 是 | 否 | 入口Ability名称 | +| installationFree | boolean | 是 | 否 | 是否支持免安装 | +| mainElementName9+ | string | 是 | 否 | 入口ability信息 | +| extensionAbilityInfo9+ | Array\ | 是 | 否 | extensionAbility信息 | +| metadata9+ | Array\ | 是 | 否 | Ability的元信息 | ## ReqPermissionDetail -- GitLab