1e41f4b71Sopenharmony_ci# @ohos.bundle.bundleManager (bundleManager模块)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci本模块提供应用信息查询能力,支持[BundleInfo](js-apis-bundleManager-bundleInfo.md)、[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)、[AbilityInfo](js-apis-bundleManager-abilityInfo.md)、[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)等信息的查询。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci## 导入模块
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci```ts
11e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
12e41f4b71Sopenharmony_ci```
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## 枚举
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci### BundleFlag
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci包信息标志,指示需要获取的包信息的内容。
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| 名称                                          | 值         | 说明                                                         |
23e41f4b71Sopenharmony_ci| --------------------------------------------- | ---------- | ------------------------------------------------------------ |
24e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_DEFAULT                       | 0x00000000 | 用于获取默认bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、hapModuleInfo、ability、extensionAbility和permission的信息。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
25e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_APPLICATION              | 0x00000001 | 用于获取包含applicationInfo的bundleInfo,获取的bundleInfo不包含signatureInfo、hapModuleInfo、ability、extensionAbility和permission的信息。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
26e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_HAP_MODULE               | 0x00000002 | 用于获取包含hapModuleInfo的bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、ability、extensionAbility和permission的信息。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
27e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_ABILITY                  | 0x00000004 | 用于获取包含ability的bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、extensionAbility和permission的信息。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE一起使用。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
28e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY        | 0x00000008 | 用于获取包含extensionAbility的bundleInfo,获取的bundleInfo不包含signatureInfo、applicationInfo、ability 和permission的信息。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE一起使用。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
29e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION     | 0x00000010 | 用于获取包含permission的bundleInfo。获取的bundleInfo不包含signatureInfo、applicationInfo、hapModuleInfo、extensionAbility和ability的信息。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
30e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_METADATA                 | 0x00000020 | 用于获取applicationInfo、moduleInfo和abilityInfo中包含的metadata。它不能单独使用,它需要与GET_BUNDLE_INFO_WITH_APPLICATION、GET_BUNDLE_INFO_WITH_HAP_MODULE、GET_BUNDLE_INFO_WITH_ABILITY、GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY一起使用。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
31e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_DISABLE                  | 0x00000040 | 用于获取application被禁用的BundleInfo和被禁用的Ability信息。获取的bundleInfo不包含signatureInfo、applicationInfo、hapModuleInfo、ability、extensionAbility和permission的信息。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
32e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_SIGNATURE_INFO           | 0x00000080 | 用于获取包含signatureInfo的bundleInfo。获取的bundleInfo不包含applicationInfo、hapModuleInfo、extensionAbility、ability和permission的信息。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
33e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_MENU<sup>11+</sup>       | 0x00000100 | 用于获取包含fileContextMenuConfig的bundleInfo。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE一起使用。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
34e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_ROUTER_MAP<sup>12+</sup> | 0x00000200 | 用于获取包含routerMap的bundleInfo。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE一起使用。<br/>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
35e41f4b71Sopenharmony_ci| GET_BUNDLE_INFO_WITH_SKILL<sup>12+</sup>      | 0x00000800 | 用于获取包含skills的bundleInfo。它不能单独使用,需要与GET_BUNDLE_INFO_WITH_HAP_MODULE、GET_BUNDLE_INFO_WITH_ABILITY、GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY一起使用。<br/>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci### ExtensionAbilityType
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci指示扩展组件的类型。
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
44e41f4b71Sopenharmony_ci|:----------------:|:---:|-----|
45e41f4b71Sopenharmony_ci| FORM             | 0   | [FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md):卡片扩展能力,提供卡片开发能力。<br>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
46e41f4b71Sopenharmony_ci| WORK_SCHEDULER   | 1   | [WorkSchedulerExtensionAbility](../apis-backgroundtasks-kit/js-apis-WorkSchedulerExtensionAbility.md):延时任务扩展能力,允许应用在系统闲时执行实时性不高的任务。 |
47e41f4b71Sopenharmony_ci| INPUT_METHOD     | 2   | [InputMethodExtensionAbility](../apis-ime-kit/js-apis-inputmethod-extension-ability.md):输入法扩展能力,用于开发输入法应用。 |
48e41f4b71Sopenharmony_ci| SERVICE          | 3   | <!--Del-->[<!--DelEnd-->ServiceExtensionAbility<!--Del-->](js-apis-app-ability-serviceExtensionAbility-sys.md)<!--DelEnd-->:后台服务扩展能力,提供后台运行并对外提供相应能力。 |
49e41f4b71Sopenharmony_ci| ACCESSIBILITY    | 4   | <!--RP1-->[AccessibilityExtensionAbility](../apis-accessibility-kit/js-apis-inner-application-accessibilityExtensionContext.md)<!--RP1End-->:无障碍服务扩展能力,支持访问与操作前台界面。 |
50e41f4b71Sopenharmony_ci| DATA_SHARE       | 5   | <!--Del-->[<!--DelEnd-->DataShareExtensionAbility <!--Del-->](../apis-arkdata/js-apis-application-dataShareExtensionAbility-sys.md)<!--DelEnd-->:数据共享扩展能力,用于对外提供数据读写服务。 |
51e41f4b71Sopenharmony_ci| FILE_SHARE       | 6   | FileShareExtensionAbility:文件共享扩展能力,用于应用间的文件分享。预留能力,仅系统应用支持。 |
52e41f4b71Sopenharmony_ci| STATIC_SUBSCRIBER| 7   | <!--Del-->[<!--DelEnd-->StaticSubscriberExtensionAbility <!--Del-->](../apis-basic-services-kit/js-apis-application-staticSubscriberExtensionAbility-sys.md)<!--DelEnd-->:静态广播扩展能力,用于处理静态事件,比如开机事件。 |
53e41f4b71Sopenharmony_ci| WALLPAPER        | 8   | WallpaperExtensionAbility:壁纸扩展能力,用于实现桌面壁纸。预留能力,仅系统应用支持。 |
54e41f4b71Sopenharmony_ci| BACKUP           |  9  | [BackupExtensionAbility](../apis-core-file-kit/js-apis-application-backupExtensionAbility.md):数据备份扩展能力,提供应用数据的备份恢复能力。 |
55e41f4b71Sopenharmony_ci| WINDOW           |  10 | <!--Del-->[<!--DelEnd-->WindowExtensionAbility<!--Del-->](../apis-arkui/js-apis-application-windowExtensionAbility-sys.md)<!--DelEnd-->:界面组合扩展能力,允许系统应用进行跨应用的界面拉起和嵌入。 |
56e41f4b71Sopenharmony_ci| ENTERPRISE_ADMIN |  11 | [EnterpriseAdminExtensionAbility](../apis-mdm-kit/js-apis-EnterpriseAdminExtensionAbility.md):企业设备管理扩展能力,提供企业管理时处理管理事件的能力,比如设备上应用安装事件、锁屏密码输入错误次数过多事件等。 |
57e41f4b71Sopenharmony_ci| THUMBNAIL        | 13  | ThumbnailExtensionAbility:文件缩略图扩展能力,用于为文件提供图标缩略图的能力。预留能力,仅系统应用支持。 |
58e41f4b71Sopenharmony_ci| PREVIEW          | 14  | PreviewExtensionAbility:文件预览扩展能力,提供文件预览的能力,其他应用可以直接在应用中嵌入显示。预留能力,仅系统应用支持。 |
59e41f4b71Sopenharmony_ci| PRINT<sup>10+</sup> | 15 | PrintExtensionAbility:文件打印扩展能力,提供应用打印照片、文档等办公场景。仅系统应用支持。 |
60e41f4b71Sopenharmony_ci| SHARE<sup>10+</sup> | 16 | [ShareExtensionAbility](js-apis-app-ability-shareExtensionAbility.md):提供分享业务能力,为开发者提供基于UIExtension的分享业务模板。 |
61e41f4b71Sopenharmony_ci| PUSH<sup>10+</sup> | 17 | PushExtensionAbility:推送扩展能力,提供推送场景化消息能力。预留能力,仅系统应用支持。 |
62e41f4b71Sopenharmony_ci| DRIVER<sup>10+</sup> | 18 | [DriverExtensionAbility](../apis-driverdevelopment-kit/js-apis-app-ability-driverExtensionAbility.md):驱动扩展能力,提供外设驱动扩展能力,仅系统应用支持。 |
63e41f4b71Sopenharmony_ci| ACTION<sup>10+</sup> | 19 | [ActionExtensionAbility](js-apis-app-ability-actionExtensionAbility.md):自定义服务扩展能力,为开发者提供基于UIExtension的自定义操作业务模板。 |
64e41f4b71Sopenharmony_ci| ADS_SERVICE<sup>11+</sup> | 20 | AdsServiceExtensionAbility:广告服务扩展能力,对外提供后台自定义广告业务服务,仅系统应用支持。 |
65e41f4b71Sopenharmony_ci| EMBEDDED_UI<sup>12+</sup> | 21 | [EmbeddedUIExtensionAbility](js-apis-app-ability-embeddedUIExtensionAbility.md):嵌入式UI扩展能力,提供跨进程界面嵌入的能力。 |
66e41f4b71Sopenharmony_ci| INSIGHT_INTENT_UI<sup>12+</sup> | 22 | InsightIntentUIExtensionAbility:为开发者提供能被小艺意图调用,以窗口形态呈现内容的扩展能力。 |
67e41f4b71Sopenharmony_ci| UNSPECIFIED      | 255 | 不指定类型,配合queryExtensionAbilityInfo接口可以查询所有类型的ExtensionAbility。 |
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci### PermissionGrantState
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci指示权限授予状态。
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci **原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
79e41f4b71Sopenharmony_ci|:----------------:|:---:|:---:|
80e41f4b71Sopenharmony_ci| PERMISSION_DENIED|  -1 | 拒绝授予权限。 |
81e41f4b71Sopenharmony_ci| PERMISSION_GRANTED |  0  |  授予权限。  |
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci### SupportWindowMode
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci标识该组件所支持的窗口模式。
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci **原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
92e41f4b71Sopenharmony_ci|:----------------:|:---:|:---:|
93e41f4b71Sopenharmony_ci| FULL_SCREEN      | 0   | 窗口支持全屏显示。 |
94e41f4b71Sopenharmony_ci| SPLIT            | 1   | 窗口支持分屏显示。 |
95e41f4b71Sopenharmony_ci| FLOATING         | 2   | 支持窗口化显示。   |
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci### LaunchType
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci指示组件的启动方式。
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci **原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
106e41f4b71Sopenharmony_ci|:----------------:|:---:|:---:|
107e41f4b71Sopenharmony_ci| SINGLETON        | 0   | ability的启动模式,表示单实例。 |
108e41f4b71Sopenharmony_ci| MULTITON         | 1   | ability的启动模式,表示普通多实例。 |
109e41f4b71Sopenharmony_ci| SPECIFIED        | 2   | ability的启动模式,表示该ability内部根据业务自己指定多实例。 |
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci### AbilityType
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci指示Ability组件的类型。
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci **模型约束:** 仅可在FA模型下使用
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci|  名称   | 值   |                            说明                            |
120e41f4b71Sopenharmony_ci| :-----: | ---- | :--------------------------------------------------------: |
121e41f4b71Sopenharmony_ci| PAGE    | 1    | UI界面类型的Ability。表示基于Page模板开发的FA,用于提供与用户交互的能力。        |
122e41f4b71Sopenharmony_ci| SERVICE | 2    | 后台服务类型的Ability,无UI界面。表示基于Service模板开发的PA,用于提供后台运行任务的能力。  |
123e41f4b71Sopenharmony_ci|  DATA   | 3    | 表示基于Data模板开发的PA,用于对外部提供统一的数据访问对象。 |
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci### DisplayOrientation
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci标识该Ability的显示模式。该标签仅适用于page类型的Ability。
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci| 名称                               |值 |说明 |
132e41f4b71Sopenharmony_ci|:----------------------------------|---|---|
133e41f4b71Sopenharmony_ci| UNSPECIFIED                        |0 |表示未定义方向模式,由系统判定。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
134e41f4b71Sopenharmony_ci| LANDSCAPE                          |1 |表示横屏显示模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
135e41f4b71Sopenharmony_ci| PORTRAIT                           |2 |表示竖屏显示模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
136e41f4b71Sopenharmony_ci| FOLLOW_RECENT                      |3 |表示跟随上一个显示模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
137e41f4b71Sopenharmony_ci| LANDSCAPE_INVERTED                 |4 |表示反向横屏显示模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
138e41f4b71Sopenharmony_ci| PORTRAIT_INVERTED                  |5 |表示反向竖屏显示模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
139e41f4b71Sopenharmony_ci| AUTO_ROTATION                      |6 |表示传感器自动旋转模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
140e41f4b71Sopenharmony_ci| AUTO_ROTATION_LANDSCAPE            |7 |表示传感器自动横向旋转模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
141e41f4b71Sopenharmony_ci| AUTO_ROTATION_PORTRAIT             |8 |表示传感器自动竖向旋转模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
142e41f4b71Sopenharmony_ci| AUTO_ROTATION_RESTRICTED           |9 |表示受开关控制的自动旋转模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
143e41f4b71Sopenharmony_ci| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|表述受开关控制的自动横向旋转模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。|
144e41f4b71Sopenharmony_ci| AUTO_ROTATION_PORTRAIT_RESTRICTED  |11|表示受开关控制的自动竖向旋转模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。|
145e41f4b71Sopenharmony_ci| LOCKED                             |12|表示锁定模式。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。|
146e41f4b71Sopenharmony_ci| AUTO_ROTATION_UNSPECIFIED<sup>12+</sup> |13|受开关控制和由系统判定的自动旋转模式。<br/>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。|
147e41f4b71Sopenharmony_ci| FOLLOW_DESKTOP<sup>12+</sup> |14|跟随桌面的旋转模式。<br/>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。|
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci### CompatiblePolicy<sup>10+</sup>
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci标识共享库的版本兼容类型。
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci **原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci| 名称                   | 值   | 说明                             |
158e41f4b71Sopenharmony_ci| ---------------------- | ---- | -------------------------------- |
159e41f4b71Sopenharmony_ci| BACKWARD_COMPATIBILITY | 1    | 该字段表明共享库是向后兼容类型。 |
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci### ModuleType
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci标识模块类型。
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci **原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci| 名称    | 值   | 说明                 |
170e41f4b71Sopenharmony_ci| ------- | ---- | -------------------- |
171e41f4b71Sopenharmony_ci| ENTRY   | 1    | 应用的主模块。   |
172e41f4b71Sopenharmony_ci| FEATURE | 2    | 应用的动态特性模块。 |
173e41f4b71Sopenharmony_ci| SHARED  | 3    | 应用的动态共享库模块。  |
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci### BundleType
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci标识应用的类型。
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci **原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci| 名称           | 值   | 说明            |
184e41f4b71Sopenharmony_ci| -------------- | ---- | --------------- |
185e41f4b71Sopenharmony_ci| APP            | 0    | 该Bundle是应用。    |
186e41f4b71Sopenharmony_ci| ATOMIC_SERVICE | 1    | 该Bundle是原子化服务。 |
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci### MultiAppModeType<sup>12+</sup>
189e41f4b71Sopenharmony_ci标识应用多开的模式类型。
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci **系统能力:** SystemCapability.BundleManager.BundleFramework.Core192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
194e41f4b71Sopenharmony_ci|:----------------:|:---:|:---:|
195e41f4b71Sopenharmony_ci| UNSPECIFIED|  0 | 未指定类型。 |
196e41f4b71Sopenharmony_ci| MULTI_INSTANCE |  1  | 多实例模式。常驻进程不支持该字段。  |
197e41f4b71Sopenharmony_ci| APP_CLONE |  2  |  分身模式。  |
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci## 接口
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci### bundleManager.getBundleInfoForSelf
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_cigetBundleInfoForSelf(bundleFlags: number): Promise\<BundleInfo>
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci以异步方法根据给定的bundleFlags获取当前应用的BundleInfo,使用Promise形式返回结果。
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci**参数:**
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci| 参数名     | 类型   | 必填 | 说明                |
214e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------- |
215e41f4b71Sopenharmony_ci| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | 是   | 指定返回的BundleInfo所包含的信息。 |
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**返回值:**
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci| 类型                                                        | 说明                                  |
220e41f4b71Sopenharmony_ci| ----------------------------------------------------------- | ------------------------------------- |
221e41f4b71Sopenharmony_ci| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回当前应用的BundleInfo。|
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci**错误码:**
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
228e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
229e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**示例:**
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci```ts
234e41f4b71Sopenharmony_ci// 额外获取带有metadataArray信息的appInfo
235e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
236e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
237e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_citry {
242e41f4b71Sopenharmony_ci  bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
243e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
244e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
245e41f4b71Sopenharmony_ci    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
246e41f4b71Sopenharmony_ci  });
247e41f4b71Sopenharmony_ci} catch (err) {
248e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
249e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
250e41f4b71Sopenharmony_ci}
251e41f4b71Sopenharmony_ci```
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci### bundleManager.getBundleInfoForSelf
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_cigetBundleInfoForSelf(bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci以异步方法根据给定的bundleFlags获取当前应用的BundleInfo,使用callback形式返回结果。
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci**参数:**
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci| 参数名     | 类型   | 必填 | 说明                |
266e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------- |
267e41f4b71Sopenharmony_ci| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | 是   | 指定返回的BundleInfo所包含的信息。 |
268e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的当前应用的BundleInfo;否则为错误对象。 |
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci**错误码:**
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
275e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
276e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**示例:**
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci```ts
281e41f4b71Sopenharmony_ci// 额外获取带有permissions信息的abilitiesInfo
282e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
283e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
284e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_citry {
289e41f4b71Sopenharmony_ci  bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
290e41f4b71Sopenharmony_ci    if (err) {
291e41f4b71Sopenharmony_ci      hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
292e41f4b71Sopenharmony_ci    } else {
293e41f4b71Sopenharmony_ci      hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
294e41f4b71Sopenharmony_ci    }
295e41f4b71Sopenharmony_ci  });
296e41f4b71Sopenharmony_ci} catch (err) {
297e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
298e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
299e41f4b71Sopenharmony_ci}
300e41f4b71Sopenharmony_ci```
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci### bundleManager.getProfileByAbility
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_cigetProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci以异步方法根据给定的moduleName、abilityName和metadataName(module.json中[metadata标签](../../quick-start/module-configuration-file.md#metadata标签)下的name)获取相应配置文件的json格式字符串,使用callback形式返回结果。
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci>如果配置文件信息采用了资源引用格式,则返回值将保持资源引用格式(例如 $string:res_id),开发者可以通过资源管理模块的相关接口,来获取引用的资源。
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci**参数:**
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci| 参数名       | 类型                          | 必填 | 说明                                                         |
317e41f4b71Sopenharmony_ci| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
318e41f4b71Sopenharmony_ci| moduleName   | string                        | 是   | 表示Module名称。                                     |
319e41f4b71Sopenharmony_ci| abilityName  | string                        | 是   | 表示UIAbility组件的名称。                                    |
320e41f4b71Sopenharmony_ci| metadataName | string                        | 是   | 表示UIAbility组件的元信息名称,即module.json5配置文件中abilities标签下的metadata标签的name。                                  |
321e41f4b71Sopenharmony_ci| callback     | AsyncCallback<Array\<string>> | 是   | 回调函数,当获取成功时,err为null,data为获取到的Array\<string>;否则为错误对象。 |
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci**错误码:**
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
328e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
329e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
330e41f4b71Sopenharmony_ci| 17700002 | The specified moduleName is not existed.                      |
331e41f4b71Sopenharmony_ci| 17700003 | The specified abilityName is not existed.                     |
332e41f4b71Sopenharmony_ci| 17700024 | Failed to get the profile because there is no profile in the HAP. |
333e41f4b71Sopenharmony_ci| 17700026 | The specified bundle is disabled.                             |
334e41f4b71Sopenharmony_ci| 17700029 | The specified ability is disabled.                            |
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**示例:**
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci```ts
339e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
340e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
341e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_cilet moduleName = 'entry';
344e41f4b71Sopenharmony_cilet abilityName = 'EntryAbility';
345e41f4b71Sopenharmony_cilet metadataName = 'ability_metadata';
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_citry {
348e41f4b71Sopenharmony_ci  bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
349e41f4b71Sopenharmony_ci    if (err) {
350e41f4b71Sopenharmony_ci      hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
351e41f4b71Sopenharmony_ci    } else {
352e41f4b71Sopenharmony_ci      hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data));
353e41f4b71Sopenharmony_ci    }
354e41f4b71Sopenharmony_ci  });
355e41f4b71Sopenharmony_ci} catch (err) {
356e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
357e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
358e41f4b71Sopenharmony_ci}
359e41f4b71Sopenharmony_ci```
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci### bundleManager.getProfileByAbility
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_cigetProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\>
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci以异步方法根据给定的moduleName、abilityName和metadataName(module.json中[metadata标签](../../quick-start/module-configuration-file.md#metadata标签)下的name)获取相应配置文件的json格式字符串,使用Promise形式返回结果。
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci>如果配置文件信息采用了资源引用格式,则返回值将保持资源引用格式(例如 $string:res_id),开发者可以通过资源管理模块的相关接口,来获取引用的资源。
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ci**参数:**
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci| 参数名       | 类型   | 必填 | 说明                       |
376e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | -------------------------- |
377e41f4b71Sopenharmony_ci| moduleName   | string | 是   | 表示Module名称。   |
378e41f4b71Sopenharmony_ci| abilityName  | string | 是   | 表示UIAbility组件的名称。  |
379e41f4b71Sopenharmony_ci| metadataName | string | 否   | 表示UIAbility组件的元信息名称,即module.json5配置文件中abilities标签下的metadata标签的name,默认值为空。 |
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci**返回值:**
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci| 类型                    | 说明                            |
384e41f4b71Sopenharmony_ci| ----------------------- | ------------------------------- |
385e41f4b71Sopenharmony_ci| Promise<Array\<string>> | Promise对象,返回Array\<string>。 |
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci**错误码:**
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
392e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
393e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
394e41f4b71Sopenharmony_ci| 17700002 | The specified moduleName is not existed.                      |
395e41f4b71Sopenharmony_ci| 17700003 | The specified abilityName is not existed.                     |
396e41f4b71Sopenharmony_ci| 17700024 | Failed to get the profile because there is no profile in the HAP. |
397e41f4b71Sopenharmony_ci| 17700026 | The specified bundle is disabled.                             |
398e41f4b71Sopenharmony_ci| 17700029 | The specified ability is disabled.                            |
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci**示例:**
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci```ts
403e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
404e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
405e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_cilet moduleName = 'entry';
408e41f4b71Sopenharmony_cilet abilityName = 'EntryAbility';
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_citry {
411e41f4b71Sopenharmony_ci  bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
412e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
413e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
414e41f4b71Sopenharmony_ci    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
415e41f4b71Sopenharmony_ci  });
416e41f4b71Sopenharmony_ci} catch (err) {
417e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
418e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
419e41f4b71Sopenharmony_ci}
420e41f4b71Sopenharmony_ci```
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci```ts
423e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
424e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
425e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_cilet moduleName = 'entry';
428e41f4b71Sopenharmony_cilet abilityName = 'EntryAbility';
429e41f4b71Sopenharmony_cilet metadataName = 'ability_metadata';
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_citry {
432e41f4b71Sopenharmony_ci  bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
433e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
434e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
435e41f4b71Sopenharmony_ci    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
436e41f4b71Sopenharmony_ci  });
437e41f4b71Sopenharmony_ci} catch (err) {
438e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
439e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
440e41f4b71Sopenharmony_ci}
441e41f4b71Sopenharmony_ci```
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci### bundleManager.getProfileByAbilitySync<sup>10+</sup>
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_cigetProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?: string): Array\<string\>
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci以同步方法根据给定的moduleName、abilityName和metadataName(module.json中[metadata标签](../../quick-start/module-configuration-file.md#metadata标签)下的name)获取相应配置文件的json格式字符串,返回对象为string数组。
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci>如果配置文件信息采用了资源引用格式,则返回值将保持资源引用格式(例如 $string:res_id),开发者可以通过资源管理模块的相关接口,来获取引用的资源。
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci**参数:**
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci| 参数名       | 类型   | 必填 | 说明                       |
458e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | -------------------------- |
459e41f4b71Sopenharmony_ci| moduleName   | string | 是   | 表示Module名称。   |
460e41f4b71Sopenharmony_ci| abilityName  | string | 是   | 表示UIAbility组件的名称。  |
461e41f4b71Sopenharmony_ci| metadataName | string | 否   | 表示UIAbility组件的元信息名称,即module.json5配置文件中abilities标签下的metadata标签的name,默认值为空。 |
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci**返回值:**
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ci| 类型                    | 说明                            |
466e41f4b71Sopenharmony_ci| ----------------------- | ------------------------------- |
467e41f4b71Sopenharmony_ci| Array\<string> | 数组对象,返回Array\<string>。 |
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci**错误码:**
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
474e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
475e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
476e41f4b71Sopenharmony_ci| 17700002 | The specified moduleName is not existed.                      |
477e41f4b71Sopenharmony_ci| 17700003 | The specified abilityName is not existed.                     |
478e41f4b71Sopenharmony_ci| 17700024 | Failed to get the profile because there is no profile in the HAP. |
479e41f4b71Sopenharmony_ci| 17700026 | The specified bundle is disabled.                             |
480e41f4b71Sopenharmony_ci| 17700029 | The specified ability is disabled.                            |
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci**示例:**
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci```ts
485e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
486e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
487e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_cilet moduleName = 'entry';
490e41f4b71Sopenharmony_cilet abilityName = 'EntryAbility';
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_citry {
493e41f4b71Sopenharmony_ci  let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName);
494e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
495e41f4b71Sopenharmony_ci} catch (err) {
496e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
497e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
498e41f4b71Sopenharmony_ci}
499e41f4b71Sopenharmony_ci```
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci```ts
502e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
503e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
504e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_cilet moduleName: string = 'entry';
507e41f4b71Sopenharmony_cilet abilityName: string = 'EntryAbility';
508e41f4b71Sopenharmony_cilet metadataName: string = 'ability_metadata';
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_citry {
511e41f4b71Sopenharmony_ci  let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName);
512e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
513e41f4b71Sopenharmony_ci} catch (err) {
514e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
515e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
516e41f4b71Sopenharmony_ci}
517e41f4b71Sopenharmony_ci```
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci### bundleManager.getProfileByExtensionAbility
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_cigetProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci以异步方法根据给定的moduleName、extensionAbilityName和metadataName(module.json中[metadata标签](../../quick-start/module-configuration-file.md#metadata标签)下的name)获取相应配置文件的json格式字符串,使用callback形式返回结果。
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci>如果配置文件信息采用了资源引用格式,则返回值将保持资源引用格式(例如 $string:res_id),开发者可以通过资源管理模块的相关接口,来获取引用的资源。
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci**参数:**
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci| 参数名                 | 类型                          | 必填 | 说明                                                         |
534e41f4b71Sopenharmony_ci| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
535e41f4b71Sopenharmony_ci| moduleName           | string                        | 是   | 表示Module名称。                                   |
536e41f4b71Sopenharmony_ci| extensionAbilityName | string                        | 是   | 表示ExtensionAbility组件的名称。                         |
537e41f4b71Sopenharmony_ci| metadataName         | string                        | 是   | 表示ExtensionAbility组件的名称。组件的元信息名称,即module.json5配置文件中extensionAbilities标签下的metadata标签的name。                                 |
538e41f4b71Sopenharmony_ci| callback             | AsyncCallback<Array\<string>> | 是   | 回调函数,当获取成功时,err为null,data为获取到的Array\<string>;否则为错误对象。 |
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci**错误码:**
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
545e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
546e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
547e41f4b71Sopenharmony_ci| 17700002 | The specified moduleName is not existed.                      |
548e41f4b71Sopenharmony_ci| 17700003 | The specified extensionAbilityName not existed.            |
549e41f4b71Sopenharmony_ci| 17700024 | Failed to get the profile because there is no profile in the HAP. |
550e41f4b71Sopenharmony_ci| 17700026 | The specified bundle is disabled.                             |
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci**示例:**
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci```ts
555e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
556e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
557e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_cilet moduleName = 'entry';
560e41f4b71Sopenharmony_cilet extensionAbilityName = 'com.example.myapplication.extension';
561e41f4b71Sopenharmony_cilet metadataName = 'ability_metadata';
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_citry {
564e41f4b71Sopenharmony_ci  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
565e41f4b71Sopenharmony_ci    if (err) {
566e41f4b71Sopenharmony_ci      hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message);
567e41f4b71Sopenharmony_ci    } else {
568e41f4b71Sopenharmony_ci      hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data));
569e41f4b71Sopenharmony_ci    }
570e41f4b71Sopenharmony_ci  });
571e41f4b71Sopenharmony_ci} catch (err) {
572e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
573e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message);
574e41f4b71Sopenharmony_ci}
575e41f4b71Sopenharmony_ci```
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci### bundleManager.getProfileByExtensionAbility
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_cigetProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\>
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci以异步方法根据给定的moduleName、extensionAbilityName和metadataName(module.json中[metadata标签](../../quick-start/module-configuration-file.md#metadata标签)下的name)获取相应配置文件的json格式字符串,使用Promise形式返回结果。
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci>如果配置文件信息采用了资源引用格式,则返回值将保持资源引用格式(例如 $string:res_id),开发者可以通过资源管理模块的相关接口,来获取引用的资源。
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci**参数:**
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci| 参数名                 | 类型   | 必填 | 说明                               |
592e41f4b71Sopenharmony_ci| -------------------- | ------ | ---- | ---------------------------------- |
593e41f4b71Sopenharmony_ci| moduleName           | string | 是   | 表示Module名称。           |
594e41f4b71Sopenharmony_ci| extensionAbilityName | string | 是   | 表示ExtensionAbility组件的名称。 |
595e41f4b71Sopenharmony_ci| metadataName         | string | 否   | 表示ExtensionAbility组件的名称。组件的元信息名称,即module.json5配置文件中extensionAbilities标签下的metadata标签的name,默认值为空。         |
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci**返回值:**
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci| 类型                    | 说明                                |
600e41f4b71Sopenharmony_ci| ----------------------- | ----------------------------------- |
601e41f4b71Sopenharmony_ci| Promise<Array\<string>> | Promise对象,返回Array\<string>对象。 |
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci**错误码:**
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
608e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
609e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
610e41f4b71Sopenharmony_ci| 17700002 | The specified moduleName is not existed.                      |
611e41f4b71Sopenharmony_ci| 17700003 | The specified extensionAbilityName not existed.            |
612e41f4b71Sopenharmony_ci| 17700024 | Failed to get the profile because there is no profile in the HAP. |
613e41f4b71Sopenharmony_ci| 17700026 | The specified bundle is disabled.                             |
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_ci**示例:**
616e41f4b71Sopenharmony_ci
617e41f4b71Sopenharmony_ci```ts
618e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
619e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
620e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_cilet moduleName = 'entry';
623e41f4b71Sopenharmony_cilet extensionAbilityName = 'com.example.myapplication.extension';
624e41f4b71Sopenharmony_cilet metadataName = 'ability_metadata';
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_citry {
627e41f4b71Sopenharmony_ci  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
628e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
629e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
630e41f4b71Sopenharmony_ci    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
631e41f4b71Sopenharmony_ci  });
632e41f4b71Sopenharmony_ci} catch (err) {
633e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
634e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
635e41f4b71Sopenharmony_ci}
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_citry {
638e41f4b71Sopenharmony_ci  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
639e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
640e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
641e41f4b71Sopenharmony_ci    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
642e41f4b71Sopenharmony_ci  });
643e41f4b71Sopenharmony_ci} catch (err) {
644e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
645e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
646e41f4b71Sopenharmony_ci}
647e41f4b71Sopenharmony_ci```
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci### bundleManager.getProfileByExtensionAbilitySync<sup>10+</sup>
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_cigetProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: string, metadataName?: string): Array\<string\>
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ci以同步方法根据给定的moduleName、extensionAbilityName和metadataName(module.json中[metadata标签](../../quick-start/module-configuration-file.md#metadata标签)下的name)获取相应配置文件的json格式字符串,返回对象为string数组。
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_ci>如果配置文件信息采用了资源引用格式,则返回值将保持资源引用格式(例如 $string:res_id),开发者可以通过资源管理模块的相关接口,来获取引用的资源。
656e41f4b71Sopenharmony_ci
657e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_ci**参数:**
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci| 参数名                 | 类型   | 必填 | 说明                               |
664e41f4b71Sopenharmony_ci| -------------------- | ------ | ---- | ---------------------------------- |
665e41f4b71Sopenharmony_ci| moduleName           | string | 是   | 表示Module名称。           |
666e41f4b71Sopenharmony_ci| extensionAbilityName | string | 是   | 表示ExtensionAbility组件的名称。 |
667e41f4b71Sopenharmony_ci| metadataName         | string | 否   | 表示ExtensionAbility组件的名称。组件的元信息名称,即module.json5配置文件中extensionAbilities标签下的metadata标签的name,默认值为空。         |
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci**返回值:**
670e41f4b71Sopenharmony_ci
671e41f4b71Sopenharmony_ci| 类型                    | 说明                                |
672e41f4b71Sopenharmony_ci| ----------------------- | ----------------------------------- |
673e41f4b71Sopenharmony_ci| Array\<string> | 返回Array\<string>对象。 |
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ci**错误码:**
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
680e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
681e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
682e41f4b71Sopenharmony_ci| 17700002 | The specified moduleName is not existed.                      |
683e41f4b71Sopenharmony_ci| 17700003 | The specified extensionAbilityName not existed.            |
684e41f4b71Sopenharmony_ci| 17700024 | Failed to get the profile because there is no profile in the HAP. |
685e41f4b71Sopenharmony_ci| 17700026 | The specified bundle is disabled.                             |
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ci**示例:**
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci```ts
690e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
691e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
692e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
693e41f4b71Sopenharmony_ci
694e41f4b71Sopenharmony_cilet moduleName = 'entry';
695e41f4b71Sopenharmony_cilet extensionAbilityName = 'com.example.myapplication.extension';
696e41f4b71Sopenharmony_cilet metadataName = 'ability_metadata';
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_citry {
699e41f4b71Sopenharmony_ci  let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
700e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
701e41f4b71Sopenharmony_ci} catch (err) {
702e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
703e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
704e41f4b71Sopenharmony_ci}
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_citry {
707e41f4b71Sopenharmony_ci  let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
708e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
709e41f4b71Sopenharmony_ci} catch (err) {
710e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
711e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
712e41f4b71Sopenharmony_ci}
713e41f4b71Sopenharmony_ci```
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci### bundleManager.getBundleInfoForSelfSync<sup>10+</sup>
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_cigetBundleInfoForSelfSync(bundleFlags: number): BundleInfo
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci以同步方法根据给定的bundleFlags获取当前应用的BundleInfo。
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci**参数:**
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci| 参数名     | 类型   | 必填 | 说明                |
728e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------- |
729e41f4b71Sopenharmony_ci| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | 是   | 指定返回的BundleInfo所包含的信息。 |
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**返回值:**
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci| 类型                                              | 说明                 |
734e41f4b71Sopenharmony_ci| ------------------------------------------------- | -------------------- |
735e41f4b71Sopenharmony_ci| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 返回BundleInfo对象。 |
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**错误码:**
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
742e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
743e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ci**示例:**
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci```ts
748e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
749e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
750e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_citry {
755e41f4b71Sopenharmony_ci  let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
756e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
757e41f4b71Sopenharmony_ci} catch (err) {
758e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
759e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message);
760e41f4b71Sopenharmony_ci}
761e41f4b71Sopenharmony_ci```
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci### bundleManager.canOpenLink<sup>12+</sup>
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_cicanOpenLink(link: string): boolean
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ci查询给定的链接是否可以打开。指定链接的scheme需要在module.json文件的querySchemes字段下配置。
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**参数:**
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci| 参数名     | 类型   | 必填 | 说明                |
776e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | --------------------- |
777e41f4b71Sopenharmony_ci| link | string | 是   | 表示需要查询的链接。 |
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ci**返回值:**
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci| 类型                                              | 说明                 |
782e41f4b71Sopenharmony_ci| ------------------------------------------------- | -------------------- |
783e41f4b71Sopenharmony_ci| boolean | 返回true表示给定的链接可以打开,返回false表示给定的链接不能打开。 |
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ci**错误码:**
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
790e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
791e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
792e41f4b71Sopenharmony_ci| 17700055 | The specified link is invalid.                      |
793e41f4b71Sopenharmony_ci| 17700056 | The scheme of the specified link is not in the querySchemes.        |
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ci**示例:**
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci```ts
798e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
799e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
800e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_citry {
803e41f4b71Sopenharmony_ci  let link = 'welink://';
804e41f4b71Sopenharmony_ci  let data = bundleManager.canOpenLink(link);
805e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'canOpenLink successfully: %{public}s', JSON.stringify(data));
806e41f4b71Sopenharmony_ci} catch (err) {
807e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
808e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'canOpenLink failed: %{public}s', message);
809e41f4b71Sopenharmony_ci}
810e41f4b71Sopenharmony_ci```
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci### bundleManager.getLaunchWant<sup>13+</sup>
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_cigetLaunchWant(): Want
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci获取自身用于启动应用程序的Want参数。
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**返回值:**
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci| 类型                                | 说明                                        |
825e41f4b71Sopenharmony_ci| ----------------------------------- | ------------------------------------------- |
826e41f4b71Sopenharmony_ci| [Want](js-apis-app-ability-want.md) | 返回包含Bundle名称和Ability名称的Want对象。 |
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci**错误码:**
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                      |
833e41f4b71Sopenharmony_ci| -------- | ----------------------------- |
834e41f4b71Sopenharmony_ci| 17700072 | The launch want is not found. |
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci**示例:**
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci```ts
839e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
840e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
841e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
842e41f4b71Sopenharmony_ci
843e41f4b71Sopenharmony_citry {
844e41f4b71Sopenharmony_ci  let want = bundleManager.getLaunchWant();
845e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getLaunchWant ability name: %{public}s', want.abilityName);
846e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'getLaunchWant bundle name: %{public}s', want.bundleName);
847e41f4b71Sopenharmony_ci} catch (error) {
848e41f4b71Sopenharmony_ci  let message = (error as BusinessError).message;
849e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'getLaunchWant failed: %{public}s', message);
850e41f4b71Sopenharmony_ci}
851e41f4b71Sopenharmony_ci```