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 c96c1398a4322c93b1c0bb330c570875b7f0a16e..264aaf1fd18fdfdd308957d6b617d219ac82b991 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -493,6 +493,74 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => { }) ``` +## bundle.getBundleArchiveInfo + +getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise + +以异步方法获取有关HAP包中包含的应用程序包的信息,使用Promise形式返回结果。 + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | ------------ | +| hapFilePath | string | 是 | HAP存放路径。路径应指向当前应用程序的数据目录的相对目录。 | +| bundleFlags | number | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。默认值:0,取值范围:大于0。 | + +**返回值:** +| 类型 | 说明 | +| -------------- | -------------------------------------- | +| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 返回值为Promise对象,Promise中包含有关hap包中包含的应用程序的信息。 | + +**示例:** + +```js +let hapFilePath = "/data/xxx/test.hap"; +let bundleFlags = 0; +bundle.getBundleArchiveInfo(hapFilePath, bundleFlags) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}) +``` + +## bundle.getBundleArchiveInfo + +getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback) : void + +以异步方法获取有关HAP包中包含的应用程序包的信息,使用callback形式返回结果。 + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | ------------ | +| hapFilePath | string | 是 | HAP存放路径。路径应指向当前应用程序的数据目录的相对目录。 | +| bundleFlags | number | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。默认值:0,取值范围:大于0。| +| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。默认值:0,取值范围:大于0。| + +**示例:** + +```js +let hapFilePath = "/data/xxx/test.hap"; +let bundleFlags = 0; +bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) +``` + + ## bundle.getAbilityInfo getAbilityInfo(bundleName: string, abilityName: string): Promise\ diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md index 5d13b4af752e6a808843b5fa6ae99db7265847bf..c50ee9a95aa26fd6a979830b804d6c2d00ff036e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @@ -38,4 +38,4 @@ | removable8+ | boolean | 是 | 否 | 应用程序是否可以被移除 | | accessTokenId8+ | number | 是 | 否 | 应用程序的accessTokenId | | uid8+ | number | 是 | 否 | 应用程序的uid | -| entityType9+ | string | 是 | 否 | 应用程序的实体类型 | \ No newline at end of file +| entityType8+ | string | 是 | 否 | 应用程序的实体类型 | \ No newline at end of file