• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.bundleManager (bundleManager)
2
3The **bundleManager** module provides APIs for querying information about bundles, applications, abilities, ExtensionAbilities, and more.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import bundleManager from '@ohos.bundle.bundleManager';
13```
14
15## Required Permissions
16
17| Permission                                      | APL    | Description           |
18| ------------------------------------------ | ------------ | ------------------|
19| ohos.permission.GET_BUNDLE_INFO            | normal       | Permission to obtain basic information about a bundle.  |
20| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to obtain basic information and other sensitive information about a bundle.|
21| ohos.permission.REMOVE_CACHE_FILES         | system_basic | Permission to clear cache files of a bundle.      |
22|ohos.permission.CHANGE_ABILITY_ENABLED_STATE| system_basic | Permission to enable or disable an application or ability. |
23| ohos.permission.GET_INSTALLED_BUNDLE_LIST | system_basic | Permission to read installed application list.|
24
25For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
26
27## Enums
28
29### BundleFlag
30
31Enumerates the bundle flags, which indicate the type of bundle information to obtain.
32
33 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
34
35| Name                                     | Value        | Description                                                        |
36| ----------------------------------------- | ---------- | ------------------------------------------------------------ |
37| 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.|
38| 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.|
39| 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.|
40| 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**.|
41| 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**.|
42| 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.|
43| GET_BUNDLE_INFO_WITH_METADATA             | 0x00000020 | Used to obtain the metadata contained in the application, HAP module, ability, or ExtensionAbility information. It must be used together with **GET_BUNDLE_INFO_WITH_APPLICATION**, **GET_BUNDLE_INFO_WITH_HAP_MODULE**, **GET_BUNDLE_INFO_WITH_ABILITY**, and **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.|
44| 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.|
45| 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.|
46
47### ApplicationFlag
48
49Enumerates the application flags, which indicate the type of application information to obtain.
50
51 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
52
53 **System API**: This is a system API.
54
55| Name                                | Value        | Description                                                        |
56| ------------------------------------ | ---------- | ------------------------------------------------------------ |
57| GET_APPLICATION_INFO_DEFAULT         | 0x00000000 | Used to obtain the default application information. The obtained information does not contain the permission information or metadata.|
58| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the application information with permission information.                   |
59| GET_APPLICATION_INFO_WITH_METADATA   | 0x00000002 | Used to obtain the application information with metadata.                     |
60| GET_APPLICATION_INFO_WITH_DISABLE    | 0x00000004 | Used to obtain the application information of disabled bundles.                 |
61
62### AbilityFlag
63
64Enumerates the ability flags, which indicate the type of ability information to obtain.
65
66 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
67
68 **System API**: This is a system API.
69
70| Name                             | Value        | Description                                                        |
71| --------------------------------- | ---------- | ------------------------------------------------------------ |
72| GET_ABILITY_INFO_DEFAULT          | 0x00000000 | Used to obtain the default ability information. The obtained information does not contain the permission, metadata, or disabled ability information.|
73| GET_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the ability information with permission information.                         |
74| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ability information with application information.                    |
75| GET_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the ability information with metadata.                           |
76| GET_ABILITY_INFO_WITH_DISABLE     | 0x00000008 | Used to obtain the ability information of disabled abilities.                  |
77| GET_ABILITY_INFO_ONLY_SYSTEM_APP  | 0x00000010 | Used to obtain the ability information of system applications.                        |
78
79### ExtensionAbilityFlag
80
81Enumerates the ExtensionAbility flags, which indicate the type of ExtensionAbility information to obtain.
82
83 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
84
85 **System API**: This is a system API.
86
87| Name                                       | Value        | Description                                                        |
88| ------------------------------------------- | ---------- | ------------------------------------------------------------ |
89| GET_EXTENSION_ABILITY_INFO_DEFAULT          | 0x00000000 | Used to obtain the default ExtensionAbility information. The obtained information does not contain the permission, metadata, or disabled ability information.|
90| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the ExtensionAbility information with permission information.              |
91| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ExtensionAbility information with application information.        |
92| GET_EXTENSION_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the ExtensionAbility information with metadata.                |
93
94### ExtensionAbilityType
95
96Enumerates the types of ExtensionAbilities.
97
98 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
99
100| Name| Value| Description|
101|:----------------:|:---:|-----|
102| FORM             | 0   | [FormExtensionAbility](js-apis-app-form-formExtensionAbility.md): provides APIs for widget development.|
103| WORK_SCHEDULER   | 1   | provides APIs for widget development.: enables applications to execute non-real-time tasks when the system is idle.|
104| INPUT_METHOD     | 2   | [InputMethodExtensionAbility](js-apis-inputmethod-extension-ability.md): provides APIs for developing input method applications.|
105| SERVICE          | 3   | [ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility.md): enables applications to run in the background and provide services.|
106| ACCESSIBILITY    | 4   | [AccessibilityExtensionAbility](js-apis-application-accessibilityExtensionAbility.md): provides accessibility for access to and operations on the UI.|
107| DATA_SHARE       | 5   | [DataShareExtensionAbility](js-apis-application-dataShareExtensionAbility.md): enables applications to read and write data.|
108| FILE_SHARE       | 6   | FileShareExtensionAbility: enables file sharing between applications. This ability is reserved.|
109| STATIC_SUBSCRIBER| 7   | [StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md): provides APIs for processing static events, such as the startup event.|
110| WALLPAPER        | 8   | WallpaperExtensionAbility: provides APIs to implement the home screen wallpaper. This ability is reserved.|
111| BACKUP           |  9  | [BackupExtensionAbility](js-apis-application-backupExtensionAbility.md): provides APIs to implement application data backup and restore.|
112| WINDOW           |  10 | [WindowExtensionAbility](js-apis-application-windowExtensionAbility.md): allows system applications to display UIs of other applications.|
113| ENTERPRISE_ADMIN |  11 | [EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.|
114| THUMBNAIL        | 13  | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.|
115| PREVIEW          | 14  | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.|
116| PRINT<sup>10+</sup> | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.|
117| SHARE<sup>10+</sup> | 16 | [ShareExtensionAbility](js-apis-app-ability-shareExtensionAbility.md): provides sharing service templates based on UIExtensionAbilities.|
118| PUSH<sup>10+</sup> | 17 | PushExtensionAbility: provides APIs for pushing scenario-specific messages. This ability is reserved.|
119| DRIVER<sup>10+</sup> | 18 | [DriverExtensionAbility](js-apis-app-ability-driverExtensionAbility.md): provides APIs for the peripheral driver. This type of ability is not supported yet.|
120| ACTION<sup>10+</sup> | 19 | [ActionExtensionAbility](js-apis-app-ability-actionExtensionAbility.md): provides custom action service templates based on UIExtensionAbilities.|
121| UNSPECIFIED      | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of ExtensionAbilities.|
122
123
124### PermissionGrantState
125
126Enumerates the permission grant states.
127
128 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
129
130| Name| Value| Description|
131|:----------------:|:---:|:---:|
132| PERMISSION_DENIED|  -1 | Permission denied.|
133| PERMISSION_GRANTED |  0  |  Permission granted. |
134
135### SupportWindowMode
136
137Enumerates the window modes supported by the ability.
138
139 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
140
141| Name| Value| Description|
142|:----------------:|:---:|:---:|
143| FULL_SCREEN      | 0   | A window in full-screen mode is supported.|
144| SPLIT            | 1   | A window in split-screen mode is supported.|
145| FLOATING         | 2   | A floating window is supported.  |
146
147### LaunchType
148
149Enumerates the launch types of the ability.
150
151 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
152
153| Name| Value| Description|
154|:----------------:|:---:|:---:|
155| SINGLETON        | 0   | The ability can have only one instance.|
156| MULTITON         | 1   | The ability can have multiple instances.|
157| SPECIFIED        | 2   | The ability can have one or multiple instances, depending on the internal service of the ability.|
158
159### AbilityType
160
161Enumerates the types of abilities.
162
163 **Model restriction**: This API can be used only in the FA model.
164
165 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
166
167|  Name  | Value  |                            Description                           |
168| :-----: | ---- | :--------------------------------------------------------: |
169| PAGE    | 1    | Ability that has the UI. FA developed using the Page template to provide the capability of interacting with users.       |
170| 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. |
171|  DATA   | 3    | PA developed using the Data template to provide unified data access for external systems.|
172
173### DisplayOrientation
174
175Enumerates the display orientations of the ability. This attribute applies only to the ability using the Page template.
176
177 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
178
179| Name                              |Value|Description|
180|:----------------------------------|---|---|
181| UNSPECIFIED                        |0 |Unspecified. The orientation is determined by the system.|
182| LANDSCAPE                          |1 |Landscape.|
183| PORTRAIT                           |2 |Portrait.|
184| FOLLOW_RECENT                      |3 |The last display orientation is used.|
185| LANDSCAPE_INVERTED                 |4 |Reverse landscape.|
186| PORTRAIT_INVERTED                  |5 |Reverse portrait.|
187| AUTO_ROTATION                      |6 |Auto rotation.|
188| AUTO_ROTATION_LANDSCAPE            |7 |Auto rotation in the horizontal direction.|
189| AUTO_ROTATION_PORTRAIT             |8 |Auto rotation in the vertical direction.|
190| AUTO_ROTATION_RESTRICTED           |9 |Switched-determined auto rotation.|
191| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|Switched-determined auto rotation in the horizontal direction.|
192| AUTO_ROTATION_PORTRAIT_RESTRICTED  |11|Switched-determined auto rotation in the vertical direction.|
193| LOCKED                             |12|Locked.|
194
195### CompatiblePolicy<sup>10+</sup>
196
197Defines the version compatibility type of the shared library.
198
199 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
200
201| Name                  | Value  | Description                            |
202| ---------------------- | ---- | -------------------------------- |
203| BACKWARD_COMPATIBILITY | 1    | The shared library is backward compatible.|
204
205### ModuleType
206
207Enumerates the module types.
208
209 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
210
211| Name   | Value  | Description                |
212| ------- | ---- | -------------------- |
213| ENTRY   | 1    | Main module of the application.  |
214| FEATURE | 2    | Dynamic feature module of the application.|
215| SHARED  | 3    | Dynamic shared library module of the application. |
216
217### BundleType
218
219Enumerates the bundle types.
220
221 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
222
223| Name          | Value  | Description           |
224| -------------- | ---- | --------------- |
225| APP            | 0    | The bundle is an application.   |
226| ATOMIC_SERVICE | 1    | The bundle is an atomic service.|
227
228## APIs
229
230### bundleManager.getBundleInfoForSelf
231
232getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>
233
234Obtains the bundle information of this bundle based on the given bundle flags. This API uses a promise to return the result.
235
236**System capability**: SystemCapability.BundleManager.BundleFramework.Core
237
238**Parameters**
239
240| Name    | Type  | Mandatory| Description               |
241| ----------- | ------ | ---- | --------------------- |
242| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
243
244**Return value**
245
246| Type                                                       | Description                                 |
247| ----------------------------------------------------------- | ------------------------------------- |
248| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.|
249
250**Example**
251
252```ts
253// Obtain application info with metadataArray.
254import bundleManager from '@ohos.bundle.bundleManager';
255import { BusinessError } from '@ohos.base';
256import hilog from '@ohos.hilog';
257let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
258try {
259    bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
260        hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
261    }).catch((err: BusinessError) => {
262        hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
263    });
264} catch (err) {
265    let message = (err as BusinessError).message;
266    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
267}
268```
269
270### bundleManager.getBundleInfoForSelf
271
272getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void
273
274Obtains the bundle information of this bundle based on the given bundle flags. This API uses an asynchronous callback to return the result.
275
276**System capability**: SystemCapability.BundleManager.BundleFramework.Core
277
278**Parameters**
279
280| Name    | Type  | Mandatory| Description               |
281| ----------- | ------ | ---- | --------------------- |
282| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
283| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.|
284
285**Example**
286
287```ts
288// Obtain ability info with permissions.
289import bundleManager from '@ohos.bundle.bundleManager';
290import { BusinessError } from '@ohos.base';
291import hilog from '@ohos.hilog';
292let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
293
294try {
295    bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
296        if (err) {
297            hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
298        } else {
299            hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
300        }
301    });
302} catch (err) {
303    let message = (err as BusinessError).message;
304    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
305}
306```
307
308### bundleManager.getBundleInfo
309
310getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void
311
312Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses an asynchronous callback to return the result.
313
314No permission is required for obtaining the caller's own information.
315
316**System API**: This is a system API.
317
318**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
319
320**System capability**: SystemCapability.BundleManager.BundleFramework.Core
321
322**Parameters**
323
324| Name | Type  | Mandatory| Description                      |
325| ----------- | ------ | ---- | ---------------------------- |
326| bundleName  | string | Yes  | Bundle name.|
327| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
328| userId      | number | Yes  | User ID. |
329| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.|
330
331**Error codes**
332
333For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
334
335| ID| Error Message                             |
336| -------- | ------------------------------------- |
337| 17700001 | The specified bundleName is not found. |
338| 17700004 | The specified user ID is not found.     |
339| 17700026 | The specified bundle is disabled.      |
340
341**Example**
342
343```ts
344// Obtain the bundle information with the ability information.
345import bundleManager from '@ohos.bundle.bundleManager';
346import { BusinessError } from '@ohos.base';
347import hilog from '@ohos.hilog';
348let bundleName = 'com.example.myapplication';
349let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
350let userId = 100;
351
352try {
353    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
354        if (err) {
355            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
356        } else {
357            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
358        }
359    });
360} catch (err) {
361    let message = (err as BusinessError).message;
362    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
363}
364```
365
366```ts
367// Obtain the bundle information with the metadata in the application information.
368import bundleManager from '@ohos.bundle.bundleManager';
369import { BusinessError } from '@ohos.base';
370import hilog from '@ohos.hilog';
371let bundleName = 'com.example.myapplication';
372let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
373let userId = 100;
374
375try {
376    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
377        if (err) {
378            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
379        } else {
380            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
381        }
382    });
383} catch (err) {
384    let message = (err as BusinessError).message;
385    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
386}
387```
388
389### bundleManager.getBundleInfo
390
391getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
392
393Obtains the bundle information based on the given bundle name and bundle flags. This API uses an asynchronous callback to return the result.
394
395No permission is required for obtaining the caller's own information.
396
397**System API**: This is a system API.
398
399**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
400
401**System capability**: SystemCapability.BundleManager.BundleFramework.Core
402
403**Parameters**
404
405| Name    | Type  | Mandatory| Description                      |
406| ----------- | ------ | ---- | ---------------------------- |
407| bundleName  | string | Yes  | Bundle name.|
408| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
409| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.|
410
411**Error codes**
412
413For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
414
415| ID| Error Message                             |
416| -------- | ------------------------------------- |
417| 17700001 | The specified bundleName is not found. |
418| 17700026 | The specified bundle is disabled.      |
419
420**Example**
421
422```ts
423// Obtain the bundle information with the ExtensionAbility information.
424import bundleManager from '@ohos.bundle.bundleManager';
425import { BusinessError } from '@ohos.base';
426import hilog from '@ohos.hilog';
427let bundleName = 'com.example.myapplication';
428let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
429
430try {
431    bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
432        if (err) {
433            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
434        } else {
435            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
436        }
437    });
438} catch (err) {
439    let message = (err as BusinessError).message;
440    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
441}
442```
443
444### bundleManager.getBundleInfo
445
446getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: number): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>
447
448Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses a promise to return the result.
449
450No permission is required for obtaining the caller's own information.
451
452**System API**: This is a system API.
453
454**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
455
456**System capability**: SystemCapability.BundleManager.BundleFramework.Core
457
458**Parameters**
459
460| Name    | Type  | Mandatory| Description                      |
461| ----------- | ------ | ---- | ---------------------------- |
462| bundleName  | string | Yes  | Bundle name.|
463| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
464| userId      | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
465
466**Return value**
467
468| Type                                                       | Description                       |
469| ----------------------------------------------------------- | --------------------------- |
470| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
471
472**Error codes**
473
474For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
475
476| ID| Error Message                           |
477| -------- | --------------------------------------|
478| 17700001 | The specified bundleName is not found. |
479| 17700004 | The specified user ID is not found.     |
480| 17700026 | The specified bundle is disabled.      |
481
482**Example**
483
484```ts
485// Obtain the bundle information with the application and signature information.
486import bundleManager from '@ohos.bundle.bundleManager';
487import { BusinessError } from '@ohos.base';
488import hilog from '@ohos.hilog';
489let bundleName = 'com.example.myapplication';
490let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
491let userId = 100;
492
493try {
494    bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
495        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
496    }).catch((err: BusinessError) => {
497        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
498    });
499} catch (err) {
500    let message = (err as BusinessError).message;
501    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
502}
503```
504
505```ts
506import bundleManager from '@ohos.bundle.bundleManager';
507import { BusinessError } from '@ohos.base';
508import hilog from '@ohos.hilog';
509let bundleName = 'com.example.myapplication';
510let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
511
512try {
513    bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
514        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
515    }).catch((err: BusinessError) => {
516        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
517    });
518} catch (err) {
519    let message = (err as BusinessError).message;
520    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
521}
522
523```
524
525### bundleManager.getApplicationInfo
526
527getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void
528
529Obtains the application information based on the given bundle name, application flags, and user ID. This API uses an asynchronous callback to return the result.
530
531No permission is required for obtaining the caller's own information.
532
533**System API**: This is a system API.
534
535**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
536
537**System capability**: SystemCapability.BundleManager.BundleFramework.Core
538
539**Parameters**
540
541| Name   | Type  | Mandatory| Description                      |
542| ---------- | ------ | ---- | ---------------------------- |
543| bundleName | string | Yes  | Bundle name.|
544| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
545| userId     | number | Yes  | User ID. |
546| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the application information obtained. Otherwise, **err** is an error object.|
547
548**Error codes**
549
550For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
551
552| ID| Error Message                            |
553| -------- | --------------------------------------|
554| 17700001 | The specified bundleName is not found. |
555| 17700004 | The specified user ID is not found.     |
556| 17700026 | The specified bundle is disabled.      |
557
558**Example**
559
560```ts
561import bundleManager from '@ohos.bundle.bundleManager';
562import { BusinessError } from '@ohos.base';
563import hilog from '@ohos.hilog';
564let bundleName = 'com.example.myapplication';
565let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
566let userId = 100;
567
568try {
569    bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
570        if (err) {
571            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
572        } else {
573            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
574        }
575    });
576} catch (err) {
577    let message = (err as BusinessError).message;
578    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
579}
580```
581
582### bundleManager.getApplicationInfo
583
584getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void
585
586Obtains the application information based on the given bundle name and application flags. This API uses an asynchronous callback to return the result.
587
588No permission is required for obtaining the caller's own information.
589
590**System API**: This is a system API.
591
592**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
593
594**System capability**: SystemCapability.BundleManager.BundleFramework.Core
595
596**Parameters**
597
598| Name   | Type  | Mandatory| Description                      |
599| ---------- | ------ | ---- | ---------------------------- |
600| bundleName | string | Yes  | Bundle name.|
601| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
602| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the application information obtained. Otherwise, **err** is an error object.|
603
604**Error codes**
605
606For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
607
608| ID| Error Message                            |
609| -------- | --------------------------------------|
610| 17700001 | The specified bundleName is not found. |
611| 17700026 | The specified bundle is disabled.      |
612
613**Example**
614
615```ts
616import bundleManager from '@ohos.bundle.bundleManager';
617import { BusinessError } from '@ohos.base';
618import hilog from '@ohos.hilog';
619let bundleName = 'com.example.myapplication';
620let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
621
622try {
623    bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
624        if (err) {
625            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
626        } else {
627            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
628        }
629    });
630} catch (err) {
631    let message = (err as BusinessError).message;
632    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
633}
634```
635
636### bundleManager.getApplicationInfo
637
638getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId?: number): Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>
639
640Obtains the application information based on the given bundle name, application flags, and user ID. This API uses a promise to return the result.
641
642No permission is required for obtaining the caller's own information.
643
644**System API**: This is a system API.
645
646**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
647
648**System capability**: SystemCapability.BundleManager.BundleFramework.Core
649
650**Parameters**
651
652| Name   | Type  | Mandatory| Description                      |
653| ---------- | ------ | ---- | ---------------------------- |
654| bundleName | string | Yes  | Bundle name.|
655| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
656| userId     | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
657
658**Return value**
659
660| Type                                                        | Description                            |
661| ------------------------------------------------------------ | -------------------------------- |
662| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise used to return the application information obtained.|
663
664**Error codes**
665
666For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
667
668| ID| Error Message                            |
669| -------- | ------------------------------------- |
670| 17700001 | The specified bundleName is not found. |
671| 17700004 | The specified user ID is not found.     |
672| 17700026 | The specified bundle is disabled.      |
673
674**Example**
675
676```ts
677import bundleManager from '@ohos.bundle.bundleManager';
678import { BusinessError } from '@ohos.base';
679import hilog from '@ohos.hilog';
680let bundleName = 'com.example.myapplication';
681let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
682let userId = 100;
683
684try {
685    bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
686        hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
687    }).catch((err: BusinessError) => {
688        hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message);
689    });
690} catch (err) {
691    let message = (err as BusinessError).message;
692    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', message);
693}
694```
695
696### bundleManager.getAllBundleInfo
697
698getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void
699
700Obtains the information about all bundles based on the given bundle flags and user ID. This API uses an asynchronous callback to return the result.
701
702**System API**: This is a system API.
703
704**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
705
706**System capability**: SystemCapability.BundleManager.BundleFramework.Core
707
708**Parameters**
709
710| Name    | Type  | Mandatory| Description                                            |
711| ----------- | ------ | ---- | -------------------------------------------------- |
712| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.                   |
713| userId      | number | Yes  | User ID.                     |
714| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.|
715
716**Error codes**
717
718For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
719
720| ID| Error Message                        |
721| -------- | --------------------------------- |
722| 17700004 | The specified user ID is not found. |
723
724**Example**
725
726```ts
727import bundleManager from '@ohos.bundle.bundleManager';
728import { BusinessError } from '@ohos.base';
729import hilog from '@ohos.hilog';
730let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
731let userId = 100;
732
733try {
734    bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
735        if (err) {
736            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
737        } else {
738            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
739        }
740    });
741} catch (err) {
742    let message = (err as BusinessError).message;
743    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
744}
745```
746
747### bundleManager.getAllBundleInfo
748
749getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void
750
751Obtains the information about all bundles based on the given bundle flags. This API uses an asynchronous callback to return the result.
752
753**System API**: This is a system API.
754
755**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
756
757**System capability**: SystemCapability.BundleManager.BundleFramework.Core
758
759**Parameters**
760
761| Name    | Type  | Mandatory| Description                                            |
762| ----------- | ------ | ---- | -------------------------------------------------- |
763| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.  |
764| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.|
765
766**Example**
767
768```ts
769import bundleManager from '@ohos.bundle.bundleManager';
770import { BusinessError } from '@ohos.base';
771import hilog from '@ohos.hilog';
772let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
773
774try {
775    bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
776        if (err) {
777            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
778        } else {
779            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
780        }
781    });
782} catch (err) {
783    let message = (err as BusinessError).message;
784    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
785}
786```
787
788### bundleManager.getAllBundleInfo
789
790getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>
791
792Obtains the information about all bundles based on the given bundle flags and user ID. This API uses a promise to return the result.
793
794**System API**: This is a system API.
795
796**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
797
798**System capability**: SystemCapability.BundleManager.BundleFramework.Core
799
800**Parameters**
801
802| Name    | Type  | Mandatory| Description                                            |
803| ----------- | ------ | ---- | -------------------------------------------------- |
804| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.                  |
805| userId      | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                     |
806
807**Return value**
808
809| Type                                                        | Description                               |
810| ------------------------------------------------------------ | ----------------------------------- |
811| Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Promise used to return the array of bundle information obtained.|
812
813**Error codes**
814
815For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
816
817| ID| Error Message                        |
818| -------- | ---------------------------------- |
819| 17700004 | The specified user ID is not found. |
820
821**Example**
822
823```ts
824import bundleManager from '@ohos.bundle.bundleManager';
825import { BusinessError } from '@ohos.base';
826import hilog from '@ohos.hilog';
827let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
828
829try {
830    bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
831        hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
832    }).catch((err: BusinessError) => {
833        hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message);
834    });
835} catch (err) {
836    let message = (err as BusinessError).message;
837    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', message);
838}
839```
840
841### bundleManager.getAllApplicationInfo
842
843getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void
844
845Obtains the information about all applications based on the given application flags and user ID. This API uses an asynchronous callback to return the result.
846
847**System API**: This is a system API.
848
849**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
850
851**System capability**: SystemCapability.BundleManager.BundleFramework.Core
852
853**Parameters**
854
855| Name | Type  | Mandatory| Description                                                     |
856| -------- | ------ | ---- | ----------------------------------------------------------- |
857| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
858| userId   | number | Yes  | User ID.        |
859| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.|
860
861**Error codes**
862
863For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
864
865| ID| Error Message                        |
866| -------- | ---------------------------------- |
867| 17700004 | The specified user ID is not found. |
868
869**Example**
870
871```ts
872import bundleManager from '@ohos.bundle.bundleManager';
873import { BusinessError } from '@ohos.base';
874import hilog from '@ohos.hilog';
875let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
876let userId = 100;
877
878try {
879    bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
880        if (err) {
881            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
882        } else {
883            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
884        }
885    });
886} catch (err) {
887    let message = (err as BusinessError).message;
888    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
889}
890```
891
892### bundleManager.getAllApplicationInfo
893
894getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void
895
896Obtains the information about all applications based on the given application flags. This API uses an asynchronous callback to return the result.
897
898**System API**: This is a system API.
899
900**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
901
902**System capability**: SystemCapability.BundleManager.BundleFramework.Core
903
904**Parameters**
905
906| Name | Type  | Mandatory| Description                                                     |
907| -------- | ------ | ---- | ----------------------------------------------------------- |
908| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
909| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.|
910
911**Example**
912
913```ts
914import bundleManager from '@ohos.bundle.bundleManager';
915import { BusinessError } from '@ohos.base';
916import hilog from '@ohos.hilog';
917let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
918
919try {
920    bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
921        if (err) {
922            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
923        } else {
924            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
925        }
926    });
927} catch (err) {
928    let message = (err as BusinessError).message;
929    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
930}
931```
932
933### bundleManager.getAllApplicationInfo
934
935getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>
936
937Obtains the information about all applications based on the given application flags and user ID. This API uses a promise to return the result.
938
939**System API**: This is a system API.
940
941**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
942
943**System capability**: SystemCapability.BundleManager.BundleFramework.Core
944
945**Parameters**
946
947| Name | Type  | Mandatory| Description                                                     |
948| -------- | ------ | ---- | ---------------------------------------------------------- |
949| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
950| userId   | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                       |
951
952**Return value**
953
954| Type                                                        | Description                                    |
955| ------------------------------------------------------------ | ---------------------------------------- |
956| Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Promise used to return the array of application information obtained.|
957
958**Error codes**
959
960For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
961
962| ID| Error Message                        |
963| -------- | ---------------------------------- |
964| 17700004 | The specified user ID is not found. |
965
966**Example**
967
968```ts
969import bundleManager from '@ohos.bundle.bundleManager';
970import { BusinessError } from '@ohos.base';
971import hilog from '@ohos.hilog';
972let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
973
974try {
975    bundleManager.getAllApplicationInfo(appFlags).then((data) => {
976        hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
977    }).catch((err: BusinessError) => {
978        hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message);
979    });
980} catch (err) {
981    let message = (err as BusinessError).message;
982    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', message);
983}
984
985```
986
987### bundleManager.queryAbilityInfo
988
989queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: number, callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void
990
991Obtains an array of ability information based on the given want, ability flags, and user ID. This API uses an asynchronous callback to return the result.
992
993**System API**: This is a system API.
994
995**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
996
997**System capability**: SystemCapability.BundleManager.BundleFramework.Core
998
999**Parameters**
1000
1001| Name     | Type  | Mandatory| Description                                                 |
1002| ------------ | ------ | ---- | ------------------------------------------------------- |
1003| want         | Want   | Yes  | Want containing the bundle name to query.                |
1004| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.                      |
1005| userId       | number | Yes  | User ID.                              |
1006| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ability information obtained. Otherwise, **err** is an error object.|
1007
1008**Error codes**
1009
1010For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1011
1012| ID| Error Message                            |
1013| -------- | -------------------------------------- |
1014| 17700001 | The specified bundleName is not found. |
1015| 17700003 | The specified ability is not found.    |
1016| 17700004 | The specified userId is invalid.       |
1017| 17700026 | The specified bundle is disabled.      |
1018| 17700029 | The specified ability is disabled.     |
1019
1020**Example**
1021
1022```ts
1023import bundleManager from '@ohos.bundle.bundleManager';
1024import { BusinessError } from '@ohos.base';
1025import hilog from '@ohos.hilog';
1026import Want from '@ohos.app.ability.Want';
1027let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1028let userId = 100;
1029let want: Want = {
1030    bundleName : "com.example.myapplication",
1031    abilityName : "EntryAbility"
1032};
1033
1034try {
1035    bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
1036        if (err) {
1037            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
1038        } else {
1039            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
1040        }
1041    });
1042} catch (err) {
1043    let message = (err as BusinessError).message;
1044    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
1045}
1046```
1047
1048### bundleManager.queryAbilityInfo
1049
1050queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void
1051
1052Obtains an array of ability information based on the given want and ability flags. This API uses an asynchronous callback to return the result.
1053
1054**System API**: This is a system API.
1055
1056**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1057
1058**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1059
1060**Parameters**
1061
1062| Name     | Type  | Mandatory| Description                                                 |
1063| ------------ | ------ | ---- | -------------------------------------------------------|
1064| want         | Want   | Yes  | Want containing the bundle name to query.                |
1065| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.      |
1066| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ability information obtained. Otherwise, **err** is an error object.|
1067
1068**Error codes**
1069
1070For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1071
1072| ID| Error Message                            |
1073| -------- | -------------------------------------- |
1074| 17700001 | The specified bundleName is not found. |
1075| 17700003 | The specified ability is not found.    |
1076| 17700026 | The specified bundle is disabled.      |
1077| 17700029 | The specified ability is disabled.     |
1078
1079**Example**
1080
1081```ts
1082import bundleManager from '@ohos.bundle.bundleManager';
1083import { BusinessError } from '@ohos.base';
1084import hilog from '@ohos.hilog';
1085import Want from '@ohos.app.ability.Want';
1086let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1087let want: Want = {
1088    bundleName : "com.example.myapplication",
1089    abilityName : "EntryAbility"
1090};
1091
1092try {
1093    bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
1094        if (err) {
1095            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
1096        } else {
1097            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
1098        }
1099    });
1100} catch (err) {
1101    let message = (err as BusinessError).message;
1102    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
1103}
1104```
1105
1106### bundleManager.queryAbilityInfo
1107
1108queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>
1109
1110Obtains the ability information based on the given want, ability flags, and user ID. This API uses a promise to return the result.
1111
1112**System API**: This is a system API.
1113
1114**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1115
1116**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1117
1118**Parameters**
1119
1120| Name     | Type  | Mandatory| Description                                                 |
1121| ------------ | ------ | ---- | ------------------------------------------------------- |
1122| want         | Want   | Yes  | Want containing the bundle name to query.                |
1123| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.|
1124| userId       | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                      |
1125
1126**Return value**
1127
1128| Type                                                        | Description                                |
1129| ------------------------------------------------------------ | ------------------------------------ |
1130| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise used to return the array of ability information obtained.|
1131
1132**Error codes**
1133
1134For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1135
1136| ID| Error Message                            |
1137| -------- | ------------------------------------- |
1138| 17700001 | The specified bundleName is not found. |
1139| 17700003 | The specified ability is not found.    |
1140| 17700004 | The specified userId is invalid.       |
1141| 17700026 | The specified bundle is disabled.      |
1142| 17700029 | The specified ability is disabled.     |
1143
1144**Example**
1145
1146```ts
1147import bundleManager from '@ohos.bundle.bundleManager';
1148import { BusinessError } from '@ohos.base';
1149import hilog from '@ohos.hilog';
1150import Want from '@ohos.app.ability.Want';
1151let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1152let userId = 100;
1153let want: Want = {
1154    bundleName : "com.example.myapplication",
1155    abilityName : "EntryAbility"
1156};
1157
1158try {
1159    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
1160        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1161    }).catch((err: BusinessError) => {
1162        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1163    });
1164} catch (err) {
1165    let message = (err as BusinessError).message;
1166    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
1167}
1168```
1169
1170```ts
1171import bundleManager from '@ohos.bundle.bundleManager';
1172import { BusinessError } from '@ohos.base';
1173import hilog from '@ohos.hilog';
1174import Want from '@ohos.app.ability.Want';
1175let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1176let want: Want = {
1177    bundleName : "com.example.myapplication",
1178    abilityName : "EntryAbility"
1179};
1180
1181try {
1182    bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
1183        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1184    }).catch((err: BusinessError) => {
1185        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1186    })
1187} catch (err) {
1188    let message = (err as BusinessError).message;
1189    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
1190}
1191```
1192
1193### bundleManager.queryAbilityInfoSync<sup>10+</sup>
1194
1195queryAbilityInfoSync(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>
1196
1197Obtains the ability information based on the given want, ability flags, and user ID. This API returns the result synchronously.
1198
1199**System API**: This is a system API.
1200
1201**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1202
1203**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1204
1205**Parameters**
1206
1207| Name     | Type  | Mandatory| Description                                                 |
1208| ------------ | ------ | ---- | ------------------------------------------------------- |
1209| want         | Want   | Yes  | Want containing the bundle name to query.                |
1210| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.|
1211| userId       | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                      |
1212
1213**Return value**
1214
1215| Type                                                        | Description                                |
1216| ------------------------------------------------------------ | ------------------------------------ |
1217| Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | An array of ability information.|
1218
1219**Error codes**
1220
1221For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1222
1223| ID| Error Message                            |
1224| -------- | ------------------------------------- |
1225| 17700001 | The specified bundleName is not found. |
1226| 17700003 | The specified ability is not found.    |
1227| 17700004 | The specified userId is invalid.       |
1228| 17700026 | The specified bundle is disabled.      |
1229| 17700029 | The specified ability is disabled.     |
1230
1231**Example**
1232
1233```ts
1234import bundleManager from '@ohos.bundle.bundleManager';
1235import { BusinessError } from '@ohos.base';
1236import hilog from '@ohos.hilog';
1237import Want from '@ohos.app.ability.Want';
1238let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1239let userId = 100;
1240let want: Want = {
1241    bundleName : "com.example.myapplication",
1242    abilityName : "EntryAbility"
1243};
1244
1245try {
1246
1247    let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags, userId);
1248    hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
1249} catch (err) {
1250    let message = (err as BusinessError).message;
1251    hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
1252}
1253```
1254
1255```ts
1256import bundleManager from '@ohos.bundle.bundleManager';
1257import { BusinessError } from '@ohos.base';
1258import hilog from '@ohos.hilog';
1259import Want from '@ohos.app.ability.Want';
1260let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1261let want: Want = {
1262    bundleName : "com.example.myapplication",
1263    abilityName : "EntryAbility"
1264};
1265
1266try {
1267    let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags);
1268    hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
1269} catch (err) {
1270    let message = (err as BusinessError).message;
1271    hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
1272}
1273```
1274
1275### bundleManager.queryExtensionAbilityInfo
1276
1277queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId: number, callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void
1278
1279Obtains the ExtensionAbility information based on the given want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API uses an asynchronous callback to return the result.
1280
1281**System API**: This is a system API.
1282
1283**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1284
1285**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1286
1287**Parameters**
1288
1289| Name               | Type                                                        | Mandatory| Description                                                        |
1290| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1291| want                  | Want                                                         | Yes  | Want containing the bundle name to query.                      |
1292| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype)                | Yes  | Type of the ExtensionAbility.                                |
1293| extensionAbilityFlags | [number](#extensionabilityflag)                              | Yes  | Type of the ExtensionAbility information to obtain.   |
1294| userId                | number                                                       | Yes  | User ID.                                                |
1295| callback              | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ExtensionAbility information obtained. Otherwise, **err** is an error object.|
1296
1297**Error codes**
1298
1299For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1300
1301| ID| Error Message                                   |
1302| -------- | ------------------------------------------- |
1303| 17700001 | The specified bundleName is not found.       |
1304| 17700003 | The specified extensionAbility is not found. |
1305| 17700004 | The specified userId is invalid.             |
1306| 17700026 | The specified bundle is disabled.            |
1307
1308**Example**
1309
1310```ts
1311import bundleManager from '@ohos.bundle.bundleManager';
1312import { BusinessError } from '@ohos.base';
1313import hilog from '@ohos.hilog';
1314import Want from '@ohos.app.ability.Want';
1315let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1316let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1317let userId = 100;
1318let want: Want = {
1319    bundleName : "com.example.myapplication",
1320    abilityName : "EntryAbility"
1321};
1322
1323try {
1324    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
1325        if (err) {
1326            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1327        } else {
1328            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1329        }
1330    });
1331} catch (err) {
1332    let message = (err as BusinessError).message;
1333    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
1334}
1335```
1336
1337### bundleManager.queryExtensionAbilityInfo
1338
1339queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void
1340
1341Obtains the ExtensionAbility information based on the given want, ExtensionAbility type, and ExtensionAbility flags. This API uses an asynchronous callback to return the result.
1342
1343**System API**: This is a system API.
1344
1345**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1346
1347**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1348
1349**Parameters**
1350
1351| Name               | Type                                                        | Mandatory| Description                                                        |
1352| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1353| want                  | Want                                                         | Yes  | Want containing the bundle name to query.                      |
1354| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype)                | Yes  | Type of the ExtensionAbility.                                |
1355| extensionAbilityFlags | [number](#extensionabilityflag)                              | Yes  | Type of the ExtensionAbility information to obtain.   |
1356| callback              | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ExtensionAbility information obtained. Otherwise, **err** is an error object.|
1357
1358**Error codes**
1359
1360For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1361
1362| ID| Error Message                                    |
1363| -------- | -------------------------------------------- |
1364| 17700001 | The specified bundleName is not found.       |
1365| 17700003 | The specified extensionAbility is not found. |
1366| 17700026 | The specified bundle is disabled.            |
1367
1368**Example**
1369
1370```ts
1371import bundleManager from '@ohos.bundle.bundleManager';
1372import { BusinessError } from '@ohos.base';
1373import hilog from '@ohos.hilog';
1374import Want from '@ohos.app.ability.Want';
1375let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1376let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1377let want: Want = {
1378    bundleName : "com.example.myapplication",
1379    abilityName : "EntryAbility"
1380};
1381
1382try {
1383    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
1384        if (err) {
1385            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1386        } else {
1387            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1388        }
1389    });
1390} catch (err) {
1391    let message = (err as BusinessError).message;
1392    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
1393}
1394```
1395
1396### bundleManager.queryExtensionAbilityInfo
1397
1398queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>
1399
1400Obtains the ExtensionAbility information based on the given want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API uses a promise to return the result.
1401
1402**System API**: This is a system API.
1403
1404**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1405
1406**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1407
1408**Parameters**
1409
1410| Name               | Type                                         | Mandatory| Description                                                     |
1411| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1412| want                  | Want                                          | Yes  | Want containing the bundle name to query.                   |
1413| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype) | Yes  | Type of the ExtensionAbility.                             |
1414| extensionAbilityFlags | [number](#extensionabilityflag)               | Yes  | Type of the ExtensionAbility information to obtain.|
1415| userId                | number                                        | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                                             |
1416
1417**Return value**
1418
1419| Type                                                        | Description                                         |
1420| ------------------------------------------------------------ | --------------------------------------------- |
1421| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Promise used to return the array of ExtensionAbility information obtained.|
1422
1423**Error codes**
1424
1425For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1426
1427| ID| Error Message                            |
1428| -------- | --------------------------------------|
1429| 17700001 | The specified bundleName is not found. |
1430| 17700003 | The specified extensionAbility is not found.    |
1431| 17700004 | The specified userId is invalid.       |
1432| 17700026 | The specified bundle is disabled.      |
1433
1434**Example**
1435
1436```ts
1437import bundleManager from '@ohos.bundle.bundleManager';
1438import { BusinessError } from '@ohos.base';
1439import hilog from '@ohos.hilog';
1440import Want from '@ohos.app.ability.Want';
1441
1442let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1443let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1444let userId = 100;
1445let want: Want = {
1446    bundleName : "com.example.myapplication",
1447    abilityName : "EntryAbility"
1448};
1449
1450try {
1451    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
1452        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1453    }).catch((err: BusinessError) => {
1454        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1455    });
1456} catch (err) {
1457    let message = (err as BusinessError).message;
1458    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
1459}
1460```
1461
1462```ts
1463import bundleManager from '@ohos.bundle.bundleManager';
1464import { BusinessError } from '@ohos.base';
1465import hilog from '@ohos.hilog';
1466import Want from '@ohos.app.ability.Want';
1467let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1468let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1469let want: Want = {
1470    bundleName : "com.example.myapplication",
1471    abilityName : "EntryAbility"
1472};
1473
1474try {
1475    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
1476        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1477    }).catch((err: BusinessError) => {
1478        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1479    })
1480} catch (err) {
1481    let message = (err as BusinessError).message;
1482    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
1483}
1484```
1485
1486### bundleManager.queryExtensionAbilityInfoSync<sup>10+</sup>
1487
1488queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>
1489
1490Obtains the ExtensionAbility information based on the given want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API returns the result synchronously.
1491
1492**System API**: This is a system API.
1493
1494**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1495
1496**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1497
1498**Parameters**
1499
1500| Name               | Type                                         | Mandatory| Description                                                     |
1501| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1502| want                  | Want                                          | Yes  | Want containing the bundle name to query.                   |
1503| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype) | Yes  | Type of the ExtensionAbility.                             |
1504| extensionAbilityFlags | [number](#extensionabilityflag)               | Yes  | Type of the ExtensionAbility information to obtain.|
1505| userId                | number                                        | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                                             |
1506
1507**Return value**
1508
1509| Type                                                        | Description                                         |
1510| ------------------------------------------------------------ | --------------------------------------------- |
1511| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of ExtensionAbility information.|
1512
1513**Error codes**
1514
1515For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1516
1517| ID| Error Message                            |
1518| -------- | --------------------------------------|
1519| 17700001 | The specified bundleName is not found. |
1520| 17700003 | The specified extensionAbility is not found.    |
1521| 17700004 | The specified userId is invalid.       |
1522| 17700026 | The specified bundle is disabled.      |
1523
1524**Example**
1525
1526```ts
1527import bundleManager from '@ohos.bundle.bundleManager';
1528import { BusinessError } from '@ohos.base';
1529import hilog from '@ohos.hilog';
1530import Want from '@ohos.app.ability.Want';
1531
1532let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1533let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1534let userId = 100;
1535let want: Want = {
1536    bundleName : "com.example.myapplication",
1537    abilityName : "EntryAbility"
1538};
1539
1540try {
1541    let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId);
1542    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
1543} catch (err) {
1544    let message = (err as BusinessError).message;
1545    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
1546}
1547```
1548
1549```ts
1550import bundleManager from '@ohos.bundle.bundleManager';
1551import { BusinessError } from '@ohos.base';
1552import hilog from '@ohos.hilog';
1553import Want from '@ohos.app.ability.Want';
1554let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1555let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1556let want: Want = {
1557    bundleName : "com.example.myapplication",
1558    abilityName : "EntryAbility"
1559};
1560
1561try {
1562    let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags);
1563    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
1564} catch (err) {
1565    let message = (err as BusinessError).message;
1566    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
1567}
1568```
1569
1570### bundleManager.getBundleNameByUid
1571
1572getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void
1573
1574Obtains the bundle name based on the given UID. This API uses an asynchronous callback to return the result.
1575
1576**System API**: This is a system API.
1577
1578**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1579
1580**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1581
1582**Parameters**
1583
1584| Name  | Type                  | Mandatory| Description                                                        |
1585| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1586| uid      | number                 | Yes  | UID of the application.                                           |
1587| callback | AsyncCallback\<string> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle name obtained. Otherwise, **err** is an error object.|
1588
1589**Error codes**
1590
1591For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1592
1593| ID| Error Message           |
1594| -------- | --------------------- |
1595| 17700021 | The uid is not found. |
1596
1597**Example**
1598
1599```ts
1600import bundleManager from '@ohos.bundle.bundleManager';
1601import { BusinessError } from '@ohos.base';
1602import hilog from '@ohos.hilog';
1603let uid = 20010005;
1604try {
1605    bundleManager.getBundleNameByUid(uid, (err, data) => {
1606        if (err) {
1607            hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message);
1608        } else {
1609            hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', JSON.stringify(data));
1610        }
1611    });
1612} catch (err) {
1613    let message = (err as BusinessError).message;
1614    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', message);
1615}
1616```
1617
1618### bundleManager.getBundleNameByUid
1619
1620getBundleNameByUid(uid: number): Promise\<string>
1621
1622Obtains the bundle name based on the given UID. This API uses a promise to return the result.
1623
1624**System API**: This is a system API.
1625
1626**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1627
1628**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1629
1630**Parameters**
1631
1632| Name| Type  | Mandatory| Description               |
1633| ---- | ------ | ---- | ------------------ |
1634| uid  | number | Yes  | UID of the application.|
1635
1636**Return value**
1637
1638| Type            | Description                       |
1639| ---------------- | --------------------------- |
1640| Promise\<string> | Promise used to return the bundle name obtained.|
1641
1642**Error codes**
1643
1644For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1645
1646| ID| Error Message           |
1647| -------- | ---------------------|
1648| 17700021 | The uid is not found. |
1649
1650**Example**
1651
1652```ts
1653import bundleManager from '@ohos.bundle.bundleManager';
1654import { BusinessError } from '@ohos.base';
1655import hilog from '@ohos.hilog';
1656let uid = 20010005;
1657try {
1658    bundleManager.getBundleNameByUid(uid).then((data) => {
1659        hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data));
1660    }).catch((err: BusinessError) => {
1661        hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
1662    });
1663} catch (err) {
1664    let message = (err as BusinessError).message;
1665    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', message);
1666}
1667```
1668
1669### bundleManager.getBundleNameByUidSync<sup>10+</sup>
1670
1671getBundleNameByUidSync(uid: number): string
1672
1673Obtains the bundle name based on the given UID. This API returns the result synchronously.
1674
1675**System API**: This is a system API.
1676
1677**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1678
1679**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1680
1681**Parameters**
1682
1683| Name| Type  | Mandatory| Description               |
1684| ---- | ------ | ---- | ------------------ |
1685| uid  | number | Yes  | UID of the application.|
1686
1687**Return value**
1688
1689| Type            | Description                       |
1690| ---------------- | --------------------------- |
1691| string | Bundle name obtained.|
1692
1693**Error codes**
1694
1695For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1696
1697| ID| Error Message           |
1698| -------- | ---------------------|
1699| 17700021 | The uid is not found. |
1700
1701**Example**
1702
1703```ts
1704import bundleManager from '@ohos.bundle.bundleManager';
1705import { BusinessError } from '@ohos.base';
1706import hilog from '@ohos.hilog';
1707let uid = 20010005;
1708try {
1709    let data = bundleManager.getBundleNameByUidSync(uid);
1710    hilog.info(0x0000, 'testTag', 'getBundleNameByUidSync successfully. Data: %{public}s', JSON.stringify(data));
1711} catch (err) {
1712    let message = (err as BusinessError).message;
1713    hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', message);
1714}
1715```
1716
1717### bundleManager.getBundleArchiveInfo
1718
1719getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void
1720
1721Obtains the bundle information based on the given HAP file path and bundle flags. This API uses an asynchronous callback to return the result.
1722
1723**System API**: This is a system API.
1724
1725**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1726
1727**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1728
1729**Parameters**
1730
1731| Name      | Type  | Mandatory| Description                                                        |
1732| ----------- | ------ | ---- | ----------------------------------------------------------- |
1733| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1734| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
1735| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.|
1736
1737**Error codes**
1738
1739For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1740
1741| ID| Error Message                 |
1742| -------- | --------------------------- |
1743| 17700022 | The hapFilePath is invalid. |
1744
1745**Example**
1746
1747```ts
1748import bundleManager from '@ohos.bundle.bundleManager';
1749import { BusinessError } from '@ohos.base';
1750import hilog from '@ohos.hilog';
1751let hapFilePath = "/data/xxx/test.hap";
1752let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1753
1754try {
1755    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
1756        if (err) {
1757            hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1758        } else {
1759            hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', JSON.stringify(data));
1760        }
1761    });
1762} catch (err) {
1763    let message = (err as BusinessError).message;
1764    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
1765}
1766```
1767
1768### bundleManager.getBundleArchiveInfo
1769
1770getBundleArchiveInfo(hapFilePath: string,  bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>
1771
1772Obtains the bundle information based on the given HAP file path and bundle flags. This API uses a promise to return the result.
1773
1774**System API**: This is a system API.
1775
1776**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1777
1778**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1779
1780**Parameters**
1781
1782| Name      | Type  | Mandatory| Description                                                        |
1783| ----------- | ------ | ---- | ------------------------------------------------------------ |
1784| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1785| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
1786
1787**Return value**
1788
1789| Type                                                       | Description                       |
1790| ----------------------------------------------------------- | --------------------------- |
1791| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
1792
1793**Error codes**
1794
1795For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1796
1797| ID| Error Message                  |
1798| -------- | -------------------------- |
1799| 17700022 | The hapFilePath is invalid. |
1800
1801**Example**
1802
1803```ts
1804import bundleManager from '@ohos.bundle.bundleManager';
1805import { BusinessError } from '@ohos.base';
1806import hilog from '@ohos.hilog';
1807let hapFilePath = "/data/xxx/test.hap";
1808let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1809
1810try {
1811    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
1812        hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data));
1813    }).catch((err: BusinessError) => {
1814        hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1815    });
1816} catch (err) {
1817    let message = (err as BusinessError).message;
1818    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
1819}
1820```
1821
1822### bundleManager.getBundleArchiveInfoSync<sup>10+</sup>
1823
1824getBundleArchiveInfoSync(hapFilePath: string, bundleFlags: number): BundleInfo
1825
1826Obtains the bundle information based on the given HAP file path and bundle flags. This API returns the result synchronously.
1827
1828**System API**: This is a system API.
1829
1830**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1831
1832**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1833
1834**Parameters**
1835
1836| Name      | Type  | Mandatory| Description                                                        |
1837| ----------- | ------ | ---- | ------------------------------------------------------------ |
1838| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1839| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
1840
1841**Return value**
1842
1843| Type                                                       | Description                       |
1844| ----------------------------------------------------------- | --------------------------- |
1845| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
1846
1847**Error codes**
1848
1849For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1850
1851| ID| Error Message                  |
1852| -------- | -------------------------- |
1853| 17700022 | The hapFilePath is invalid. |
1854
1855**Example**
1856
1857```ts
1858import bundleManager from '@ohos.bundle.bundleManager';
1859import { BusinessError } from '@ohos.base';
1860import hilog from '@ohos.hilog';
1861let hapFilePath = "/data/xxx/test.hap";
1862let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1863
1864try {
1865    let data = bundleManager.getBundleArchiveInfoSync(hapFilePath, bundleFlags)
1866    hilog.info(0x0000, 'testTag', 'getBundleArchiveInfoSync successfully. Data: %{public}s', JSON.stringify(data));
1867} catch (err) {
1868    let message = (err as BusinessError).message;
1869    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfoSync failed. Cause: %{public}s', message);
1870}
1871```
1872
1873### bundleManager.cleanBundleCacheFiles
1874
1875cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void
1876
1877Clears the cache files based on the given bundle name. This API uses an asynchronous callback to return the result.
1878
1879**System API**: This is a system API.
1880
1881**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
1882
1883**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1884
1885**Parameters**
1886
1887| Name    | Type                | Mandatory| Description                                                        |
1888| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
1889| bundleName | string               | Yes  | Bundle name.                  |
1890| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1891
1892**Error codes**
1893
1894For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1895
1896| ID| Error Message                                                    |
1897| -------- | ------------------------------------------------------------ |
1898| 17700001 | The specified bundleName is not found.                        |
1899| 17700030 | The specified bundle does not support clearing of cache files. |
1900
1901**Example**
1902
1903```ts
1904import bundleManager from '@ohos.bundle.bundleManager';
1905import { BusinessError } from '@ohos.base';
1906import hilog from '@ohos.hilog';
1907let bundleName = "com.ohos.myapplication";
1908
1909try {
1910    bundleManager.cleanBundleCacheFiles(bundleName, err => {
1911        if (err) {
1912            hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1913        } else {
1914            hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1915        }
1916    });
1917} catch (err) {
1918    let message = (err as BusinessError).message;
1919    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
1920}
1921```
1922
1923### bundleManager.cleanBundleCacheFiles
1924
1925cleanBundleCacheFiles(bundleName: string): Promise\<void>
1926
1927Clears the cache files based on the given bundle name. This API uses a promise to return the result.
1928
1929**System API**: This is a system API.
1930
1931**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
1932
1933**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1934
1935**Parameters**
1936
1937| Name    | Type  | Mandatory| Description                                      |
1938| ---------- | ------ | ---- | ------------------------------------------ |
1939| bundleName | string | Yes  | Bundle name.|
1940
1941**Return value**
1942
1943| Type          | Description                                                        |
1944| -------------- | ------------------------------------------------------------ |
1945| Promise\<void> | Promise that returns no value. If clearing the cache files fails, an error object is thrown.|
1946
1947**Error codes**
1948
1949For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1950
1951| ID| Error Message                                                  |
1952| -------- | ---------------------------------------------------------- |
1953| 17700001 | The specified bundleName is not found.                      |
1954| 17700030 | The specified bundle does not support clearing of cache files. |
1955
1956**Example**
1957
1958```ts
1959import bundleManager from '@ohos.bundle.bundleManager';
1960import { BusinessError } from '@ohos.base';
1961import hilog from '@ohos.hilog';
1962let bundleName = "com.ohos.myapplication";
1963
1964try {
1965    bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
1966        hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1967    }).catch((err: BusinessError) => {
1968        hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1969    });
1970} catch (err) {
1971    let message = (err as BusinessError).message;
1972    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
1973}
1974```
1975
1976### bundleManager.setApplicationEnabled
1977
1978setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void
1979
1980Enables or disables an application. This API uses an asynchronous callback to return the result.
1981
1982**System API**: This is a system API.
1983
1984**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1985
1986**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1987
1988**Parameters**
1989
1990| Name     | Type   | Mandatory| Description                                 |
1991| ---------- | ------- | ---- | ------------------------------------- |
1992| bundleName | string  | Yes  | Bundle name.               |
1993| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.|
1994| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1995
1996**Error codes**
1997
1998For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1999
2000| ID| Error Message                            |
2001| -------- | -------------------------------------- |
2002| 17700001 | The specified bundleName is not found. |
2003
2004**Example**
2005
2006```ts
2007import bundleManager from '@ohos.bundle.bundleManager';
2008import { BusinessError } from '@ohos.base';
2009import hilog from '@ohos.hilog';
2010let bundleName = "com.ohos.myapplication";
2011
2012try {
2013    bundleManager.setApplicationEnabled(bundleName, false, err => {
2014        if (err) {
2015            hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
2016        } else {
2017            hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
2018        }
2019    });
2020} catch (err) {
2021    let message = (err as BusinessError).message;
2022    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
2023}
2024```
2025
2026### bundleManager.setApplicationEnabled
2027
2028setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>
2029
2030Enables or disables an application. This API uses a promise to return the result.
2031
2032**System API**: This is a system API.
2033
2034**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2035
2036**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2037
2038**Parameters**
2039
2040| Name     | Type   | Mandatory| Description                                 |
2041| ---------- | ------- | ---- | ------------------------------------- |
2042| bundleName | string  | Yes  | Bundle name.           |
2043| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.|
2044
2045**Return value**
2046
2047| Type          | Description                                |
2048| -------------- | ------------------------------------ |
2049| Promise\<void> | Promise that returns no value.|
2050
2051**Error codes**
2052
2053For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2054
2055| ID| Error Message                            |
2056| -------- | -------------------------------------- |
2057| 17700001 | The specified bundleName is not found. |
2058
2059**Example**
2060
2061```ts
2062import bundleManager from '@ohos.bundle.bundleManager';
2063import { BusinessError } from '@ohos.base';
2064import hilog from '@ohos.hilog';
2065let bundleName = "com.ohos.myapplication";
2066
2067try {
2068    bundleManager.setApplicationEnabled(bundleName, false).then(() => {
2069        hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
2070    }).catch((err: BusinessError) => {
2071        hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
2072    });
2073} catch (err) {
2074    let message = (err as BusinessError).message;
2075    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
2076}
2077```
2078
2079### bundleManager.setApplicationEnabledSync<sup>10+</sup>
2080
2081setApplicationEnabledSync(bundleName: string, isEnabled: boolean): void
2082
2083Enables or disables an application. This API returns the result synchronously.
2084
2085**System API**: This is a system API.
2086
2087**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2088
2089**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2090
2091**Parameters**
2092
2093| Name     | Type   | Mandatory| Description                                 |
2094| ---------- | ------- | ---- | ------------------------------------- |
2095| bundleName | string  | Yes  | Bundle name.               |
2096| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.|
2097
2098**Error codes**
2099
2100For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2101
2102| ID| Error Message                            |
2103| -------- | -------------------------------------- |
2104| 17700001 | The specified bundleName is not found. |
2105
2106**Example**
2107
2108```ts
2109import bundleManager from '@ohos.bundle.bundleManager';
2110import { BusinessError } from '@ohos.base';
2111import hilog from '@ohos.hilog';
2112let bundleName = "com.ohos.myapplication";
2113
2114try {
2115    bundleManager.setApplicationEnabledSync(bundleName, false);
2116    hilog.info(0x0000, 'testTag', 'setApplicationEnabledSync successfully.');
2117} catch (err) {
2118    let message = (err as BusinessError).message;
2119    hilog.error(0x0000, 'testTag', 'setApplicationEnabledSync failed: %{public}s', message);
2120}
2121```
2122
2123### bundleManager.setAbilityEnabled
2124
2125setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\<void>): void
2126
2127Enables or disables an ability. This API uses an asynchronous callback to return the result.
2128
2129**System API**: This is a system API.
2130
2131**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2132
2133**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2134
2135**Parameters**
2136
2137| Name   | Type       | Mandatory| Description                                 |
2138| -------- | ----------- | ---- | ------------------------------------- |
2139| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.             |
2140| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.|
2141| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
2142
2143**Error codes**
2144
2145For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2146
2147| ID| Error Message                             |
2148| -------- | ---------------------------------------|
2149| 17700001 | The specified bundleName is not found.  |
2150| 17700003 | The specified abilityInfo is not found. |
2151
2152**Example**
2153
2154```ts
2155import bundleManager from '@ohos.bundle.bundleManager';
2156import { BusinessError } from '@ohos.base';
2157import hilog from '@ohos.hilog';
2158import Want from '@ohos.app.ability.Want';
2159let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2160let userId = 100;
2161let want: Want = {
2162    bundleName : "com.example.myapplication",
2163    abilityName : "EntryAbility"
2164};
2165
2166try {
2167    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2168        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2169        let info = abilitiesInfo[0];
2170
2171        bundleManager.setAbilityEnabled(info, false, err => {
2172            if (err) {
2173                hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
2174            } else {
2175                hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
2176            }
2177        });
2178    }).catch((err: BusinessError) => {
2179        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2180    });
2181} catch (err) {
2182    let message = (err as BusinessError).message;
2183    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2184}
2185```
2186
2187### bundleManager.setAbilityEnabled
2188
2189setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\<void>
2190
2191Enables or disables an ability. This API uses a promise to return the result.
2192
2193**System API**: This is a system API.
2194
2195**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2196
2197**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2198
2199**Parameters**
2200
2201| Name   | Type       | Mandatory| Description                                 |
2202| -------- | ----------- | ---- | ------------------------------------- |
2203| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.                  |
2204| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.|
2205
2206**Return value**
2207
2208| Type          | Description                             |
2209| -------------- | --------------------------------- |
2210| Promise\<void> | Promise that returns no value.|
2211
2212**Error codes**
2213
2214For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2215
2216| ID| Error Message                             |
2217| -------- | -------------------------------------- |
2218| 17700001 | The specified bundleName is not found.  |
2219| 17700003 | The specified abilityInfo is not found. |
2220
2221**Example**
2222
2223```ts
2224import bundleManager from '@ohos.bundle.bundleManager';
2225import { BusinessError } from '@ohos.base';
2226import hilog from '@ohos.hilog';
2227import Want from '@ohos.app.ability.Want';
2228let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2229let userId = 100;
2230let want: Want = {
2231    bundleName : "com.example.myapplication",
2232    abilityName : "EntryAbility"
2233};
2234
2235try {
2236    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2237        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2238        let info = abilitiesInfo[0];
2239
2240        bundleManager.setAbilityEnabled(info, false).then(() => {
2241            hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
2242        }).catch((err: BusinessError) => {
2243            hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
2244        });
2245    }).catch((err: BusinessError) => {
2246        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2247    });
2248} catch (err) {
2249    let message = (err as BusinessError).message;
2250    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2251}
2252```
2253
2254### bundleManager.setAbilityEnabledSync<sup>10+</sup>
2255
2256setAbilityEnabledSync(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): void
2257
2258Enables or disables an ability. This API returns the result synchronously.
2259
2260**System API**: This is a system API.
2261
2262**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2263
2264**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2265
2266**Parameters**
2267
2268| Name   | Type       | Mandatory| Description                                 |
2269| -------- | ----------- | ---- | ------------------------------------- |
2270| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.             |
2271| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.|
2272
2273**Error codes**
2274
2275For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2276
2277| ID| Error Message                             |
2278| -------- | ---------------------------------------|
2279| 17700001 | The specified bundleName is not found.  |
2280| 17700003 | The specified abilityInfo is not found. |
2281
2282**Example**
2283
2284```ts
2285import bundleManager from '@ohos.bundle.bundleManager';
2286import { BusinessError } from '@ohos.base';
2287import hilog from '@ohos.hilog';
2288import Want from '@ohos.app.ability.Want';
2289let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2290let userId = 100;
2291let want: Want = {
2292    bundleName : "com.example.myapplication",
2293    abilityName : "EntryAbility"
2294};
2295
2296try {
2297    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2298        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2299        let info = abilitiesInfo[0];
2300
2301        try {
2302            bundleManager.setAbilityEnabledSync(info, false);
2303            hilog.info(0x0000, "testTag", "setAbilityEnabledSync successfully.");
2304        } catch (err) {
2305            let message = (err as BusinessError).message;
2306            hilog.error(0x0000, 'testTag', 'setAbilityEnabledSync failed: %{public}s', message);
2307        }
2308    }).catch((err: BusinessError) => {
2309        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2310    });
2311} catch (err) {
2312    let message = (err as BusinessError).message;
2313    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2314}
2315```
2316
2317### bundleManager.isApplicationEnabled
2318
2319isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void
2320
2321Checks whether an application is enabled. This API uses an asynchronous callback to return the result.
2322
2323**System API**: This is a system API.
2324
2325**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2326
2327**Parameters**
2328
2329| Name     | Type  | Mandatory| Description                      |
2330| ---------- | ------ | ---- | -------------------------- |
2331| bundleName | string | Yes  | Bundle name.|
2332| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.|
2333
2334**Error codes**
2335
2336For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2337
2338| ID| Error Message                            |
2339| -------- | -------------------------------------- |
2340| 17700001 | The specified bundleName is not found. |
2341
2342**Example**
2343
2344```ts
2345import bundleManager from '@ohos.bundle.bundleManager';
2346import { BusinessError } from '@ohos.base';
2347import hilog from '@ohos.hilog';
2348let bundleName = 'com.example.myapplication';
2349
2350try {
2351    bundleManager.isApplicationEnabled(bundleName, (err, data) => {
2352        if (err) {
2353            hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message);
2354        } else {
2355            hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', JSON.stringify(data));
2356        }
2357    });
2358} catch (err) {
2359    let message = (err as BusinessError).message;
2360    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', message);
2361}
2362```
2363
2364### bundleManager.isApplicationEnabled
2365
2366isApplicationEnabled(bundleName: string): Promise\<boolean>
2367
2368Checks whether an application is enabled. This API uses a promise to return the result.
2369
2370**System API**: This is a system API.
2371
2372**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2373
2374**Parameters**
2375
2376| Name     | Type  | Mandatory| Description                      |
2377| ---------- | ------ | ---- | -------------------------- |
2378| bundleName | string | Yes  | Bundle name. |
2379
2380**Return value**
2381
2382| Type             | Description                                                        |
2383| ----------------- | ------------------------------------------------------------ |
2384| Promise\<boolean> | Promise used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.|
2385
2386**Error codes**
2387
2388For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2389
2390| ID| Error Message                            |
2391| -------- | -------------------------------------- |
2392| 17700001 | The specified bundleName is not found. |
2393
2394**Example**
2395
2396```ts
2397import bundleManager from '@ohos.bundle.bundleManager';
2398import { BusinessError } from '@ohos.base';
2399import hilog from '@ohos.hilog';
2400let bundleName = 'com.example.myapplication';
2401
2402try {
2403    bundleManager.isApplicationEnabled(bundleName).then((data) => {
2404        hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data));
2405    }).catch((err: BusinessError) => {
2406        hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
2407    });
2408} catch (err) {
2409    let message = (err as BusinessError).message;
2410    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message);
2411}
2412```
2413
2414### bundleManager.isApplicationEnabledSync<sup>10+</sup>
2415
2416isApplicationEnabledSync(bundleName: string): boolean
2417
2418Checks whether an application is enabled. This API returns the result synchronously.
2419
2420**System API**: This is a system API.
2421
2422**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2423
2424**Parameters**
2425
2426| Name     | Type  | Mandatory| Description                      |
2427| ---------- | ------ | ---- | -------------------------- |
2428| bundleName | string | Yes  | Bundle name.|
2429
2430**Return value**
2431
2432| Type   | Description                                                        |
2433| ------- | ------------------------------------------------------------ |
2434| boolean | Returns **true** if the application is enabled; returns **false** otherwise.|
2435
2436**Error codes**
2437
2438For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2439
2440| ID| Error Message                            |
2441| -------- | -------------------------------------- |
2442| 17700001 | The specified bundleName is not found. |
2443
2444**Example**
2445
2446```ts
2447import bundleManager from '@ohos.bundle.bundleManager';
2448import { BusinessError } from '@ohos.base';
2449import hilog from '@ohos.hilog';
2450let bundleName = 'com.example.myapplication';
2451
2452try {
2453    let data = bundleManager.isApplicationEnabledSync(bundleName);
2454    hilog.info(0x0000, 'testTag', 'isApplicationEnabledSync successfully: %{public}s', JSON.stringify(data));
2455} catch (err) {
2456    let message = (err as BusinessError).message;
2457    hilog.error(0x0000, 'testTag', 'isApplicationEnabledSync failed: %{public}s', message);
2458}
2459```
2460
2461### bundleManager.isAbilityEnabled
2462
2463isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\<boolean>): void
2464
2465Checks whether an ability is enabled. This API uses an asynchronous callback to return the result.
2466
2467**System API**: This is a system API.
2468
2469**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2470
2471**Parameters**
2472
2473| Name| Type       | Mandatory| Description                       |
2474| ---- | ----------- | ---- | --------------------------- |
2475| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2476| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
2477
2478**Error codes**
2479
2480For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2481
2482| ID| Error Message                             |
2483| -------- | --------------------------------------- |
2484| 17700001 | The specified bundleName is not found.  |
2485| 17700003 | The specified abilityName is not found. |
2486
2487**Example**
2488
2489```ts
2490import bundleManager from '@ohos.bundle.bundleManager';
2491import { BusinessError } from '@ohos.base';
2492import hilog from '@ohos.hilog';
2493import Want from '@ohos.app.ability.Want';
2494let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2495let userId = 100;
2496let want: Want = {
2497    bundleName : "com.example.myapplication",
2498    abilityName : "EntryAbility"
2499};
2500
2501try {
2502    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2503        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2504        let info = abilitiesInfo[0];
2505
2506        bundleManager.isAbilityEnabled(info, (err, data) => {
2507            if (err) {
2508                hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s', err.message);
2509            } else {
2510                hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data));
2511            }
2512        });
2513    }).catch((err: BusinessError) => {
2514        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2515    });
2516} catch (err) {
2517    let message = (err as BusinessError).message;
2518    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2519}
2520```
2521
2522### bundleManager.isAbilityEnabled
2523
2524isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\<boolean>
2525
2526Checks whether an ability is enabled. This API uses a promise to return the result.
2527
2528**System API**: This is a system API.
2529
2530**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2531
2532**Parameters**
2533
2534| Name| Type       | Mandatory| Description                       |
2535| ---- | ----------- | ---- | --------------------------- |
2536| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2537
2538**Return value**
2539
2540| Type             | Description                                                        |
2541| ----------------- | ------------------------------------------------------------ |
2542| Promise\<boolean> | Promise used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
2543
2544**Error codes**
2545
2546For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2547
2548| ID| Error Message                             |
2549| -------- | --------------------------------------- |
2550| 17700001 | The specified bundleName is not found.  |
2551| 17700003 | The specified abilityName is not found. |
2552
2553**Example**
2554
2555```ts
2556import bundleManager from '@ohos.bundle.bundleManager';
2557import { BusinessError } from '@ohos.base';
2558import hilog from '@ohos.hilog';
2559import Want from '@ohos.app.ability.Want';
2560let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2561let userId = 100;
2562let want: Want = {
2563    bundleName : "com.example.myapplication",
2564    abilityName : "EntryAbility"
2565};
2566
2567try {
2568    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2569        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2570        let info = abilitiesInfo[0];
2571
2572        bundleManager.isAbilityEnabled(info).then((data) => {
2573            hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data));
2574        }).catch((err: BusinessError) => {
2575            hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message);
2576        });
2577    }).catch((err: BusinessError) => {
2578        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2579    });
2580} catch (err) {
2581    let message = (err as BusinessError).message;
2582    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2583}
2584```
2585
2586### bundleManager.isAbilityEnabledSync<sup>10+</sup>
2587
2588isAbilityEnabledSync(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): boolean
2589
2590Checks whether an ability is enabled. This API returns the result synchronously.
2591
2592**System API**: This is a system API.
2593
2594**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2595
2596**Parameters**
2597
2598| Name| Type       | Mandatory| Description                       |
2599| ---- | ----------- | ---- | --------------------------- |
2600| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2601
2602**Return value**
2603
2604| Type   | Description                                                                |
2605| ------- | ------------------------------------------------------------------- |
2606| boolean | Returns **true** if the ability is enabled; returns **false** otherwise.|
2607
2608**Error codes**
2609
2610For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2611
2612| ID| Error Message                             |
2613| -------- | --------------------------------------- |
2614| 17700001 | The specified bundleName is not found.  |
2615| 17700003 | The specified abilityName is not found. |
2616
2617**Example**
2618
2619```ts
2620import bundleManager from '@ohos.bundle.bundleManager';
2621import { BusinessError } from '@ohos.base';
2622import hilog from '@ohos.hilog';
2623import Want from '@ohos.app.ability.Want';
2624let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2625let userId = 100;
2626let want: Want = {
2627    bundleName : "com.example.myapplication",
2628    abilityName : "EntryAbility"
2629};
2630
2631try {
2632    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2633        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2634        let info = abilitiesInfo[0];
2635
2636        try {
2637            let data = bundleManager.isAbilityEnabledSync(info);
2638            hilog.info(0x0000, 'testTag', 'isAbilityEnabledSync successfully: %{public}s', JSON.stringify(data));
2639        } catch (err) {
2640            let message = (err as BusinessError).message;
2641            hilog.error(0x0000, 'testTag', 'isAbilityEnabledSync failed: %{public}s', message);
2642        }
2643    }).catch((err: BusinessError) => {
2644        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2645    });
2646} catch (err) {
2647    let message = (err as BusinessError).message;
2648    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2649}
2650```
2651
2652### bundleManager.getLaunchWantForBundle
2653
2654getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void
2655
2656Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API uses an asynchronous callback to return the result.
2657
2658**System API**: This is a system API.
2659
2660**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2661
2662**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2663
2664**Parameters**
2665
2666| Name    | Type                | Mandatory| Description                                                        |
2667| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
2668| bundleName | string               | Yes  | Bundle name.                                    |
2669| userId     | number               | Yes  | User ID.                                                  |
2670| callback   | AsyncCallback\<Want> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **Want** object obtained. Otherwise, **err** is an error object.|
2671
2672**Error codes**
2673
2674For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2675
2676| ID| Error Message                            |
2677| -------- | --------------------------------------|
2678| 17700001 | The specified bundleName is not found. |
2679| 17700004 | The specified user ID is not found.     |
2680| 17700026 | The specified bundle is disabled.      |
2681
2682**Example**
2683
2684```ts
2685import bundleManager from '@ohos.bundle.bundleManager';
2686import { BusinessError } from '@ohos.base';
2687import hilog from '@ohos.hilog';
2688let bundleName = 'com.example.myapplication';
2689let userId = 100;
2690
2691try {
2692    bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
2693        if (err) {
2694            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2695        } else {
2696            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
2697        }
2698    });
2699} catch (err) {
2700    let message = (err as BusinessError).message;
2701    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
2702}
2703```
2704
2705### bundleManager.getLaunchWantForBundle
2706
2707getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
2708
2709Obtains the Want used to launch the bundle based on the given bundle name. This API uses an asynchronous callback to return the result.
2710
2711**System API**: This is a system API.
2712
2713**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2714
2715**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2716
2717**Parameters**
2718
2719| Name    | Type                | Mandatory| Description                                                        |
2720| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
2721| bundleName | string               | Yes  | Bundle name.                                    |
2722| callback   | AsyncCallback\<Want> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **Want** object obtained. Otherwise, **err** is an error object.|
2723
2724**Error codes**
2725
2726For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2727
2728| ID| Error Message                            |
2729| -------- | --------------------------------------|
2730| 17700001 | The specified bundleName is not found. |
2731| 17700026 | The specified bundle is disabled.      |
2732
2733**Example**
2734
2735```ts
2736import bundleManager from '@ohos.bundle.bundleManager';
2737import { BusinessError } from '@ohos.base';
2738import hilog from '@ohos.hilog';
2739let bundleName = 'com.example.myapplication';
2740
2741try {
2742    bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
2743        if (err) {
2744            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2745        } else {
2746            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
2747        }
2748    });
2749} catch (err) {
2750    let message = (err as BusinessError).message;
2751    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
2752}
2753```
2754
2755### bundleManager.getLaunchWantForBundle
2756
2757getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>
2758
2759Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API uses a promise to return the result.
2760
2761**System API**: This is a system API.
2762
2763**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2764
2765**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2766
2767**Parameters**
2768
2769| Name    | Type  | Mandatory| Description                      |
2770| ---------- | ------ | ---- | ------------------------- |
2771| bundleName | string | Yes  | Bundle name.|
2772| userId     | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
2773
2774**Return value**
2775
2776| Type          | Description                     |
2777| -------------- | ------------------------- |
2778| Promise\<Want> | Promise used to return the **Want** object obtained.|
2779
2780**Error codes**
2781
2782For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2783
2784| ID| Error Message                            |
2785| -------- | --------------------------------------|
2786| 17700001 | The specified bundleName is not found. |
2787| 17700004 | The specified user ID is not found.     |
2788| 17700026 | The specified bundle is disabled.      |
2789
2790**Example**
2791
2792```ts
2793import bundleManager from '@ohos.bundle.bundleManager';
2794import { BusinessError } from '@ohos.base';
2795import hilog from '@ohos.hilog';
2796let bundleName = 'com.example.myapplication';
2797let userId = 100;
2798
2799try {
2800    bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
2801        hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data));
2802    }).catch((err: BusinessError) => {
2803        hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message);
2804    });
2805} catch (err) {
2806    let message = (err as BusinessError).message;
2807    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', message);
2808}
2809```
2810
2811
2812### bundleManager.getLaunchWantForBundleSync<sup>10+</sup>
2813
2814getLaunchWantForBundleSync(bundleName: string, userId?: number): Want
2815
2816Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API returns the result synchronously.
2817
2818**System API**: This is a system API.
2819
2820**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2821
2822**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2823
2824**Parameters**
2825
2826| Name    | Type  | Mandatory| Description                      |
2827| ---------- | ------ | ---- | ------------------------- |
2828| bundleName | string | Yes  | Bundle name.|
2829| userId     | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
2830
2831**Return value**
2832
2833| Type          | Description                     |
2834| -------------- | ------------------------- |
2835| Want | **Want** object.|
2836
2837**Error codes**
2838
2839For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2840
2841| ID| Error Message                            |
2842| -------- | --------------------------------------|
2843| 17700001 | The specified bundleName is not found. |
2844| 17700004 | The specified user ID is not found.     |
2845| 17700026 | The specified bundle is disabled.      |
2846
2847**Example**
2848
2849```ts
2850import bundleManager from '@ohos.bundle.bundleManager';
2851import { BusinessError } from '@ohos.base';
2852import hilog from '@ohos.hilog';
2853import Want from '@ohos.app.ability.Want';
2854let bundleName = 'com.example.myapplication';
2855let userId = 100;
2856
2857try {
2858    let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName, userId);
2859    hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
2860} catch (err) {
2861    let message = (err as BusinessError).message;
2862    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
2863}
2864```
2865
2866```ts
2867import bundleManager from '@ohos.bundle.bundleManager';
2868import { BusinessError } from '@ohos.base';
2869import hilog from '@ohos.hilog';
2870import Want from '@ohos.app.ability.Want';
2871let bundleName = 'com.example.myapplication';
2872let userId = 100;
2873
2874try {
2875    let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName);
2876    hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
2877} catch (err) {
2878    let message = (err as BusinessError).message;
2879    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
2880}
2881```
2882
2883### bundleManager.getProfileByAbility
2884
2885getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
2886
2887Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API uses an asynchronous callback to return the result.
2888
2889**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2890
2891**Parameters**
2892
2893| Name      | Type                         | Mandatory| Description                                                        |
2894| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
2895| moduleName   | string                        | Yes  | Module name.                                    |
2896| abilityName  | string                        | Yes  | Name of the UIAbility component.                                   |
2897| metadataName | string                        | Yes  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file.                                 |
2898| callback     | AsyncCallback<Array\<string>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.|
2899
2900**Error codes**
2901
2902For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2903
2904| ID| Error Message                                                    |
2905| -------- | ------------------------------------------------------------ |
2906| 17700002 | The specified moduleName is not existed.                      |
2907| 17700003 | The specified abilityName is not existed.                     |
2908| 17700024 | Failed to get the profile because there is no profile in the HAP. |
2909| 17700026 | The specified bundle is disabled.                             |
2910| 17700029 | The specified ability is disabled.                            |
2911
2912**Example**
2913
2914```ts
2915import bundleManager from '@ohos.bundle.bundleManager';
2916import { BusinessError } from '@ohos.base';
2917import hilog from '@ohos.hilog';
2918let moduleName = 'entry';
2919let abilityName = 'EntryAbility';
2920let metadataName = 'ability_metadata';
2921
2922try {
2923    bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
2924        if (err) {
2925            hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2926        } else {
2927            hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data));
2928        }
2929    });
2930} catch (err) {
2931    let message = (err as BusinessError).message;
2932    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
2933}
2934```
2935
2936### bundleManager.getProfileByAbility
2937
2938getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\>
2939
2940Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API uses a promise to return the result.
2941
2942**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2943
2944**Parameters**
2945
2946| Name      | Type  | Mandatory| Description                      |
2947| ------------ | ------ | ---- | -------------------------- |
2948| moduleName   | string | Yes  | Module name.  |
2949| abilityName  | string | Yes  | Name of the UIAbility component. |
2950| metadataName | string | No  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. The default value is null.|
2951
2952**Return value**
2953
2954| Type                   | Description                           |
2955| ----------------------- | ------------------------------- |
2956| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
2957
2958**Error codes**
2959
2960For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2961
2962| ID| Error Message                                                    |
2963| -------- | ------------------------------------------------------------ |
2964| 17700002 | The specified moduleName is not existed.                      |
2965| 17700003 | The specified abilityName is not existed.                     |
2966| 17700024 | Failed to get the profile because there is no profile in the HAP. |
2967| 17700026 | The specified bundle is disabled.                             |
2968| 17700029 | The specified ability is disabled.                            |
2969
2970**Example**
2971
2972```ts
2973import bundleManager from '@ohos.bundle.bundleManager';
2974import { BusinessError } from '@ohos.base';
2975import hilog from '@ohos.hilog';
2976let moduleName = 'entry';
2977let abilityName = 'EntryAbility';
2978
2979try {
2980    bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
2981        hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
2982    }).catch((err: BusinessError) => {
2983        hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2984    });
2985} catch (err) {
2986    let message = (err as BusinessError).message;
2987    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
2988}
2989```
2990
2991```ts
2992import bundleManager from '@ohos.bundle.bundleManager';
2993import { BusinessError } from '@ohos.base';
2994import hilog from '@ohos.hilog';
2995let moduleName = 'entry';
2996let abilityName = 'EntryAbility';
2997let metadataName = 'ability_metadata';
2998try {
2999    bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
3000        hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
3001    }).catch((err: BusinessError) => {
3002        hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
3003    });
3004} catch (err) {
3005    let message = (err as BusinessError).message;
3006    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message);
3007}
3008```
3009
3010### bundleManager.getProfileByAbilitySync<sup>10+</sup>
3011
3012getProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?: string): Array\<string\>
3013
3014Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API returns the result synchronously. The result value is a string array.
3015
3016**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3017
3018**Parameters**
3019
3020| Name      | Type  | Mandatory| Description                      |
3021| ------------ | ------ | ---- | -------------------------- |
3022| moduleName   | string | Yes  | Module name.  |
3023| abilityName  | string | Yes  | Name of the UIAbility component. |
3024| metadataName | string | No  | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. The default value is null.|
3025
3026**Return value**
3027
3028| Type                   | Description                           |
3029| ----------------------- | ------------------------------- |
3030| Array\<string> | An array of JSON strings.|
3031
3032**Error codes**
3033
3034For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3035
3036| ID| Error Message                                                    |
3037| -------- | ------------------------------------------------------------ |
3038| 17700002 | The specified moduleName is not existed.                      |
3039| 17700003 | The specified abilityName is not existed.                     |
3040| 17700024 | Failed to get the profile because there is no profile in the HAP. |
3041| 17700026 | The specified bundle is disabled.                             |
3042| 17700029 | The specified ability is disabled.                            |
3043
3044**Example**
3045
3046```ts
3047import bundleManager from '@ohos.bundle.bundleManager';
3048import { BusinessError } from '@ohos.base';
3049import hilog from '@ohos.hilog';
3050let moduleName = 'entry';
3051let abilityName = 'EntryAbility';
3052
3053try {
3054    let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName);
3055    hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
3056} catch (err) {
3057    let message = (err as BusinessError).message;
3058    hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
3059}
3060```
3061
3062```ts
3063import bundleManager from '@ohos.bundle.bundleManager';
3064import { BusinessError } from '@ohos.base';
3065import hilog from '@ohos.hilog';
3066let moduleName: string = 'entry';
3067let abilityName: string = 'EntryAbility';
3068let metadataName: string = 'ability_metadata';
3069try {
3070    let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName);
3071    hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
3072} catch (err) {
3073    let message = (err as BusinessError).message;
3074    hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message);
3075}
3076```
3077
3078### bundleManager.getProfileByExtensionAbility
3079
3080getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void
3081
3082Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API uses an asynchronous callback to return the result.
3083
3084**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3085
3086**Parameters**
3087
3088| Name                | Type                         | Mandatory| Description                                                        |
3089| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
3090| moduleName           | string                        | Yes  | Module name.                                  |
3091| extensionAbilityName | string                        | Yes  | Name of the ExtensionAbility component.                        |
3092| metadataName         | string                        | Yes  | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file.                                |
3093| callback             | AsyncCallback<Array\<string>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.|
3094
3095**Error codes**
3096
3097For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3098
3099| ID| Error Message                                                    |
3100| -------- | ------------------------------------------------------------ |
3101| 17700002 | The specified moduleName is not existed.                      |
3102| 17700003 | The specified extensionAbilityName not existed.            |
3103| 17700024 | Failed to get the profile because there is no profile in the HAP. |
3104| 17700026 | The specified bundle is disabled.                             |
3105
3106**Example**
3107
3108```ts
3109import bundleManager from '@ohos.bundle.bundleManager';
3110import { BusinessError } from '@ohos.base';
3111import hilog from '@ohos.hilog';
3112let moduleName = 'entry';
3113let extensionAbilityName = 'com.example.myapplication.extension';
3114let metadataName = 'ability_metadata';
3115
3116try {
3117    bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
3118        if (err) {
3119            hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message);
3120        } else {
3121            hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data));
3122        }
3123    });
3124} catch (err) {
3125    let message = (err as BusinessError).message;
3126    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message);
3127}
3128```
3129
3130### bundleManager.getProfileByExtensionAbility
3131
3132getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\>
3133
3134Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API uses a promise to return the result.
3135
3136**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3137
3138**Parameters**
3139
3140| Name                | Type  | Mandatory| Description                              |
3141| -------------------- | ------ | ---- | ---------------------------------- |
3142| moduleName           | string | Yes  | Module name.          |
3143| extensionAbilityName | string | Yes  | Name of the ExtensionAbility component.|
3144| metadataName         | string | No  | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. The default value is null.        |
3145
3146**Return value**
3147
3148| Type                   | Description                               |
3149| ----------------------- | ----------------------------------- |
3150| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
3151
3152**Error codes**
3153
3154For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3155
3156| ID| Error Message                                                    |
3157| -------- | ------------------------------------------------------------ |
3158| 17700002 | The specified moduleName is not existed.                      |
3159| 17700003 | The specified extensionAbilityName not existed.            |
3160| 17700024 | Failed to get the profile because there is no profile in the HAP. |
3161| 17700026 | The specified bundle is disabled.                             |
3162
3163**Example**
3164
3165```ts
3166import bundleManager from '@ohos.bundle.bundleManager';
3167import { BusinessError } from '@ohos.base';
3168import hilog from '@ohos.hilog';
3169let moduleName = 'entry';
3170let extensionAbilityName = 'com.example.myapplication.extension';
3171let metadataName = 'ability_metadata';
3172
3173try {
3174    bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
3175        hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
3176    }).catch((err: BusinessError) => {
3177        hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
3178    });
3179} catch (err) {
3180    let message = (err as BusinessError).message;
3181    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
3182}
3183
3184try {
3185    bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
3186        hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
3187    }).catch((err: BusinessError) => {
3188        hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
3189    });
3190} catch (err) {
3191    let message = (err as BusinessError).message;
3192    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message);
3193}
3194```
3195
3196### bundleManager.getProfileByExtensionAbilitySync<sup>10+</sup>
3197
3198getProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: string, metadataName?: string): Array\<string\>
3199
3200Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API returns the result synchronously. The result value is a string array.
3201
3202**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3203
3204**Parameters**
3205
3206| Name                | Type  | Mandatory| Description                              |
3207| -------------------- | ------ | ---- | ---------------------------------- |
3208| moduleName           | string | Yes  | Module name.          |
3209| extensionAbilityName | string | Yes  | Name of the ExtensionAbility component.|
3210| metadataName         | string | No  | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. The default value is null.        |
3211
3212**Return value**
3213
3214| Type                   | Description                               |
3215| ----------------------- | ----------------------------------- |
3216| Array\<string> | An array of JSON strings.|
3217
3218**Error codes**
3219
3220For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3221
3222| ID| Error Message                                                    |
3223| -------- | ------------------------------------------------------------ |
3224| 17700002 | The specified moduleName is not existed.                      |
3225| 17700003 | The specified extensionAbilityName not existed.            |
3226| 17700024 | Failed to get the profile because there is no profile in the HAP. |
3227| 17700026 | The specified bundle is disabled.                             |
3228
3229**Example**
3230
3231```ts
3232import bundleManager from '@ohos.bundle.bundleManager';
3233import { BusinessError } from '@ohos.base';
3234import hilog from '@ohos.hilog';
3235let moduleName = 'entry';
3236let extensionAbilityName = 'com.example.myapplication.extension';
3237let metadataName = 'ability_metadata';
3238
3239try {
3240    let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
3241    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
3242} catch (err) {
3243    let message = (err as BusinessError).message;
3244    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
3245}
3246
3247try {
3248    let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
3249    hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data));
3250} catch (err) {
3251    let message = (err as BusinessError).message;
3252    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
3253}
3254```
3255
3256### bundleManager.getPermissionDef
3257
3258getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>): void
3259
3260Obtains the **PermissionDef** struct based on the given permission name. This API uses an asynchronous callback to return the result.
3261
3262**System API**: This is a system API.
3263
3264**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3265
3266**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3267
3268**Parameters**
3269
3270| Name          | Type                                                        | Mandatory| Description                                                        |
3271| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3272| permissionName | string                                                       | Yes  | Name of the permission.                                              |
3273| callback       | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **PermissionDef** object obtained. Otherwise, **err** is an error object.|
3274
3275**Error codes**
3276
3277For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3278
3279| ID| Error Message                             |
3280| -------- | ------------------------------------- |
3281| 17700006 | The specified permission is not found. |
3282
3283**Example**
3284
3285```ts
3286import bundleManager from '@ohos.bundle.bundleManager';
3287import { BusinessError } from '@ohos.base';
3288import hilog from '@ohos.hilog';
3289let permission = "ohos.permission.GET_BUNDLE_INFO";
3290try {
3291    bundleManager.getPermissionDef(permission, (err, data) => {
3292        if (err) {
3293            hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message);
3294        } else {
3295            hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', JSON.stringify(data));
3296        }
3297    });
3298} catch (err) {
3299    let message = (err as BusinessError).message;
3300    hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', message);
3301}
3302```
3303
3304### bundleManager.getPermissionDef
3305
3306getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>
3307
3308Obtains the **PermissionDef** struct based on the given permission name. This API uses a promise to return the result.
3309
3310**System API**: This is a system API.
3311
3312**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3313
3314**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3315
3316**Parameters**
3317
3318| Name          | Type  | Mandatory| Description          |
3319| -------------- | ------ | ---- | -------------- |
3320| permissionName | string | Yes  | Name of the permission.|
3321
3322**Return value**
3323
3324| Type                                                        | Description                                      |
3325| ------------------------------------------------------------ | ------------------------------------------ |
3326| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | Promise used to return the **PermissionDef** object obtained.|
3327
3328**Error codes**
3329
3330For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3331
3332| ID| Error Message                             |
3333| -------- | ------------------------------------- |
3334| 17700006 | The specified permission is not found. |
3335
3336**Example**
3337
3338```ts
3339import bundleManager from '@ohos.bundle.bundleManager';
3340import { BusinessError } from '@ohos.base';
3341import hilog from '@ohos.hilog';
3342let permissionName = "ohos.permission.GET_BUNDLE_INFO";
3343try {
3344    bundleManager.getPermissionDef(permissionName).then((data) => {
3345        hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data));
3346    }).catch((err: BusinessError) => {
3347        hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message);
3348    });
3349} catch (err) {
3350    let message = (err as BusinessError).message;
3351    hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', message);
3352}
3353```
3354
3355### bundleManager.getPermissionDefSync<sup>10+</sup>
3356
3357getPermissionDefSync(permissionName: string): [PermissionDef](js-apis-bundleManager-permissionDef.md);
3358
3359Obtains the **PermissionDef** struct based on the given permission name. This API returns the result synchronously.
3360
3361**System API**: This is a system API.
3362
3363**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3364
3365**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3366
3367**Parameters**
3368
3369| Name          | Type  | Mandatory| Description          |
3370| -------------- | ------ | ---- | -------------- |
3371| permissionName | string | Yes  | Name of the permission.|
3372
3373**Return value**
3374
3375| Type                                                        | Description                                      |
3376| ------------------------------------------------------------ | ------------------------------------------ |
3377|[PermissionDef](js-apis-bundleManager-permissionDef.md) | **PermissionDef** object.|
3378
3379**Error codes**
3380
3381For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3382
3383| ID| Error Message                             |
3384| -------- | ------------------------------------- |
3385| 17700006 | The specified permission is not found. |
3386
3387**Example**
3388
3389```ts
3390import bundleManager from '@ohos.bundle.bundleManager';
3391import { BusinessError } from '@ohos.base';
3392import hilog from '@ohos.hilog';
3393let permissionName = "ohos.permission.GET_BUNDLE_INFO";
3394try {
3395    let PermissionDef = bundleManager.getPermissionDefSync(permissionName);
3396    hilog.info(0x0000, 'testTag', 'getPermissionDefSync successfully. Data: %{public}s', JSON.stringify(PermissionDef));
3397} catch (err) {
3398    let message = (err as BusinessError).message;
3399    hilog.error(0x0000, 'testTag', 'getPermissionDefSync failed. Cause: %{public}s', message);
3400}
3401```
3402
3403### bundleManager.getAbilityLabel
3404
3405getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<string>): void
3406
3407Obtains the ability label based on the given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result.
3408
3409**System API**: This is a system API.
3410
3411**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3412
3413**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
3414
3415**Parameters**
3416
3417| Name     | Type                  | Mandatory| Description                                                        |
3418| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
3419| bundleName  | string                 | Yes  | Bundle name.                                    |
3420| moduleName  | string                 | Yes  | Module name.                                    |
3421| abilityName | string                 | Yes  | Name of the UIAbility component.                                   |
3422| callback    | AsyncCallback\<string> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the label obtained. Otherwise, **err** is an error object.|
3423
3424**Error codes**
3425
3426For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3427
3428| ID| Error Message                              |
3429| -------- | -------------------------------------- |
3430| 17700001 | The specified bundleName is not found.  |
3431| 17700002 | The specified moduleName is not found.  |
3432| 17700003 | The specified abilityName is not found. |
3433| 17700026 | The specified bundle is disabled.       |
3434| 17700029 | The specified ability is disabled.      |
3435
3436**Example**
3437
3438```ts
3439import bundleManager from '@ohos.bundle.bundleManager';
3440import { BusinessError } from '@ohos.base';
3441import hilog from '@ohos.hilog';
3442let bundleName = 'com.example.myapplication';
3443let moduleName = 'entry';
3444let abilityName = 'EntryAbility';
3445
3446try {
3447    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
3448        if (err) {
3449            hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message);
3450        } else {
3451            hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', JSON.stringify(data));
3452        }
3453    });
3454} catch (err) {
3455    let message = (err as BusinessError).message;
3456    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', message);
3457}
3458```
3459
3460### bundleManager.getAbilityLabel
3461
3462getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>
3463
3464Obtains the ability label based on the given bundle name, module name, and ability name. This API uses a promise to return the result.
3465
3466**System API**: This is a system API.
3467
3468**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3469
3470**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
3471
3472**Parameters**
3473
3474| Name     | Type  | Mandatory| Description                     |
3475| ----------- | ------ | ---- | ------------------------- |
3476| bundleName  | string | Yes  | Bundle name. |
3477| moduleName  | string | Yes  | Module name. |
3478| abilityName | string | Yes  | Name of the UIAbility component.|
3479
3480**Return value**
3481
3482| Type            | Description                               |
3483| ---------------- | ----------------------------------- |
3484| Promise\<string> | Promise used to return the label.|
3485
3486**Error codes**
3487
3488For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3489
3490| ID| Error Message                             |
3491| -------- | --------------------------------------- |
3492| 17700001 | The specified bundleName is not found.  |
3493| 17700002 | The specified moduleName is not found.  |
3494| 17700003 | The specified abilityName is not found. |
3495| 17700026 | The specified bundle is disabled.       |
3496| 17700029 | The specified ability is disabled.      |
3497
3498**Example**
3499
3500```ts
3501import bundleManager from '@ohos.bundle.bundleManager';
3502import { BusinessError } from '@ohos.base';
3503import hilog from '@ohos.hilog';
3504let bundleName = 'com.example.myapplication';
3505let moduleName = 'entry';
3506let abilityName = 'EntryAbility';
3507
3508try {
3509    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
3510        hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data));
3511    }).catch((err: BusinessError) => {
3512        hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message);
3513    });
3514} catch (err) {
3515    let message = (err as BusinessError).message;
3516    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', message);
3517}
3518```
3519
3520### bundleManager.getAbilityLabelSync<sup>10+</sup>
3521
3522getAbilityLabelSync(bundleName: string, moduleName: string, abilityName: string): string
3523
3524Obtains the ability label based on the given bundle name, module name, and ability name. This API returns the result synchronously.
3525
3526**System API**: This is a system API.
3527
3528**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3529
3530**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
3531
3532**Parameters**
3533
3534| Name     | Type  | Mandatory| Description                     |
3535| ----------- | ------ | ---- | ------------------------- |
3536| bundleName  | string | Yes  | Bundle name. |
3537| moduleName  | string | Yes  | Module name. |
3538| abilityName | string | Yes  | Name of the UIAbility component.|
3539
3540**Return value**
3541
3542| Type            | Description                               |
3543| ---------------- | ----------------------------------- |
3544| string | Label of the ability.|
3545
3546**Error codes**
3547
3548For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3549
3550| ID| Error Message                             |
3551| -------- | --------------------------------------- |
3552| 17700001 | The specified bundleName is not found.  |
3553| 17700002 | The specified moduleName is not found.  |
3554| 17700003 | The specified abilityName is not found. |
3555| 17700026 | The specified bundle is disabled.       |
3556| 17700029 | The specified ability is disabled.      |
3557
3558**Example**
3559
3560```ts
3561import bundleManager from '@ohos.bundle.bundleManager';
3562import { BusinessError } from '@ohos.base';
3563import hilog from '@ohos.hilog';
3564let bundleName = 'com.example.myapplication';
3565let moduleName = 'entry';
3566let abilityName = 'EntryAbility';
3567
3568try {
3569    let abilityLabel = bundleManager.getAbilityLabelSync(bundleName, moduleName, abilityName);
3570    hilog.info(0x0000, 'testTag', 'getAbilityLabelSync successfully. Data: %{public}s', abilityLabel);
3571} catch (err) {
3572    let message = (err as BusinessError).message;
3573    hilog.error(0x0000, 'testTag', 'getAbilityLabelSync failed. Cause: %{public}s', message);
3574}
3575```
3576
3577### bundleManager.getApplicationInfoSync
3578
3579getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md)
3580
3581Obtains the application information based on the given bundle name, application flags, and user ID. This API returns the result synchronously.
3582
3583**System API**: This is a system API.
3584
3585**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3586
3587**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3588
3589**Parameters**
3590
3591| Name      | Type  | Mandatory| Description                                                      |
3592| ----------- | ------ | ---- | ----------------------------------------------------------|
3593| bundleName  | string | Yes  | Bundle name.                                 |
3594| applicationFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.      |
3595| userId      | number | Yes  | User ID.                                        |
3596
3597**Return value**
3598
3599| Type           | Description                     |
3600| --------------- | ------------------------- |
3601| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
3602
3603**Error codes**
3604
3605For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3606
3607| ID| Error Message                            |
3608| -------- | -------------------------------------- |
3609| 17700001 | The specified bundleName is not found. |
3610| 17700004 | The specified user ID is not found.     |
3611| 17700026 | The specified bundle is disabled.      |
3612
3613**Example**
3614
3615```ts
3616import bundleManager from '@ohos.bundle.bundleManager';
3617import { BusinessError } from '@ohos.base';
3618import hilog from '@ohos.hilog';
3619let bundleName = 'com.example.myapplication';
3620let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
3621let userId = 100;
3622
3623try {
3624    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
3625    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
3626} catch (err) {
3627    let message = (err as BusinessError).message;
3628    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
3629}
3630```
3631
3632### bundleManager.getApplicationInfoSync
3633
3634getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md)
3635
3636Obtains the application information based on the given bundle name and application flags. This API returns the result synchronously.
3637
3638**System API**: This is a system API.
3639
3640**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3641
3642**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3643
3644**Parameters**
3645
3646| Name          | Type                      | Mandatory| Description                                                 |
3647| ---------------- | -------------------------- | ---- | ----------------------------------------------------- |
3648| bundleName       | string                     | Yes  | Bundle name.                           |
3649| applicationFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.|
3650
3651**Return value**
3652
3653| Type                                                       | Description                     |
3654| ----------------------------------------------------------- | ------------------------- |
3655| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
3656
3657**Error codes**
3658
3659For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3660
3661| ID| Error Message                              |
3662| -------- | -------------------------------------- |
3663| 17700001 | The specified bundleName is not found. |
3664| 17700026 | The specified bundle is disabled.      |
3665
3666**Example**
3667
3668```ts
3669import bundleManager from '@ohos.bundle.bundleManager';
3670import { BusinessError } from '@ohos.base';
3671import hilog from '@ohos.hilog';
3672let bundleName = 'com.example.myapplication';
3673let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
3674
3675try {
3676    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
3677    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
3678} catch (err) {
3679    let message = (err as BusinessError).message;
3680    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
3681}
3682```
3683
3684### bundleManager.getBundleInfoSync
3685
3686getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md)
3687
3688Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API returns the result synchronously.
3689
3690**System API**: This is a system API.
3691
3692**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3693
3694**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3695
3696**Parameters**
3697
3698| Name      | Type  | Mandatory| Description                                                    |
3699| ----------- | ------ | ---- | -------------------------------------------------------- |
3700| bundleName  | string | Yes  | Bundle name.                                |
3701| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
3702| userId      | number | Yes  | User ID.                                            |
3703
3704**Return value**
3705
3706| Type      | Description                |
3707| ---------- | -------------------- |
3708| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
3709
3710**Error codes**
3711
3712For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3713
3714| ID| Error Message                            |
3715| -------- | ------------------------------------- |
3716| 17700001 | The specified bundleName is not found. |
3717| 17700004 | The specified user ID is not found.     |
3718| 17700026 | The specified bundle is disabled.      |
3719
3720**Example**
3721
3722```ts
3723import bundleManager from '@ohos.bundle.bundleManager';
3724import { BusinessError } from '@ohos.base';
3725import hilog from '@ohos.hilog';
3726let bundleName = 'com.example.myapplication';
3727let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
3728let userId = 100;
3729
3730try {
3731    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
3732    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
3733} catch (err) {
3734    let message = (err as BusinessError).message;
3735    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
3736}
3737```
3738
3739### bundleManager.getBundleInfoSync
3740
3741getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md)
3742
3743Obtains the bundle information based on the given bundle name and bundle flags. This API returns the result synchronously.
3744
3745**System API**: This is a system API.
3746
3747**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3748
3749**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3750
3751**Parameters**
3752
3753| Name     | Type                 | Mandatory| Description                                                  |
3754| ----------- | --------------------- | ---- | ------------------------------------------------------ |
3755| bundleName  | string                | Yes  | Bundle name.                            |
3756| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
3757
3758**Return value**
3759
3760| Type                                             | Description                |
3761| ------------------------------------------------- | -------------------- |
3762| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
3763
3764**Error codes**
3765
3766For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3767
3768| ID| Error Message                              |
3769| -------- | -------------------------------------- |
3770| 17700001 | The specified bundleName is not found. |
3771| 17700026 | The specified bundle is disabled.      |
3772
3773**Example**
3774
3775```ts
3776import bundleManager from '@ohos.bundle.bundleManager';
3777import { BusinessError } from '@ohos.base';
3778import hilog from '@ohos.hilog';
3779let bundleName = 'com.example.myapplication';
3780let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
3781try {
3782    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
3783    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
3784} catch (err) {
3785    let message = (err as BusinessError).message;
3786    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
3787}
3788```
3789
3790### bundleManager.getSharedBundleInfo<sup>10+</sup>
3791
3792getSharedBundleInfo(bundleName: string,  moduleName: string, callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void
3793
3794Obtains the shared bundle information based on the given bundle name. This API uses an asynchronous callback to return the result.
3795
3796**System API**: This is a system API.
3797
3798**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3799
3800**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3801
3802**Parameters**
3803
3804| Name    | Type                                                        | Mandatory| Description                                                        |
3805| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3806| bundleName | string                                                       | Yes  | Bundle name.                                  |
3807| moduleName | string                                                       | Yes  | Module name.                                  |
3808| callback   | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)\>\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the shared bundle information obtained.|
3809
3810**Error codes**
3811
3812For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3813
3814| ID| Error Message                              |
3815| -------- | -------------------------------------- |
3816| 17700001 | The specified bundleName is not found. |
3817| 17700002 | The specified moduleName is not found. |
3818
3819**Example**
3820
3821```ts
3822import bundleManager from '@ohos.bundle.bundleManager';
3823import { BusinessError } from '@ohos.base';
3824import hilog from '@ohos.hilog';
3825let bundleName = 'com.example.myapplication';
3826let moduleName = 'library';
3827
3828try {
3829    bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => {
3830        if (err) {
3831            hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message);
3832        } else {
3833            hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
3834        }
3835    });
3836} catch (err) {
3837    let message = (err as BusinessError).message;
3838    hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', message);
3839}
3840```
3841
3842### bundleManager.getSharedBundleInfo<sup>10+</sup>
3843
3844getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<SharedBundleInfo\>\>
3845
3846Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result.
3847
3848**System API**: This is a system API.
3849
3850**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3851
3852**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3853
3854**Parameters**
3855
3856| Name    | Type  | Mandatory| Description                      |
3857| ---------- | ------ | ---- | -------------------------- |
3858| bundleName | string | Yes  | Bundle name.|
3859| moduleName | string | Yes  | Module name.|
3860
3861**Return value**
3862
3863| Type                                                        | Description                               |
3864| ------------------------------------------------------------ | ----------------------------------- |
3865| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)\>\> | Promise used to return the shared bundle information obtained.|
3866
3867**Error codes**
3868
3869For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3870
3871| ID| Error Message                              |
3872| -------- | -------------------------------------- |
3873| 17700001 | The specified bundleName is not found. |
3874| 17700002 | The specified moduleName is not found. |
3875
3876**Example**
3877
3878```ts
3879import bundleManager from '@ohos.bundle.bundleManager';
3880import { BusinessError } from '@ohos.base';
3881import hilog from '@ohos.hilog';
3882let bundleName = 'com.example.myapplication';
3883let moduleName = 'library';
3884
3885try {
3886    bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => {
3887        hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
3888    }).catch((err: BusinessError) => {
3889        hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message);
3890    });
3891} catch (err) {
3892    let message = (err as BusinessError).message;
3893    hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', message);
3894}
3895```
3896
3897### bundleManager.getAllSharedBundleInfo<sup>10+</sup>
3898
3899getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void
3900
3901Obtains the information about all shared bundles. This API uses an asynchronous callback to return the result.
3902
3903**System API**: This is a system API.
3904
3905**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3906
3907**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3908
3909**Parameters**
3910
3911| Name  | Type                                                        | Mandatory| Description                                                        |
3912| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3913| callback | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)\>\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is an array of the shared bundle information obtained.|
3914
3915**Example**
3916
3917```ts
3918import bundleManager from '@ohos.bundle.bundleManager';
3919import { BusinessError } from '@ohos.base';
3920import hilog from '@ohos.hilog';
3921
3922try {
3923    bundleManager.getAllSharedBundleInfo((err, data) => {
3924        if (err) {
3925            hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message);
3926        } else {
3927            hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
3928        }
3929    });
3930} catch (err) {
3931    let message = (err as BusinessError).message;
3932    hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', message);
3933}
3934```
3935
3936### bundleManager.getAllSharedBundleInfo<sup>10+</sup>
3937
3938getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>
3939
3940Obtains the information about all shared bundles. This API uses a promise to return the result.
3941
3942**System API**: This is a system API.
3943
3944**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3945
3946**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3947
3948**Return value**
3949
3950| Type                                                        | Description                               |
3951| ------------------------------------------------------------ | ----------------------------------- |
3952| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)\>\> | Promise used to return an array of the shared bundle information obtained.|
3953
3954**Example**
3955
3956```ts
3957import bundleManager from '@ohos.bundle.bundleManager';
3958import { BusinessError } from '@ohos.base';
3959import hilog from '@ohos.hilog';
3960
3961try {
3962    bundleManager.getAllSharedBundleInfo().then((data) => {
3963        hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
3964    }).catch((err: BusinessError) => {
3965        hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
3966    });
3967} catch (err) {
3968    let message = (err as BusinessError).message;
3969    hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', message);
3970}
3971```
3972
3973### bundleManager.getAppProvisionInfo<sup>10+</sup>
3974
3975getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)\>): void
3976
3977Obtains the provision profile based on the given bundle name. This API uses an asynchronous callback to return the result.
3978
3979**System API**: This is a system API.
3980
3981**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3982
3983**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3984
3985**Parameters**
3986
3987| Name  | Type                                                        | Mandatory| Description                                                        |
3988| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3989| bundleName | string | Yes  | Bundle name.|
3990| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the provision profile obtained.|
3991
3992**Error codes**
3993
3994For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
3995
3996| ID| Error Message                              |
3997| -------- | -------------------------------------- |
3998| 17700001 | The specified bundleName is not found. |
3999
4000**Example**
4001
4002```ts
4003import bundleManager from '@ohos.bundle.bundleManager';
4004import { BusinessError } from '@ohos.base';
4005import hilog from '@ohos.hilog';
4006let bundleName = "com.ohos.myapplication";
4007
4008try {
4009    bundleManager.getAppProvisionInfo(bundleName, (err, data) => {
4010        if (err) {
4011            hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message);
4012        } else {
4013            hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data));
4014        }
4015    });
4016} catch (err) {
4017    let message = (err as BusinessError).message;
4018    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
4019}
4020```
4021
4022### bundleManager.getAppProvisionInfo<sup>10+</sup>
4023
4024getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)\>): void
4025
4026Obtains the provision profile based on the given bundle name and user ID. This API uses an asynchronous callback to return the result.
4027
4028**System API**: This is a system API.
4029
4030**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4031
4032**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4033
4034**Parameters**
4035
4036| Name  | Type                                                        | Mandatory| Description                                                        |
4037| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4038| bundleName | string | Yes  | Bundle name.|
4039| userId | number | Yes| User ID, which can be obtained by calling [getOsAccountLocalId](js-apis-osAccount.md#getosaccountlocalid9).|
4040| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the provision profile obtained.|
4041
4042
4043**Error codes**
4044
4045For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
4046
4047| ID| Error Message                              |
4048| -------- | -------------------------------------- |
4049| 17700001 | The specified bundleName is not found. |
4050| 17700004 | The specified user ID is not found. |
4051
4052**Example**
4053
4054```ts
4055import bundleManager from '@ohos.bundle.bundleManager';
4056import { BusinessError } from '@ohos.base';
4057import hilog from '@ohos.hilog';
4058let bundleName = "com.ohos.myapplication";
4059let userId = 100;
4060
4061try {
4062    bundleManager.getAppProvisionInfo(bundleName, userId, (err, data) => {
4063        if (err) {
4064            hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message);
4065        } else {
4066            hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data));
4067        }
4068    });
4069} catch (err) {
4070    let message = (err as BusinessError).message;
4071    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
4072}
4073```
4074
4075### bundleManager.getAppProvisionInfo<sup>10+</sup>
4076
4077getAppProvisionInfo(bundleName: string, userId?: number): Promise\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)\>
4078
4079Obtains the provision profile based on the given bundle name and user ID. This API uses a promise to return the result.
4080
4081**System API**: This is a system API.
4082
4083**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4084
4085**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4086
4087**Parameters**
4088
4089| Name  | Type        | Mandatory| Description         |
4090| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4091| bundleName | string | Yes| Bundle name.|
4092| userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. You can call [getOsAccountLocalId](js-apis-osAccount.md#getosaccountlocalid9) to obtain the user ID on the current device.|
4093
4094
4095**Return value**
4096
4097| Type                                                        | Description                               |
4098| ------------------------------------------------------------ | ----------------------------------- |
4099| Promise\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)\> | Promise used to return the provision profile obtained.|
4100
4101**Error codes**
4102
4103For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
4104
4105| ID| Error Message                              |
4106| -------- | -------------------------------------- |
4107| 17700001 | The specified bundleName is not found. |
4108| 17700004 | The specified user ID is not found. |
4109
4110**Example**
4111
4112```ts
4113import bundleManager from '@ohos.bundle.bundleManager';
4114import { BusinessError } from '@ohos.base';
4115import hilog from '@ohos.hilog';
4116let bundleName = "com.ohos.myapplication";
4117let userId = 100;
4118
4119try {
4120    bundleManager.getAppProvisionInfo(bundleName).then((data) => {
4121        hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
4122    }).catch((err: BusinessError) => {
4123        hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
4124    });
4125} catch (err) {
4126    let message = (err as BusinessError).message;
4127    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
4128}
4129
4130try {
4131    bundleManager.getAppProvisionInfo(bundleName, userId).then((data) => {
4132        hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
4133    }).catch((err: BusinessError) => {
4134        hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
4135    });
4136} catch (err) {
4137    let message = (err as BusinessError).message;
4138    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
4139}
4140```
4141
4142### bundleManager.getAppProvisionInfoSync<sup>10+</sup>
4143
4144getAppProvisionInfoSync(bundleName: string, userId?: number): AppProvisionInfo
4145
4146Obtains the provision profile based on the given bundle name and user ID. This API returns the result synchronously.
4147
4148**System API**: This is a system API.
4149
4150**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4151
4152**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4153
4154**Parameters**
4155
4156| Name  | Type        | Mandatory| Description         |
4157| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4158| bundleName | string | Yes| Bundle name.|
4159| userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. You can call [getOsAccountLocalId](js-apis-osAccount.md#getosaccountlocalid9) to obtain the user ID on the current device.|
4160
4161
4162**Return value**
4163
4164| Type                                                        | Description                               |
4165| ------------------------------------------------------------ | ----------------------------------- |
4166| [AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md) | Provision profile.|
4167
4168**Error codes**
4169
4170For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
4171
4172| ID| Error Message                              |
4173| -------- | -------------------------------------- |
4174| 17700001 | The specified bundleName is not found. |
4175| 17700004 | The specified user ID is not found. |
4176
4177**Example**
4178
4179```ts
4180import bundleManager from '@ohos.bundle.bundleManager';
4181import { BusinessError } from '@ohos.base';
4182import hilog from '@ohos.hilog';
4183let bundleName = "com.ohos.myapplication";
4184let userId = 100;
4185
4186try {
4187    let data = bundleManager.getAppProvisionInfoSync(bundleName);
4188    hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4189} catch (err) {
4190    let message = (err as BusinessError).message;
4191    hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
4192}
4193
4194try {
4195    let data = bundleManager.getAppProvisionInfoSync(bundleName, userId);
4196    hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4197} catch (err) {
4198    let message = (err as BusinessError).message;
4199    hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
4200}
4201```
4202
4203### bundleManager.getSpecifiedDistributionType<sup>10+</sup>
4204getSpecifiedDistributionType(bundleName: string): string
4205
4206Obtains the distribution type of a bundle in synchronous mode. The return value is the **specifiedDistributionType** field value in [InstallParam](./js-apis-installer.md#installparam) passed when **install** is called.
4207
4208**System API**: This is a system API.
4209
4210**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4211
4212**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4213
4214**Parameters**
4215
4216| Name        | Type                               | Mandatory| Description                        |
4217| -------------- | ----------------------------------- | ---- | ---------------------------- |
4218| bundleName | string | Yes  | Bundle name.|
4219
4220**Return value**
4221
4222| Type         | Description                                  |
4223| ------------- | -------------------------------------- |
4224| string | Distribution type of the bundle.|
4225
4226**Error codes**
4227
4228For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
4229
4230| ID| Error Message                                                    |
4231| -------- | ------------------------------------------------------------ |
4232| 17700001 | The specified bundleName is not found. |
4233
4234**Example**
4235```ts
4236import bundleManager from '@ohos.bundle.bundleManager';
4237import { BusinessError } from '@ohos.base';
4238let bundleName = "com.example.myapplication";
4239
4240try {
4241    let type = bundleManager.getSpecifiedDistributionType(bundleName);
4242    console.info('getSpecifiedDistributionType successfully, type:' + type);
4243} catch (error) {
4244    let message = (error as BusinessError).message;
4245    console.error('getSpecifiedDistributionType failed. Cause: ' + message);
4246}
4247```
4248
4249
4250### bundleManager.getAdditionalInfo<sup>10+</sup>
4251
4252getAdditionalInfo(bundleName: string): string
4253
4254Obtains additional information about a bundle in synchronous mode. The return value is the **additionalInfo** field value in [InstallParam](./js-apis-installer.md#installparam) passed when **install** is called.
4255
4256**System API**: This is a system API.
4257
4258**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4259
4260**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4261
4262**Parameters**
4263
4264| Name        | Type                               | Mandatory| Description                        |
4265| -------------- | ----------------------------------- | ---- | ---------------------------- |
4266| bundleName | string | Yes  | Bundle name.|
4267
4268**Return value**
4269
4270| Type         | Description                                  |
4271| ------------- | -------------------------------------- |
4272| string | Additional information about the bundle.|
4273
4274**Error codes**
4275
4276For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
4277
4278| ID| Error Message                                                    |
4279| -------- | ------------------------------------------------------------ |
4280| 17700001 | The specified bundleName is not found. |
4281
4282**Example**
4283
4284```ts
4285import bundleManager from '@ohos.bundle.bundleManager';
4286import { BusinessError } from '@ohos.base';
4287let bundleName = "com.example.myapplication";
4288
4289try {
4290    let info = bundleManager.getAdditionalInfo(bundleName);
4291    console.info('getAdditionalInfo successfully, additionInfo:' + info);
4292} catch (error) {
4293    let message = (error as BusinessError).message;
4294    console.error('getAdditionalInfo failed. Cause: ' + message);
4295}
4296```
4297
4298### bundleManager.getBundleInfoForSelfSync<sup>10+</sup>
4299
4300getBundleInfoForSelfSync(bundleFlags: number): BundleInfo
4301
4302Obtains the bundle information of this bundle based on the given bundle flags in synchronous mode.
4303
4304**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4305
4306**Parameters**
4307
4308| Name    | Type  | Mandatory| Description               |
4309| ----------- | ------ | ---- | --------------------- |
4310| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
4311
4312**Return value**
4313
4314| Type                                             | Description                |
4315| ------------------------------------------------- | -------------------- |
4316| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
4317
4318**Example**
4319
4320```ts
4321import bundleManager from '@ohos.bundle.bundleManager';
4322import { BusinessError } from '@ohos.base';
4323import hilog from '@ohos.hilog';
4324let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
4325try {
4326    let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
4327    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
4328} catch (err) {
4329    let message = (err as BusinessError).message;
4330    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message);
4331}
4332```
4333