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