• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.bundleManager (bundleManager)
2
3The **bundleManager** module provides APIs for querying information about bundles, applications, abilities, Extension abilities, 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                                      | Permission Level    | Description           |
18| ------------------------------------------ | ------------ | ------------------|
19| ohos.permission.GET_BUNDLE_INFO            | normal       | Permission to query information about a specified bundle.  |
20| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all bundles.|
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
24For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
25
26## Enums
27
28### BundleFlag
29
30Enumerates the bundle flags, which indicate the type of bundle information to obtain.
31
32 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
33
34| Name                                     | Value        | Description                                                        |
35| ----------------------------------------- | ---------- | ------------------------------------------------------------ |
36| 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, Extension ability, or permission.|
37| 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, Extension ability, or permission.|
38| 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, Extension ability, or permission.|
39| 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, Extension ability, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.|
40| GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY    | 0x00000008 | Used to obtain the bundle information with Extension ability 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**.|
41| 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 Extension ability.|
42| GET_BUNDLE_INFO_WITH_METADATA             | 0x00000020 | Used to obtain the metadata contained in the application, HAP module, ability, or Extension ability 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**.|
43| GET_BUNDLE_INFO_WITH_DISABLE              | 0x00000040 | Used to obtain the information about disabled bundles and abilities of a bundle. The obtained bundle information does not contain information about the signature, application, HAP module, ability, Extension ability, or permission.|
44| 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, Extension ability, or permission.|
45
46### ApplicationFlag
47
48Enumerates the application flags, which indicate the type of application information to obtain.
49
50 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
51
52 **System API**: This is a system API and cannot be called by third-party applications.
53
54| Name                                | Value        | Description                                                        |
55| ------------------------------------ | ---------- | ------------------------------------------------------------ |
56| GET_APPLICATION_INFO_DEFAULT         | 0x00000000 | Used to obtain the default application information. The obtained information does not contain the permission information or metadata.|
57| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the application information with permission information.                   |
58| GET_APPLICATION_INFO_WITH_METADATA   | 0x00000002 | Used to obtain the application information with metadata.                     |
59| GET_APPLICATION_INFO_WITH_DISABLE    | 0x00000004 | Used to obtain the application information of disabled bundles.                 |
60
61### AbilityFlag
62
63Enumerates the ability flags, which indicate the type of ability information to obtain.
64
65 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
66
67 **System API**: This is a system API and cannot be called by third-party applications.
68
69| Name                             | Value        | Description                                                        |
70| --------------------------------- | ---------- | ------------------------------------------------------------ |
71| 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.|
72| GET_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the ability information with permission information.                         |
73| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ability information with application information.                    |
74| GET_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the ability information with metadata.                           |
75| GET_ABILITY_INFO_WITH_DISABLE     | 0x00000008 | Used to obtain the ability information of disabled abilities.                  |
76| GET_ABILITY_INFO_ONLY_SYSTEM_APP  | 0x00000010 | Used to obtain the ability information of system applications.                        |
77
78### ExtensionAbilityFlag
79
80Enumerates the Extension ability flags, which indicate the type of Extension ability information to obtain.
81
82 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
83
84 **System API**: This is a system API and cannot be called by third-party applications.
85
86| Name                                       | Value        | Description                                                        |
87| ------------------------------------------- | ---------- | ------------------------------------------------------------ |
88| GET_EXTENSION_ABILITY_INFO_DEFAULT          | 0x00000000 | Used to obtain the default Extension ability information. The obtained information does not contain the permission, metadata, or disabled ability information.|
89| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the Extension ability information with permission information.              |
90| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the Extension ability information with application information.        |
91| GET_EXTENSION_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the Extension ability information with metadata.                |
92
93### ExtensionAbilityType
94
95Enumerates the types of Extension abilities.
96
97 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
98
99| Name| Value| Description|
100|:----------------:|:---:|-----|
101| FORM             | 0   | [FormExtensionAbility](../../application-models/widget-development-stage.md): provides APIs for widget development.|
102| WORK_SCHEDULER   | 1   | [WorkSchedulerExtensionAbility](../../task-management/work-scheduler-dev-guide.md): enables applications to execute non-real-time tasks when the system is idle.|
103| INPUT_METHOD     | 2   | [InputMethodExtensionAbility](js-apis-inputmethod-extension-ability.md): provides APIs for developing input method applications.|
104| SERVICE          | 3   | [ServiceExtensionAbility](../../application-models/serviceextensionability.md): enables applications to run in the background and provide services.|
105| ACCESSIBILITY    | 4   | [AccessibilityExtensionAbility](js-apis-application-accessibilityExtensionAbility.md): provides accessibility for access to and operations on the UI.|
106| DATA_SHARE       | 5   | [DataShareExtensionAbility](../../database/database-datashare-guidelines.md): enables applications to read and write data.|
107| FILE_SHARE       | 6   | FileShareExtensionAbility: enables file sharing between applications. This ability is reserved.|
108| STATIC_SUBSCRIBER| 7   | [StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md): provides APIs for processing static events, such as the startup event.|
109| WALLPAPER        | 8   | WallpaperExtensionAbility: provides APIs to implement the home screen wallpaper. This ability is reserved.|
110| BACKUP           |  9  | BackupExtensionAbility: provides APIs for backing up and restoring application data and public data. This ability is reserved.|
111| WINDOW           |  10 | [WindowExtensionAbility](js-apis-application-windowExtensionAbility.md): allows system applications to display UIs of other applications.|
112| 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.|
113| THUMBNAIL        | 13  | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.|
114| 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.|
115| UNSPECIFIED      | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.|
116
117
118### PermissionGrantState
119
120Enumerates the permission grant states.
121
122 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
123
124| Name| Value| Description|
125|:----------------:|:---:|:---:|
126| PERMISSION_DENIED|  -1 | Permission denied.|
127| PERMISSION_GRANTED |  0  |  Permission granted. |
128
129### SupportWindowMode
130
131Enumerates the window modes supported by the ability.
132
133 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
134
135| Name| Value| Description|
136|:----------------:|:---:|:---:|
137| FULL_SCREEN      | 0   | A window in full-screen mode is supported.|
138| SPLIT            | 1   | A window in split-screen mode is supported.|
139| FLOATING         | 2   | A floating window is supported.  |
140
141### LaunchType
142
143Enumerates the launch types of the ability.
144
145 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
146
147| Name| Value| Description|
148|:----------------:|:---:|:---:|
149| SINGLETON        | 0   | The ability can have only one instance.|
150| MULTITON         | 1   | The ability can have multiple instances.|
151| SPECIFIED        | 2   | The ability can have one or multiple instances, depending on the internal service of the ability.|
152
153### AbilityType
154
155Enumerates the types of abilities.
156
157 **Model restriction**: This API can be used only in the FA model.
158
159 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
160
161|  Name  | Value  |                            Description                           |
162| :-----: | ---- | :--------------------------------------------------------: |
163|  PAGE   | 1    |     FA developed using the Page template to provide the capability of interacting with users.    |
164| SERVICE | 2    |  PA developed using the Service template to provide the capability of running tasks in the background.  |
165|  DATA   | 3    | PA developed using the Data template to provide unified data access for external systems.|
166
167### DisplayOrientation
168
169Enumerates the display orientations of the ability. This attribute applies only to the ability using the Page template.
170
171 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
172
173| Name                              |Value|Description|
174|:----------------------------------|---|---|
175| UNSPECIFIED                        |0 |Unspecified. The orientation is determined by the system.|
176| LANDSCAPE                          |1 |Landscape.|
177| PORTRAIT                           |2 |Portrait.|
178| FOLLOW_RECENT                      |3 |The last display orientation is used.|
179| LANDSCAPE_INVERTED                 |4 |Reverse landscape.|
180| PORTRAIT_INVERTED                  |5 |Reverse portrait.|
181| AUTO_ROTATION                      |6 |Auto rotation.|
182| AUTO_ROTATION_LANDSCAPE            |7 |Auto rotation in the horizontal direction.|
183| AUTO_ROTATION_PORTRAIT             |8 |Auto rotation in the vertical direction.|
184| AUTO_ROTATION_RESTRICTED           |9 |Switched-determined auto rotation.|
185| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|Switched-determined auto rotation in the horizontal direction.|
186| AUTO_ROTATION_PORTRAIT_RESTRICTED  |11|Switched-determined auto rotation in the vertical direction.|
187| LOCKED                             |12|Locked.|
188
189### ModuleType
190
191Enumerates the module types.
192
193 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
194
195| Name   | Value  | Description                |
196| ------- | ---- | -------------------- |
197| ENTRY   | 1    | Main module of the application.  |
198| FEATURE | 2    | Dynamic feature module of the application.|
199| SHARED  | 3    | Dynamic shared library module of the application. |
200
201### BundleType
202
203Enumerates the bundle types.
204
205 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
206
207| Name          | Value  | Description           |
208| -------------- | ---- | --------------- |
209| APP            | 0    | The bundle is a common application.   |
210| ATOMIC_SERVICE | 1    | The bundle is an atomic service.|
211
212## APIs
213
214### bundleManager.getBundleInfoForSelf
215
216getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>;
217
218Obtains the bundle information of this bundle based on the given bundle flags. This API uses a promise to return the result.
219
220**System capability**: SystemCapability.BundleManager.BundleFramework.Core
221
222**Parameters**
223
224| Name    | Type  | Mandatory| Description               |
225| ----------- | ------ | ---- | --------------------- |
226| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
227
228**Return value**
229
230| Type                                                       | Description                                 |
231| ----------------------------------------------------------- | ------------------------------------- |
232| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.|
233
234**Example**
235
236```ts
237import bundleManager from '@ohos.bundle.bundleManager';
238import hilog from '@ohos.hilog';
239let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
240try {
241    bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
242        hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
243    }).catch(err => {
244        hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
245    });
246} catch (err) {
247    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
248}
249```
250
251### bundleManager.getBundleInfoForSelf
252
253getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void;
254
255Obtains the bundle information of this bundle based on the given bundle flags. This API uses an asynchronous callback to return the result.
256
257**System capability**: SystemCapability.BundleManager.BundleFramework.Core
258
259**Parameters**
260
261| Name    | Type  | Mandatory| Description               |
262| ----------- | ------ | ---- | --------------------- |
263| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
264| 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.|
265
266**Example**
267
268```ts
269import bundleManager from '@ohos.bundle.bundleManager';
270import hilog from '@ohos.hilog';
271let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
272
273try {
274    bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => {
275        if (err) {
276            hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
277        } else {
278            hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data));
279        }
280    });
281} catch (err) {
282    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message);
283}
284```
285
286### bundleManager.getBundleInfo
287
288getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void;
289
290Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses an asynchronous callback to return the result.
291
292No permission is required for obtaining the caller's own information.
293
294**System API**: This is a system API.
295
296**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
297
298**System capability**: SystemCapability.BundleManager.BundleFramework.Core
299
300**Parameters**
301
302| Name | Type  | Mandatory| Description                      |
303| ----------- | ------ | ---- | ---------------------------- |
304| bundleName  | string | Yes  | Bundle name.|
305| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
306| userId      | number | Yes  | User ID. |
307| 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.|
308
309**Error codes**
310
311For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
312
313| ID| Error Message                             |
314| -------- | ------------------------------------- |
315| 17700001 | The specified bundleName is not found. |
316| 17700004 | The specified user ID is not found.     |
317| 17700026 | The specified bundle is disabled.      |
318
319**Example**
320
321```ts
322// Obtain the bundle information with the ability information.
323import bundleManager from '@ohos.bundle.bundleManager';
324import hilog from '@ohos.hilog';
325let bundleName = 'com.example.myapplication';
326let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
327let userId = 100;
328
329try {
330    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
331        if (err) {
332            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
333        } else {
334            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
335        }
336    });
337} catch (err) {
338    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
339}
340```
341
342```ts
343// Obtain the bundle information with the metadata in the application information.
344import bundleManager from '@ohos.bundle.bundleManager';
345import hilog from '@ohos.hilog';
346let bundleName = 'com.example.myapplication';
347let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
348let userId = 100;
349
350try {
351    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
352        if (err) {
353            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
354        } else {
355            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
356        }
357    });
358} catch (err) {
359    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
360}
361```
362
363### bundleManager.getBundleInfo
364
365getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void;
366
367Obtains the bundle information based on the given bundle name and bundle flags. This API uses an asynchronous callback to return the result.
368
369No permission is required for obtaining the caller's own information.
370
371**System API**: This is a system API.
372
373**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
374
375**System capability**: SystemCapability.BundleManager.BundleFramework.Core
376
377**Parameters**
378
379| Name    | Type  | Mandatory| Description                      |
380| ----------- | ------ | ---- | ---------------------------- |
381| bundleName  | string | Yes  | Bundle name.|
382| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
383| 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.|
384
385**Error codes**
386
387For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
388
389| ID| Error Message                             |
390| -------- | ------------------------------------- |
391| 17700001 | The specified bundleName is not found. |
392| 17700004 | The specified user ID is not found.    |
393| 17700026 | The specified bundle is disabled.      |
394
395**Example**
396
397```ts
398// Obtain the bundle information with the Extension ability information.
399import bundleManager from '@ohos.bundle.bundleManager';
400import hilog from '@ohos.hilog';
401let bundleName = 'com.example.myapplication';
402let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
403
404try {
405    bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
406        if (err) {
407            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
408        } else {
409            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
410        }
411    });
412} catch (err) {
413    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
414}
415```
416
417### bundleManager.getBundleInfo
418
419getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: number): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>;
420
421Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses a promise to return the result.
422
423No permission is required for obtaining the caller's own information.
424
425**System API**: This is a system API.
426
427**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
428
429**System capability**: SystemCapability.BundleManager.BundleFramework.Core
430
431**Parameters**
432
433| Name    | Type  | Mandatory| Description                      |
434| ----------- | ------ | ---- | ---------------------------- |
435| bundleName  | string | Yes  | Bundle name.|
436| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
437| userId      | number | No  | User ID. |
438
439**Return value**
440
441| Type                                                       | Description                       |
442| ----------------------------------------------------------- | --------------------------- |
443| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
444
445**Error codes**
446
447For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
448
449| ID| Error Message                           |
450| -------- | --------------------------------------|
451| 17700001 | The specified bundleName is not found. |
452| 17700004 | The specified user ID is not found.     |
453| 17700026 | The specified bundle is disabled.      |
454
455**Example**
456
457```ts
458// Obtain the bundle information with the application and signature information.
459import bundleManager from '@ohos.bundle.bundleManager';
460import hilog from '@ohos.hilog';
461let bundleName = 'com.example.myapplication';
462let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
463let userId = 100;
464
465try {
466    bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
467        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
468    }).catch(err => {
469        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
470    });
471} catch (err) {
472    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
473}
474```
475
476```ts
477import bundleManager from '@ohos.bundle.bundleManager';
478import hilog from '@ohos.hilog';
479let bundleName = 'com.example.myapplication';
480let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
481
482try {
483    bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
484        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
485    }).catch(err => {
486        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
487    });
488} catch (err) {
489    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
490}
491
492```
493
494### bundleManager.getApplicationInfo
495
496getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void;
497
498Obtains the application information based on the given bundle name, application flags, and user ID. This API uses an asynchronous callback to return the result.
499
500No permission is required for obtaining the caller's own information.
501
502**System API**: This is a system API.
503
504**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
505
506**System capability**: SystemCapability.BundleManager.BundleFramework.Core
507
508**Parameters**
509
510| Name   | Type  | Mandatory| Description                      |
511| ---------- | ------ | ---- | ---------------------------- |
512| bundleName | string | Yes  | Bundle name.|
513| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
514| userId     | number | Yes  | User ID. |
515| 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.|
516
517**Error codes**
518
519For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
520
521| ID| Error Message                            |
522| -------- | --------------------------------------|
523| 17700001 | The specified bundleName is not found. |
524| 17700004 | The specified user ID is not found.     |
525| 17700026 | The specified bundle is disabled.      |
526
527**Example**
528
529```ts
530import bundleManager from '@ohos.bundle.bundleManager';
531import hilog from '@ohos.hilog';
532let bundleName = 'com.example.myapplication';
533let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
534let userId = 100;
535
536try {
537    bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
538        if (err) {
539            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
540        } else {
541            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
542        }
543    });
544} catch (err) {
545    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
546}
547```
548
549### bundleManager.getApplicationInfo
550
551getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void;
552
553Obtains the application information based on the given bundle name and application flags. This API uses an asynchronous callback to return the result.
554
555No permission is required for obtaining the caller's own information.
556
557**System API**: This is a system API.
558
559**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
560
561**System capability**: SystemCapability.BundleManager.BundleFramework.Core
562
563**Parameters**
564
565| Name   | Type  | Mandatory| Description                      |
566| ---------- | ------ | ---- | ---------------------------- |
567| bundleName | string | Yes  | Bundle name.|
568| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
569| 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.|
570
571**Error codes**
572
573For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
574
575| ID| Error Message                            |
576| -------- | --------------------------------------|
577| 17700001 | The specified bundleName is not found. |
578| 17700004 | The specified user ID is not found.     |
579| 17700026 | The specified bundle is disabled.      |
580
581**Example**
582
583```ts
584import bundleManager from '@ohos.bundle.bundleManager';
585import hilog from '@ohos.hilog';
586let bundleName = 'com.example.myapplication';
587let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
588
589try {
590    bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
591        if (err) {
592            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
593        } else {
594            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
595        }
596    });
597} catch (err) {
598    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
599}
600```
601
602### bundleManager.getApplicationInfo
603
604getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId?: number): Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>;
605
606Obtains the application information based on the given bundle name, application flags, and user ID. This API uses a promise to return the result.
607
608No permission is required for obtaining the caller's own information.
609
610**System API**: This is a system API.
611
612**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
613
614**System capability**: SystemCapability.BundleManager.BundleFramework.Core
615
616**Parameters**
617
618| Name   | Type  | Mandatory| Description                      |
619| ---------- | ------ | ---- | ---------------------------- |
620| bundleName | string | Yes  | Bundle name.|
621| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
622| userId     | number | No  | User ID.|
623
624**Return value**
625
626| Type                                                        | Description                            |
627| ------------------------------------------------------------ | -------------------------------- |
628| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise used to return the application information obtained.|
629
630**Error codes**
631
632For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
633
634| ID| Error Message                            |
635| -------- | ------------------------------------- |
636| 17700001 | The specified bundleName is not found. |
637| 17700004 | The specified user ID is not found.     |
638| 17700026 | The specified bundle is disabled.      |
639
640**Example**
641
642```ts
643import bundleManager from '@ohos.bundle.bundleManager';
644import hilog from '@ohos.hilog';
645let bundleName = 'com.example.myapplication';
646let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
647let userId = 100;
648
649try {
650    bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
651        hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
652    }).catch(err => {
653        hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message);
654    });
655} catch (err) {
656    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message);
657}
658```
659
660### bundleManager.getAllBundleInfo
661
662getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void;
663
664Obtains the information about all bundles based on the given bundle flags and user ID. This API uses an asynchronous callback to return the result.
665
666**System API**: This is a system API.
667
668**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
669
670**System capability**: SystemCapability.BundleManager.BundleFramework.Core
671
672**Parameters**
673
674| Name    | Type  | Mandatory| Description                                            |
675| ----------- | ------ | ---- | -------------------------------------------------- |
676| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.                   |
677| userId      | number | Yes  | User ID.                     |
678| 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.|
679
680**Error codes**
681
682For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
683
684| ID| Error Message                        |
685| -------- | --------------------------------- |
686| 17700004 | The specified user ID is not found. |
687
688**Example**
689
690```ts
691import bundleManager from '@ohos.bundle.bundleManager';
692import hilog from '@ohos.hilog';
693let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
694let userId = 100;
695
696try {
697    bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
698        if (err) {
699            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
700        } else {
701            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
702        }
703    });
704} catch (err) {
705    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
706}
707```
708
709### bundleManager.getAllBundleInfo
710
711getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void;
712
713Obtains the information about all bundles based on the given bundle flags. This API uses an asynchronous callback to return the result.
714
715**System API**: This is a system API.
716
717**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
718
719**System capability**: SystemCapability.BundleManager.BundleFramework.Core
720
721**Parameters**
722
723| Name    | Type  | Mandatory| Description                                            |
724| ----------- | ------ | ---- | -------------------------------------------------- |
725| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.  |
726| 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.|
727
728**Error codes**
729
730For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
731
732| ID| Error Message                        |
733| -------- | ---------------------------------- |
734| 17700004 | The specified user ID is not found. |
735
736**Example**
737
738```ts
739import bundleManager from '@ohos.bundle.bundleManager';
740import hilog from '@ohos.hilog';
741let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
742
743try {
744    bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
745        if (err) {
746            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
747        } else {
748            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
749        }
750    });
751} catch (err) {
752    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
753}
754```
755
756### bundleManager.getAllBundleInfo
757
758getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>;
759
760Obtains the information about all bundles based on the given bundle flags and user ID. This API uses a promise to return the result.
761
762**System API**: This is a system API.
763
764**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
765
766**System capability**: SystemCapability.BundleManager.BundleFramework.Core
767
768**Parameters**
769
770| Name    | Type  | Mandatory| Description                                            |
771| ----------- | ------ | ---- | -------------------------------------------------- |
772| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.                  |
773| userId      | number | No  | User ID.                        |
774
775**Return value**
776
777| Type                                                        | Description                               |
778| ------------------------------------------------------------ | ----------------------------------- |
779| Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Promise used to return the array of bundle information obtained.|
780
781**Error codes**
782
783For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
784
785| ID| Error Message                        |
786| -------- | ---------------------------------- |
787| 17700004 | The specified user ID is not found. |
788
789**Example**
790
791```ts
792import bundleManager from '@ohos.bundle.bundleManager';
793import hilog from '@ohos.hilog';
794let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
795
796try {
797    bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
798        hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
799    }).catch(err => {
800        hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message);
801    });
802} catch (err) {
803    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message);
804}
805```
806
807### bundleManager.getAllApplicationInfo
808
809getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void;
810
811Obtains the information about all applications based on the given application flags and user ID. This API uses an asynchronous callback to return the result.
812
813**System API**: This is a system API.
814
815**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
816
817**System capability**: SystemCapability.BundleManager.BundleFramework.Core
818
819**Parameters**
820
821| Name | Type  | Mandatory| Description                                                     |
822| -------- | ------ | ---- | ----------------------------------------------------------- |
823| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
824| userId   | number | Yes  | User ID.        |
825| 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.|
826
827**Error codes**
828
829For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
830
831| ID| Error Message                        |
832| -------- | ---------------------------------- |
833| 17700004 | The specified user ID is not found. |
834
835**Example**
836
837```ts
838import bundleManager from '@ohos.bundle.bundleManager';
839import hilog from '@ohos.hilog';
840let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
841let userId = 100;
842
843try {
844    bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
845        if (err) {
846            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
847        } else {
848            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
849        }
850    });
851} catch (err) {
852    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
853}
854```
855
856### bundleManager.getAllApplicationInfo
857
858getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void;
859
860Obtains the information about all applications based on the given application flags. This API uses an asynchronous callback to return the result.
861
862**System API**: This is a system API.
863
864**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
865
866**System capability**: SystemCapability.BundleManager.BundleFramework.Core
867
868**Parameters**
869
870| Name | Type  | Mandatory| Description                                                     |
871| -------- | ------ | ---- | ----------------------------------------------------------- |
872| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
873| 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.|
874
875**Error codes**
876
877For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
878
879| ID| Error Message                        |
880| -------- | ---------------------------------- |
881| 17700004 | The specified user ID is not found. |
882
883**Example**
884
885```ts
886import bundleManager from '@ohos.bundle.bundleManager';
887import hilog from '@ohos.hilog';
888let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
889
890try {
891    bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
892        if (err) {
893            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
894        } else {
895            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
896        }
897    });
898} catch (err) {
899    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
900}
901```
902
903### bundleManager.getAllApplicationInfo
904
905getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>;
906
907Obtains the information about all applications based on the given application flags and user ID. This API uses a promise to return the result.
908
909**System API**: This is a system API.
910
911**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
912
913**System capability**: SystemCapability.BundleManager.BundleFramework.Core
914
915**Parameters**
916
917| Name | Type  | Mandatory| Description                                                     |
918| -------- | ------ | ---- | ---------------------------------------------------------- |
919| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
920| userId   | number | No  | User ID.                                 |
921
922**Return value**
923
924| Type                                                        | Description                                    |
925| ------------------------------------------------------------ | ---------------------------------------- |
926| Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Promise used to return the array of application information obtained.|
927
928**Error codes**
929
930For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
931
932| ID| Error Message                        |
933| -------- | ---------------------------------- |
934| 17700004 | The specified user ID is not found. |
935
936**Example**
937
938```ts
939import bundleManager from '@ohos.bundle.bundleManager';
940import hilog from '@ohos.hilog';
941let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
942
943try {
944    bundleManager.getAllApplicationInfo(appFlags).then((data) => {
945        hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
946    }).catch(err => {
947        hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message);
948    });
949} catch (err) {
950    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message);
951}
952
953```
954
955### bundleManager.queryAbilityInfo
956
957queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: number, callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void;
958
959Obtains 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.
960
961**System API**: This is a system API.
962
963**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
964
965**System capability**: SystemCapability.BundleManager.BundleFramework.Core
966
967**Parameters**
968
969| Name     | Type  | Mandatory| Description                                                 |
970| ------------ | ------ | ---- | ------------------------------------------------------- |
971| want         | Want   | Yes  | Want containing the bundle name to query.                |
972| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.                      |
973| userId       | number | Yes  | User ID.                              |
974| 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.|
975
976**Error codes**
977
978For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
979
980| ID| Error Message                            |
981| -------- | -------------------------------------- |
982| 17700001 | The specified bundleName is not found. |
983| 17700003 | The specified ability is not found.    |
984| 17700004 | The specified userId is invalid.       |
985| 17700026 | The specified bundle is disabled.      |
986| 17700029 | The specified ability is disabled.     |
987
988**Example**
989
990```ts
991import bundleManager from '@ohos.bundle.bundleManager';
992import hilog from '@ohos.hilog';
993let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
994let userId = 100;
995let want = {
996    bundleName : "com.example.myapplication",
997    abilityName : "com.example.myapplication.MainAbility"
998};
999
1000try {
1001    bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
1002        if (err) {
1003            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
1004        } else {
1005            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
1006        }
1007    });
1008} catch (err) {
1009    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
1010}
1011```
1012
1013### bundleManager.queryAbilityInfo
1014
1015queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void;
1016
1017Obtains an array of ability information based on the given want and ability flags. This API uses an asynchronous callback to return the result.
1018
1019**System API**: This is a system API.
1020
1021**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1022
1023**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1024
1025**Parameters**
1026
1027| Name     | Type  | Mandatory| Description                                                 |
1028| ------------ | ------ | ---- | -------------------------------------------------------|
1029| want         | Want   | Yes  | Want containing the bundle name to query.                |
1030| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.      |
1031| 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.|
1032
1033**Error codes**
1034
1035For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1036
1037| ID| Error Message                            |
1038| -------- | -------------------------------------- |
1039| 17700001 | The specified bundleName is not found. |
1040| 17700003 | The specified ability is not found.    |
1041| 17700004 | The specified userId is invalid.       |
1042| 17700026 | The specified bundle is disabled.      |
1043| 17700029 | The specified ability is disabled.     |
1044
1045**Example**
1046
1047```ts
1048import bundleManager from '@ohos.bundle.bundleManager';
1049import hilog from '@ohos.hilog';
1050let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1051let want = {
1052    bundleName : "com.example.myapplication",
1053    abilityName : "com.example.myapplication.MainAbility"
1054};
1055
1056try {
1057    bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
1058        if (err) {
1059            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
1060        } else {
1061            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
1062        }
1063    });
1064} catch (err) {
1065    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
1066}
1067```
1068
1069### bundleManager.queryAbilityInfo
1070
1071queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>;
1072
1073Obtains the ability information based on the given want, ability flags, and user ID. This API uses a promise to return the result.
1074
1075**System API**: This is a system API.
1076
1077**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1078
1079**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1080
1081**Parameters**
1082
1083| Name     | Type  | Mandatory| Description                                                 |
1084| ------------ | ------ | ---- | ------------------------------------------------------- |
1085| want         | Want   | Yes  | Want containing the bundle name to query.                |
1086| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.|
1087| userId       | number | No  | User ID.                              |
1088
1089**Return value**
1090
1091| Type                                                        | Description                                |
1092| ------------------------------------------------------------ | ------------------------------------ |
1093| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise used to return the array of ability information obtained.|
1094
1095**Error codes**
1096
1097For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1098
1099| ID| Error Message                            |
1100| -------- | ------------------------------------- |
1101| 17700001 | The specified bundleName is not found. |
1102| 17700003 | The specified ability is not found.    |
1103| 17700004 | The specified userId is invalid.       |
1104| 17700026 | The specified bundle is disabled.      |
1105| 17700029 | The specified ability is disabled.     |
1106
1107**Example**
1108
1109```ts
1110import bundleManager from '@ohos.bundle.bundleManager';
1111import hilog from '@ohos.hilog';
1112let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1113let userId = 100;
1114let want = {
1115    bundleName : "com.example.myapplication",
1116    abilityName : "com.example.myapplication.MainAbility"
1117};
1118
1119try {
1120    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
1121        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1122    }).catch(err => {
1123        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1124    });
1125} catch (err) {
1126    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1127}
1128```
1129
1130```ts
1131import bundleManager from '@ohos.bundle.bundleManager';
1132import hilog from '@ohos.hilog';
1133let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1134let want = {
1135    bundleName : "com.example.myapplication",
1136    abilityName : "com.example.myapplication.MainAbility"
1137};
1138
1139try {
1140    bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
1141        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1142    }).catch(err => {
1143        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1144    })
1145} catch (err) {
1146    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1147}
1148```
1149
1150### bundleManager.queryExtensionAbilityInfo
1151
1152queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId: number, callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void;
1153
1154Obtains the Extension ability information based on the given want, Extension ability type, Extension ability flags, and user ID. This API uses an asynchronous callback to return the result.
1155
1156**System API**: This is a system API.
1157
1158**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1159
1160**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1161
1162**Parameters**
1163
1164| Name               | Type                                                        | Mandatory| Description                                                        |
1165| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1166| want                  | Want                                                         | Yes  | Want containing the bundle name to query.                      |
1167| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype)                | Yes  | Type of the Extension ability.                                |
1168| extensionAbilityFlags | [number](#extensionabilityflag)                              | Yes  | Type of the Extension ability information to obtain.   |
1169| userId                | number                                                       | Yes  | User ID.                                                |
1170| 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 Extension ability information obtained. Otherwise, **err** is an error object.|
1171
1172**Error codes**
1173
1174For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1175
1176| ID| Error Message                                   |
1177| -------- | ------------------------------------------- |
1178| 17700001 | The specified bundleName is not found.       |
1179| 17700003 | The specified extensionAbility is not found. |
1180| 17700004 | The specified userId is invalid.             |
1181| 17700026 | The specified bundle is disabled.            |
1182
1183**Example**
1184
1185```ts
1186import bundleManager from '@ohos.bundle.bundleManager';
1187import hilog from '@ohos.hilog';
1188let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1189let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1190let userId = 100;
1191let want = {
1192    bundleName : "com.example.myapplication",
1193    abilityName : "com.example.myapplication.MainAbility"
1194};
1195
1196try {
1197    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
1198        if (err) {
1199            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1200        } else {
1201            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1202        }
1203    });
1204} catch (err) {
1205    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1206}
1207```
1208
1209### bundleManager.queryExtensionAbilityInfo
1210
1211queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void;
1212
1213Obtains the Extension ability information based on the given want, Extension ability type, and Extension ability flags. This API uses an asynchronous callback to return the result.
1214
1215**System API**: This is a system API.
1216
1217**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1218
1219**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1220
1221**Parameters**
1222
1223| Name               | Type                                                        | Mandatory| Description                                                        |
1224| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1225| want                  | Want                                                         | Yes  | Want containing the bundle name to query.                      |
1226| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype)                | Yes  | Type of the Extension ability.                                |
1227| extensionAbilityFlags | [number](#extensionabilityflag)                              | Yes  | Type of the Extension ability information to obtain.   |
1228| 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 Extension ability information obtained. Otherwise, **err** is an error object.|
1229
1230**Error codes**
1231
1232For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1233
1234| ID| Error Message                                    |
1235| -------- | -------------------------------------------- |
1236| 17700001 | The specified bundleName is not found.       |
1237| 17700003 | The specified extensionAbility is not found. |
1238| 17700004 | The specified userId is invalid.       |
1239| 17700026 | The specified bundle is disabled.            |
1240
1241**Example**
1242
1243```ts
1244import bundleManager from '@ohos.bundle.bundleManager';
1245import hilog from '@ohos.hilog';
1246let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1247let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1248let want = {
1249    bundleName : "com.example.myapplication",
1250    abilityName : "com.example.myapplication.MainAbility"
1251};
1252
1253try {
1254    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
1255        if (err) {
1256            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1257        } else {
1258            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1259        }
1260    });
1261} catch (err) {
1262    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1263}
1264```
1265
1266### bundleManager.queryExtensionAbilityInfo
1267
1268queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>;
1269
1270Obtains the Extension ability information based on the given want, Extension ability type, Extension ability flags, and user ID. This API uses a promise to return the result.
1271
1272**System API**: This is a system API.
1273
1274**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1275
1276**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1277
1278**Parameters**
1279
1280| Name               | Type                                         | Mandatory| Description                                                     |
1281| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1282| want                  | Want                                          | Yes  | Want containing the bundle name to query.                   |
1283| extensionAbilityType  | [ExtensionAbilityType](#extensionabilitytype) | Yes  | Type of the Extension ability.                             |
1284| extensionAbilityFlags | [number](#extensionabilityflag)               | Yes  | Type of the Extension ability information to obtain.|
1285| userId                | number                                        | No  | User ID.                                             |
1286
1287**Return value**
1288
1289| Type                                                        | Description                                         |
1290| ------------------------------------------------------------ | --------------------------------------------- |
1291| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Promise used to return the array of Extension ability information obtained.|
1292
1293**Error codes**
1294
1295For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1296
1297| ID| Error Message                            |
1298| -------- | --------------------------------------|
1299| 17700001 | The specified bundleName is not found. |
1300| 17700003 | The specified extensionAbility is not found.    |
1301| 17700004 | The specified userId is invalid.       |
1302| 17700026 | The specified bundle is disabled.      |
1303
1304**Example**
1305
1306```ts
1307import bundleManager from '@ohos.bundle.bundleManager';
1308import hilog from '@ohos.hilog';
1309
1310let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1311let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1312let userId = 100;
1313let want = {
1314    bundleName : "com.example.myapplication",
1315    abilityName : "com.example.myapplication.MainAbility"
1316};
1317
1318try {
1319    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
1320        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1321    }).catch(err => {
1322        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1323    });
1324} catch (err) {
1325    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1326}
1327```
1328
1329```ts
1330import bundleManager from '@ohos.bundle.bundleManager';
1331import hilog from '@ohos.hilog';
1332let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1333let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1334let want = {
1335    bundleName : "com.example.myapplication",
1336    abilityName : "com.example.myapplication.MainAbility"
1337};
1338
1339try {
1340    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
1341        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1342    }).catch(err => {
1343        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1344    })
1345} catch (err) {
1346    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1347}
1348```
1349
1350### bundleManager.getBundleNameByUid
1351
1352getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void;
1353
1354Obtains the bundle name based on the given UID. This API uses an asynchronous callback to return the result.
1355
1356**System API**: This is a system API.
1357
1358**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1359
1360**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1361
1362**Parameters**
1363
1364| Name  | Type                  | Mandatory| Description                                                        |
1365| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1366| uid      | number                 | Yes  | UID of the application.                                           |
1367| 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.|
1368
1369**Error codes**
1370
1371For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1372
1373| ID| Error Message           |
1374| -------- | --------------------- |
1375| 17700021 | The uid is not found. |
1376
1377**Example**
1378
1379```ts
1380import bundleManager from '@ohos.bundle.bundleManager';
1381import hilog from '@ohos.hilog';
1382let uid = 20010005;
1383try {
1384    bundleManager.getBundleNameByUid(uid, (err, data) => {
1385        if (err) {
1386            hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message);
1387        } else {
1388            hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', JSON.stringify(data));
1389        }
1390    });
1391} catch (err) {
1392    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message);
1393}
1394```
1395
1396### bundleManager.getBundleNameByUid
1397
1398getBundleNameByUid(uid: number): Promise\<string>;
1399
1400Obtains the bundle name based on the given UID. 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| uid  | number | Yes  | UID of the application.|
1413
1414**Return value**
1415
1416| Type            | Description                       |
1417| ---------------- | --------------------------- |
1418| Promise\<string> | Promise used to return the bundle name obtained.|
1419
1420**Error codes**
1421
1422For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1423
1424| ID| Error Message           |
1425| -------- | ---------------------|
1426| 17700021 | The uid is not found. |
1427
1428**Example**
1429
1430```ts
1431import bundleManager from '@ohos.bundle.bundleManager';
1432import hilog from '@ohos.hilog';
1433let uid = 20010005;
1434try {
1435    bundleManager.getBundleNameByUid(uid).then((data) => {
1436        hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data));
1437    }).catch(err => {
1438        hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
1439    });
1440} catch (err) {
1441    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
1442}
1443```
1444
1445### bundleManager.getBundleArchiveInfo
1446
1447getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void;
1448
1449Obtains the bundle information based on the given HAP file path and bundle flags. This API uses an asynchronous callback to return the result.
1450
1451**System API**: This is a system API.
1452
1453**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1454
1455**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1456
1457**Parameters**
1458
1459| Name      | Type  | Mandatory| Description                                                        |
1460| ----------- | ------ | ---- | ----------------------------------------------------------- |
1461| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1462| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
1463| 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.|
1464
1465**Error codes**
1466
1467For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1468
1469| ID| Error Message                 |
1470| -------- | --------------------------- |
1471| 17700022 | The hapFilePath is invalid. |
1472
1473**Example**
1474
1475```ts
1476import bundleManager from '@ohos.bundle.bundleManager';
1477import hilog from '@ohos.hilog';
1478let hapFilePath = "/data/xxx/test.hap";
1479let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1480
1481try {
1482    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
1483        if (err) {
1484            hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1485        } else {
1486            hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', JSON.stringify(data));
1487        }
1488    });
1489} catch (err) {
1490    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1491}
1492```
1493
1494### bundleManager.getBundleArchiveInfo
1495
1496getBundleArchiveInfo(hapFilePath: string,  bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>;
1497
1498Obtains the bundle information based on the given HAP file path and bundle flags. This API uses a promise to return the result.
1499
1500**System API**: This is a system API.
1501
1502**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1503
1504**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1505
1506**Parameters**
1507
1508| Name      | Type  | Mandatory| Description                                                        |
1509| ----------- | ------ | ---- | ------------------------------------------------------------ |
1510| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1511| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.      |
1512
1513**Return value**
1514
1515| Type                                                       | Description                       |
1516| ----------------------------------------------------------- | --------------------------- |
1517| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
1518
1519**Error codes**
1520
1521For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1522
1523| ID| Error Message                  |
1524| -------- | -------------------------- |
1525| 17700022 | The hapFilePath is invalid. |
1526
1527**Example**
1528
1529```ts
1530import bundleManager from '@ohos.bundle.bundleManager';
1531import hilog from '@ohos.hilog';
1532let hapFilePath = "/data/xxx/test.hap";
1533let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1534
1535try {
1536    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
1537        hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data));
1538    }).catch(err => {
1539        hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1540    });
1541} catch (err) {
1542    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1543}
1544```
1545
1546### bundleManager.cleanBundleCacheFiles
1547
1548cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
1549
1550Clears the cache files based on the given bundle name. This API uses an asynchronous callback to return the result.
1551
1552**System API**: This is a system API.
1553
1554**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
1555
1556**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1557
1558**Parameters**
1559
1560| Name    | Type                | Mandatory| Description                                                        |
1561| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
1562| bundleName | string               | Yes  | Bundle name.                  |
1563| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1564
1565**Error codes**
1566
1567For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1568
1569| ID| Error Message                                                    |
1570| -------- | ------------------------------------------------------------ |
1571| 17700001 | The specified bundleName is not found.                        |
1572| 17700030 | The specified bundle does not support clearing of cache files. |
1573
1574**Example**
1575
1576```ts
1577import bundleManager from '@ohos.bundle.bundleManager';
1578import hilog from '@ohos.hilog';
1579let bundleName = "com.ohos.myapplication";
1580
1581try {
1582    bundleManager.cleanBundleCacheFiles(bundleName, err => {
1583        if (err) {
1584            hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1585        } else {
1586            hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1587        }
1588    });
1589} catch (err) {
1590    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1591}
1592```
1593
1594### bundleManager.cleanBundleCacheFiles
1595
1596cleanBundleCacheFiles(bundleName: string): Promise\<void>;
1597
1598Clears the cache files based on the given bundle name. This API uses a promise to return the result.
1599
1600**System API**: This is a system API.
1601
1602**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
1603
1604**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1605
1606**Parameters**
1607
1608| Name    | Type  | Mandatory| Description                                      |
1609| ---------- | ------ | ---- | ------------------------------------------ |
1610| bundleName | string | Yes  | Bundle name.|
1611
1612**Return value**
1613
1614| Type          | Description                                                        |
1615| -------------- | ------------------------------------------------------------ |
1616| Promise\<void> | Promise that returns no value. If clearing the cache files fails, an error object is thrown.|
1617
1618**Error codes**
1619
1620For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1621
1622| ID| Error Message                                                  |
1623| -------- | ---------------------------------------------------------- |
1624| 17700001 | The specified bundleName is not found.                      |
1625| 17700030 | The specified bundle does not support clearing of cache files. |
1626
1627**Example**
1628
1629```ts
1630import bundleManager from '@ohos.bundle.bundleManager';
1631import hilog from '@ohos.hilog';
1632let bundleName = "com.ohos.myapplication";
1633
1634try {
1635    bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
1636        hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1637    }).catch(err => {
1638        hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1639    });
1640} catch (err) {
1641    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1642}
1643```
1644
1645### bundleManager.setApplicationEnabled
1646
1647setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void;
1648
1649Enables or disables an application. This API uses an asynchronous callback to return the result.
1650
1651**System API**: This is a system API.
1652
1653**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1654
1655**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1656
1657**Parameters**
1658
1659| Name     | Type   | Mandatory| Description                                 |
1660| ---------- | ------- | ---- | ------------------------------------- |
1661| bundleName | string  | Yes  | Bundle name.               |
1662| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.|
1663| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1664
1665**Error codes**
1666
1667For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1668
1669| ID| Error Message                            |
1670| -------- | -------------------------------------- |
1671| 17700001 | The specified bundleName is not found. |
1672
1673**Example**
1674
1675```ts
1676import bundleManager from '@ohos.bundle.bundleManager';
1677import hilog from '@ohos.hilog';
1678let bundleName = "com.ohos.myapplication";
1679
1680try {
1681    bundleManager.setApplicationEnabled(bundleName, false, err => {
1682        if (err) {
1683            hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
1684        } else {
1685            hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
1686        }
1687    });
1688} catch (err) {
1689    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
1690}
1691```
1692
1693### bundleManager.setApplicationEnabled
1694
1695setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>;
1696
1697Enables or disables an application. This API uses a promise to return the result.
1698
1699**System API**: This is a system API.
1700
1701**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1702
1703**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1704
1705**Parameters**
1706
1707| Name     | Type   | Mandatory| Description                                 |
1708| ---------- | ------- | ---- | ------------------------------------- |
1709| bundleName | string  | Yes  | Bundle name.           |
1710| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.|
1711
1712**Return value**
1713
1714| Type          | Description                                |
1715| -------------- | ------------------------------------ |
1716| Promise\<void> | Promise that returns no value.|
1717
1718**Error codes**
1719
1720For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1721
1722| ID| Error Message                            |
1723| -------- | -------------------------------------- |
1724| 17700001 | The specified bundleName is not found. |
1725
1726**Example**
1727
1728```ts
1729import bundleManager from '@ohos.bundle.bundleManager';
1730import hilog from '@ohos.hilog';
1731let bundleName = "com.ohos.myapplication";
1732
1733try {
1734    bundleManager.setApplicationEnabled(bundleName, false).then(() => {
1735        hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
1736    }).catch(err => {
1737        hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
1738    });
1739} catch (err) {
1740    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
1741}
1742```
1743
1744### bundleManager.setAbilityEnabled
1745
1746setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\<void>): void;
1747
1748Enables or disables an ability. This API uses an asynchronous callback to return the result.
1749
1750**System API**: This is a system API.
1751
1752**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1753
1754**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1755
1756**Parameters**
1757
1758| Name   | Type       | Mandatory| Description                                 |
1759| -------- | ----------- | ---- | ------------------------------------- |
1760| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.             |
1761| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.|
1762| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1763
1764**Error codes**
1765
1766For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1767
1768| ID| Error Message                             |
1769| -------- | ---------------------------------------|
1770| 17700001 | The specified bundleName is not found.  |
1771| 17700003 | The specified abilityInfo is not found. |
1772
1773**Example**
1774
1775```ts
1776import bundleManager from '@ohos.bundle.bundleManager';
1777import hilog from '@ohos.hilog';
1778let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1779let userId = 100;
1780let want = {
1781    bundleName : "com.example.myapplication",
1782    abilityName : "com.example.myapplication.MainAbility"
1783};
1784let info;
1785
1786try {
1787    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
1788        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
1789        info = abilitiesInfo[0];
1790
1791        bundleManager.setAbilityEnabled(info, false, err => {
1792            if (err) {
1793                hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
1794            } else {
1795                hilog.info(0x0001, "testTag", "setAbilityEnabled successfully.");
1796            }
1797        });
1798    }).catch(err => {
1799        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1800    });
1801} catch (err) {
1802    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1803}
1804```
1805
1806### bundleManager.setAbilityEnabled
1807
1808setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\<void>;
1809
1810Enables or disables an ability. This API uses a promise to return the result.
1811
1812**System API**: This is a system API.
1813
1814**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1815
1816**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1817
1818**Parameters**
1819
1820| Name   | Type       | Mandatory| Description                                 |
1821| -------- | ----------- | ---- | ------------------------------------- |
1822| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.                  |
1823| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.|
1824
1825**Return value**
1826
1827| Type          | Description                             |
1828| -------------- | --------------------------------- |
1829| Promise\<void> | Promise that returns no value.|
1830
1831**Error codes**
1832
1833For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1834
1835| ID| Error Message                             |
1836| -------- | -------------------------------------- |
1837| 17700001 | The specified bundleName is not found.  |
1838| 17700003 | The specified abilityInfo is not found. |
1839
1840**Example**
1841
1842```ts
1843import bundleManager from '@ohos.bundle.bundleManager';
1844import hilog from '@ohos.hilog';
1845let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1846let userId = 100;
1847let want = {
1848    bundleName : "com.example.myapplication",
1849    abilityName : "com.example.myapplication.MainAbility"
1850};
1851let info;
1852
1853try {
1854    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
1855        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
1856        info = abilitiesInfo[0];
1857
1858        bundleManager.setAbilityEnabled(info, false).then(() => {
1859            hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
1860        }).catch(err => {
1861            hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
1862        });
1863    }).catch(err => {
1864        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1865    });
1866} catch (err) {
1867    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1868}
1869```
1870
1871### bundleManager.isApplicationEnabled
1872
1873isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void;
1874
1875Checks whether an application is enabled. This API uses an asynchronous callback to return the result.
1876
1877**System API**: This is a system API.
1878
1879**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1880
1881**Parameters**
1882
1883| Name     | Type  | Mandatory| Description                      |
1884| ---------- | ------ | ---- | -------------------------- |
1885| bundleName | string | Yes  | Bundle name.|
1886| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.|
1887
1888**Error codes**
1889
1890For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1891
1892| ID| Error Message                            |
1893| -------- | -------------------------------------- |
1894| 17700001 | The specified bundleName is not found. |
1895
1896**Example**
1897
1898```ts
1899import bundleManager from '@ohos.bundle.bundleManager';
1900import hilog from '@ohos.hilog';
1901let bundleName = 'com.example.myapplication';
1902
1903try {
1904    bundleManager.isApplicationEnabled(bundleName, (err, data) => {
1905        if (err) {
1906            hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message);
1907        } else {
1908            hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', JSON.stringify(data));
1909        }
1910    });
1911} catch (err) {
1912    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message);
1913}
1914```
1915
1916### bundleManager.isApplicationEnabled
1917
1918isApplicationEnabled(bundleName: string): Promise\<boolean>;
1919
1920Checks whether an application is enabled. This API uses a promise to return the result.
1921
1922**System API**: This is a system API.
1923
1924**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1925
1926**Parameters**
1927
1928| Name     | Type  | Mandatory| Description                      |
1929| ---------- | ------ | ---- | -------------------------- |
1930| bundleName | string | Yes  | Bundle name. |
1931
1932**Return value**
1933
1934| Type             | Description                                                        |
1935| ----------------- | ------------------------------------------------------------ |
1936| Promise\<boolean> | Promise used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.|
1937
1938**Error codes**
1939
1940For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1941
1942| ID| Error Message                            |
1943| -------- | -------------------------------------- |
1944| 17700001 | The specified bundleName is not found. |
1945
1946**Example**
1947
1948```ts
1949import bundleManager from '@ohos.bundle.bundleManager';
1950import hilog from '@ohos.hilog';
1951let bundleName = 'com.example.myapplication';
1952
1953try {
1954    bundleManager.isApplicationEnabled(bundleName).then((data) => {
1955        hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data));
1956    }).catch(err => {
1957        hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
1958    });
1959} catch (err) {
1960    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
1961}
1962```
1963
1964### bundleManager.isAbilityEnabled
1965
1966isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\<boolean>): void;
1967
1968Checks whether an ability is enabled. This API uses an asynchronous callback to return the result.
1969
1970**System API**: This is a system API.
1971
1972**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1973
1974**Parameters**
1975
1976| Name| Type       | Mandatory| Description                       |
1977| ---- | ----------- | ---- | --------------------------- |
1978| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
1979| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
1980
1981**Error codes**
1982
1983For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
1984
1985| ID| Error Message                             |
1986| -------- | --------------------------------------- |
1987| 17700001 | The specified bundleName is not found.  |
1988| 17700003 | The specified abilityName is not found. |
1989
1990**Example**
1991
1992```ts
1993import bundleManager from '@ohos.bundle.bundleManager';
1994import hilog from '@ohos.hilog';
1995let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1996let userId = 100;
1997let want = {
1998    bundleName : "com.example.myapplication",
1999    abilityName : "com.example.myapplication.MainAbility"
2000};
2001let info;
2002
2003try {
2004    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2005        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2006        info = abilitiesInfo[0];
2007
2008        bundleManager.isAbilityEnabled(info, (err, data) => {
2009            if (err) {
2010                hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s', err.message);
2011            } else {
2012                hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data));
2013            }
2014        });
2015    }).catch(err => {
2016        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2017    });
2018} catch (err) {
2019    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2020}
2021```
2022
2023### bundleManager.isAbilityEnabled
2024
2025isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\<boolean>;
2026
2027Checks whether an ability is enabled. This API uses a promise to return the result.
2028
2029**System API**: This is a system API.
2030
2031**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2032
2033**Parameters**
2034
2035| Name| Type       | Mandatory| Description                       |
2036| ---- | ----------- | ---- | --------------------------- |
2037| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2038
2039**Return value**
2040
2041| Type             | Description                                                        |
2042| ----------------- | ------------------------------------------------------------ |
2043| Promise\<boolean> | Promise used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
2044
2045**Error codes**
2046
2047For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2048
2049| ID| Error Message                             |
2050| -------- | --------------------------------------- |
2051| 17700001 | The specified bundleName is not found.  |
2052| 17700003 | The specified abilityName is not found. |
2053
2054**Example**
2055
2056```ts
2057import bundleManager from '@ohos.bundle.bundleManager';
2058import hilog from '@ohos.hilog';
2059let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2060let userId = 100;
2061let want = {
2062    bundleName : "com.example.myapplication",
2063    abilityName : "com.example.myapplication.MainAbility"
2064};
2065let info;
2066
2067try {
2068    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2069        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2070        info = abilitiesInfo[0];
2071
2072        bundleManager.isAbilityEnabled(info).then((data) => {
2073            hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data));
2074        }).catch(err => {
2075            hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message);
2076        });
2077    }).catch(err => {
2078        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2079    });
2080} catch (err) {
2081    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2082}
2083```
2084
2085### bundleManager.getLaunchWantForBundle
2086
2087getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void;
2088
2089Obtains 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.
2090
2091**System API**: This is a system API.
2092
2093**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2094
2095**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2096
2097**Parameters**
2098
2099| Name    | Type                | Mandatory| Description                                                        |
2100| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
2101| bundleName | string               | Yes  | Bundle name.                                    |
2102| userId     | number               | Yes  | User ID.                                                  |
2103| 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.|
2104
2105**Error codes**
2106
2107For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2108
2109| ID| Error Message                            |
2110| -------- | --------------------------------------|
2111| 17700001 | The specified bundleName is not found. |
2112| 17700004 | The specified user ID is not found.     |
2113| 17700026 | The specified bundle is disabled.      |
2114
2115**Example**
2116
2117```ts
2118import bundleManager from '@ohos.bundle.bundleManager';
2119import hilog from '@ohos.hilog';
2120let bundleName = 'com.example.myapplication';
2121let userId = 100;
2122
2123try {
2124    bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
2125        if (err) {
2126            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2127        } else {
2128            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
2129        }
2130    });
2131} catch (err) {
2132    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2133}
2134```
2135
2136### bundleManager.getLaunchWantForBundle
2137
2138getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void;
2139
2140Obtains the Want used to launch the bundle based on the given bundle name. This API uses an asynchronous callback to return the result.
2141
2142**System API**: This is a system API.
2143
2144**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2145
2146**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2147
2148**Parameters**
2149
2150| Name    | Type                | Mandatory| Description                                                        |
2151| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
2152| bundleName | string               | Yes  | Bundle name.                                    |
2153| 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.|
2154
2155**Error codes**
2156
2157For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2158
2159| ID| Error Message                            |
2160| -------- | --------------------------------------|
2161| 17700001 | The specified bundleName is not found. |
2162| 17700004 | The specified user ID is not found.     |
2163| 17700026 | The specified bundle is disabled.      |
2164
2165**Example**
2166
2167```ts
2168import bundleManager from '@ohos.bundle.bundleManager';
2169import hilog from '@ohos.hilog';
2170let bundleName = 'com.example.myapplication';
2171
2172try {
2173    bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
2174        if (err) {
2175            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2176        } else {
2177            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
2178        }
2179    });
2180} catch (err) {
2181    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2182}
2183```
2184
2185### bundleManager.getLaunchWantForBundle
2186
2187getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
2188
2189Obtains 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.
2190
2191**System API**: This is a system API.
2192
2193**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2194
2195**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2196
2197**Parameters**
2198
2199| Name    | Type  | Mandatory| Description                      |
2200| ---------- | ------ | ---- | ------------------------- |
2201| bundleName | string | Yes  | Bundle name.|
2202| userId     | number | No  | User ID.              |
2203
2204**Return value**
2205
2206| Type          | Description                     |
2207| -------------- | ------------------------- |
2208| Promise\<Want> | Promise used to return the **Want** object obtained.|
2209
2210**Error codes**
2211
2212For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2213
2214| ID| Error Message                            |
2215| -------- | --------------------------------------|
2216| 17700001 | The specified bundleName is not found. |
2217| 17700004 | The specified user ID is not found.     |
2218| 17700026 | The specified bundle is disabled.      |
2219
2220**Example**
2221
2222```ts
2223import bundleManager from '@ohos.bundle.bundleManager';
2224import hilog from '@ohos.hilog';
2225let bundleName = 'com.example.myapplication';
2226let userId = 100;
2227
2228try {
2229    bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
2230        hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data));
2231    }).catch(err => {
2232        hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message);
2233    });
2234} catch (err) {
2235    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message);
2236}
2237```
2238
2239### bundleManager.getProfileByAbility
2240
2241getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void;
2242
2243Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses an asynchronous callback to return the result.
2244
2245**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2246
2247**Parameters**
2248
2249| Name      | Type                         | Mandatory| Description                                                        |
2250| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
2251| moduleName   | string                        | Yes  | Module name.                                    |
2252| abilityName  | string                        | Yes  | Ability name.                                   |
2253| metadataName | string                        | Yes  | Metadata name.                                 |
2254| 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.|
2255
2256**Error codes**
2257
2258For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2259
2260| ID| Error Message                                                    |
2261| -------- | ------------------------------------------------------------ |
2262| 17700002 | The specified moduleName is not existed.                      |
2263| 17700003 | The specified abilityName is not existed.                     |
2264| 17700024 | Failed to get the profile because there is no profile in the HAP. |
2265| 17700026 | The specified bundle is disabled.                             |
2266| 17700029 | The specified ability is disabled.                            |
2267
2268**Example**
2269
2270```ts
2271import bundleManager from '@ohos.bundle.bundleManager';
2272import hilog from '@ohos.hilog';
2273let moduleName = 'entry';
2274let abilityName = 'MainAbility';
2275let metadataName = 'com.example.myapplication.metadata';
2276
2277try {
2278    bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => {
2279        if (err) {
2280            hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2281        } else {
2282            hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data));
2283        }
2284    });
2285} catch (err) {
2286    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2287}
2288```
2289
2290### bundleManager.getProfileByAbility
2291
2292getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\>;
2293
2294Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses a promise to return the result.
2295
2296**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2297
2298**Parameters**
2299
2300| Name      | Type  | Mandatory| Description                      |
2301| ------------ | ------ | ---- | -------------------------- |
2302| moduleName   | string | Yes  | Module name.  |
2303| abilityName  | string | Yes  | Ability name. |
2304| metadataName | string | No  | Metadata name.|
2305
2306**Return value**
2307
2308| Type                   | Description                           |
2309| ----------------------- | ------------------------------- |
2310| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
2311
2312**Error codes**
2313
2314For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2315
2316| ID| Error Message                                                    |
2317| -------- | ------------------------------------------------------------ |
2318| 17700002 | The specified moduleName is not existed.                      |
2319| 17700003 | The specified abilityName is not existed.                     |
2320| 17700024 | Failed to get the profile because there is no profile in the HAP. |
2321| 17700026 | The specified bundle is disabled.                             |
2322| 17700029 | The specified ability is disabled.                            |
2323
2324**Example**
2325
2326```ts
2327import bundleManager from '@ohos.bundle.bundleManager';
2328import hilog from '@ohos.hilog';
2329let moduleName = 'entry';
2330let abilityName = 'MainAbility';
2331
2332try {
2333    bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => {
2334        hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
2335    }).catch(err => {
2336        hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2337    });
2338} catch (err) {
2339    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2340}
2341```
2342
2343```ts
2344import bundleManager from '@ohos.bundle.bundleManager';
2345import hilog from '@ohos.hilog';
2346let moduleName = 'entry';
2347let abilityName = 'MainAbility';
2348let metadataName = 'com.example.myapplication.metadata';
2349try {
2350    bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => {
2351        hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data));
2352    }).catch(err => {
2353        hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2354    });
2355} catch (err) {
2356    hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message);
2357}
2358```
2359
2360### bundleManager.getProfileByExtensionAbility
2361
2362getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void;
2363
2364Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result.
2365
2366**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2367
2368**Parameters**
2369
2370| Name                | Type                         | Mandatory| Description                                                        |
2371| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
2372| moduleName           | string                        | Yes  | Module name.                                  |
2373| extensionAbilityName | string                        | Yes  | Extension ability name.                        |
2374| metadataName         | string                        | Yes  | Metadata name.                                |
2375| 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.|
2376
2377**Error codes**
2378
2379For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2380
2381| ID| Error Message                                                    |
2382| -------- | ------------------------------------------------------------ |
2383| 17700002 | The specified moduleName is not existed.                      |
2384| 17700003 | The specified extensionAbilityName not existed.            |
2385| 17700024 | Failed to get the profile because there is no profile in the HAP. |
2386| 17700026 | The specified bundle is disabled.                             |
2387
2388**Example**
2389
2390```ts
2391import bundleManager from '@ohos.bundle.bundleManager';
2392import hilog from '@ohos.hilog';
2393let moduleName = 'entry';
2394let extensionAbilityName = 'com.example.myapplication.extension';
2395let metadataName = 'com.example.myapplication.metadata';
2396
2397try {
2398    bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => {
2399        if (err) {
2400            hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message);
2401        } else {
2402            hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data));
2403        }
2404    });
2405} catch (err) {
2406    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message);
2407}
2408```
2409
2410### bundleManager.getProfileByExtensionAbility
2411
2412getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\>;
2413
2414Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses a promise to return the result.
2415
2416**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2417
2418**Parameters**
2419
2420| Name                | Type  | Mandatory| Description                              |
2421| -------------------- | ------ | ---- | ---------------------------------- |
2422| moduleName           | string | Yes  | Module name.          |
2423| extensionAbilityName | string | Yes  | Extension ability name.|
2424| metadataName         | string | No  | Metadata name.        |
2425
2426**Return value**
2427
2428| Type                   | Description                               |
2429| ----------------------- | ----------------------------------- |
2430| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.|
2431
2432**Error codes**
2433
2434For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2435
2436| ID| Error Message                                                    |
2437| -------- | ------------------------------------------------------------ |
2438| 17700002 | The specified moduleName is not existed.                      |
2439| 17700003 | The specified extensionAbilityName not existed.            |
2440| 17700024 | Failed to get the profile because there is no profile in the HAP. |
2441| 17700026 | The specified bundle is disabled.                             |
2442
2443**Example**
2444
2445```ts
2446import bundleManager from '@ohos.bundle.bundleManager';
2447import hilog from '@ohos.hilog';
2448let moduleName = 'entry';
2449let extensionAbilityName = 'com.example.myapplication.extension';
2450let metadataName = 'com.example.myapplication.metadata';
2451
2452try {
2453    bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => {
2454        hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
2455    }).catch(err => {
2456        hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
2457    });
2458} catch (err) {
2459    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
2460}
2461
2462try {
2463    bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => {
2464        hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data));
2465    }).catch(err => {
2466        hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
2467    });
2468} catch (err) {
2469    hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message);
2470}
2471```
2472
2473### bundleManager.getPermissionDef
2474
2475getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>): void;
2476
2477Obtains the details of a permission in the form of a **PermissionDef** struct. This API uses an asynchronous callback to return the result.
2478
2479**System API**: This is a system API.
2480
2481**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2482
2483**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2484
2485**Parameters**
2486
2487| Name          | Type                                                        | Mandatory| Description                                                        |
2488| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2489| permissionName | string                                                       | Yes  | Name of the permission.                                              |
2490| 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 array of **PermissionDef** objects obtained. Otherwise, **err** is an error object.|
2491
2492**Error codes**
2493
2494For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2495
2496| ID| Error Message                             |
2497| -------- | ------------------------------------- |
2498| 17700006 | The specified permission is not found. |
2499
2500**Example**
2501
2502```ts
2503import bundleManager from '@ohos.bundle.bundleManager';
2504import hilog from '@ohos.hilog';
2505let permission = "ohos.permission.GET_BUNDLE_INFO";
2506try {
2507    bundleManager.getPermissionDef(permission, (err, data) => {
2508        if (err) {
2509            hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message);
2510        } else {
2511            hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', JSON.stringify(data));
2512        }
2513    });
2514} catch (err) {
2515    hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message);
2516}
2517```
2518
2519### bundleManager.getPermissionDef
2520
2521getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>;
2522
2523Obtains the details of a permission in the form of a **PermissionDef** struct. This API uses a promise to return the result.
2524
2525**System API**: This is a system API.
2526
2527**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2528
2529**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2530
2531**Parameters**
2532
2533| Name          | Type  | Mandatory| Description          |
2534| -------------- | ------ | ---- | -------------- |
2535| permissionName | string | Yes  | Name of the permission.|
2536
2537**Return value**
2538
2539| Type                                                        | Description                                      |
2540| ------------------------------------------------------------ | ------------------------------------------ |
2541| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | Promise used to return the array of **PermissionDef** objects obtained.|
2542
2543**Error codes**
2544
2545For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2546
2547| ID| Error Message                             |
2548| -------- | ------------------------------------- |
2549| 17700006 | The specified permission is not found. |
2550
2551**Example**
2552
2553```ts
2554import bundleManager from '@ohos.bundle.bundleManager';
2555import hilog from '@ohos.hilog';
2556let permissionName = "ohos.permission.GET_BUNDLE_INFO";
2557try {
2558    bundleManager.getPermissionDef(permissionName).then((data) => {
2559        hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data));
2560    }).catch(err => {
2561        hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message);
2562    });
2563} catch (err) {
2564    hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message);
2565}
2566```
2567
2568### bundleManager.getAbilityLabel
2569
2570getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<string>): void;
2571
2572Obtains the ability label based on the given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result.
2573
2574**System API**: This is a system API.
2575
2576**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2577
2578**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
2579
2580**Parameters**
2581
2582| Name     | Type                  | Mandatory| Description                                                        |
2583| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
2584| bundleName  | string                 | Yes  | Bundle name.                                    |
2585| moduleName  | string                 | Yes  | Module name.                                    |
2586| abilityName | string                 | Yes  | Ability name.                                   |
2587| 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.|
2588
2589**Error codes**
2590
2591For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2592
2593| ID| Error Message                              |
2594| -------- | -------------------------------------- |
2595| 17700001 | The specified bundleName is not found.  |
2596| 17700002 | The specified moduleName is not found.  |
2597| 17700003 | The specified abilityName is not found. |
2598| 17700026 | The specified bundle is disabled.       |
2599| 17700029 | The specified ability is disabled.      |
2600
2601**Example**
2602
2603```ts
2604import bundleManager from '@ohos.bundle.bundleManager';
2605import hilog from '@ohos.hilog';
2606let bundleName = 'com.example.myapplication';
2607let moduleName = 'entry';
2608let abilityName = 'MainAbility';
2609
2610try {
2611    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
2612        if (err) {
2613            hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message);
2614        } else {
2615            hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', JSON.stringify(data));
2616        }
2617    });
2618} catch (err) {
2619    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message);
2620}
2621```
2622
2623### bundleManager.getAbilityLabel
2624
2625getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>;
2626
2627Obtains the ability label based on the given bundle name, module name, and ability name. This API uses a promise to return the result.
2628
2629**System API**: This is a system API.
2630
2631**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2632
2633**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
2634
2635**Parameters**
2636
2637| Name     | Type  | Mandatory| Description                     |
2638| ----------- | ------ | ---- | ------------------------- |
2639| bundleName  | string | Yes  | Bundle name. |
2640| moduleName  | string | Yes  | Module name. |
2641| abilityName | string | Yes  | Ability name.|
2642
2643**Return value**
2644
2645| Type            | Description                               |
2646| ---------------- | ----------------------------------- |
2647| Promise\<string> | Promise used to return the label.|
2648
2649**Error codes**
2650
2651For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2652
2653| ID| Error Message                             |
2654| -------- | --------------------------------------- |
2655| 17700001 | The specified bundleName is not found.  |
2656| 17700002 | The specified moduleName is not found.  |
2657| 17700003 | The specified abilityName is not found. |
2658| 17700026 | The specified bundle is disabled.       |
2659| 17700029 | The specified ability is disabled.      |
2660
2661**Example**
2662
2663```ts
2664import bundleManager from '@ohos.bundle.bundleManager';
2665import hilog from '@ohos.hilog';
2666let bundleName = 'com.example.myapplication';
2667let moduleName = 'entry';
2668let abilityName = 'MainAbility';
2669
2670try {
2671    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
2672        hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data));
2673    }).catch(err => {
2674        hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message);
2675    });
2676} catch (err) {
2677    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message);
2678}
2679```
2680
2681### bundleManager.getApplicationInfoSync
2682
2683getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
2684
2685Synchronously obtains the application information based on the given bundle name, application flags, and user ID.
2686
2687**System API**: This is a system API.
2688
2689**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2690
2691**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2692
2693**Parameters**
2694
2695| Name      | Type  | Mandatory| Description                                                      |
2696| ----------- | ------ | ---- | ----------------------------------------------------------|
2697| bundleName  | string | Yes  | Bundle name.                                 |
2698| applicationFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.      |
2699| userId      | number | Yes  | User ID.                                        |
2700
2701**Return value**
2702
2703| Type           | Description                     |
2704| --------------- | ------------------------- |
2705| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
2706
2707**Error codes**
2708
2709For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2710
2711| ID| Error Message                            |
2712| -------- | -------------------------------------- |
2713| 17700001 | The specified bundleName is not found. |
2714| 17700004 | The specified user ID is not found.     |
2715| 17700026 | The specified bundle is disabled.      |
2716
2717**Example**
2718
2719```ts
2720import bundleManager from '@ohos.bundle.bundleManager';
2721import hilog from '@ohos.hilog';
2722let bundleName = 'com.example.myapplication';
2723let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
2724let userId = 100;
2725
2726try {
2727    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
2728    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
2729} catch (err) {
2730    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', err.message);
2731}
2732```
2733
2734### bundleManager.getApplicationInfoSync
2735
2736getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
2737
2738Synchronously obtains the application information based on the given bundle name and application flags.
2739
2740**System API**: This is a system API.
2741
2742**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2743
2744**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2745
2746**Parameters**
2747
2748| Name          | Type                      | Mandatory| Description                                                 |
2749| ---------------- | -------------------------- | ---- | ----------------------------------------------------- |
2750| bundleName       | string                     | Yes  | Bundle name.                           |
2751| applicationFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.|
2752
2753**Return value**
2754
2755| Type                                                       | Description                     |
2756| ----------------------------------------------------------- | ------------------------- |
2757| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
2758
2759**Error codes**
2760
2761For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2762
2763| ID| Error Message                              |
2764| -------- | -------------------------------------- |
2765| 17700001 | The specified bundleName is not found. |
2766| 17700026 | The specified bundle is disabled.      |
2767
2768**Example**
2769
2770```ts
2771import bundleManager from '@ohos.bundle.bundleManager';
2772import hilog from '@ohos.hilog';
2773let bundleName = 'com.example.myapplication';
2774let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
2775
2776try {
2777    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
2778    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
2779} catch (err) {
2780    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', err.message);
2781}
2782```
2783
2784### bundleManager.getBundleInfoSync
2785
2786getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
2787
2788Synchronously obtains the bundle information based on the given bundle name, bundle flags, and user ID.
2789
2790**System API**: This is a system API.
2791
2792**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2793
2794**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2795
2796**Parameters**
2797
2798| Name      | Type  | Mandatory| Description                                                    |
2799| ----------- | ------ | ---- | -------------------------------------------------------- |
2800| bundleName  | string | Yes  | Bundle name.                                |
2801| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
2802| userId      | number | Yes  | User ID.                                            |
2803
2804**Return value**
2805
2806| Type      | Description                |
2807| ---------- | -------------------- |
2808| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
2809
2810**Error codes**
2811
2812For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2813
2814| ID| Error Message                            |
2815| -------- | ------------------------------------- |
2816| 17700001 | The specified bundleName is not found. |
2817| 17700004 | The specified user ID is not found.     |
2818| 17700026 | The specified bundle is disabled.      |
2819
2820**Example**
2821
2822```ts
2823import bundleManager from '@ohos.bundle.bundleManager';
2824import hilog from '@ohos.hilog';
2825let bundleName = 'com.example.myapplication';
2826let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
2827let userId = 100;
2828
2829try {
2830    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
2831    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
2832} catch (err) {
2833    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message);
2834}
2835```
2836
2837### bundleManager.getBundleInfoSync
2838
2839getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
2840
2841Synchronously obtains the bundle information based on the given bundle name and bundle flags.
2842
2843**System API**: This is a system API.
2844
2845**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2846
2847**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2848
2849**Parameters**
2850
2851| Name     | Type                 | Mandatory| Description                                                  |
2852| ----------- | --------------------- | ---- | ------------------------------------------------------ |
2853| bundleName  | string                | Yes  | Bundle name.                            |
2854| bundleFlags | [number](#bundleflag) | Yes  | Type of the bundle information to obtain.|
2855
2856**Return value**
2857
2858| Type                                             | Description                |
2859| ------------------------------------------------- | -------------------- |
2860| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
2861
2862**Error codes**
2863
2864For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
2865
2866| ID| Error Message                              |
2867| -------- | -------------------------------------- |
2868| 17700001 | The specified bundleName is not found. |
2869| 17700026 | The specified bundle is disabled.      |
2870
2871**Example**
2872
2873```ts
2874import bundleManager from '@ohos.bundle.bundleManager';
2875import hilog from '@ohos.hilog';
2876let bundleName = 'com.example.myapplication';
2877let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
2878try {
2879    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
2880    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
2881} catch (err) {
2882    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message);
2883}
2884```
2885