• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.bundleManager (bundleManager)
2<!--Kit: Ability Kit-->
3<!--Subsystem: BundleManager-->
4<!--Owner: @wanghang904-->
5<!--Designer: @hanfeng6-->
6<!--Tester: @kongjing2-->
7<!--Adviser: @Brilliantry_Rui-->
8
9The module provides APIs for obtaining application information, including [bundle information](js-apis-bundleManager-bundleInfo.md), [application information](js-apis-bundleManager-applicationInfo.md), [ability information](js-apis-bundleManager-abilityInfo.md) (information about a UIAbility), and [ExtensionAbility information](js-apis-bundleManager-extensionAbilityInfo.md).
10
11> **NOTE**
12> 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.
13
14## Modules to Import
15
16```ts
17import { bundleManager } from '@kit.AbilityKit';
18```
19
20## BundleFlag
21
22Enumerates the bundle flags, which indicate the type of bundle information to obtain.
23
24**System capability**: SystemCapability.BundleManager.BundleFramework.Core
25
26| Name                                         | Value        | Description                                                        |
27| --------------------------------------------- | ---------- | ------------------------------------------------------------ |
28| 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.|
29| 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.|
30| 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.|
31| 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.|
32| 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.|
33| 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.|
34| GET_BUNDLE_INFO_WITH_METADATA                 | 0x00000020 | Used to obtain the metadata contained in the application, 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.|
35| 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.|
36| 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.|
37| 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.|
38| 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.|
39| 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.|
40
41## ExtensionAbilityType
42
43Enumerates the types of ExtensionAbility components.
44
45**System capability**: SystemCapability.BundleManager.BundleFramework.Core
46
47| Name| Value| Description|
48|:----------------:|:---:|-----|
49| 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.|
50| WORK_SCHEDULER   | 1   | [WorkSchedulerExtensionAbility](../apis-backgroundtasks-kit/js-apis-WorkSchedulerExtensionAbility.md): provides extended capabilities related to deferred tasks, enabling applications to execute non-real-time tasks when the system is idle.|
51| INPUT_METHOD     | 2   | [InputMethodExtensionAbility](../apis-ime-kit/js-apis-inputmethod-extension-ability.md): provides extended capabilities related to input method applications.|
52|<!--DelRow--> SERVICE          | 3   | [ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility-sys.md): provides extended capabilities related to background services.|
53| ACCESSIBILITY    | 4   | <!--RP1-->[AccessibilityExtensionAbility](../apis-accessibility-kit/js-apis-application-accessibilityExtensionAbility.md)<!--RP1End-->: provides extended capabilities related to accessibility services, supporting access and operation of the foreground UI.|
54|<!--DelRow--> DATA_SHARE       | 5   | [DataShareExtensionAbility](../apis-arkdata/js-apis-application-dataShareExtensionAbility-sys.md): provides extended capabilities related to data sharing, providing data reading and writing services.|
55|<!--DelRow--> FILE_SHARE       | 6   | FileShareExtensionAbility: provides extended capabilities related to file sharing between applications. This ability is reserved and supported only by system applications.|
56|<!--DelRow--> STATIC_SUBSCRIBER| 7   | [StaticSubscriberExtensionAbility](../apis-basic-services-kit/js-apis-application-staticSubscriberExtensionAbility-sys.md): provides extended capabilities related to static broadcast, used to handle static events such as startup events.|
57|<!--DelRow--> WALLPAPER        | 8   | WallpaperExtensionAbility: provides extended capabilities to implement wallpapers displayed on home screen. This ability is reserved and supported only by system applications.|
58| BACKUP           |  9  | [BackupExtensionAbility](../apis-core-file-kit/js-apis-application-backupExtensionAbility.md): provides extended capabilities for data backup and restore.|
59|<!--DelRow--> WINDOW     |  10 | [WindowExtensionAbility](../apis-arkui/js-apis-application-windowExtensionAbility-sys.md): provides extended capabilities that allow system applications to pull up and embed UIs of other applications.|
60| ENTERPRISE_ADMIN |  11 | [EnterpriseAdminExtensionAbility](../apis-mdm-kit/js-apis-EnterpriseAdminExtensionAbility.md): provides extended capabilities for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.|
61|<!--DelRow--> THUMBNAIL        | 13  | ThumbnailExtensionAbility: provides extended capabilities for offering thumbnails for files. This ability is reserved and supported only by system applications.|
62|<!--DelRow--> PREVIEW          | 14  | PreviewExtensionAbility: provides extended capabilities 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.|
63|<!--DelRow--> PRINT<sup>10+</sup> | 15 | PrintExtensionAbility: provides extended capabilities for printing photos and documents in office scenarios. This ability is supported only by system applications.|
64| SHARE<sup>10+</sup> | 16 | [ShareExtensionAbility](js-apis-app-ability-shareExtensionAbility.md): provides sharing service templates based on the UIExtensionAbility.|
65|<!--DelRow--> PUSH<sup>10+</sup> | 17 | PushExtensionAbility: provides extended capabilities for pushing scenario-specific messages. This ability is reserved and supported only by system applications.|
66| DRIVER<sup>10+</sup> | 18 | [DriverExtensionAbility](../apis-driverdevelopment-kit/js-apis-app-ability-driverExtensionAbility.md): provides extended capabilities for the peripheral driver. When an application configures an ExtensionAbility of the driver type, it is recognized as a driver application. Driver applications do not differentiate between users during installation, uninstall, and recovery. Moreover, when a new user account is created, the existing driver applications on the device are installed for that user. For example, when a sub-user is created, the driver applications already installed by the primary user is automatically installed for the sub-user. If a driver application is uninstalled for a sub-user, it is also removed for the primary user.|
67| ACTION<sup>10+</sup> | 19 | [ActionExtensionAbility](js-apis-app-ability-actionExtensionAbility.md): provides custom action service templates based on the UIExtensionAbility.|
68|<!--DelRow--> ADS_SERVICE<sup>11+</sup> | 20 | AdsServiceExtensionAbility: provides background customized ad services for external systems. This ability is supported only by system applications.|
69| EMBEDDED_UI<sup>12+</sup> | 21 | [EmbeddedUIExtensionAbility](js-apis-app-ability-embeddedUIExtensionAbility.md): provides extended capabilities for the embeddable UI across process.|
70| INSIGHT_INTENT_UI<sup>12+</sup> | 22 | InsightIntentUIExtensionAbility: provides extended capabilities that enable applications to be called by Celia intents so as to be displayed in windows.|
71| FENCE<sup>18+</sup> | 24 | [FenceExtensionAbility](../apis-location-kit/js-apis-app-ability-FenceExtensionAbility.md): provides geofence-related capabilities. It inherits from ExtensionAbility.|<!--RP2--><!--RP2End-->
72| ASSET_ACCELERATION<sup>18+</sup> | 26 | AssetAccelerationExtensionAbility: provides extended capabilities of pre-downloading background resources when the device is idle.|
73| FORM_EDIT<sup>18+</sup> | 27 | [FormEditExtensionAbility](../apis-form-kit/js-apis-app-form-formEditExtensionAbility.md): provides extended capabilities related to widget editing. It inherits from UIExtensionAbility.|
74| DISTRIBUTED<sup>20+</sup> | 28 | [DistributedExtensionAbility](../apis-distributedservice-kit/js-apis-distributedExtensionAbility.md): provides extended capabilities for distributed services and lifecycle callbacks for creation, destruction, and connection of the DistributedExtensionAbility.|
75| APP_SERVICE<sup>20+</sup> | 29 | [AppServiceExtensionAbility](../apis-ability-kit/js-apis-app-ability-appServiceExtensionAbility.md): provides backend service capabilities for enterprise common applications.|
76| LIVE_FORM<sup>20+</sup> | 30 | [LiveFormExtensionAbility](../apis-form-kit/js-apis-app-form-LiveFormExtensionAbility.md): provides extended capabilities for interactive widgets, and provides lifecycle callbacks for creating and destroying interactive widgets.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
77| UNSPECIFIED      | 255 | The ability type is not specified. <!--Del-->It can be used in [queryExtensionAbilityInfo](js-apis-bundleManager-sys.md#bundlemanagerqueryextensionabilityinfo) to obtain ExtensionAbility components of all types.<!--DelEnd-->|
78
79## PermissionGrantState
80
81Enumerates the permission grant states.
82
83**Atomic service API**: This API can be used in atomic services since API version 11.
84
85**System capability**: SystemCapability.BundleManager.BundleFramework.Core
86
87| Name| Value| Description|
88|:----------------:|:---:|:---:|
89| PERMISSION_DENIED|  -1 | Permission denied.|
90| PERMISSION_GRANTED |  0  |  Permission granted. |
91
92## SupportWindowMode
93
94Enumerates the window modes supported by the ability.
95
96**Atomic service API**: This API can be used in atomic services since API version 11.
97
98**System capability**: SystemCapability.BundleManager.BundleFramework.Core
99
100| Name| Value| Description|
101|:----------------:|:---:|:---:|
102| FULL_SCREEN      | 0   | A window in full-screen mode is supported.|
103| SPLIT            | 1   | A window in split-screen mode is supported.|
104| FLOATING         | 2   | A floating window is supported.  |
105
106## LaunchType
107
108Enumerates the launch types of the ability.
109
110**Atomic service API**: This API can be used in atomic services since API version 11.
111
112**System capability**: SystemCapability.BundleManager.BundleFramework.Core
113
114| Name| Value| Description|
115|:----------------:|:---:|:---:|
116| SINGLETON        | 0   | The ability can have only one instance.|
117| MULTITON         | 1   | The ability can have multiple instances.|
118| SPECIFIED        | 2   | The ability can have one or multiple instances, depending on the internal service of the ability.|
119
120## AbilityType
121
122Enumerates the types of abilities.
123
124**Model restriction**: This API can be used only in the FA model.
125
126**System capability**: SystemCapability.BundleManager.BundleFramework.Core
127
128|  Name  | Value  |                            Description                           |
129| :-----: | ---- | :--------------------------------------------------------: |
130| PAGE    | 1    | Ability that has the UI. FA developed using the Page template to provide the capability of interacting with users.       |
131| 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. |
132|  DATA   | 3    | PA developed using the Data template to provide unified data access for external systems.|
133
134## DisplayOrientation
135
136Enumerates the display orientations of the ability. This enum applies only to the ability using the Page template.
137
138**System capability**: SystemCapability.BundleManager.BundleFramework.Core
139
140| Name                              |Value|Description|
141|:----------------------------------|---|---|
142| 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.|
143| LANDSCAPE                          |1 |Landscape.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
144| PORTRAIT                           |2 |Portrait.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
145| 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.|
146| LANDSCAPE_INVERTED                 |4 |Reverse landscape.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
147| PORTRAIT_INVERTED                  |5 |Reverse portrait.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
148| AUTO_ROTATION                      |6 |Automatically rotates when the sensor changes to landscape or portrait mode.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
149| AUTO_ROTATION_LANDSCAPE            |7 |Automatically rotates when the sensor changes to landscape mode.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
150| AUTO_ROTATION_PORTRAIT             |8 |Automatically rotates when the sensor changes to portrait mode.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
151| AUTO_ROTATION_RESTRICTED           |9 |Switched-determined auto rotation.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
152| 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.|
153| 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.|
154| LOCKED                             |12|Locked.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
155| 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.|
156| 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.|
157
158## CompatiblePolicy<sup>10+</sup>
159
160Defines the version compatibility type of the shared library.
161
162**Atomic service API**: This API can be used in atomic services since API version 11.
163
164**System capability**: SystemCapability.BundleManager.BundleFramework.Core
165
166| Name                  | Value  | Description                            |
167| ---------------------- | ---- | -------------------------------- |
168| BACKWARD_COMPATIBILITY | 1    | The shared library is backward compatible.|
169
170## ModuleType
171
172Enumerates the module types.
173
174**Atomic service API**: This API can be used in atomic services since API version 11.
175
176**System capability**: SystemCapability.BundleManager.BundleFramework.Core
177
178| Name   | Value  | Description                |
179| ------- | ---- | -------------------- |
180| ENTRY   | 1    | Main module of and entry to the application, providing the basic application functionality.  |
181| FEATURE | 2    | Dynamic feature module of the application, extending the application functionality. This type of HAP can be installed based on user needs and device types.|
182| SHARED  | 3    | [Dynamic shared library](../../quick-start/in-app-hsp.md) of the application. |
183
184## BundleType
185
186Enumerates the bundle types.
187
188**Atomic service API**: This API can be used in atomic services since API version 11.
189
190**System capability**: SystemCapability.BundleManager.BundleFramework.Core
191
192| Name          | Value  | Description           |
193| -------------- | ---- | --------------- |
194| APP            | 0    | The bundle is an application.   |
195| ATOMIC_SERVICE | 1    | The bundle is an atomic service.|
196
197## MultiAppModeType<sup>12+</sup>
198Enumerates the types of the multi-app mode.
199
200**System capability**: SystemCapability.BundleManager.BundleFramework.Core
201
202| Name| Value| Description|
203|:----------------:|:---:|:---:|
204| UNSPECIFIED|  0 | Unspecified. It is the default value of [multiAppMode](../../quick-start/app-configuration-file.md#multiappmode).|
205| MULTI_INSTANCE |  1  | [Multi-instance mode](../../quick-start/multiInstance.md). A resident process does not support this value. |
206| APP_CLONE |  2  |  [App clone mode](../../quick-start/app-clone.md) |
207
208## AbilityFlag<sup>20+</sup>
209
210Enumerates the ability flags, which indicate the type of ability information to obtain.
211
212**Atomic service API**: This API can be used in atomic services since API version 20.
213
214**System capability**: SystemCapability.BundleManager.BundleFramework.Core
215
216| Name                             | Value        | Description                                                        |
217| --------------------------------- | ---------- | ------------------------------------------------------------ |
218| GET_ABILITY_INFO_DEFAULT          | 0x00000000 | Used to obtain the default [ability information](js-apis-bundleManager-abilityInfo.md), which does not contain permissions, metadata, or ability information of disabled abilities. <!--Del-->You can use [setAbilityEnabled](./js-apis-bundleManager-sys.md#bundlemanagersetabilityenabled) to set the ability enabling status and use [isAbilityEnabled](./js-apis-bundleManager-sys.md#bundlemanagerisabilityenabled-1) to obtain the ability enabling status.<!--DelEnd-->|
219| GET_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the ability information containing permissions.                        |
220| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ability information containing application information.                    |
221| GET_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the ability information containing metadata.                           |
222| GET_ABILITY_INFO_WITH_DISABLE     | 0x00000008 | Used to obtain the ability information of disabled abilities.                  |
223| GET_ABILITY_INFO_ONLY_SYSTEM_APP  | 0x00000010 | Used to obtain the ability information of system applications.                          |
224| GET_ABILITY_INFO_WITH_APP_LINKING | 0x00000040 | Used to obtain the ability information that passes <!--RP3-->[domain name verification](../../application-models/app-linking-startup.md#working-principles)<!--RP3End-->.         |
225| GET_ABILITY_INFO_WITH_SKILL       | 0x00000080 | Used to obtain the ability information containing skills.                   |
226
227## bundleManager.getBundleInfoForSelf
228
229getBundleInfoForSelf(bundleFlags: number): Promise\<BundleInfo>
230
231Obtains the bundle information based on the given bundle flags. This API uses a promise to return the result.
232
233**Atomic service API**: This API can be used in atomic services since API version 11.
234
235**System capability**: SystemCapability.BundleManager.BundleFramework.Core
236
237**Parameters**
238
239| Name    | Type  | Mandatory| Description               |
240| ----------- | ------ | ---- | --------------------- |
241| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
242
243**Return value**
244
245| Type                                                       | Description                                 |
246| ----------------------------------------------------------- | ------------------------------------- |
247| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.|
248
249**Error codes**
250
251For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
252
253| ID| Error Message                                                    |
254| -------- | ------------------------------------------------------------ |
255| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
256
257**Example**
258
259```ts
260// Obtain the bundle information, which contains the application information including a metadata array.
261import { bundleManager } from '@kit.AbilityKit';
262import { BusinessError } from '@kit.BasicServicesKit';
263import { hilog } from '@kit.PerformanceAnalysisKit';
264
265let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
266
267try {
268  bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
269    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
270  }).catch((err: BusinessError) => {
271    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
272  });
273} catch (err) {
274  let message = (err as BusinessError).message;
275  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
276}
277```
278
279## bundleManager.getBundleInfoForSelf
280
281getBundleInfoForSelf(bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
282
283Obtains the bundle information based on the given bundle flags. This API uses an asynchronous callback to return the result.
284
285**Atomic service API**: This API can be used in atomic services since API version 11.
286
287**System capability**: SystemCapability.BundleManager.BundleFramework.Core
288
289**Parameters**
290
291| Name    | Type  | Mandatory| Description               |
292| ----------- | ------ | ---- | --------------------- |
293| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
294| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the information is successfully obtained, **err** is **null** and **data** is the bundle information of the current application. Otherwise, **err** is an error object.|
295
296**Error codes**
297
298For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
299
300| ID| Error Message                                                    |
301| -------- | ------------------------------------------------------------ |
302| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
303
304**Example**
305
306```ts
307// Obtain the bundle information, which contains the ability information including permissions.
308import { bundleManager } from '@kit.AbilityKit';
309import { BusinessError } from '@kit.BasicServicesKit';
310import { hilog } from '@kit.PerformanceAnalysisKit';
311
312let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
313
314try {
315  bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
316    if (err) {
317      hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
318    } else {
319      hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
320    }
321  });
322} catch (err) {
323  let message = (err as BusinessError).message;
324  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
325}
326```
327
328## bundleManager.getProfileByAbility
329
330getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
331
332Obtains the JSON string array of the current application's configuration file based on the given module name, ability name, and metadata name (name configured in [metadata](../../quick-start/module-configuration-file.md#metadata) of the **module.json5** file). This API uses an asynchronous callback to return the result.
333
334>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 manager module](../apis-localization-kit/js-apis-resource-manager.md).
335
336**Atomic service API**: This API can be used in atomic services since API version 11.
337
338**System capability**: SystemCapability.BundleManager.BundleFramework.Core
339
340**Parameters**
341
342| Name      | Type                         | Mandatory| Description                                                        |
343| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
344| moduleName   | string                        | Yes  | Module name.                                    |
345| abilityName  | string                        | Yes  | Name of the UIAbility component.                                   |
346| metadataName | string                        | Yes  | [Metadata name](../../quick-start/module-configuration-file.md#metadata) of the UIAbility component, that is, **name** of the **metadata** tag under [abilities](../../quick-start/module-configuration-file.md#abilities) in the **module.json5** file.                                 |
347| callback     | AsyncCallback<Array\<string>> | Yes  | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the information is successfully obtained, **err** is **null** and **data** is **Array\<string>**. Otherwise, **err** is an error object.|
348
349**Error codes**
350
351For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
352
353| ID| Error Message                                                    |
354| -------- | ------------------------------------------------------------ |
355| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
356| 17700002 | The specified moduleName is not existed.                      |
357| 17700003 | The specified abilityName is not existed.                     |
358| 17700024 | Failed to get the profile because there is no profile in the HAP. |
359| 17700029 | The specified ability is disabled.                            |
360
361**Example**
362
363```ts
364import { bundleManager } from '@kit.AbilityKit';
365import { BusinessError } from '@kit.BasicServicesKit';
366import { hilog } from '@kit.PerformanceAnalysisKit';
367
368let moduleName = 'entry';
369let abilityName = 'EntryAbility';
370let metadataName = 'ability_metadata';
371
372try {
373  bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
374    if (err) {
375      hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
376    } else {
377      hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data));
378    }
379  });
380} catch (err) {
381  let message = (err as BusinessError).message;
382  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
383}
384```
385
386## bundleManager.getProfileByAbility
387
388getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\>
389
390Obtains the JSON string array of the current application's configuration file based on the given module name, ability name, and metadata name (name configured in [metadata](../../quick-start/module-configuration-file.md#metadata) of the **module.json5** file). This API uses a promise to return the result.
391
392>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 manager module](../apis-localization-kit/js-apis-resource-manager.md).
393
394**Atomic service API**: This API can be used in atomic services since API version 11.
395
396**System capability**: SystemCapability.BundleManager.BundleFramework.Core
397
398**Parameters**
399
400| Name      | Type  | Mandatory| Description                      |
401| ------------ | ------ | ---- | -------------------------- |
402| moduleName   | string | Yes  | Module name.  |
403| abilityName  | string | Yes  | Name of the UIAbility component. |
404| metadataName | string | No  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under [abilities](../../quick-start/module-configuration-file.md#abilities) in the **module.json5** file. The default value is null.|
405
406**Return value**
407
408| Type                   | Description                           |
409| ----------------------- | ------------------------------- |
410| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
411
412**Error codes**
413
414For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
415
416| ID| Error Message                                                    |
417| -------- | ------------------------------------------------------------ |
418| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
419| 17700002 | The specified moduleName is not existed.                      |
420| 17700003 | The specified abilityName is not existed.                     |
421| 17700024 | Failed to get the profile because there is no profile in the HAP. |
422| 17700029 | The specified ability is disabled.                            |
423
424**Example**
425
426```ts
427import { bundleManager } from '@kit.AbilityKit';
428import { BusinessError } from '@kit.BasicServicesKit';
429import { hilog } from '@kit.PerformanceAnalysisKit';
430
431let moduleName = 'entry';
432let abilityName = 'EntryAbility';
433
434try {
435  // Obtain the JSON string array of the configuration file based on the module name and ability name.
436  bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
437    hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
438  }).catch((err: BusinessError) => {
439    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
440  });
441} catch (err) {
442  let message = (err as BusinessError).message;
443  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
444}
445```
446
447```ts
448import { bundleManager } from '@kit.AbilityKit';
449import { BusinessError } from '@kit.BasicServicesKit';
450import { hilog } from '@kit.PerformanceAnalysisKit';
451
452let moduleName = 'entry';
453let abilityName = 'EntryAbility';
454let metadataName = 'ability_metadata';
455
456try {
457  // Obtain the JSON string array of the current application's configuration file based on the module name, ability name, and metadata name.
458  bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
459    hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
460  }).catch((err: BusinessError) => {
461    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
462  });
463} catch (err) {
464  let message = (err as BusinessError).message;
465  hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
466}
467```
468
469## bundleManager.getProfileByAbilitySync<sup>10+</sup>
470
471getProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?: string): Array\<string\>
472
473Obtains the JSON string array of the current application's configuration file based on the given module name, ability name, and metadata name (name configured in [metadata](../../quick-start/module-configuration-file.md#metadata) of the **module.json5** file). This API returns the result synchronously. The result value is a string array.
474
475>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 manager module](../apis-localization-kit/js-apis-resource-manager.md).
476
477**Atomic service API**: This API can be used in atomic services since API version 11.
478
479**System capability**: SystemCapability.BundleManager.BundleFramework.Core
480
481**Parameters**
482
483| Name      | Type  | Mandatory| Description                      |
484| ------------ | ------ | ---- | -------------------------- |
485| moduleName   | string | Yes  | Module name.  |
486| abilityName  | string | Yes  | Name of the UIAbility component. |
487| metadataName | string | No  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under [abilities](../../quick-start/module-configuration-file.md#abilities) in the **module.json5** file. The default value is null.|
488
489**Return value**
490
491| Type                   | Description                           |
492| ----------------------- | ------------------------------- |
493| Array\<string> | An array of JSON strings.|
494
495**Error codes**
496
497For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
498
499| ID| Error Message                                                    |
500| -------- | ------------------------------------------------------------ |
501| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
502| 17700002 | The specified moduleName is not existed.                      |
503| 17700003 | The specified abilityName is not existed.                     |
504| 17700024 | Failed to get the profile because there is no profile in the HAP. |
505| 17700029 | The specified ability is disabled.                            |
506
507**Example**
508
509```ts
510import { bundleManager } from '@kit.AbilityKit';
511import { BusinessError } from '@kit.BasicServicesKit';
512import { hilog } from '@kit.PerformanceAnalysisKit';
513
514let moduleName = 'entry';
515let abilityName = 'EntryAbility';
516
517try {
518  // Obtain the JSON string array of the configuration file based on the module name and ability name.
519  let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName);
520  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
521} catch (err) {
522  let message = (err as BusinessError).message;
523  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
524}
525```
526
527```ts
528import { bundleManager } from '@kit.AbilityKit';
529import { BusinessError } from '@kit.BasicServicesKit';
530import { hilog } from '@kit.PerformanceAnalysisKit';
531
532let moduleName: string = 'entry';
533let abilityName: string = 'EntryAbility';
534let metadataName: string = 'ability_metadata';
535
536try {
537  // Obtain the JSON string array of the configuration file based on the module name, ability name, and metadata name.
538  let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName);
539  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
540} catch (err) {
541  let message = (err as BusinessError).message;
542  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
543}
544```
545
546## bundleManager.getProfileByExtensionAbility
547
548getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
549
550Obtains the JSON string array of the current application's configuration file based on the given module name, ExtensionAbility name, and metadata name (name configured in [metadata](../../quick-start/module-configuration-file.md#metadata) of the **module.json5** file). This API uses an asynchronous callback to return the result.
551
552>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 manager module](../apis-localization-kit/js-apis-resource-manager.md).
553
554**Atomic service API**: This API can be used in atomic services since API version 11.
555
556**System capability**: SystemCapability.BundleManager.BundleFramework.Core
557
558**Parameters**
559
560| Name                | Type                         | Mandatory| Description                                                        |
561| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
562| moduleName           | string                        | Yes  | Module name.                                  |
563| extensionAbilityName | string                        | Yes  | Name of the ExtensionAbility component.                        |
564| metadataName         | string                        | Yes  | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under [extensionAbilities](../../quick-start/module-configuration-file.md#extensionabilities) in the **module.json5** file.                                |
565| callback             | AsyncCallback<Array\<string>> | Yes  | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the information is successfully obtained, **err** is **null** and **data** is **Array\<string>**. Otherwise, **err** is an error object.|
566
567**Error codes**
568
569For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
570
571| ID| Error Message                                                    |
572| -------- | ------------------------------------------------------------ |
573| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
574| 17700002 | The specified moduleName is not existed.                      |
575| 17700003 | The specified extensionAbilityName not existed.            |
576| 17700024 | Failed to get the profile because there is no profile in the HAP. |
577
578**Example**
579
580```ts
581import { bundleManager } from '@kit.AbilityKit';
582import { BusinessError } from '@kit.BasicServicesKit';
583import { hilog } from '@kit.PerformanceAnalysisKit';
584
585let moduleName = 'entry';
586let extensionAbilityName = 'com.example.myapplication.extension';
587let metadataName = 'ability_metadata';
588
589try {
590  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
591    if (err) {
592      hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message);
593    } else {
594      hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data));
595    }
596  });
597} catch (err) {
598  let message = (err as BusinessError).message;
599  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message);
600}
601```
602
603## bundleManager.getProfileByExtensionAbility
604
605getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\>
606
607Obtains the JSON string array of the current application's configuration file based on the given module name, ExtensionAbility name, and metadata name (name configured in [metadata](../../quick-start/module-configuration-file.md#metadata) of the **module.json5** file). This API uses a promise to return the result.
608
609>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 manager module](../apis-localization-kit/js-apis-resource-manager.md).
610
611**Atomic service API**: This API can be used in atomic services since API version 11.
612
613**System capability**: SystemCapability.BundleManager.BundleFramework.Core
614
615**Parameters**
616
617| Name                | Type  | Mandatory| Description                              |
618| -------------------- | ------ | ---- | ---------------------------------- |
619| moduleName           | string | Yes  | Module name.          |
620| extensionAbilityName | string | Yes  | Name of the ExtensionAbility component.|
621| metadataName         | string | No  | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under [extensionAbilities](../../quick-start/module-configuration-file.md#extensionabilities) in the **module.json5** file. The default value is null.        |
622
623**Return value**
624
625| Type                   | Description                               |
626| ----------------------- | ----------------------------------- |
627| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
628
629**Error codes**
630
631For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
632
633| ID| Error Message                                                    |
634| -------- | ------------------------------------------------------------ |
635| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
636| 17700002 | The specified moduleName is not existed.                      |
637| 17700003 | The specified extensionAbilityName not existed.            |
638| 17700024 | Failed to get the profile because there is no profile in the HAP. |
639
640**Example**
641
642```ts
643import { bundleManager } from '@kit.AbilityKit';
644import { BusinessError } from '@kit.BasicServicesKit';
645import { hilog } from '@kit.PerformanceAnalysisKit';
646
647let moduleName = 'entry';
648let extensionAbilityName = 'com.example.myapplication.extension';
649let metadataName = 'ability_metadata';
650
651try {
652  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
653    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
654  }).catch((err: BusinessError) => {
655    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
656  });
657} catch (err) {
658  let message = (err as BusinessError).message;
659  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
660}
661
662try {
663  bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
664    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
665  }).catch((err: BusinessError) => {
666    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
667  });
668} catch (err) {
669  let message = (err as BusinessError).message;
670  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
671}
672```
673
674## bundleManager.getProfileByExtensionAbilitySync<sup>10+</sup>
675
676getProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: string, metadataName?: string): Array\<string\>
677
678Obtains the JSON string array of the current application's configuration file based on the given module name, ExtensionAbility name, and metadata name (name configured in [metadata](../../quick-start/module-configuration-file.md#metadata) of the **module.json5** file). This API returns the result synchronously. The result value is a string array.
679
680>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 manager module](../apis-localization-kit/js-apis-resource-manager.md).
681
682**Atomic service API**: This API can be used in atomic services since API version 11.
683
684**System capability**: SystemCapability.BundleManager.BundleFramework.Core
685
686**Parameters**
687
688| Name                | Type  | Mandatory| Description                              |
689| -------------------- | ------ | ---- | ---------------------------------- |
690| moduleName           | string | Yes  | Module name.          |
691| extensionAbilityName | string | Yes  | Name of the ExtensionAbility component.|
692| metadataName         | string | No  | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under [extensionAbilities](../../quick-start/module-configuration-file.md#extensionabilities) in the **module.json5** file. The default value is null.|
693
694**Return value**
695
696| Type                   | Description                               |
697| ----------------------- | ----------------------------------- |
698| Array\<string> | An array of JSON strings.|
699
700**Error codes**
701
702For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
703
704| ID| Error Message                                                    |
705| -------- | ------------------------------------------------------------ |
706| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
707| 17700002 | The specified moduleName is not existed.                      |
708| 17700003 | The specified extensionAbilityName not existed.            |
709| 17700024 | Failed to get the profile because there is no profile in the HAP. |
710
711**Example**
712
713```ts
714import { bundleManager } from '@kit.AbilityKit';
715import { BusinessError } from '@kit.BasicServicesKit';
716import { hilog } from '@kit.PerformanceAnalysisKit';
717
718let moduleName = 'entry';
719let extensionAbilityName = 'com.example.myapplication.extension';
720let metadataName = 'ability_metadata';
721
722try {
723  let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
724  hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
725} catch (err) {
726  let message = (err as BusinessError).message;
727  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
728}
729
730try {
731  let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
732  hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
733} catch (err) {
734  let message = (err as BusinessError).message;
735  hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
736}
737```
738
739## bundleManager.getBundleInfoForSelfSync<sup>10+</sup>
740
741getBundleInfoForSelfSync(bundleFlags: number): BundleInfo
742
743Obtains the bundle information of this bundle based on the given bundle flags. This API returns the result synchronously.
744
745**Atomic service API**: This API can be used in atomic services since API version 11.
746
747**System capability**: SystemCapability.BundleManager.BundleFramework.Core
748
749**Parameters**
750
751| Name    | Type  | Mandatory| Description               |
752| ----------- | ------ | ---- | --------------------- |
753| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
754
755**Return value**
756
757| Type                                             | Description                |
758| ------------------------------------------------- | -------------------- |
759| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
760
761**Error codes**
762
763For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
764
765| ID| Error Message                                                    |
766| -------- | ------------------------------------------------------------ |
767| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
768
769**Example**
770
771```ts
772import { bundleManager } from '@kit.AbilityKit';
773import { BusinessError } from '@kit.BasicServicesKit';
774import { hilog } from '@kit.PerformanceAnalysisKit';
775
776let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
777
778try {
779  let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
780  hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
781} catch (err) {
782  let message = (err as BusinessError).message;
783  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message);
784}
785```
786
787## bundleManager.canOpenLink<sup>12+</sup>
788
789canOpenLink(link: string): boolean
790
791Checks whether a link can be opened. The scheme of the specified link must be configured in the **querySchemes** field of the [module.json5](../../quick-start/module-configuration-file.md) file.
792
793**Atomic service API**: This API can be used in atomic services since API version 12.
794
795**System capability**: SystemCapability.BundleManager.BundleFramework.Core
796
797**Parameters**
798
799| Name    | Type  | Mandatory| Description               |
800| ----------- | ------ | ---- | --------------------- |
801| link | string | Yes  | Link to check.|
802
803**Return value**
804
805| Type                                             | Description                |
806| ------------------------------------------------- | -------------------- |
807| boolean | Check result for whether the link can be opened. **true** if it can be opened, **false** otherwise.|
808
809**Error codes**
810
811For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
812
813| ID| Error Message                                                    |
814| -------- | ------------------------------------------------------------ |
815| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
816| 17700055 | The specified link is invalid.                      |
817| 17700056 | The scheme of the specified link is not in the querySchemes.        |
818
819**Example**
820
821```ts
822import { bundleManager } from '@kit.AbilityKit';
823import { BusinessError } from '@kit.BasicServicesKit';
824import { hilog } from '@kit.PerformanceAnalysisKit';
825
826try {
827  let link = 'welink://';
828  let data = bundleManager.canOpenLink(link);
829  hilog.info(0x0000, 'testTag', 'canOpenLink successfully: %{public}s', JSON.stringify(data));
830} catch (err) {
831  let message = (err as BusinessError).message;
832  hilog.error(0x0000, 'testTag', 'canOpenLink failed: %{public}s', message);
833}
834```
835
836## bundleManager.getLaunchWant<sup>13+</sup>
837
838getLaunchWant(): Want
839
840Obtains the **Want** parameter used to start this application.
841
842**Atomic service API**: This API can be used in atomic services since API version 13.
843
844**System capability**: SystemCapability.BundleManager.BundleFramework.Core
845
846**Return value**
847
848| Type                               | Description                                       |
849| ----------------------------------- | ------------------------------------------- |
850| [Want](js-apis-app-ability-want.md) | Want object that contains the bundle name and ability name.|
851
852**Error codes**
853
854For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md).
855
856| ID| Error Message                     |
857| -------- | ----------------------------- |
858| 17700072 | The launch want is not found. |
859
860**Example**
861
862```ts
863import { BusinessError } from '@kit.BasicServicesKit';
864import { bundleManager } from '@kit.AbilityKit';
865import { hilog } from '@kit.PerformanceAnalysisKit';
866
867try {
868  let want = bundleManager.getLaunchWant();
869  hilog.info(0x0000, 'testTag', 'getLaunchWant ability name: %{public}s', want.abilityName);
870  hilog.info(0x0000, 'testTag', 'getLaunchWant bundle name: %{public}s', want.bundleName);
871} catch (error) {
872  let message = (error as BusinessError).message;
873  hilog.error(0x0000, 'testTag', 'getLaunchWant failed: %{public}s', message);
874}
875```
876
877## bundleManager.getBundleInfo<sup>14+</sup>
878
879getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void
880
881Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses an asynchronous callback to return the result.
882
883No permission is required for obtaining the caller's own information.
884
885**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
886
887**System capability**: SystemCapability.BundleManager.BundleFramework.Core
888
889**Parameters**
890
891| Name | Type  | Mandatory| Description                      |
892| ----------- | ------ | ---- | ---------------------------- |
893| bundleName  | string | Yes  | Bundle name.|
894| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
895| userId      | number | Yes  | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). |
896| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the information is successfully obtained, **err** is **null** and **data** is the bundle information. Otherwise, **err** is an error object.|
897
898**Error codes**
899
900For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
901
902| ID| Error Message                             |
903| -------- | ------------------------------------- |
904| 201 | Permission denied. |
905| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
906| 17700001 | The specified bundleName is not found. |
907| 17700004 | The specified user ID is not found.     |
908| 17700026 | The specified bundle is disabled.     |
909
910**Example**
911
912```ts
913// Obtain the bundle information, which contains the ability information.
914import { bundleManager } from '@kit.AbilityKit';
915import { BusinessError } from '@kit.BasicServicesKit';
916import { hilog } from '@kit.PerformanceAnalysisKit';
917
918let bundleName = 'com.example.myapplication';
919let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
920let userId = 100;
921
922try {
923    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
924        if (err) {
925            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
926        } else {
927            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
928        }
929    });
930} catch (err) {
931    let message = (err as BusinessError).message;
932    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
933}
934```
935
936```ts
937// Obtain the bundle information, which contains the application information including metadata.
938import { bundleManager } from '@kit.AbilityKit';
939import { BusinessError } from '@kit.BasicServicesKit';
940import { hilog } from '@kit.PerformanceAnalysisKit';
941
942let bundleName = 'com.example.myapplication';
943let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
944let userId = 100;
945
946try {
947    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
948        if (err) {
949            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
950        } else {
951            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
952        }
953    });
954} catch (err) {
955    let message = (err as BusinessError).message;
956    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
957}
958```
959
960## bundleManager.getBundleInfo<sup>14+</sup>
961
962getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
963
964Obtains the bundle information based on the given bundle name and bundle flags. This API uses an asynchronous callback to return the result.
965
966No permission is required for obtaining the caller's own information.
967
968**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
969
970**System capability**: SystemCapability.BundleManager.BundleFramework.Core
971
972**Parameters**
973
974| Name    | Type  | Mandatory| Description                      |
975| ----------- | ------ | ---- | ---------------------------- |
976| bundleName  | string | Yes  | Bundle name.|
977| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
978| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the information is successfully obtained, **err** is **null** and **data** is the bundle information. Otherwise, **err** is an error object.|
979
980**Error codes**
981
982For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
983
984| ID| Error Message                             |
985| -------- | ------------------------------------- |
986| 201 | Permission denied. |
987| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
988| 17700001 | The specified bundleName is not found. |
989| 17700026 | The specified bundle is disabled.     |
990
991**Example**
992
993```ts
994// Obtain the bundle information with the ExtensionAbility information.
995import { bundleManager } from '@kit.AbilityKit';
996import { BusinessError } from '@kit.BasicServicesKit';
997import { hilog } from '@kit.PerformanceAnalysisKit';
998
999let bundleName = 'com.example.myapplication';
1000let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
1001
1002try {
1003    bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
1004        if (err) {
1005            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
1006        } else {
1007            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
1008        }
1009    });
1010} catch (err) {
1011    let message = (err as BusinessError).message;
1012    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
1013}
1014```
1015
1016## bundleManager.getBundleInfo<sup>14+</sup>
1017
1018getBundleInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<BundleInfo>
1019
1020Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses a promise to return the result.
1021
1022No permission is required for obtaining the caller's own information.
1023
1024**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1025
1026**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1027
1028**Parameters**
1029
1030| Name    | Type  | Mandatory| Description                      |
1031| ----------- | ------ | ---- | ---------------------------- |
1032| bundleName  | string | Yes  | Bundle name.|
1033| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.      |
1034| userId      | number | No  | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. |
1035
1036**Return value**
1037
1038| Type                                                       | Description                       |
1039| ----------------------------------------------------------- | --------------------------- |
1040| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
1041
1042**Error codes**
1043
1044For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1045
1046| ID| Error Message                           |
1047| -------- | --------------------------------------|
1048| 201 | Permission denied. |
1049| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1050| 17700001 | The specified bundleName is not found. |
1051| 17700004 | The specified user ID is not found.     |
1052| 17700026 | The specified bundle is disabled.     |
1053
1054**Example**
1055
1056```ts
1057// Obtain the bundle information with the application and signature information.
1058import { bundleManager } from '@kit.AbilityKit';
1059import { BusinessError } from '@kit.BasicServicesKit';
1060import { hilog } from '@kit.PerformanceAnalysisKit';
1061
1062let bundleName = 'com.example.myapplication';
1063let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1064let userId = 100;
1065
1066try {
1067    bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
1068        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
1069    }).catch((err: BusinessError) => {
1070        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
1071    });
1072} catch (err) {
1073    let message = (err as BusinessError).message;
1074    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
1075}
1076```
1077
1078```ts
1079import { bundleManager } from '@kit.AbilityKit';
1080import { BusinessError } from '@kit.BasicServicesKit';
1081import { hilog } from '@kit.PerformanceAnalysisKit';
1082
1083let bundleName = 'com.example.myapplication';
1084let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1085
1086try {
1087    bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
1088        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
1089    }).catch((err: BusinessError) => {
1090        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
1091    });
1092} catch (err) {
1093    let message = (err as BusinessError).message;
1094    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
1095}
1096
1097```
1098
1099## bundleManager.getBundleInfoSync<sup>14+</sup>
1100
1101getBundleInfoSync(bundleName: string, bundleFlags: number, userId: number): BundleInfo
1102
1103Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API returns the result synchronously.
1104
1105No permission is required for obtaining the caller's own information.
1106
1107**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1108
1109**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1110
1111**Parameters**
1112
1113| Name      | Type  | Mandatory| Description                                                    |
1114| ----------- | ------ | ---- | -------------------------------------------------------- |
1115| bundleName  | string | Yes  | Bundle name.                                |
1116| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
1117| userId      | number | Yes  | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).             |
1118
1119**Return value**
1120
1121| Type      | Description                |
1122| ---------- | -------------------- |
1123| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
1124
1125**Error codes**
1126
1127For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1128
1129| ID| Error Message                            |
1130| -------- | ------------------------------------- |
1131| 201 | Permission denied. |
1132| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1133| 17700001 | The specified bundleName is not found. |
1134| 17700004 | The specified user ID is not found.     |
1135| 17700026 | The specified bundle is disabled.     |
1136
1137**Example**
1138
1139```ts
1140import { bundleManager } from '@kit.AbilityKit';
1141import { BusinessError } from '@kit.BasicServicesKit';
1142import { hilog } from '@kit.PerformanceAnalysisKit';
1143
1144let bundleName = 'com.example.myapplication';
1145let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
1146let userId = 100;
1147
1148try {
1149    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
1150    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
1151} catch (err) {
1152    let message = (err as BusinessError).message;
1153    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
1154}
1155```
1156
1157## bundleManager.getBundleInfoSync<sup>14+</sup>
1158
1159getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo
1160
1161Obtains the bundle information for the caller's user based on the given bundle name and bundle flags. This API returns the result synchronously.
1162
1163No permission is required for obtaining the caller's own information.
1164
1165**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1166
1167**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1168
1169**Parameters**
1170
1171| Name     | Type                 | Mandatory| Description                                                  |
1172| ----------- | --------------------- | ---- | ------------------------------------------------------ |
1173| bundleName  | string                | Yes  | Bundle name.                            |
1174| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
1175
1176**Return value**
1177
1178| Type                                             | Description                |
1179| ------------------------------------------------- | -------------------- |
1180| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
1181
1182**Error codes**
1183
1184For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1185
1186| ID| Error Message                              |
1187| -------- | -------------------------------------- |
1188| 201 | Permission denied. |
1189| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1190| 17700001 | The specified bundleName is not found. |
1191| 17700026 | The specified bundle is disabled.     |
1192
1193**Example**
1194
1195```ts
1196import { bundleManager } from '@kit.AbilityKit';
1197import { BusinessError } from '@kit.BasicServicesKit';
1198import { hilog } from '@kit.PerformanceAnalysisKit';
1199
1200let bundleName = 'com.example.myapplication';
1201let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
1202try {
1203    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
1204    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
1205} catch (err) {
1206    let message = (err as BusinessError).message;
1207    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
1208}
1209```
1210
1211## bundleManager.getBundleNameByUid<sup>14+</sup>
1212
1213getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void
1214
1215Obtains the bundle name based on the given UID. This API uses an asynchronous callback to return the result.
1216
1217**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1218
1219**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1220
1221**Parameters**
1222
1223| Name  | Type                  | Mandatory| Description                                                        |
1224| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1225| uid      | number                 | Yes  | UID of the application.                                           |
1226| callback | AsyncCallback\<string> | Yes  | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the information is successfully obtained, **err** is **null** and **data** is the bundle name. Otherwise, **err** is an error object.|
1227
1228**Error codes**
1229
1230For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1231
1232| ID| Error Message           |
1233| -------- | --------------------- |
1234| 201 | Permission denied. |
1235| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1236| 17700021 | The uid is not found. |
1237
1238**Example**
1239
1240```ts
1241import { bundleManager } from '@kit.AbilityKit';
1242import { BusinessError } from '@kit.BasicServicesKit';
1243import { hilog } from '@kit.PerformanceAnalysisKit';
1244
1245let uid = 20010005;
1246try {
1247    bundleManager.getBundleNameByUid(uid, (err, data) => {
1248        if (err) {
1249            hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message);
1250        } else {
1251            hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', JSON.stringify(data));
1252        }
1253    });
1254} catch (err) {
1255    let message = (err as BusinessError).message;
1256    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', message);
1257}
1258```
1259
1260## bundleManager.getBundleNameByUid<sup>14+</sup>
1261
1262getBundleNameByUid(uid: number): Promise\<string>
1263
1264Obtains the bundle name based on the given UID. This API uses a promise to return the result.
1265
1266**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1267
1268**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1269
1270**Parameters**
1271
1272| Name| Type  | Mandatory| Description               |
1273| ---- | ------ | ---- | ------------------ |
1274| uid  | number | Yes  | UID of the application.|
1275
1276**Return value**
1277
1278| Type            | Description                       |
1279| ---------------- | --------------------------- |
1280| Promise\<string> | Promise used to return the bundle name obtained.|
1281
1282**Error codes**
1283
1284For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1285
1286| ID| Error Message           |
1287| -------- | ---------------------|
1288| 201 | Permission denied. |
1289| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1290| 17700021 | The uid is not found. |
1291
1292**Example**
1293
1294```ts
1295import { bundleManager } from '@kit.AbilityKit';
1296import { BusinessError } from '@kit.BasicServicesKit';
1297import { hilog } from '@kit.PerformanceAnalysisKit';
1298
1299let uid = 20010005;
1300try {
1301    bundleManager.getBundleNameByUid(uid).then((data) => {
1302        hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data));
1303    }).catch((err: BusinessError) => {
1304        hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
1305    });
1306} catch (err) {
1307    let message = (err as BusinessError).message;
1308    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', message);
1309}
1310```
1311
1312## bundleManager.getBundleNameByUidSync<sup>14+</sup>
1313
1314getBundleNameByUidSync(uid: number): string
1315
1316Obtains the bundle name based on the given UID. This API returns the result synchronously.
1317
1318**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1319
1320**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1321
1322**Parameters**
1323
1324| Name| Type  | Mandatory| Description               |
1325| ---- | ------ | ---- | ------------------ |
1326| uid  | number | Yes  | UID of the application.|
1327
1328**Return value**
1329
1330| Type            | Description                       |
1331| ---------------- | --------------------------- |
1332| string | Bundle name obtained.|
1333
1334**Error codes**
1335
1336For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1337
1338| ID| Error Message           |
1339| -------- | ---------------------|
1340| 201 | Permission denied. |
1341| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1342| 17700021 | The uid is not found. |
1343
1344**Example**
1345
1346```ts
1347import { bundleManager } from '@kit.AbilityKit';
1348import { BusinessError } from '@kit.BasicServicesKit';
1349import { hilog } from '@kit.PerformanceAnalysisKit';
1350
1351let uid = 20010005;
1352try {
1353    let data = bundleManager.getBundleNameByUidSync(uid);
1354    hilog.info(0x0000, 'testTag', 'getBundleNameByUidSync successfully. Data: %{public}s', JSON.stringify(data));
1355} catch (err) {
1356    let message = (err as BusinessError).message;
1357    hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', message);
1358}
1359```
1360
1361## bundleManager.getAppCloneIdentity<sup>14+</sup>
1362
1363getAppCloneIdentity(uid: number): Promise\<AppCloneIdentity>;
1364
1365Obtains the bundle name and clone index of a cloned application based on the given UID. This API uses a promise to return the result.
1366
1367**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1368
1369**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1370
1371**Parameters**
1372
1373| Name    | Type  | Mandatory| Description                      |
1374| ---------- | ------ | ---- | ---------------------------|
1375|    uid     | number |  Yes |     UID of the application.     |
1376
1377**Return value**
1378
1379| Type                                                       | Description                       |
1380| ----------------------------------------------------------- | --------------------------- |
1381| Promise\<[AppCloneIdentity](js-apis-bundleManager-bundleInfo.md#appcloneidentity14)> | Promise used to return \<AppCloneIdentity>.|
1382
1383**Error codes**
1384
1385For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1386
1387| ID| Error Message                           |
1388| -------- | --------------------------------------|
1389| 201 | Permission denied. |
1390| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1391| 17700021 | The uid is not found. |
1392
1393**Example**
1394
1395```ts
1396import { bundleManager } from '@kit.AbilityKit';
1397import { BusinessError } from '@kit.BasicServicesKit';
1398import { hilog } from '@kit.PerformanceAnalysisKit';
1399
1400let uid = 20010005;
1401
1402try {
1403    bundleManager.getAppCloneIdentity(uid).then((res) => {
1404        hilog.info(0x0000, 'testTag', 'getAppCloneIdentity res = %{public}s', JSON.stringify(res));
1405    }).catch((err: BusinessError) => {
1406        hilog.error(0x0000, 'testTag', 'getAppCloneIdentity failed. Cause: %{public}s', err.message);
1407    });
1408} catch (err) {
1409    let message = (err as BusinessError).message;
1410    hilog.error(0x0000, 'testTag', 'getAppCloneIdentity failed. Cause: %{public}s', message);
1411}
1412```
1413
1414## bundleManager.getSignatureInfo<sup>18+</sup>
1415
1416getSignatureInfo(uid: number): SignatureInfo
1417
1418Obtains the [signature information](./js-apis-bundleManager-bundleInfo.md#signatureinfo) of an application based on the given UID.
1419
1420**Required permissions**: ohos.permission.GET_SIGNATURE_INFO
1421
1422**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1423
1424**Parameters**
1425
1426| Name| Type  | Mandatory| Description               |
1427| ---- | ------ | ---- | ------------------ |
1428| uid  | number | Yes  | UID of the application.|
1429
1430**Return value**
1431
1432| Type            | Description                       |
1433| ---------------- | --------------------------- |
1434| [SignatureInfo](./js-apis-bundleManager-bundleInfo.md#signatureinfo) | SignatureInfo object.|
1435
1436**Error codes**
1437
1438For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1439
1440| ID| Error Message           |
1441| -------- | ---------------------|
1442| 201 | Permission denied. |
1443| 17700021 | The uid is not found. |
1444
1445**Example**
1446
1447```ts
1448import { bundleManager } from '@kit.AbilityKit';
1449import { BusinessError } from '@kit.BasicServicesKit';
1450import { hilog } from '@kit.PerformanceAnalysisKit';
1451
1452let uid = 20010005; // Replace uid with the UID of the corresponding application.
1453try {
1454    let data = bundleManager.getSignatureInfo(uid);
1455    hilog.info(0x0000, 'testTag', 'getSignatureInfo successfully. Data: %{public}s', JSON.stringify(data));
1456} catch (err) {
1457    let message = (err as BusinessError).message;
1458    hilog.error(0x0000, 'testTag', 'getSignatureInfo failed. Cause: %{public}s', message);
1459}
1460```
1461
1462
1463## bundleManager.getAbilityInfo<sup>20+</sup>
1464
1465getAbilityInfo(uri: string, abilityFlags: number): Promise\<Array\<AbilityInfo>>
1466
1467Obtains the ability information based on the given resource identifier and ability flag. This API uses a promise to return the result.
1468
1469**Atomic service API**: This API can be used in atomic services since API version 20.
1470
1471**Required permissions**: ohos.permission.GET_ABILITY_INFO
1472
1473**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1474
1475**Device behavior differences**: This API can be properly called only on PCs/2-in-1 devices. If it is called on other device types, error code 201 is returned.
1476
1477**Parameters**
1478
1479| Name     | Type  | Mandatory| Description                                                 |
1480| ------------ | ------ | ---- | ------------------------------------------------------- |
1481| uri         | string   | Yes  | URI of the resource. The value is the same as that of the [uris field under skills in the module.json5 file](../../quick-start/module-configuration-file.md#skills).                  |
1482| abilityFlags  | number | Yes  | [Ability flag](js-apis-bundleManager.md#abilityflag20), indicating the ability information to be obtained.|
1483
1484**Return value**
1485
1486| Type                                                        | Description                                |
1487| ------------------------------------------------------------ | ------------------------------------ |
1488| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise used to return the ability information array.|
1489
1490**Error codes**
1491
1492For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1493
1494| ID| Error Message                            |
1495| -------- | ------------------------------------- |
1496| 201 | Permission denied. |
1497| 17700003 | The ability is not found.    |
1498
1499**Example**
1500
1501```ts
1502import { bundleManager } from '@kit.AbilityKit';
1503import { BusinessError } from '@kit.BasicServicesKit';
1504
1505let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_WITH_APPLICATION;
1506let uri = "https://www.example.com";
1507
1508try {
1509    bundleManager.getAbilityInfo(uri, abilityFlags).then((data) => {
1510        console.info('getAbilityInfo successfully. Data: ' + JSON.stringify(data));
1511    }).catch((err: BusinessError) => {
1512        let message = (err as BusinessError).message;
1513        console.error('getAbilityInfo failed. Cause: ' + message);
1514    });
1515} catch (err) {
1516    let message = (err as BusinessError).message;
1517    console.error('getAbilityInfo failed. Cause: ' + message);
1518}
1519```
1520
1521## ApplicationInfo
1522
1523type ApplicationInfo = _ApplicationInfo
1524
1525Defines the application information.
1526
1527**Atomic service API**: This API can be used in atomic services since API version 11.
1528
1529**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1530
1531| Type                                                        | Description          |
1532| ------------------------------------------------------------ | -------------- |
1533| [_ApplicationInfo](js-apis-bundleManager-applicationInfo.md#applicationinfo-1) | Application information.|
1534
1535## ModuleMetadata<sup>10+</sup>
1536
1537type ModuleMetadata = _ModuleMetadata
1538
1539Defines the metadata of a module.
1540
1541**Atomic service API**: This API can be used in atomic services since API version 11.
1542
1543**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1544
1545| Type                                                        | Description          |
1546| ------------------------------------------------------------ | -------------- |
1547| [_ModuleMetadata](js-apis-bundleManager-applicationInfo.md#modulemetadata10) | Metadata of the module.|
1548
1549## Metadata
1550
1551type Metadata = _Metadata
1552
1553Defines the metadata.
1554
1555**Atomic service API**: This API can be used in atomic services since API version 11.
1556
1557**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1558
1559| Type                                                        | Description          |
1560| ------------------------------------------------------------ | -------------- |
1561| [_Metadata](js-apis-bundleManager-metadata.md#metadata-1) | Metadata.|
1562
1563## BundleInfo
1564
1565type BundleInfo = _BundleInfo.BundleInfo
1566
1567Defines the bundle information.
1568
1569**Atomic service API**: This API can be used in atomic services since API version 11.
1570
1571**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1572
1573| Type                                                        | Description          |
1574| ------------------------------------------------------------ | -------------- |
1575| [_BundleInfo.BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1) | Bundle information.|
1576
1577
1578## UsedScene
1579
1580type UsedScene = _BundleInfo.UsedScene
1581
1582Defines the use scenario and timing for using the permission.
1583
1584**Atomic service API**: This API can be used in atomic services since API version 11.
1585
1586**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1587
1588| Type                                                        | Description          |
1589| ------------------------------------------------------------ | -------------- |
1590| [_BundleInfo.UsedScene](js-apis-bundleManager-bundleInfo.md#usedscene) | Use scenario and timing for using the permission.|
1591
1592## ReqPermissionDetail
1593
1594type ReqPermissionDetail = _BundleInfo.ReqPermissionDetail
1595
1596Defines the detailed information of the permissions to request from the system.
1597
1598**Atomic service API**: This API can be used in atomic services since API version 11.
1599
1600**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1601
1602| Type                                                        | Description          |
1603| ------------------------------------------------------------ | -------------- |
1604| [_BundleInfo.ReqPermissionDetail](js-apis-bundleManager-bundleInfo.md#reqpermissiondetail) | Detailed information of the permissions to request from the system.|
1605
1606## SignatureInfo
1607
1608type SignatureInfo = _BundleInfo.SignatureInfo
1609
1610Defines the signature information of the bundle.
1611
1612**Atomic service API**: This API can be used in atomic services since API version 11.
1613
1614**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1615
1616| Type                                                        | Description          |
1617| ------------------------------------------------------------ | -------------- |
1618| [_BundleInfo.SignatureInfo](js-apis-bundleManager-bundleInfo.md#signatureinfo) | Signature information of the bundle.|
1619
1620## HapModuleInfo
1621
1622type HapModuleInfo = _HapModuleInfo.HapModuleInfo
1623
1624Defines the module information.
1625
1626**Atomic service API**: This API can be used in atomic services since API version 11.
1627
1628**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1629
1630| Type                                                        | Description          |
1631| ------------------------------------------------------------ | -------------- |
1632| [_HapModuleInfo.HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md#hapmoduleinfo-1) | Module information.|
1633
1634## PreloadItem
1635
1636type PreloadItem = _HapModuleInfo.PreloadItem
1637
1638Defines the preloaded module information in the atomic service.
1639
1640**Atomic service API**: This API can be used in atomic services since API version 11.
1641
1642**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1643
1644| Type                                                        | Description          |
1645| ------------------------------------------------------------ | -------------- |
1646| [_HapModuleInfo.PreloadItem](js-apis-bundleManager-hapModuleInfo.md#preloaditem) | Preloaded module information in the atomic service.|
1647
1648## Dependency
1649
1650type Dependency = _HapModuleInfo.Dependency
1651
1652Defines the information about the dynamic shared libraries on which the module depends.
1653
1654**Atomic service API**: This API can be used in atomic services since API version 11.
1655
1656**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1657
1658| Type                                                        | Description          |
1659| ------------------------------------------------------------ | -------------- |
1660| [_HapModuleInfo.Dependency](js-apis-bundleManager-hapModuleInfo.md#dependency) | Information about the dynamic shared libraries on which the module depends.|
1661
1662## RouterItem<sup>12+</sup>
1663
1664type RouterItem = _HapModuleInfo.RouterItem
1665
1666Defines the router table configuration of the module.
1667
1668**Atomic service API**: This API can be used in atomic services since API version 12.
1669
1670**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1671
1672| Type                                                        | Description          |
1673| ------------------------------------------------------------ | -------------- |
1674| [_HapModuleInfo.RouterItem](js-apis-bundleManager-hapModuleInfo.md#routeritem12) | Router table configuration of the module.|
1675
1676## DataItem<sup>12+</sup>
1677
1678type DataItem = _HapModuleInfo.DataItem
1679
1680Defines the user-defined data in the routing table configuration of the module.
1681
1682**Atomic service API**: This API can be used in atomic services since API version 12.
1683
1684**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1685
1686| Type                                                        | Description          |
1687| ------------------------------------------------------------ | -------------- |
1688| [_HapModuleInfo.DataItem](js-apis-bundleManager-hapModuleInfo.md#dataitem12) | User-defined data in the routing table configuration of the module.|
1689
1690## AbilityInfo
1691
1692type AbilityInfo = _AbilityInfo.AbilityInfo
1693
1694Defines the ability information.
1695
1696**Atomic service API**: This API can be used in atomic services since API version 11.
1697
1698**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1699
1700| Type                                                        | Description          |
1701| ------------------------------------------------------------ | -------------- |
1702| [_AbilityInfo.AbilityInfo](js-apis-bundleManager-abilityInfo.md#abilityinfo-1) |Ability information.|
1703
1704## WindowSize
1705
1706type WindowSize = _AbilityInfo.WindowSize
1707
1708Defines the window size.
1709
1710**Atomic service API**: This API can be used in atomic services since API version 11.
1711
1712**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1713
1714| Type                                                        | Description          |
1715| ------------------------------------------------------------ | -------------- |
1716| [_AbilityInfo.WindowSize](js-apis-bundleManager-abilityInfo.md#windowsize) |Window size.|
1717
1718
1719## ExtensionAbilityInfo
1720
1721type ExtensionAbilityInfo = _ExtensionAbilityInfo.ExtensionAbilityInfo
1722
1723Defines the ExtensionAbility information.
1724
1725**Atomic service API**: This API can be used in atomic services since API version 11.
1726
1727**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1728
1729| Type                                                        | Description          |
1730| ------------------------------------------------------------ | -------------- |
1731| [_ExtensionAbilityInfo.ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md#extensionabilityinfo-1) |ExtensionAbility information.|
1732
1733## ElementName
1734
1735type ElementName = _ElementName
1736
1737Defines the element name.
1738
1739**Atomic service API**: This API can be used in atomic services since API version 11.
1740
1741**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1742
1743| Type                                                        | Description          |
1744| ------------------------------------------------------------ | -------------- |
1745| [_ElementName](js-apis-bundleManager-elementName.md#elementname-1) |Element name.|
1746
1747## Skill<sup>12+</sup>
1748
1749type Skill = _Skill.Skill
1750
1751Defines the skill information.
1752
1753**Atomic service API**: This API can be used in atomic services since API version 12.
1754
1755**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1756
1757| Type                                                        | Description          |
1758| ------------------------------------------------------------ | -------------- |
1759| [_Skill.Skill](js-apis-bundleManager-skill.md#skill-1) |Skill information.|
1760
1761## SkillUrl<sup>12+</sup>
1762
1763type SkillUrl = _Skill.SkillUri
1764
1765Defines the SkillUri information.
1766
1767**Atomic service API**: This API can be used in atomic services since API version 12.
1768
1769**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1770
1771| Type                                                        | Description          |
1772| ------------------------------------------------------------ | -------------- |
1773| [_Skill.SkillUri](js-apis-bundleManager-skill.md#skilluri) |SkillUri information.|
1774
1775## AppCloneIdentity<sup>15+</sup>
1776
1777type AppCloneIdentity = _BundleInfo.AppCloneIdentity
1778
1779Describes the identity information of an application clone.
1780
1781**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1782
1783| Type                                                        | Description          |
1784| ------------------------------------------------------------ | -------------- |
1785| [_BundleInfo.AppCloneIdentity](js-apis-bundleManager-bundleInfo.md#appcloneidentity14) |Identity information of an application clone.|
1786