1# @ohos.bundle.bundleManager (bundleManager)
2
3The bundleManager module provides APIs for obtaining application information, including [BundleInfo](js-apis-bundleManager-bundleInfo.md), [ApplicationInfo](js-apis-bundleManager-applicationInfo.md), [AbilityInfo](js-apis-bundleManager-abilityInfo.md), and [ExtensionAbility](js-apis-bundleManager-extensionAbilityInfo.md).
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { bundleManager } from '@kit.AbilityKit';
13```
14
15## Enums
16
17### BundleFlag
18
19Enumerates the bundle flags, which indicate the type of bundle information to obtain.
20
21 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
22
23| Name                                         | Value        | Description                                                        |
24| --------------------------------------------- | ---------- | ------------------------------------------------------------ |
25| GET_BUNDLE_INFO_DEFAULT                       | 0x00000000 | Used to obtain the default bundle information. The obtained information does not contain information about the signature, application, HAP module, ability, ExtensionAbility, or permission.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
26| GET_BUNDLE_INFO_WITH_APPLICATION              | 0x00000001 | Used to obtain the bundle information with application information. The obtained information does not contain information about the signature, HAP module, ability, ExtensionAbility, or permission.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
27| GET_BUNDLE_INFO_WITH_HAP_MODULE               | 0x00000002 | Used to obtain the bundle information with HAP module information. The obtained information does not contain information about the signature, application, ability, ExtensionAbility, or permission.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
28| GET_BUNDLE_INFO_WITH_ABILITY                  | 0x00000004 | Used to obtain the bundle information with ability information. The obtained information does not contain information about the signature, application, ExtensionAbility, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
29| GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY        | 0x00000008 | Used to obtain the bundle information with ExtensionAbility information. The obtained information does not contain information about the signature, application, ability, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
30| GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION     | 0x00000010 | Used to obtain the bundle information with permission information. The obtained information does not contain information about the signature, application, HAP module, ability, or ExtensionAbility.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
31| GET_BUNDLE_INFO_WITH_METADATA                 | 0x00000020 | Used to obtain the metadata contained in the application, HAP module, ability, or ExtensionAbility information. It must be used together with **GET_BUNDLE_INFO_WITH_APPLICATION**, **GET_BUNDLE_INFO_WITH_HAP_MODULE**, **GET_BUNDLE_INFO_WITH_ABILITY**, and **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
32| GET_BUNDLE_INFO_WITH_DISABLE                  | 0x00000040 | Used to obtain the information about disabled bundles and abilities of a bundle. The obtained information does not contain information about the signature, application, HAP module, ability, ExtensionAbility, or permission.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
33| GET_BUNDLE_INFO_WITH_SIGNATURE_INFO           | 0x00000080 | Used to obtain the bundle information with signature information. The obtained information does not contain information about the application, HAP module, ability, ExtensionAbility, or permission.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
34| GET_BUNDLE_INFO_WITH_MENU<sup>11+</sup>       | 0x00000100 | Used to obtain the bundle information with the file context menu configuration. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
35| GET_BUNDLE_INFO_WITH_ROUTER_MAP<sup>12+</sup> | 0x00000200 | Used to obtain the bundle information with the router map. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
36| GET_BUNDLE_INFO_WITH_SKILL<sup>12+</sup>      | 0x00000800 | Used to obtain the bundle information with the skills. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**, **GET_BUNDLE_INFO_WITH_ABILITY**, and **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
37
38### ExtensionAbilityType
39
40Enumerates the types of ExtensionAbilities.
41
42 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
43
44| Name| Value| Description|
45|:----------------:|:---:|-----|
46| FORM             | 0   | [FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md): provides APIs for widget development.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
47| WORK_SCHEDULER   | 1   | [WorkSchedulerExtensionAbility](../apis-backgroundtasks-kit/js-apis-WorkSchedulerExtensionAbility.md): enables applications to execute non-real-time tasks when the system is idle.|
48| INPUT_METHOD     | 2   | [InputMethodExtensionAbility](../apis-ime-kit/js-apis-inputmethod-extension-ability.md): provides APIs for developing input method applications.|
49| SERVICE          | 3   | <!--Del-->[<!--DelEnd-->ServiceExtensionAbility<!--Del-->](js-apis-app-ability-serviceExtensionAbility-sys.md)<!--DelEnd-->: enables applications to run in the background and provide services.|
50| ACCESSIBILITY    | 4   | [AccessibilityExtensionAbility](https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/is-inner-application-accessibilityextensioncontext-V5): provides accessibility for access to and operations on the UI.|
51| DATA_SHARE       | 5   | <!--Del-->[<!--DelEnd-->DataShareExtensionAbility <!--Del-->](../apis-arkdata/js-apis-application-dataShareExtensionAbility-sys.md)<!--DelEnd-->: enables applications to read and write data.|
52| FILE_SHARE       | 6   | FileShareExtensionAbility: enables file sharing between applications. This ability is reserved and supported only by system applications.|
53| STATIC_SUBSCRIBER| 7   | <!--Del-->[<!--DelEnd-->StaticSubscriberExtensionAbility <!--Del-->](../apis-basic-services-kit/js-apis-application-staticSubscriberExtensionAbility-sys.md)<!--DelEnd-->: provides APIs for processing static events, such as the startup event.|
54| WALLPAPER        | 8   | WallpaperExtensionAbility: provides APIs to implement the home screen wallpaper. This ability is reserved and supported only by system applications.|
55| BACKUP           |  9  | [BackupExtensionAbility](../apis-core-file-kit/js-apis-application-backupExtensionAbility.md): provides APIs to implement application data backup and restore.|
56| WINDOW           |  10 | <!--Del-->[<!--DelEnd-->WindowExtensionAbility<!--Del-->](../apis-arkui/js-apis-application-windowExtensionAbility-sys.md)<!--DelEnd-->: allows system applications to display UIs of other applications.|
57| ENTERPRISE_ADMIN |  11 | [EnterpriseAdminExtensionAbility](../apis-mdm-kit/js-apis-EnterpriseAdminExtensionAbility.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.|
58| THUMBNAIL        | 13  | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved and supported only by system applications.|
59| PREVIEW          | 14  | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved and supported only by system applications.|
60| PRINT<sup>10+</sup> | 15 | PrintExtensionAbility: provides APIs for printing images. This ability is supported only by system applications.|
61| SHARE<sup>10+</sup> | 16 | [ShareExtensionAbility](js-apis-app-ability-shareExtensionAbility.md): provides sharing service templates based on UIExtensionAbilities.|
62| PUSH<sup>10+</sup> | 17 | PushExtensionAbility: provides APIs for pushing scenario-specific messages. This ability is reserved and supported only by system applications.|
63| DRIVER<sup>10+</sup> | 18 | [DriverExtensionAbility](../apis-driverdevelopment-kit/js-apis-app-ability-driverExtensionAbility.md): provides APIs for the peripheral driver. This ability is supported only by system applications.|
64| ACTION<sup>10+</sup> | 19 | [ActionExtensionAbility](js-apis-app-ability-actionExtensionAbility.md): provides custom action service templates based on UIExtensionAbilities.|
65| ADS_SERVICE<sup>11+</sup> | 20 | AdsServiceExtensionAbility: provides background customized ad services for external systems. This ability is supported only by system applications.|
66| EMBEDDED_UI<sup>12+</sup> | 21 | [EmbeddedUIExtensionAbility](js-apis-app-ability-embeddedUIExtensionAbility.md): provides ExtensionAbilities for the embeddable UI across process.|
67| INSIGHT_INTENT_UI<sup>12+</sup> | 22 | **InsightIntentUIExtensionAbility**: provides APIs that enable applications to be called by Celia intents so as to be displayed in windows.|
68| UNSPECIFIED      | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of ExtensionAbilities.|
69
70
71### PermissionGrantState
72
73Enumerates the permission grant states.
74
75 **Atomic service API**: This API can be used in atomic services since API version 11.
76
77 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
78
79| Name| Value| Description|
80|:----------------:|:---:|:---:|
81| PERMISSION_DENIED|  -1 | Permission denied.|
82| PERMISSION_GRANTED |  0  |  Permission granted. |
83
84### SupportWindowMode
85
86Enumerates the window modes supported by the ability.
87
88 **Atomic service API**: This API can be used in atomic services since API version 11.
89
90 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
91
92| Name| Value| Description|
93|:----------------:|:---:|:---:|
94| FULL_SCREEN      | 0   | A window in full-screen mode is supported.|
95| SPLIT            | 1   | A window in split-screen mode is supported.|
96| FLOATING         | 2   | A floating window is supported.  |
97
98### LaunchType
99
100Enumerates the launch types of the ability.
101
102 **Atomic service API**: This API can be used in atomic services since API version 11.
103
104 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
105
106| Name| Value| Description|
107|:----------------:|:---:|:---:|
108| SINGLETON        | 0   | The ability can have only one instance.|
109| MULTITON         | 1   | The ability can have multiple instances.|
110| SPECIFIED        | 2   | The ability can have one or multiple instances, depending on the internal service of the ability.|
111
112### AbilityType
113
114Enumerates the types of abilities.
115
116 **Model restriction**: This API can be used only in the FA model.
117
118 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
119
120|  Name  | Value  |                            Description                           |
121| :-----: | ---- | :--------------------------------------------------------: |
122| PAGE    | 1    | Ability that has the UI. FA developed using the Page template to provide the capability of interacting with users.       |
123| SERVICE | 2    | Ability of the background service type, without the UI. PA developed using the Service template to provide the capability of running tasks in the background. |
124|  DATA   | 3    | PA developed using the Data template to provide unified data access for external systems.|
125
126### DisplayOrientation
127
128Enumerates the display orientations of the ability. This property applies only to the ability using the Page template.
129
130 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
131
132| Name                              |Value|Description|
133|:----------------------------------|---|---|
134| UNSPECIFIED                        |0 |Unspecified. The orientation is determined by the system.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
135| LANDSCAPE                          |1 |Landscape.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
136| PORTRAIT                           |2 |Portrait.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
137| FOLLOW_RECENT                      |3 |The last display orientation is used.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
138| LANDSCAPE_INVERTED                 |4 |Reverse landscape.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
139| PORTRAIT_INVERTED                  |5 |Reverse portrait.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
140| AUTO_ROTATION                      |6 |Auto rotation.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
141| AUTO_ROTATION_LANDSCAPE            |7 |Auto rotation in the horizontal direction.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
142| AUTO_ROTATION_PORTRAIT             |8 |Auto rotation in the vertical direction.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
143| AUTO_ROTATION_RESTRICTED           |9 |Switched-determined auto rotation.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
144| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|Switched-determined auto rotation in the horizontal direction.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
145| AUTO_ROTATION_PORTRAIT_RESTRICTED  |11|Switched-determined auto rotation in the vertical direction.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
146| LOCKED                             |12|Locked.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
147| AUTO_ROTATION_UNSPECIFIED<sup>12+</sup> |13|Auto rotation controlled by the switch and determined by the system.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
148| FOLLOW_DESKTOP<sup>12+</sup> |14|Following the orientation of the home screen.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
149
150### CompatiblePolicy<sup>10+</sup>
151
152Defines the version compatibility type of the shared library.
153
154 **Atomic service API**: This API can be used in atomic services since API version 11.
155
156 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
157
158| Name                  | Value  | Description                            |
159| ---------------------- | ---- | -------------------------------- |
160| BACKWARD_COMPATIBILITY | 1    | The shared library is backward compatible.|
161
162### ModuleType
163
164Enumerates the module types.
165
166 **Atomic service API**: This API can be used in atomic services since API version 11.
167
168 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
169
170| Name   | Value  | Description                |
171| ------- | ---- | -------------------- |
172| ENTRY   | 1    | Main module of the application.  |
173| FEATURE | 2    | Dynamic feature module of the application.|
174| SHARED  | 3    | Dynamic shared library module of the application. |
175
176### BundleType
177
178Enumerates the bundle types.
179
180 **Atomic service API**: This API can be used in atomic services since API version 11.
181
182 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
183
184| Name          | Value  | Description           |
185| -------------- | ---- | --------------- |
186| APP            | 0    | The bundle is an application.   |
187| ATOMIC_SERVICE | 1    | The bundle is an atomic service.|
188
189### MultiAppModeType<sup>12+</sup>
190Enumerates the types of the multi-app mode.
191
192 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
193
194| Name| Value| Description|
195|:----------------:|:---:|:---:|
196| UNSPECIFIED|  0 | Unspecified type.|
197| MULTI_INSTANCE |  1  | Multiton mode. A resident process does not support this value. |
198| APP_CLONE |  2  |  App clone mode. |
199
200## APIs
201
202### bundleManager.getBundleInfoForSelf
203
204getBundleInfoForSelf(bundleFlags: number): Promise\<BundleInfo>
205
206Obtains the bundle information of this bundle based on the given bundle flags. This API uses a promise to return the result.
207
208**Atomic service API**: This API can be used in atomic services since API version 11.
209
210**System capability**: SystemCapability.BundleManager.BundleFramework.Core
211
212**Parameters**
213
214| Name    | Type  | Mandatory| Description               |
215| ----------- | ------ | ---- | --------------------- |
216| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
217
218**Return value**
219
220| Type                                                       | Description                                 |
221| ----------------------------------------------------------- | ------------------------------------- |
222| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.|
223
224**Error codes**
225
226For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
227
228| ID| Error Message                                                    |
229| -------- | ------------------------------------------------------------ |
230| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
231
232**Example**
233
234```ts
235// Obtain application info with metadataArray.
236import { bundleManager } from '@kit.AbilityKit';
237import { BusinessError } from '@kit.BasicServicesKit';
238import { hilog } from '@kit.PerformanceAnalysisKit';
239
240let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
241
242try {
243  bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
244    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
245  }).catch((err: BusinessError) => {
246    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
247  });
248} catch (err) {
249  let message = (err as BusinessError).message;
250  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
251}
252```
253
254### bundleManager.getBundleInfoForSelf
255
256getBundleInfoForSelf(bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
257
258Obtains the bundle information of this bundle based on the given bundle flags. This API uses an asynchronous callback to return the result.
259
260**Atomic service API**: This API can be used in atomic services since API version 11.
261
262**System capability**: SystemCapability.BundleManager.BundleFramework.Core
263
264**Parameters**
265
266| Name    | Type  | Mandatory| Description               |
267| ----------- | ------ | ---- | --------------------- |
268| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
269| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.|
270
271**Error codes**
272
273For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
274
275| ID| Error Message                                                    |
276| -------- | ------------------------------------------------------------ |
277| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
278
279**Example**
280
281```ts
282// Obtain ability info with permissions.
283import { bundleManager } from '@kit.AbilityKit';
284import { BusinessError } from '@kit.BasicServicesKit';
285import { hilog } from '@kit.PerformanceAnalysisKit';
286
287let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
288
289try {
290  bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
291    if (err) {
292      hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
293    } else {
294      hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
295    }
296  });
297} catch (err) {
298  let message = (err as BusinessError).message;
299  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
300}
301```
302
303### bundleManager.getProfileByAbility
304
305getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
306
307Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API uses an asynchronous callback to return the result.
308
309> **NOTE**
310> 
311> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module.
312
313**Atomic service API**: This API can be used in atomic services since API version 11.
314
315**System capability**: SystemCapability.BundleManager.BundleFramework.Core
316
317**Parameters**
318
319| Name      | Type                         | Mandatory| Description                                                        |
320| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
321| moduleName   | string                        | Yes  | Module name.                                    |
322| abilityName  | string                        | Yes  | Name of the UIAbility component.                                   |
323| metadataName | string                        | Yes  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file.                                 |
324| callback     | AsyncCallback<Array\<string>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.|
325
326**Error codes**
327
328For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
329
330| ID| Error Message                                                    |
331| -------- | ------------------------------------------------------------ |
332| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
333| 17700002 | The specified moduleName is not existed.                      |
334| 17700003 | The specified abilityName is not existed.                     |
335| 17700024 | Failed to get the profile because there is no profile in the HAP. |
336| 17700026 | The specified bundle is disabled.                             |
337| 17700029 | The specified ability is disabled.                            |
338
339**Example**
340
341```ts
342import { bundleManager } from '@kit.AbilityKit';
343import { BusinessError } from '@kit.BasicServicesKit';
344import { hilog } from '@kit.PerformanceAnalysisKit';
345
346let moduleName = 'entry';
347let abilityName = 'EntryAbility';
348let metadataName = 'ability_metadata';
349
350try {
351  bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
352    if (err) {
353      hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
354    } else {
355      hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data));
356    }
357  });
358} catch (err) {
359  let message = (err as BusinessError).message;
360  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
361}
362```
363
364### bundleManager.getProfileByAbility
365
366getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\>
367
368Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API uses a promise to return the result.
369
370> **NOTE**
371> 
372> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module.
373
374**Atomic service API**: This API can be used in atomic services since API version 11.
375
376**System capability**: SystemCapability.BundleManager.BundleFramework.Core
377
378**Parameters**
379
380| Name      | Type  | Mandatory| Description                      |
381| ------------ | ------ | ---- | -------------------------- |
382| moduleName   | string | Yes  | Module name.  |
383| abilityName  | string | Yes  | Name of the UIAbility component. |
384| metadataName | string | No  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. The default value is null.|
385
386**Return value**
387
388| Type                   | Description                           |
389| ----------------------- | ------------------------------- |
390| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
391
392**Error codes**
393
394For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
395
396| ID| Error Message                                                    |
397| -------- | ------------------------------------------------------------ |
398| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
399| 17700002 | The specified moduleName is not existed.                      |
400| 17700003 | The specified abilityName is not existed.                     |
401| 17700024 | Failed to get the profile because there is no profile in the HAP. |
402| 17700026 | The specified bundle is disabled.                             |
403| 17700029 | The specified ability is disabled.                            |
404
405**Example**
406
407```ts
408import { bundleManager } from '@kit.AbilityKit';
409import { BusinessError } from '@kit.BasicServicesKit';
410import { hilog } from '@kit.PerformanceAnalysisKit';
411
412let moduleName = 'entry';
413let abilityName = 'EntryAbility';
414
415try {
416  bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
417    hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
418  }).catch((err: BusinessError) => {
419    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
420  });
421} catch (err) {
422  let message = (err as BusinessError).message;
423  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
424}
425```
426
427```ts
428import { bundleManager } from '@kit.AbilityKit';
429import { BusinessError } from '@kit.BasicServicesKit';
430import { hilog } from '@kit.PerformanceAnalysisKit';
431
432let moduleName = 'entry';
433let abilityName = 'EntryAbility';
434let metadataName = 'ability_metadata';
435
436try {
437  bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
438    hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
439  }).catch((err: BusinessError) => {
440    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
441  });
442} catch (err) {
443  let message = (err as BusinessError).message;
444  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
445}
446```
447
448### bundleManager.getProfileByAbilitySync<sup>10+</sup>
449
450getProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?: string): Array\<string\>
451
452Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API returns the result synchronously. The result value is a string array.
453
454> **NOTE**
455> 
456> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module.
457
458**Atomic service API**: This API can be used in atomic services since API version 11.
459
460**System capability**: SystemCapability.BundleManager.BundleFramework.Core
461
462**Parameters**
463
464| Name      | Type  | Mandatory| Description                      |
465| ------------ | ------ | ---- | -------------------------- |
466| moduleName   | string | Yes  | Module name.  |
467| abilityName  | string | Yes  | Name of the UIAbility component. |
468| metadataName | string | No  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. The default value is null.|
469
470**Return value**
471
472| Type                   | Description                           |
473| ----------------------- | ------------------------------- |
474| Array\<string> | An array of JSON strings.|
475
476**Error codes**
477
478For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
479
480| ID| Error Message                                                    |
481| -------- | ------------------------------------------------------------ |
482| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
483| 17700002 | The specified moduleName is not existed.                      |
484| 17700003 | The specified abilityName is not existed.                     |
485| 17700024 | Failed to get the profile because there is no profile in the HAP. |
486| 17700026 | The specified bundle is disabled.                             |
487| 17700029 | The specified ability is disabled.                            |
488
489**Example**
490
491```ts
492import { bundleManager } from '@kit.AbilityKit';
493import { BusinessError } from '@kit.BasicServicesKit';
494import { hilog } from '@kit.PerformanceAnalysisKit';
495
496let moduleName = 'entry';
497let abilityName = 'EntryAbility';
498
499try {
500  let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName);
501  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
502} catch (err) {
503  let message = (err as BusinessError).message;
504  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
505}
506```
507
508```ts
509import { bundleManager } from '@kit.AbilityKit';
510import { BusinessError } from '@kit.BasicServicesKit';
511import { hilog } from '@kit.PerformanceAnalysisKit';
512
513let moduleName: string = 'entry';
514let abilityName: string = 'EntryAbility';
515let metadataName: string = 'ability_metadata';
516
517try {
518  let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName);
519  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
520} catch (err) {
521  let message = (err as BusinessError).message;
522  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
523}
524```
525
526### bundleManager.getProfileByExtensionAbility
527
528getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
529
530Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API uses an asynchronous callback to return the result.
531
532> **NOTE**
533> 
534> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module.
535
536**Atomic service API**: This API can be used in atomic services since API version 11.
537
538**System capability**: SystemCapability.BundleManager.BundleFramework.Core
539
540**Parameters**
541
542| Name                | Type                         | Mandatory| Description                                                        |
543| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
544| moduleName           | string                        | Yes  | Module name.                                  |
545| extensionAbilityName | string                        | Yes  | Name of the ExtensionAbility component.                        |
546| metadataName         | string                        | Yes  |  Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file.                                |
547| callback             | AsyncCallback<Array\<string>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.|
548
549**Error codes**
550
551For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
552
553| ID| Error Message                                                    |
554| -------- | ------------------------------------------------------------ |
555| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
556| 17700002 | The specified moduleName is not existed.                      |
557| 17700003 | The specified extensionAbilityName not existed.            |
558| 17700024 | Failed to get the profile because there is no profile in the HAP. |
559| 17700026 | The specified bundle is disabled.                             |
560
561**Example**
562
563```ts
564import { bundleManager } from '@kit.AbilityKit';
565import { BusinessError } from '@kit.BasicServicesKit';
566import { hilog } from '@kit.PerformanceAnalysisKit';
567
568let moduleName = 'entry';
569let extensionAbilityName = 'com.example.myapplication.extension';
570let metadataName = 'ability_metadata';
571
572try {
573  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
574    if (err) {
575      hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message);
576    } else {
577      hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data));
578    }
579  });
580} catch (err) {
581  let message = (err as BusinessError).message;
582  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message);
583}
584```
585
586### bundleManager.getProfileByExtensionAbility
587
588getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\>
589
590Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API uses a promise to return the result.
591
592> **NOTE**
593> 
594> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module.
595
596**Atomic service API**: This API can be used in atomic services since API version 11.
597
598**System capability**: SystemCapability.BundleManager.BundleFramework.Core
599
600**Parameters**
601
602| Name                | Type  | Mandatory| Description                              |
603| -------------------- | ------ | ---- | ---------------------------------- |
604| moduleName           | string | Yes  | Module name.          |
605| extensionAbilityName | string | Yes  | Name of the ExtensionAbility component.|
606| metadataName         | string | No  |  Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. The default value is null.        |
607
608**Return value**
609
610| Type                   | Description                               |
611| ----------------------- | ----------------------------------- |
612| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
613
614**Error codes**
615
616For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
617
618| ID| Error Message                                                    |
619| -------- | ------------------------------------------------------------ |
620| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
621| 17700002 | The specified moduleName is not existed.                      |
622| 17700003 | The specified extensionAbilityName not existed.            |
623| 17700024 | Failed to get the profile because there is no profile in the HAP. |
624| 17700026 | The specified bundle is disabled.                             |
625
626**Example**
627
628```ts
629import { bundleManager } from '@kit.AbilityKit';
630import { BusinessError } from '@kit.BasicServicesKit';
631import { hilog } from '@kit.PerformanceAnalysisKit';
632
633let moduleName = 'entry';
634let extensionAbilityName = 'com.example.myapplication.extension';
635let metadataName = 'ability_metadata';
636
637try {
638  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
639    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
640  }).catch((err: BusinessError) => {
641    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
642  });
643} catch (err) {
644  let message = (err as BusinessError).message;
645  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
646}
647
648try {
649  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
650    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
651  }).catch((err: BusinessError) => {
652    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
653  });
654} catch (err) {
655  let message = (err as BusinessError).message;
656  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
657}
658```
659
660### bundleManager.getProfileByExtensionAbilitySync<sup>10+</sup>
661
662getProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: string, metadataName?: string): Array\<string\>
663
664Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API returns the result synchronously. The result value is a string array.
665
666> **NOTE**
667> 
668> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module.
669
670**Atomic service API**: This API can be used in atomic services since API version 11.
671
672**System capability**: SystemCapability.BundleManager.BundleFramework.Core
673
674**Parameters**
675
676| Name                | Type  | Mandatory| Description                              |
677| -------------------- | ------ | ---- | ---------------------------------- |
678| moduleName           | string | Yes  | Module name.          |
679| extensionAbilityName | string | Yes  | Name of the ExtensionAbility component.|
680| metadataName         | string | No  |  Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. The default value is null.        |
681
682**Return value**
683
684| Type                   | Description                               |
685| ----------------------- | ----------------------------------- |
686| Array\<string> | An array of JSON strings.|
687
688**Error codes**
689
690For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
691
692| ID| Error Message                                                    |
693| -------- | ------------------------------------------------------------ |
694| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
695| 17700002 | The specified moduleName is not existed.                      |
696| 17700003 | The specified extensionAbilityName not existed.            |
697| 17700024 | Failed to get the profile because there is no profile in the HAP. |
698| 17700026 | The specified bundle is disabled.                             |
699
700**Example**
701
702```ts
703import { bundleManager } from '@kit.AbilityKit';
704import { BusinessError } from '@kit.BasicServicesKit';
705import { hilog } from '@kit.PerformanceAnalysisKit';
706
707let moduleName = 'entry';
708let extensionAbilityName = 'com.example.myapplication.extension';
709let metadataName = 'ability_metadata';
710
711try {
712  let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
713  hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
714} catch (err) {
715  let message = (err as BusinessError).message;
716  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
717}
718
719try {
720  let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
721  hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
722} catch (err) {
723  let message = (err as BusinessError).message;
724  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
725}
726```
727
728### bundleManager.getBundleInfoForSelfSync<sup>10+</sup>
729
730getBundleInfoForSelfSync(bundleFlags: number): BundleInfo
731
732Obtains the bundle information of this bundle based on the given bundle flags. This API returns the result synchronously.
733
734**Atomic service API**: This API can be used in atomic services since API version 11.
735
736**System capability**: SystemCapability.BundleManager.BundleFramework.Core
737
738**Parameters**
739
740| Name    | Type  | Mandatory| Description               |
741| ----------- | ------ | ---- | --------------------- |
742| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
743
744**Return value**
745
746| Type                                             | Description                |
747| ------------------------------------------------- | -------------------- |
748| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
749
750**Error codes**
751
752For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
753
754| ID| Error Message                                                    |
755| -------- | ------------------------------------------------------------ |
756| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
757
758**Example**
759
760```ts
761import { bundleManager } from '@kit.AbilityKit';
762import { BusinessError } from '@kit.BasicServicesKit';
763import { hilog } from '@kit.PerformanceAnalysisKit';
764
765let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
766
767try {
768  let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
769  hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
770} catch (err) {
771  let message = (err as BusinessError).message;
772  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message);
773}
774```
775
776### bundleManager.canOpenLink<sup>12+</sup>
777
778canOpenLink(link: string): boolean
779
780Checks whether a link can be opened. The scheme of the specified link must be configured in the **querySchemes** field of the **module.json** file.
781
782**Atomic service API**: This API can be used in atomic services since API version 12.
783
784**System capability**: SystemCapability.BundleManager.BundleFramework.Core
785
786**Parameters**
787
788| Name    | Type  | Mandatory| Description               |
789| ----------- | ------ | ---- | --------------------- |
790| link | string | Yes  | Link to check.|
791
792**Return value**
793
794| Type                                             | Description                |
795| ------------------------------------------------- | -------------------- |
796| boolean | **true**: The link can be opened.<br>**false**: The link cannot be opened.|
797
798**Error codes**
799
800For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
801
802| ID| Error Message                                                    |
803| -------- | ------------------------------------------------------------ |
804| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
805| 17700055 | The specified link is invalid.                      |
806| 17700056 | The scheme of the specified link is not in the querySchemes.        |
807
808**Example**
809
810```ts
811import { bundleManager } from '@kit.AbilityKit';
812import { BusinessError } from '@kit.BasicServicesKit';
813import { hilog } from '@kit.PerformanceAnalysisKit';
814
815try {
816  let link = 'welink://';
817  let data = bundleManager.canOpenLink(link);
818  hilog.info(0x0000, 'testTag', 'canOpenLink successfully: %{public}s', JSON.stringify(data));
819} catch (err) {
820  let message = (err as BusinessError).message;
821  hilog.error(0x0000, 'testTag', 'canOpenLink failed: %{public}s', message);
822}
823```
824
825### bundleManager.getLaunchWant<sup>13+</sup>
826
827getLaunchWant(): Want
828
829Obtains the **Want** parameter used to start the application.
830
831**Atomic service API**: This API can be used in atomic services since API version 13.
832
833**System capability**: SystemCapability.BundleManager.BundleFramework.Core
834
835**Return value**
836
837| Type                               | Description                                       |
838| ----------------------------------- | ------------------------------------------- |
839| [Want](js-apis-app-ability-want.md) | Want object that contains the bundle name and ability name.|
840
841**Error codes**
842
843For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md).
844
845| ID| Error Message                     |
846| -------- | ----------------------------- |
847| 17700072 | The launch want is not found. |
848
849**Example**
850
851```ts
852import { BusinessError } from '@kit.BasicServicesKit';
853import { bundleManager } from '@kit.AbilityKit';
854import { hilog } from '@kit.PerformanceAnalysisKit';
855
856try {
857  let want = bundleManager.getLaunchWant();
858  hilog.info(0x0000, 'testTag', 'getLaunchWant ability name: %{public}s', want.abilityName);
859  hilog.info(0x0000, 'testTag', 'getLaunchWant bundle name: %{public}s', want.bundleName);
860} catch (error) {
861  let message = (error as BusinessError).message;
862  hilog.error(0x0000, 'testTag', 'getLaunchWant failed: %{public}s', message);
863}
864```
865