• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.bundleManager (bundleManager) (System API)
2
3The bundleManager module provides APIs for obtaining application information, including [BundleInfo](js-apis-bundleManager-bundleInfo.md), [ApplicationInfo](js-apis-bundleManager-ApplicationInfo-sys.md), [AbilityInfo](js-apis-bundleManager-abilityInfo.md), and [ExtensionAbility](js-apis-bundleManager-extensionAbilityInfo.md).
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.bundle.bundleManager](js-apis-bundleManager.md).
10
11## Modules to Import
12
13```ts
14import { bundleManager } from '@kit.AbilityKit';
15```
16
17## Required Permissions
18
19| Permission                                      | APL    | Description           |
20| ------------------------------------------ | ------------ | ------------------|
21| ohos.permission.GET_BUNDLE_INFO            | normal       | Permission to obtain basic information about a bundle.  |
22| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to obtain basic information and other sensitive information about a bundle.|
23| ohos.permission.REMOVE_CACHE_FILES         | system_basic | Permission to clear cache files of a bundle.      |
24| ohos.permission.CHANGE_ABILITY_ENABLED_STATE| system_basic | Permission to enable or disable an application or ability. |
25| ohos.permission.GET_INSTALLED_BUNDLE_LIST | system_basic | Permission to read installed application list.|
26
27For details about the APL, see [Basic Concepts in the Permission Mechanism](../../security/AccessToken/app-permission-mgmt-overview.md#basic-concepts-in-the-permission-mechanism).
28
29## BundleFlag
30
31Enumerates the bundle flags, which indicate the type of bundle information to obtain.
32
33 **System capability**: SystemCapability.BundleManager.BundleFramework.Core
34
35| Name                                         | Value        | Description                                                        |
36| --------------------------------------------- | ---------- | ------------------------------------------------------------ |
37| GET_BUNDLE_INFO_DEFAULT                       | 0x00000000 | Used to obtain the default bundle information. The obtained information does not contain information about the signature, application, HAP module, ability, ExtensionAbility, or permission.|
38| GET_BUNDLE_INFO_WITH_APPLICATION              | 0x00000001 | Used to obtain the bundle information with application information. The obtained information does not contain information about the signature, HAP module, ability, ExtensionAbility, or permission.|
39| GET_BUNDLE_INFO_WITH_HAP_MODULE               | 0x00000002 | Used to obtain the bundle information with HAP module information. The obtained information does not contain information about the signature, application, ability, ExtensionAbility, or permission.|
40| GET_BUNDLE_INFO_WITH_ABILITY                  | 0x00000004 | Used to obtain the bundle information with ability information. The obtained information does not contain information about the signature, application, ExtensionAbility, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.|
41| GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY        | 0x00000008 | Used to obtain the bundle information with ExtensionAbility information. The obtained information does not contain information about the signature, application, ability, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.|
42| GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION     | 0x00000010 | Used to obtain the bundle information with permission information. The obtained information does not contain information about the signature, application, HAP module, ability, or ExtensionAbility.|
43| GET_BUNDLE_INFO_WITH_METADATA                 | 0x00000020 | Used to obtain the metadata contained in the application, HAP module, ability, or ExtensionAbility information. It must be used together with **GET_BUNDLE_INFO_WITH_APPLICATION**, **GET_BUNDLE_INFO_WITH_HAP_MODULE**, **GET_BUNDLE_INFO_WITH_ABILITY**, and **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.|
44| GET_BUNDLE_INFO_WITH_DISABLE                  | 0x00000040 | Used to obtain the information about disabled bundles and abilities of a bundle. The obtained information does not contain information about the signature, application, HAP module, ability, ExtensionAbility, or permission.|
45| GET_BUNDLE_INFO_WITH_SIGNATURE_INFO           | 0x00000080 | Used to obtain the bundle information with signature information. The obtained information does not contain information about the application, HAP module, ability, ExtensionAbility, or permission.|
46| GET_BUNDLE_INFO_WITH_MENU<sup>11+</sup>       | 0x00000100 | Used to obtain the bundle information with the file context menu configuration. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.|
47| GET_BUNDLE_INFO_WITH_ROUTER_MAP<sup>12+</sup> | 0x00000200 | Used to obtain the bundle information with the router map. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.|
48| GET_BUNDLE_INFO_WITH_SKILL<sup>12+</sup>      | 0x00000800 | Used to obtain the bundle information with the skills. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**, **GET_BUNDLE_INFO_WITH_ABILITY**, and **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.|
49| GET_BUNDLE_INFO_ONLY_WITH_LAUNCHER_ABILITY<sup>12+</sup> | 0x00001000 | Used to obtain the bundle information of the application that has only a home screen icon. It is valid only in the [getAllBundleInfo](#bundlemanagergetallbundleinfo) API.|
50| GET_BUNDLE_INFO_OF_ANY_USER<sup>12+</sup>      | 0x00002000 | Used to obtain the bundle information of an application installed by any user. It must be used together with **GET_BUNDLE_INFO_WITH_APPLICATION**. It is valid only in the [getBundleInfo](#bundlemanagergetbundleinfo14) and [getAllBundleInfo](#bundlemanagergetallbundleinfo) APIs.<br>**System API**: This enumerated value can be used in system APIs since API version 12.|
51| GET_BUNDLE_INFO_EXCLUDE_CLONE<sup>12+</sup> | 0x00004000 | Used to obtain the bundle information of a main application (excluding its clones). It is valid only in the [getAllBundleInfo](#bundlemanagergetallbundleinfo) API.|
52
53## ApplicationFlag
54
55Enumerates the application flags, which indicate the type of application information to obtain.
56
57**System capability**: SystemCapability.BundleManager.BundleFramework.Core
58
59**System API**: This is a system API.
60
61| Name                                | Value        | Description                                                        |
62| ------------------------------------ | ---------- | ------------------------------------------------------------ |
63| GET_APPLICATION_INFO_DEFAULT         | 0x00000000 | Used to obtain the default application information. The obtained information does not contain the permission information or metadata.|
64| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the application information with permission information.                   |
65| GET_APPLICATION_INFO_WITH_METADATA   | 0x00000002 | Used to obtain the application information with metadata.                     |
66| GET_APPLICATION_INFO_WITH_DISABLE    | 0x00000004 | Used to obtain the application information of disabled bundles.                 |
67
68## AbilityFlag
69
70Enumerates the ability flags, which indicate the type of ability information to obtain.
71
72**System capability**: SystemCapability.BundleManager.BundleFramework.Core
73
74**System API**: This is a system API.
75
76| Name                             | Value        | Description                                                        |
77| --------------------------------- | ---------- | ------------------------------------------------------------ |
78| 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.|
79| GET_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the ability information with permission information.                         |
80| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ability information with application information.                    |
81| GET_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the ability information with metadata.                           |
82| GET_ABILITY_INFO_WITH_DISABLE     | 0x00000008 | Used to obtain the ability information of disabled abilities.                  |
83| GET_ABILITY_INFO_ONLY_SYSTEM_APP  | 0x00000010 | Used to obtain the ability information of system applications.                        |
84| GET_ABILITY_INFO_WITH_APP_LINKING<sup>12+</sup>  | 0x00000040 | Used to obtain the ability information filtered by domain name verification.                        |
85| GET_ABILITY_INFO_WITH_SKILL<sup>12+</sup>   | 0x00000080 | Used to obtain the ability information with skills.                        |
86
87## ExtensionAbilityFlag
88
89Enumerates the ExtensionAbility flags, which indicate the type of ExtensionAbility information to obtain.
90
91**System capability**: SystemCapability.BundleManager.BundleFramework.Core
92
93**System API**: This is a system API.
94
95| Name                                       | Value        | Description                                                        |
96| ------------------------------------------- | ---------- | ------------------------------------------------------------ |
97| GET_EXTENSION_ABILITY_INFO_DEFAULT          | 0x00000000 | Used to obtain the default ExtensionAbility information. The obtained information does not contain the permission, metadata, or disabled ability information.|
98| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | Used to obtain the ExtensionAbility information with permission information.              |
99| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ExtensionAbility information with application information.        |
100| GET_EXTENSION_ABILITY_INFO_WITH_METADATA    | 0x00000004 | Used to obtain the ExtensionAbility information with metadata.                |
101| GET_EXTENSION_ABILITY_INFO_WITH_SKILL<sup>12+</sup>     | 0x00000010 | Used to obtain the ExtensionAbility information with skills.                |
102
103## ProfileType<sup>11+</sup>
104
105Enumerates the types of profiles (also called application files).
106
107**System capability**: SystemCapability.BundleManager.BundleFramework.Core
108
109**System API**: This is a system API.
110
111| Name          | Value  | Description           |
112| -------------- | ---- | --------------- |
113| INTENT_PROFILE  | 1    | Profile of the InsightIntent framework.   |
114
115## AppDistributionType<sup>12+</sup>
116
117Enumerates the application [distribution types](../../security/app-provision-structure.md).
118
119**System capability**: SystemCapability.BundleManager.BundleFramework.Core
120
121**System API**: This is a system API.
122
123| Name             | Value  | Description           |
124| ----------------- | ---- | --------------- |
125| APP_GALLERY       | 1    | Application distributed by AppGallery.   |
126| ENTERPRISE        | 2    | Enterprise application that can be installed on personal devices.   |
127| ENTERPRISE_NORMAL | 3    | Common enterprise application that can be installed on enterprise devices only through an enterprise mobile device management (MDM) application. The applications of this type do not require device management privileges.   |
128| ENTERPRISE_MDM    | 4    | Enterprise MDM application that can be installed only on enterprise devices. The applications of this type must have device management privileges, such as remote locking devices and installing common enterprise applications on devices.   |
129| OS_INTEGRATION    | 5    | Preinstalled system application.   |
130| CROWDTESTING      | 6    | Crowdtesting application.   |
131| NONE              | 7    | Other.          |
132
133## ApplicationInfoFlag<sup>12+</sup>
134Enumerates the application information flag, which describes the status between an application and user.
135
136**System capability**: SystemCapability.BundleManager.BundleFramework.Core
137
138**System API**: This is a system API.
139
140| Name| Value| Description|
141|----------------|---|---|
142| FLAG_INSTALLED|  0x00000001 | The application is installed for the specified user.|
143| FLAG_OTHER_INSTALLED<sup>15+</sup>|  0x00000010 | The application is installed for users other than the specified user.|
144| FLAG_PREINSTALLED_APP<sup>15+</sup>|  0x00000020 | The application is a preinstalled application.|
145| FLAG_PREINSTALLED_APP_UPDATE<sup>15+</sup>|  0x00000040 | The preinstalled application is updated.|
146
147## bundleManager.getBundleInfo<sup>14+</sup>
148
149getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void
150
151Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses an asynchronous callback to return the result.
152
153No permission is required for obtaining the caller's own information.
154
155**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
156
157**System capability**: SystemCapability.BundleManager.BundleFramework.Core
158
159**Parameters**
160
161| Name | Type  | Mandatory| Description                      |
162| ----------- | ------ | ---- | ---------------------------- |
163| bundleName  | string | Yes  | Bundle name.|
164| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
165| userId      | number | Yes  | User ID. |
166| 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.|
167
168**Error codes**
169
170For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
171
172| ID| Error Message                             |
173| -------- | ------------------------------------- |
174| 201 | Permission denied. |
175| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
176| 17700001 | The specified bundleName is not found. |
177| 17700004 | The specified user ID is not found.     |
178| 17700026 | The specified bundle is disabled.      |
179
180**Example**
181
182```ts
183// Obtain the bundle information with the ability information.
184import { bundleManager } from '@kit.AbilityKit';
185import { BusinessError } from '@kit.BasicServicesKit';
186import { hilog } from '@kit.PerformanceAnalysisKit';
187let bundleName = 'com.example.myapplication';
188let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
189let userId = 100;
190
191try {
192    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
193        if (err) {
194            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
195        } else {
196            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
197        }
198    });
199} catch (err) {
200    let message = (err as BusinessError).message;
201    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
202}
203```
204
205```ts
206// Obtain the bundle information with the metadata in the application information.
207import { bundleManager } from '@kit.AbilityKit';
208import { BusinessError } from '@kit.BasicServicesKit';
209import { hilog } from '@kit.PerformanceAnalysisKit';
210let bundleName = 'com.example.myapplication';
211let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
212let userId = 100;
213
214try {
215    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
216        if (err) {
217            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
218        } else {
219            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
220        }
221    });
222} catch (err) {
223    let message = (err as BusinessError).message;
224    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
225}
226```
227
228## bundleManager.getBundleInfo<sup>14+</sup>
229
230getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
231
232Obtains the bundle information based on the given bundle name and bundle flags. This API uses an asynchronous callback to return the result.
233
234No permission is required for obtaining the caller's own information.
235
236**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
237
238**System capability**: SystemCapability.BundleManager.BundleFramework.Core
239
240**Parameters**
241
242| Name    | Type  | Mandatory| Description                      |
243| ----------- | ------ | ---- | ---------------------------- |
244| bundleName  | string | Yes  | Bundle name.|
245| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
246| 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.|
247
248**Error codes**
249
250For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
251
252| ID| Error Message                             |
253| -------- | ------------------------------------- |
254| 201 | Permission denied. |
255| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
256| 17700001 | The specified bundleName is not found. |
257| 17700026 | The specified bundle is disabled.      |
258
259**Example**
260
261```ts
262// Obtain the bundle information with the ExtensionAbility information.
263import { bundleManager } from '@kit.AbilityKit';
264import { BusinessError } from '@kit.BasicServicesKit';
265import { hilog } from '@kit.PerformanceAnalysisKit';
266let bundleName = 'com.example.myapplication';
267let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
268
269try {
270    bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
271        if (err) {
272            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
273        } else {
274            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
275        }
276    });
277} catch (err) {
278    let message = (err as BusinessError).message;
279    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
280}
281```
282
283## bundleManager.getBundleInfo<sup>14+</sup>
284
285getBundleInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<BundleInfo>
286
287Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses a promise to return the result.
288
289No permission is required for obtaining the caller's own information.
290
291**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
292
293**System capability**: SystemCapability.BundleManager.BundleFramework.Core
294
295**Parameters**
296
297| Name    | Type  | Mandatory| Description                      |
298| ----------- | ------ | ---- | ---------------------------- |
299| bundleName  | string | Yes  | Bundle name.|
300| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.      |
301| userId      | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
302
303**Return value**
304
305| Type                                                       | Description                       |
306| ----------------------------------------------------------- | --------------------------- |
307| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
308
309**Error codes**
310
311For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
312
313| ID| Error Message                           |
314| -------- | --------------------------------------|
315| 201 | Permission denied. |
316| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
317| 17700001 | The specified bundleName is not found. |
318| 17700004 | The specified user ID is not found.     |
319| 17700026 | The specified bundle is disabled.      |
320
321**Example**
322
323```ts
324// Obtain the bundle information with the application and signature information.
325import { bundleManager } from '@kit.AbilityKit';
326import { BusinessError } from '@kit.BasicServicesKit';
327import { hilog } from '@kit.PerformanceAnalysisKit';
328let bundleName = 'com.example.myapplication';
329let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
330let userId = 100;
331
332try {
333    bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
334        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
335    }).catch((err: BusinessError) => {
336        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
337    });
338} catch (err) {
339    let message = (err as BusinessError).message;
340    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
341}
342```
343
344```ts
345import { bundleManager } from '@kit.AbilityKit';
346import { BusinessError } from '@kit.BasicServicesKit';
347import { hilog } from '@kit.PerformanceAnalysisKit';
348let bundleName = 'com.example.myapplication';
349let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
350
351try {
352    bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
353        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
354    }).catch((err: BusinessError) => {
355        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
356    });
357} catch (err) {
358    let message = (err as BusinessError).message;
359    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
360}
361
362```
363
364## bundleManager.getApplicationInfo
365
366getApplicationInfo(bundleName: string, appFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void
367
368Obtains the application information based on the given bundle name, application flags, and user ID. This API uses an asynchronous callback to return the result.
369
370No permission is required for obtaining the caller's own information.
371
372**System API**: This is a system API.
373
374**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
375
376**System capability**: SystemCapability.BundleManager.BundleFramework.Core
377
378**Parameters**
379
380| Name   | Type  | Mandatory| Description                      |
381| ---------- | ------ | ---- | ---------------------------- |
382| bundleName | string | Yes  | Bundle name.|
383| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
384| userId     | number | Yes  | User ID. |
385| 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.|
386
387**Error codes**
388
389For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
390
391| ID| Error Message                            |
392| -------- | --------------------------------------|
393| 201 | Permission denied. |
394| 202 | Permission denied, non-system app called system api. |
395| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
396| 17700001 | The specified bundleName is not found. |
397| 17700004 | The specified user ID is not found.     |
398| 17700026 | The specified bundle is disabled.      |
399
400**Example**
401
402```ts
403import { bundleManager } from '@kit.AbilityKit';
404import { BusinessError } from '@kit.BasicServicesKit';
405import { hilog } from '@kit.PerformanceAnalysisKit';
406let bundleName = 'com.example.myapplication';
407let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
408let userId = 100;
409
410try {
411    bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
412        if (err) {
413            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
414        } else {
415            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
416        }
417    });
418} catch (err) {
419    let message = (err as BusinessError).message;
420    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
421}
422```
423
424## bundleManager.getApplicationInfo
425
426getApplicationInfo(bundleName: string, appFlags: number, callback: AsyncCallback\<ApplicationInfo>): void
427
428Obtains the application information based on the given bundle name and application flags. This API uses an asynchronous callback to return the result.
429
430No permission is required for obtaining the caller's own information.
431
432**System API**: This is a system API.
433
434**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
435
436**System capability**: SystemCapability.BundleManager.BundleFramework.Core
437
438**Parameters**
439
440| Name   | Type  | Mandatory| Description                      |
441| ---------- | ------ | ---- | ---------------------------- |
442| bundleName | string | Yes  | Bundle name.|
443| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
444| 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.|
445
446**Error codes**
447
448For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
449
450| ID| Error Message                            |
451| -------- | --------------------------------------|
452| 201 | Permission denied. |
453| 202 | Permission denied, non-system app called system api. |
454| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
455| 17700001 | The specified bundleName is not found. |
456| 17700026 | The specified bundle is disabled.      |
457
458**Example**
459
460```ts
461import { bundleManager } from '@kit.AbilityKit';
462import { BusinessError } from '@kit.BasicServicesKit';
463import { hilog } from '@kit.PerformanceAnalysisKit';
464let bundleName = 'com.example.myapplication';
465let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
466
467try {
468    bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
469        if (err) {
470            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
471        } else {
472            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
473        }
474    });
475} catch (err) {
476    let message = (err as BusinessError).message;
477    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
478}
479```
480
481## bundleManager.getApplicationInfo
482
483getApplicationInfo(bundleName: string, appFlags: number, userId?: number): Promise\<ApplicationInfo>
484
485Obtains the application information based on the given bundle name, application flags, and user ID. This API uses a promise to return the result.
486
487No permission is required for obtaining the caller's own information.
488
489**System API**: This is a system API.
490
491**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
492
493**System capability**: SystemCapability.BundleManager.BundleFramework.Core
494
495**Parameters**
496
497| Name   | Type  | Mandatory| Description                      |
498| ---------- | ------ | ---- | ---------------------------- |
499| bundleName | string | Yes  | Bundle name.|
500| appFlags   | [number](#applicationflag) | Yes  | Type of the application information to obtain.   |
501| userId     | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
502
503**Return value**
504
505| Type                                                        | Description                            |
506| ------------------------------------------------------------ | -------------------------------- |
507| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise used to return the application information obtained.|
508
509**Error codes**
510
511For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
512
513| ID| Error Message                            |
514| -------- | ------------------------------------- |
515| 201 | Permission denied. |
516| 202 | Permission denied, non-system app called system api. |
517| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
518| 17700001 | The specified bundleName is not found. |
519| 17700004 | The specified user ID is not found.     |
520| 17700026 | The specified bundle is disabled.      |
521
522**Example**
523
524```ts
525import { bundleManager } from '@kit.AbilityKit';
526import { BusinessError } from '@kit.BasicServicesKit';
527import { hilog } from '@kit.PerformanceAnalysisKit';
528let bundleName = 'com.example.myapplication';
529let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
530let userId = 100;
531
532try {
533    bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
534        hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
535    }).catch((err: BusinessError) => {
536        hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message);
537    });
538} catch (err) {
539    let message = (err as BusinessError).message;
540    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', message);
541}
542```
543
544## bundleManager.getAllBundleInfo
545
546getAllBundleInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void
547
548Obtains all the bundle information in the system based on the given bundle flags and user ID. This API uses an asynchronous callback to return the result.
549
550**System API**: This is a system API.
551
552**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
553
554**System capability**: SystemCapability.BundleManager.BundleFramework.Core
555
556**Parameters**
557
558| Name    | Type  | Mandatory| Description                                            |
559| ----------- | ------ | ---- | -------------------------------------------------- |
560| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.                   |
561| userId      | number | Yes  | User ID.                     |
562| 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.|
563
564**Error codes**
565
566For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
567
568| ID| Error Message                        |
569| -------- | --------------------------------- |
570| 201 | Permission denied. |
571| 202 | Permission denied, non-system app called system api. |
572| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
573| 17700004 | The specified user ID is not found. |
574
575**Example**
576
577```ts
578import { bundleManager } from '@kit.AbilityKit';
579import { BusinessError } from '@kit.BasicServicesKit';
580import { hilog } from '@kit.PerformanceAnalysisKit';
581let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
582let userId = 100;
583
584try {
585    bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
586        if (err) {
587            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
588        } else {
589            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
590        }
591    });
592} catch (err) {
593    let message = (err as BusinessError).message;
594    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
595}
596```
597
598## bundleManager.getAllBundleInfo
599
600getAllBundleInfo(bundleFlags: number, callback: AsyncCallback<Array\<BundleInfo>>): void
601
602Obtains all the bundle information in the system based on the given bundle flags. This API uses an asynchronous callback to return the result.
603
604**System API**: This is a system API.
605
606**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
607
608**System capability**: SystemCapability.BundleManager.BundleFramework.Core
609
610**Parameters**
611
612| Name    | Type  | Mandatory| Description                                            |
613| ----------- | ------ | ---- | -------------------------------------------------- |
614| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.  |
615| 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.|
616
617**Error codes**
618
619For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
620
621| ID| Error Message                        |
622| -------- | ---------------------------------- |
623| 201 | Permission denied. |
624| 202 | Permission denied, non-system app called system api. |
625| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
626
627**Example**
628
629```ts
630import { bundleManager } from '@kit.AbilityKit';
631import { BusinessError } from '@kit.BasicServicesKit';
632import { hilog } from '@kit.PerformanceAnalysisKit';
633let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
634
635try {
636    bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
637        if (err) {
638            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
639        } else {
640            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
641        }
642    });
643} catch (err) {
644    let message = (err as BusinessError).message;
645    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
646}
647```
648
649## bundleManager.getAllBundleInfo
650
651getAllBundleInfo(bundleFlags: number, userId?: number): Promise<Array\<BundleInfo>>
652
653Obtains all the bundle information in the system based on the given bundle flags and user ID. This API uses a promise to return the result.
654
655**System API**: This is a system API.
656
657**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
658
659**System capability**: SystemCapability.BundleManager.BundleFramework.Core
660
661**Parameters**
662
663| Name    | Type  | Mandatory| Description                                            |
664| ----------- | ------ | ---- | -------------------------------------------------- |
665| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.                  |
666| userId      | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                     |
667
668**Return value**
669
670| Type                                                        | Description                               |
671| ------------------------------------------------------------ | ----------------------------------- |
672| Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Promise used to return the array of bundle information obtained.|
673
674**Error codes**
675
676For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
677
678| ID| Error Message                        |
679| -------- | ---------------------------------- |
680| 201 | Permission denied. |
681| 202 | Permission denied, non-system app called system api. |
682| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
683| 17700004 | The specified user ID is not found. |
684
685**Example**
686
687```ts
688import { bundleManager } from '@kit.AbilityKit';
689import { BusinessError } from '@kit.BasicServicesKit';
690import { hilog } from '@kit.PerformanceAnalysisKit';
691let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
692
693try {
694    bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
695        hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
696    }).catch((err: BusinessError) => {
697        hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message);
698    });
699} catch (err) {
700    let message = (err as BusinessError).message;
701    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', message);
702}
703```
704
705## bundleManager.getAllApplicationInfo
706
707getAllApplicationInfo(appFlags: number, userId: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void
708
709Obtains all the application information in the system based on the given application flags and user ID. This API uses an asynchronous callback to return the result.
710
711**System API**: This is a system API.
712
713**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
714
715**System capability**: SystemCapability.BundleManager.BundleFramework.Core
716
717**Parameters**
718
719| Name | Type  | Mandatory| Description                                                     |
720| -------- | ------ | ---- | ----------------------------------------------------------- |
721| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
722| userId   | number | Yes  | User ID.        |
723| 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.|
724
725**Error codes**
726
727For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
728
729| ID| Error Message                        |
730| -------- | ---------------------------------- |
731| 201 | Permission denied. |
732| 202 | Permission denied, non-system app called system api. |
733| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
734| 17700004 | The specified user ID is not found. |
735
736**Example**
737
738```ts
739import { bundleManager } from '@kit.AbilityKit';
740import { BusinessError } from '@kit.BasicServicesKit';
741import { hilog } from '@kit.PerformanceAnalysisKit';
742let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
743let userId = 100;
744
745try {
746    bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
747        if (err) {
748            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
749        } else {
750            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
751        }
752    });
753} catch (err) {
754    let message = (err as BusinessError).message;
755    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
756}
757```
758
759## bundleManager.getAllApplicationInfo
760
761getAllApplicationInfo(appFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void
762
763Obtains all the application information in the system based on the given application flags. This API uses an asynchronous callback to return the result.
764
765**System API**: This is a system API.
766
767**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
768
769**System capability**: SystemCapability.BundleManager.BundleFramework.Core
770
771**Parameters**
772
773| Name | Type  | Mandatory| Description                                                     |
774| -------- | ------ | ---- | ----------------------------------------------------------- |
775| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
776| 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.|
777
778**Error codes**
779
780For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
781
782| ID| Error Message                        |
783| -------- | ---------------------------------- |
784| 201 | Permission denied. |
785| 202 | Permission denied, non-system app called system api. |
786| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
787
788**Example**
789
790```ts
791import { bundleManager } from '@kit.AbilityKit';
792import { BusinessError } from '@kit.BasicServicesKit';
793import { hilog } from '@kit.PerformanceAnalysisKit';
794let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
795
796try {
797    bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
798        if (err) {
799            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
800        } else {
801            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
802        }
803    });
804} catch (err) {
805    let message = (err as BusinessError).message;
806    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
807}
808```
809
810## bundleManager.getAllApplicationInfo
811
812getAllApplicationInfo(appFlags: number, userId?: number): Promise<Array\<ApplicationInfo>>
813
814Obtains all the application information in the system based on the given application flags and user ID. This API uses a promise to return the result.
815
816**System API**: This is a system API.
817
818**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST
819
820**System capability**: SystemCapability.BundleManager.BundleFramework.Core
821
822**Parameters**
823
824| Name | Type  | Mandatory| Description                                                     |
825| -------- | ------ | ---- | ---------------------------------------------------------- |
826| appFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.                      |
827| userId   | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                       |
828
829**Return value**
830
831| Type                                                        | Description                                    |
832| ------------------------------------------------------------ | ---------------------------------------- |
833| Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Promise used to return the array of application information obtained.|
834
835**Error codes**
836
837For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
838
839| ID| Error Message                        |
840| -------- | ---------------------------------- |
841| 201 | Permission denied. |
842| 202 | Permission denied, non-system app called system api. |
843| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
844| 17700004 | The specified user ID is not found. |
845
846**Example**
847
848```ts
849import { bundleManager } from '@kit.AbilityKit';
850import { BusinessError } from '@kit.BasicServicesKit';
851import { hilog } from '@kit.PerformanceAnalysisKit';
852let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
853
854try {
855    bundleManager.getAllApplicationInfo(appFlags).then((data) => {
856        hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
857    }).catch((err: BusinessError) => {
858        hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message);
859    });
860} catch (err) {
861    let message = (err as BusinessError).message;
862    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', message);
863}
864
865```
866
867## bundleManager.queryAbilityInfo
868
869queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void
870
871Obtains the ability information based on the given Want, ability flags, and user ID. This API uses an asynchronous callback to return the result.
872
873**System API**: This is a system API.
874
875**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
876
877**System capability**: SystemCapability.BundleManager.BundleFramework.Core
878
879**Parameters**
880
881| Name     | Type  | Mandatory| Description                                                 |
882| ------------ | ------ | ---- | ------------------------------------------------------- |
883| want         | Want   | Yes  | Want containing the bundle name to query.                |
884| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.                      |
885| userId       | number | Yes  | User ID.                              |
886| 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.|
887
888**Error codes**
889
890For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
891
892| ID| Error Message                            |
893| -------- | -------------------------------------- |
894| 201 | Permission denied. |
895| 202 | Permission denied, non-system app called system api. |
896| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
897| 17700001 | The specified bundleName is not found. |
898| 17700003 | The specified ability is not found.    |
899| 17700004 | The specified userId is invalid.       |
900| 17700026 | The specified bundle is disabled.      |
901| 17700029 | The specified ability is disabled.     |
902
903**Example**
904
905```ts
906import { bundleManager } from '@kit.AbilityKit';
907import { BusinessError } from '@kit.BasicServicesKit';
908import { hilog } from '@kit.PerformanceAnalysisKit';
909import { Want } from '@kit.AbilityKit';
910let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
911let userId = 100;
912let want: Want = {
913    bundleName : "com.example.myapplication",
914    abilityName : "EntryAbility"
915};
916
917try {
918    bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
919        if (err) {
920            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
921        } else {
922            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
923        }
924    });
925} catch (err) {
926    let message = (err as BusinessError).message;
927    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
928}
929```
930
931## bundleManager.queryAbilityInfo
932
933queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback<Array\<AbilityInfo>>): void
934
935Obtains the ability information based on the given Want and ability flags. This API uses an asynchronous callback to return the result.
936
937**System API**: This is a system API.
938
939**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
940
941**System capability**: SystemCapability.BundleManager.BundleFramework.Core
942
943**Parameters**
944
945| Name     | Type  | Mandatory| Description                                                 |
946| ------------ | ------ | ---- | -------------------------------------------------------|
947| want         | Want   | Yes  | Want containing the bundle name to query.                |
948| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.      |
949| 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.|
950
951**Error codes**
952
953For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
954
955| ID| Error Message                            |
956| -------- | -------------------------------------- |
957| 201 | Permission denied. |
958| 202 | Permission denied, non-system app called system api. |
959| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
960| 17700001 | The specified bundleName is not found. |
961| 17700003 | The specified ability is not found.    |
962| 17700026 | The specified bundle is disabled.      |
963| 17700029 | The specified ability is disabled.     |
964
965**Example**
966
967```ts
968import { bundleManager } from '@kit.AbilityKit';
969import { BusinessError } from '@kit.BasicServicesKit';
970import { hilog } from '@kit.PerformanceAnalysisKit';
971import { Want } from '@kit.AbilityKit';
972let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
973let want: Want = {
974    bundleName : "com.example.myapplication",
975    abilityName : "EntryAbility"
976};
977
978try {
979    bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
980        if (err) {
981            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
982        } else {
983            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
984        }
985    });
986} catch (err) {
987    let message = (err as BusinessError).message;
988    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
989}
990```
991
992## bundleManager.queryAbilityInfo
993
994queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise<Array\<AbilityInfo>>
995
996Obtains the ability information based on the given Want, ability flags, and user ID. This API uses a promise to return the result.
997
998**System API**: This is a system API.
999
1000**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1001
1002**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1003
1004**Parameters**
1005
1006| Name     | Type  | Mandatory| Description                                                 |
1007| ------------ | ------ | ---- | ------------------------------------------------------- |
1008| want         | Want   | Yes  | Want containing the bundle name to query.                |
1009| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.|
1010| userId       | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                      |
1011
1012**Return value**
1013
1014| Type                                                        | Description                                |
1015| ------------------------------------------------------------ | ------------------------------------ |
1016| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise used to return the array of ability information obtained.|
1017
1018**Error codes**
1019
1020For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1021
1022| ID| Error Message                            |
1023| -------- | ------------------------------------- |
1024| 201 | Permission denied. |
1025| 202 | Permission denied, non-system app called system api. |
1026| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1027| 17700001 | The specified bundleName is not found. |
1028| 17700003 | The specified ability is not found.    |
1029| 17700004 | The specified userId is invalid.       |
1030| 17700026 | The specified bundle is disabled.      |
1031| 17700029 | The specified ability is disabled.     |
1032
1033**Example**
1034
1035```ts
1036import { bundleManager } from '@kit.AbilityKit';
1037import { BusinessError } from '@kit.BasicServicesKit';
1038import { hilog } from '@kit.PerformanceAnalysisKit';
1039import { Want } from '@kit.AbilityKit';
1040let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1041let userId = 100;
1042let want: Want = {
1043    bundleName : "com.example.myapplication",
1044    abilityName : "EntryAbility"
1045};
1046
1047try {
1048    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
1049        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1050    }).catch((err: BusinessError) => {
1051        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1052    });
1053} catch (err) {
1054    let message = (err as BusinessError).message;
1055    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
1056}
1057```
1058
1059```ts
1060import { bundleManager } from '@kit.AbilityKit';
1061import { BusinessError } from '@kit.BasicServicesKit';
1062import { hilog } from '@kit.PerformanceAnalysisKit';
1063import { Want } from '@kit.AbilityKit';
1064let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1065let want: Want = {
1066    bundleName : "com.example.myapplication",
1067    abilityName : "EntryAbility"
1068};
1069
1070try {
1071    bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
1072        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1073    }).catch((err: BusinessError) => {
1074        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1075    })
1076} catch (err) {
1077    let message = (err as BusinessError).message;
1078    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
1079}
1080```
1081
1082## bundleManager.queryAbilityInfoSync<sup>10+</sup>
1083
1084queryAbilityInfoSync(want: Want, abilityFlags: number, userId?: number): Array\<AbilityInfo>
1085
1086Obtains the ability information based on the given want, ability flags, and user ID. This API returns the result synchronously.
1087
1088**System API**: This is a system API.
1089
1090**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1091
1092**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1093
1094**Parameters**
1095
1096| Name     | Type  | Mandatory| Description                                                 |
1097| ------------ | ------ | ---- | ------------------------------------------------------- |
1098| want         | Want   | Yes  | Want containing the bundle name to query.                |
1099| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.|
1100| userId       | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                      |
1101
1102**Return value**
1103
1104| Type                                                        | Description                                |
1105| ------------------------------------------------------------ | ------------------------------------ |
1106| Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | An array of ability information.|
1107
1108**Error codes**
1109
1110For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1111
1112| ID| Error Message                            |
1113| -------- | ------------------------------------- |
1114| 201 | Permission denied. |
1115| 202 | Permission denied, non-system app called system api. |
1116| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1117| 17700001 | The specified bundleName is not found. |
1118| 17700003 | The specified ability is not found.    |
1119| 17700004 | The specified userId is invalid.       |
1120| 17700026 | The specified bundle is disabled.      |
1121| 17700029 | The specified ability is disabled.     |
1122
1123**Example**
1124
1125```ts
1126import { bundleManager } from '@kit.AbilityKit';
1127import { BusinessError } from '@kit.BasicServicesKit';
1128import { hilog } from '@kit.PerformanceAnalysisKit';
1129import { Want } from '@kit.AbilityKit';
1130let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1131let userId = 100;
1132let want: Want = {
1133    bundleName : "com.example.myapplication",
1134    abilityName : "EntryAbility"
1135};
1136
1137try {
1138
1139    let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags, userId);
1140    hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
1141} catch (err) {
1142    let message = (err as BusinessError).message;
1143    hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
1144}
1145```
1146
1147```ts
1148import { bundleManager } from '@kit.AbilityKit';
1149import { BusinessError } from '@kit.BasicServicesKit';
1150import { hilog } from '@kit.PerformanceAnalysisKit';
1151import { Want } from '@kit.AbilityKit';
1152let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1153let want: Want = {
1154    bundleName : "com.example.myapplication",
1155    abilityName : "EntryAbility"
1156};
1157
1158try {
1159    let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags);
1160    hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
1161} catch (err) {
1162    let message = (err as BusinessError).message;
1163    hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
1164}
1165```
1166
1167## bundleManager.queryAbilityInfo<sup>12+</sup>
1168
1169queryAbilityInfo(wants: Array\<Want>, abilityFlags: number, userId?: number): Promise<Array\<AbilityInfo>>
1170
1171Obtains the ability information based on the given Want list, ability flags, and user ID. This API uses a promise to return the result.
1172
1173**System API**: This is a system API.
1174
1175**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1176
1177**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1178
1179**Parameters**
1180
1181| Name     | Type  | Mandatory| Description                                                 |
1182| ------------ | ------ | ---- | ------------------------------------------------------- |
1183| want         | Array\<Want>   | Yes  | List of want containing the bundle name to query.                |
1184| abilityFlags | [number](#abilityflag) | Yes  | Type of the ability information to obtain.|
1185| userId       | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                      |
1186
1187**Return value**
1188
1189| Type                                                        | Description                                |
1190| ------------------------------------------------------------ | ------------------------------------ |
1191| Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | An array of ability information.|
1192
1193**Error codes**
1194
1195For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1196
1197| ID| Error Message                            |
1198| -------- | ------------------------------------- |
1199| 201 | Permission denied. |
1200| 202 | Permission denied, non-system app called system api. |
1201| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1202| 17700001 | The specified bundleName is not found. |
1203| 17700003 | The specified ability is not found.    |
1204| 17700004 | The specified userId is invalid.       |
1205| 17700026 | The specified bundle is disabled.      |
1206| 17700029 | The specified ability is disabled.     |
1207
1208**Example**
1209
1210```ts
1211import { bundleManager } from '@kit.AbilityKit';
1212import { BusinessError } from '@kit.BasicServicesKit';
1213import { hilog } from '@kit.PerformanceAnalysisKit';
1214import { Want } from '@kit.AbilityKit';
1215let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1216let userId = 100;
1217let want: Want = {
1218    bundleName : "com.example.myapplication1",
1219    abilityName : "EntryAbility"
1220};
1221let want1: Want = {
1222    bundleName : "com.example.myapplication2",
1223    abilityName : "EntryAbility"
1224};
1225let wants: Array<Want> = [ want, want1 ];
1226 try {
1227        bundleManager.queryAbilityInfo(wants, abilityFlags, userId).then((data) => {
1228        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1229      }).catch((err: BusinessError) => {
1230        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1231      })
1232    } catch (err) {
1233      let message = (err as BusinessError).message;
1234      hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
1235    }
1236```
1237
1238## bundleManager.queryExtensionAbilityInfo
1239
1240queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void
1241
1242Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API uses an asynchronous callback to return the result.
1243
1244**System API**: This is a system API.
1245
1246**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1247
1248**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1249
1250**Parameters**
1251
1252| Name               | Type                                                        | Mandatory| Description                                                        |
1253| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1254| want                  | Want                                                         | Yes  | Want containing the bundle name to query.                      |
1255| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype)                | Yes  | Type of the ExtensionAbility.                                |
1256| extensionAbilityFlags | [number](#extensionabilityflag)                              | Yes  | Type of the ExtensionAbility information to obtain.   |
1257| userId                | number                                                       | Yes  | User ID.                                                |
1258| callback              | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ExtensionAbility information obtained. Otherwise, **err** is an error object.|
1259
1260**Error codes**
1261
1262For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1263
1264| ID| Error Message                                   |
1265| -------- | ------------------------------------------- |
1266| 201 | Permission denied. |
1267| 202 | Permission denied, non-system app called system api. |
1268| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1269| 17700001 | The specified bundleName is not found.       |
1270| 17700003 | The specified extensionAbility is not found. |
1271| 17700004 | The specified userId is invalid.             |
1272| 17700026 | The specified bundle is disabled.            |
1273
1274**Example**
1275
1276```ts
1277import { bundleManager } from '@kit.AbilityKit';
1278import { BusinessError } from '@kit.BasicServicesKit';
1279import { hilog } from '@kit.PerformanceAnalysisKit';
1280import { Want } from '@kit.AbilityKit';
1281let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1282let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1283let userId = 100;
1284let want: Want = {
1285    bundleName : "com.example.myapplication",
1286    abilityName : "EntryAbility"
1287};
1288
1289try {
1290    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
1291        if (err) {
1292            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1293        } else {
1294            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1295        }
1296    });
1297} catch (err) {
1298    let message = (err as BusinessError).message;
1299    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
1300}
1301```
1302
1303## bundleManager.queryExtensionAbilityInfo
1304
1305queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void
1306
1307Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, and ExtensionAbility flags. This API uses an asynchronous callback to return the result.
1308
1309**System API**: This is a system API.
1310
1311**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1312
1313**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1314
1315**Parameters**
1316
1317| Name               | Type                                                        | Mandatory| Description                                                        |
1318| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1319| want                  | Want                                                         | Yes  | Want containing the bundle name to query.                      |
1320| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype)                | Yes  | Type of the ExtensionAbility.                                |
1321| extensionAbilityFlags | [number](#extensionabilityflag)                              | Yes  | Type of the ExtensionAbility information to obtain.   |
1322| callback              | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ExtensionAbility information obtained. Otherwise, **err** is an error object.|
1323
1324**Error codes**
1325
1326For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1327
1328| ID| Error Message                                    |
1329| -------- | -------------------------------------------- |
1330| 201 | Permission denied. |
1331| 202 | Permission denied, non-system app called system api. |
1332| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1333| 17700001 | The specified bundleName is not found.       |
1334| 17700003 | The specified extensionAbility is not found. |
1335| 17700026 | The specified bundle is disabled.            |
1336
1337**Example**
1338
1339```ts
1340import { bundleManager } from '@kit.AbilityKit';
1341import { BusinessError } from '@kit.BasicServicesKit';
1342import { hilog } from '@kit.PerformanceAnalysisKit';
1343import { Want } from '@kit.AbilityKit';
1344let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1345let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1346let want: Want = {
1347    bundleName : "com.example.myapplication",
1348    abilityName : "EntryAbility"
1349};
1350
1351try {
1352    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
1353        if (err) {
1354            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1355        } else {
1356            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1357        }
1358    });
1359} catch (err) {
1360    let message = (err as BusinessError).message;
1361    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
1362}
1363```
1364
1365## bundleManager.queryExtensionAbilityInfo
1366
1367queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId?: number): Promise<Array\<ExtensionAbilityInfo>>
1368
1369Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API uses a promise to return the result.
1370
1371**System API**: This is a system API.
1372
1373**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1374
1375**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1376
1377**Parameters**
1378
1379| Name               | Type                                         | Mandatory| Description                                                     |
1380| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1381| want                  | Want                                          | Yes  | Want containing the bundle name to query.                   |
1382| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype) | Yes  | Type of the ExtensionAbility.                             |
1383| extensionAbilityFlags | [number](#extensionabilityflag)               | Yes  | Type of the ExtensionAbility information to obtain.|
1384| userId                | number                                        | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                                             |
1385
1386**Return value**
1387
1388| Type                                                        | Description                                         |
1389| ------------------------------------------------------------ | --------------------------------------------- |
1390| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Promise used to return the array of ExtensionAbility information obtained.|
1391
1392**Error codes**
1393
1394For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1395
1396| ID| Error Message                            |
1397| -------- | --------------------------------------|
1398| 201 | Permission denied. |
1399| 202 | Permission denied, non-system app called system api. |
1400| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1401| 17700001 | The specified bundleName is not found. |
1402| 17700003 | The specified extensionAbility is not found.    |
1403| 17700004 | The specified userId is invalid.       |
1404| 17700026 | The specified bundle is disabled.      |
1405
1406**Example**
1407
1408```ts
1409import { bundleManager } from '@kit.AbilityKit';
1410import { BusinessError } from '@kit.BasicServicesKit';
1411import { hilog } from '@kit.PerformanceAnalysisKit';
1412import { Want } from '@kit.AbilityKit';
1413
1414let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1415let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1416let userId = 100;
1417let want: Want = {
1418    bundleName : "com.example.myapplication",
1419    abilityName : "EntryAbility"
1420};
1421
1422try {
1423    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
1424        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1425    }).catch((err: BusinessError) => {
1426        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1427    });
1428} catch (err) {
1429    let message = (err as BusinessError).message;
1430    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
1431}
1432```
1433
1434```ts
1435import { bundleManager } from '@kit.AbilityKit';
1436import { BusinessError } from '@kit.BasicServicesKit';
1437import { hilog } from '@kit.PerformanceAnalysisKit';
1438import { Want } from '@kit.AbilityKit';
1439let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1440let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1441let want: Want = {
1442    bundleName : "com.example.myapplication",
1443    abilityName : "EntryAbility"
1444};
1445
1446try {
1447    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
1448        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1449    }).catch((err: BusinessError) => {
1450        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1451    })
1452} catch (err) {
1453    let message = (err as BusinessError).message;
1454    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
1455}
1456```
1457
1458## bundleManager.queryExtensionAbilityInfoSync<sup>10+</sup>
1459
1460queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId?: number): Array\<ExtensionAbilityInfo>
1461
1462Obtains the ExtensionAbility information based on the given want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API returns the result synchronously.
1463
1464**System API**: This is a system API.
1465
1466**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1467
1468**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1469
1470**Parameters**
1471
1472| Name               | Type                                         | Mandatory| Description                                                     |
1473| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1474| want                  | Want                                          | Yes  | Want containing the bundle name to query.                   |
1475| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype) | Yes  | Type of the ExtensionAbility.                             |
1476| extensionAbilityFlags | [number](#extensionabilityflag)               | Yes  | Type of the ExtensionAbility information to obtain.|
1477| userId                | number                                        | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.                                             |
1478
1479**Return value**
1480
1481| Type                                                        | Description                                         |
1482| ------------------------------------------------------------ | --------------------------------------------- |
1483| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of ExtensionAbility information.|
1484
1485**Error codes**
1486
1487For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1488
1489| ID| Error Message                            |
1490| -------- | --------------------------------------|
1491| 201 | Permission denied. |
1492| 202 | Permission denied, non-system app called system api. |
1493| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
1494| 17700001 | The specified bundleName is not found. |
1495| 17700003 | The specified extensionAbility is not found.    |
1496| 17700004 | The specified userId is invalid.       |
1497| 17700026 | The specified bundle is disabled.      |
1498
1499**Example**
1500
1501```ts
1502import { bundleManager } from '@kit.AbilityKit';
1503import { BusinessError } from '@kit.BasicServicesKit';
1504import { hilog } from '@kit.PerformanceAnalysisKit';
1505import { Want } from '@kit.AbilityKit';
1506
1507let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1508let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1509let userId = 100;
1510let want: Want = {
1511    bundleName : "com.example.myapplication",
1512    abilityName : "EntryAbility"
1513};
1514
1515try {
1516    let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId);
1517    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
1518} catch (err) {
1519    let message = (err as BusinessError).message;
1520    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
1521}
1522```
1523
1524```ts
1525import { bundleManager } from '@kit.AbilityKit';
1526import { BusinessError } from '@kit.BasicServicesKit';
1527import { hilog } from '@kit.PerformanceAnalysisKit';
1528import { Want } from '@kit.AbilityKit';
1529let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1530let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1531let want: Want = {
1532    bundleName : "com.example.myapplication",
1533    abilityName : "EntryAbility"
1534};
1535
1536try {
1537    let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags);
1538    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
1539} catch (err) {
1540    let message = (err as BusinessError).message;
1541    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
1542}
1543```
1544
1545## bundleManager.getBundleNameByUid<sup>14+</sup>
1546
1547getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void
1548
1549Obtains the bundle name based on the given UID. This API uses an asynchronous callback to return the result.
1550
1551**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1552
1553**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1554
1555**Parameters**
1556
1557| Name  | Type                  | Mandatory| Description                                                        |
1558| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1559| uid      | number                 | Yes  | UID of the application.                                           |
1560| 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.|
1561
1562**Error codes**
1563
1564For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1565
1566| ID| Error Message           |
1567| -------- | --------------------- |
1568| 201 | Permission denied. |
1569| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1570| 17700021 | The uid is not found. |
1571
1572**Example**
1573
1574```ts
1575import { bundleManager } from '@kit.AbilityKit';
1576import { BusinessError } from '@kit.BasicServicesKit';
1577import { hilog } from '@kit.PerformanceAnalysisKit';
1578let uid = 20010005;
1579try {
1580    bundleManager.getBundleNameByUid(uid, (err, data) => {
1581        if (err) {
1582            hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message);
1583        } else {
1584            hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', JSON.stringify(data));
1585        }
1586    });
1587} catch (err) {
1588    let message = (err as BusinessError).message;
1589    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', message);
1590}
1591```
1592
1593## bundleManager.getBundleNameByUid<sup>14+</sup>
1594
1595getBundleNameByUid(uid: number): Promise\<string>
1596
1597Obtains the bundle name based on the given UID. This API uses a promise to return the result.
1598
1599**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1600
1601**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1602
1603**Parameters**
1604
1605| Name| Type  | Mandatory| Description               |
1606| ---- | ------ | ---- | ------------------ |
1607| uid  | number | Yes  | UID of the application.|
1608
1609**Return value**
1610
1611| Type            | Description                       |
1612| ---------------- | --------------------------- |
1613| Promise\<string> | Promise used to return the bundle name obtained.|
1614
1615**Error codes**
1616
1617For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1618
1619| ID| Error Message           |
1620| -------- | ---------------------|
1621| 201 | Permission denied. |
1622| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1623| 17700021 | The uid is not found. |
1624
1625**Example**
1626
1627```ts
1628import { bundleManager } from '@kit.AbilityKit';
1629import { BusinessError } from '@kit.BasicServicesKit';
1630import { hilog } from '@kit.PerformanceAnalysisKit';
1631let uid = 20010005;
1632try {
1633    bundleManager.getBundleNameByUid(uid).then((data) => {
1634        hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data));
1635    }).catch((err: BusinessError) => {
1636        hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
1637    });
1638} catch (err) {
1639    let message = (err as BusinessError).message;
1640    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', message);
1641}
1642```
1643
1644## bundleManager.getBundleNameByUidSync<sup>14+</sup>
1645
1646getBundleNameByUidSync(uid: number): string
1647
1648Obtains the bundle name based on the given UID. This API returns the result synchronously.
1649
1650**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1651
1652**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1653
1654**Parameters**
1655
1656| Name| Type  | Mandatory| Description               |
1657| ---- | ------ | ---- | ------------------ |
1658| uid  | number | Yes  | UID of the application.|
1659
1660**Return value**
1661
1662| Type            | Description                       |
1663| ---------------- | --------------------------- |
1664| string | Bundle name obtained.|
1665
1666**Error codes**
1667
1668For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1669
1670| ID| Error Message           |
1671| -------- | ---------------------|
1672| 201 | Permission denied. |
1673| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1674| 17700021 | The uid is not found. |
1675
1676**Example**
1677
1678```ts
1679import { bundleManager } from '@kit.AbilityKit';
1680import { BusinessError } from '@kit.BasicServicesKit';
1681import { hilog } from '@kit.PerformanceAnalysisKit';
1682let uid = 20010005;
1683try {
1684    let data = bundleManager.getBundleNameByUidSync(uid);
1685    hilog.info(0x0000, 'testTag', 'getBundleNameByUidSync successfully. Data: %{public}s', JSON.stringify(data));
1686} catch (err) {
1687    let message = (err as BusinessError).message;
1688    hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', message);
1689}
1690```
1691
1692## bundleManager.getBundleArchiveInfo
1693
1694getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
1695
1696Obtains the bundle information based on the given HAP file path and bundle flags. This API uses an asynchronous callback to return the result.
1697
1698**System API**: This is a system API.
1699
1700**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1701
1702**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1703
1704**Parameters**
1705
1706| Name      | Type  | Mandatory| Description                                                        |
1707| ----------- | ------ | ---- | ----------------------------------------------------------- |
1708| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1709| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.      |
1710| 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.|
1711
1712**Error codes**
1713
1714For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1715
1716| ID| Error Message                 |
1717| -------- | --------------------------- |
1718| 201 | Permission denied. |
1719| 202 | Permission denied, non-system app called system api. |
1720| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1721| 17700022 | The hapFilePath is invalid. |
1722
1723**Example**
1724
1725```ts
1726import { bundleManager } from '@kit.AbilityKit';
1727import { BusinessError } from '@kit.BasicServicesKit';
1728import { hilog } from '@kit.PerformanceAnalysisKit';
1729let hapFilePath = "/data/xxx/test.hap";
1730let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1731
1732try {
1733    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
1734        if (err) {
1735            hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1736        } else {
1737            hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', JSON.stringify(data));
1738        }
1739    });
1740} catch (err) {
1741    let message = (err as BusinessError).message;
1742    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
1743}
1744```
1745
1746## bundleManager.getBundleArchiveInfo
1747
1748getBundleArchiveInfo(hapFilePath: string,  bundleFlags: number): Promise\<BundleInfo>
1749
1750Obtains the bundle information based on the given HAP file path and bundle flags. This API uses a promise to return the result.
1751
1752**System API**: This is a system API.
1753
1754**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1755
1756**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1757
1758**Parameters**
1759
1760| Name      | Type  | Mandatory| Description                                                        |
1761| ----------- | ------ | ---- | ------------------------------------------------------------ |
1762| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1763| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.      |
1764
1765**Return value**
1766
1767| Type                                                       | Description                       |
1768| ----------------------------------------------------------- | --------------------------- |
1769| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.|
1770
1771**Error codes**
1772
1773For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1774
1775| ID| Error Message                  |
1776| -------- | -------------------------- |
1777| 201 | Permission denied. |
1778| 202 | Permission denied, non-system app called system api. |
1779| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1780| 17700022 | The hapFilePath is invalid. |
1781
1782**Example**
1783
1784```ts
1785import { bundleManager } from '@kit.AbilityKit';
1786import { BusinessError } from '@kit.BasicServicesKit';
1787import { hilog } from '@kit.PerformanceAnalysisKit';
1788let hapFilePath = "/data/xxx/test.hap";
1789let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1790
1791try {
1792    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
1793        hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data));
1794    }).catch((err: BusinessError) => {
1795        hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1796    });
1797} catch (err) {
1798    let message = (err as BusinessError).message;
1799    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
1800}
1801```
1802
1803## bundleManager.getBundleArchiveInfoSync<sup>10+</sup>
1804
1805getBundleArchiveInfoSync(hapFilePath: string, bundleFlags: number): BundleInfo
1806
1807Obtains the bundle information based on the given HAP file path and bundle flags. This API returns the result synchronously.
1808
1809**System API**: This is a system API.
1810
1811**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1812
1813**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1814
1815**Parameters**
1816
1817| Name      | Type  | Mandatory| Description                                                        |
1818| ----------- | ------ | ---- | ------------------------------------------------------------ |
1819| hapFilePath | string | Yes  | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.|
1820| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.      |
1821
1822**Return value**
1823
1824| Type                                                       | Description                       |
1825| ----------------------------------------------------------- | --------------------------- |
1826| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
1827
1828**Error codes**
1829
1830For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1831
1832| ID| Error Message                  |
1833| -------- | -------------------------- |
1834| 201 | Permission denied. |
1835| 202 | Permission denied, non-system app called system api. |
1836| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1837| 17700022 | The hapFilePath is invalid. |
1838
1839**Example**
1840
1841```ts
1842import { bundleManager } from '@kit.AbilityKit';
1843import { BusinessError } from '@kit.BasicServicesKit';
1844import { hilog } from '@kit.PerformanceAnalysisKit';
1845let hapFilePath = "/data/xxx/test.hap";
1846let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1847
1848try {
1849    let data = bundleManager.getBundleArchiveInfoSync(hapFilePath, bundleFlags)
1850    hilog.info(0x0000, 'testTag', 'getBundleArchiveInfoSync successfully. Data: %{public}s', JSON.stringify(data));
1851} catch (err) {
1852    let message = (err as BusinessError).message;
1853    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfoSync failed. Cause: %{public}s', message);
1854}
1855```
1856
1857## bundleManager.getAllBundleCacheSize<sup>15+</sup>
1858
1859getAllBundleCacheSize(): Promise\<number>
1860
1861Obtains the global cache size. This API uses a promise to return the result.
1862
1863**System API**: This is a system API.
1864
1865**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1866
1867**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1868
1869**Return value**
1870
1871| Type                                      | Description     |
1872| ---------------------------------------- | ------- |
1873| Promise\<number> | Promise used to return the size of the global cache, in bytes.|
1874
1875**Error codes**
1876
1877For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1878
1879| ID| Error Message                                                  |
1880| -------- | ---------------------------------------------------------- |
1881| 201 | Permission denied. |
1882| 202 | Permission denied, non-system app called system api. |
1883
1884**Example**
1885
1886```ts
1887import { bundleManager } from '@kit.AbilityKit';
1888import { BusinessError } from '@kit.BasicServicesKit';
1889import { hilog } from '@kit.PerformanceAnalysisKit';
1890
1891try {
1892    bundleManager.getAllBundleCacheSize().then((data) => {
1893        hilog.info(0x0000, 'testTag','getAllBundleCacheSize successful. Data: ' + JSON.stringify(data));
1894    }).catch((err: BusinessError) => {
1895        hilog.error(0x0000, 'testTag', 'getAllBundleCacheSize failed: %{public}s', err.message);
1896    });
1897} catch (err) {
1898    let message = (err as BusinessError).message;
1899    hilog.error(0x0000, 'testTag', 'getAllBundleCacheSize failed: %{public}s', message);
1900}
1901```
1902
1903## bundleManager.cleanAllBundleCache<sup>15+</sup>
1904
1905cleanAllBundleCache(): Promise\<void>
1906
1907Clears the global cache. This API uses a promise to return the result.
1908
1909**System API**: This is a system API.
1910
1911**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
1912
1913**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1914
1915**Return value**
1916
1917| Type                                      | Description     |
1918| ---------------------------------------- | ------- |
1919| Promise\<void> | Promise that returns no value.|
1920
1921**Error codes**
1922
1923For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1924
1925| ID| Error Message                                                  |
1926| -------- | ---------------------------------------------------------- |
1927| 201 | Permission denied. |
1928| 202 | Permission denied, non-system app called system api. |
1929
1930**Example**
1931
1932```ts
1933import { bundleManager } from '@kit.AbilityKit';
1934import { BusinessError } from '@kit.BasicServicesKit';
1935import { hilog } from '@kit.PerformanceAnalysisKit';
1936
1937try {
1938    bundleManager.cleanAllBundleCache().then((data) => {
1939        hilog.info(0x0000, 'testTag','cleanAllBundleCache successful.');
1940    }).catch((err: BusinessError) => {
1941        hilog.error(0x0000, 'testTag', 'cleanAllBundleCache failed: %{public}s', err.message);
1942    });
1943} catch (err) {
1944    let message = (err as BusinessError).message;
1945    hilog.error(0x0000, 'testTag', 'cleanAllBundleCache failed: %{public}s', message);
1946}
1947```
1948
1949## bundleManager.cleanBundleCacheFiles
1950
1951cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void
1952
1953Clears the bundle cache based on the given bundle name. This API uses an asynchronous callback to return the result.
1954
1955No permission is required when the caller clears its own cache.
1956
1957**System API**: This is a system API.
1958
1959**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
1960
1961**System capability**: SystemCapability.BundleManager.BundleFramework.Core
1962
1963**Parameters**
1964
1965| Name    | Type                | Mandatory| Description                                                        |
1966| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
1967| bundleName | string               | Yes  | Bundle name.                  |
1968| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1969
1970**Error codes**
1971
1972For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
1973
1974| ID| Error Message                                                    |
1975| -------- | ------------------------------------------------------------ |
1976| 201 | Permission denied. |
1977| 202 | Permission denied, non-system app called system api. |
1978| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
1979| 17700001 | The specified bundleName is not found.                        |
1980| 17700030 | The specified bundle does not support clearing of cache files. |
1981
1982**Example**
1983
1984```ts
1985import { bundleManager } from '@kit.AbilityKit';
1986import { BusinessError } from '@kit.BasicServicesKit';
1987import { hilog } from '@kit.PerformanceAnalysisKit';
1988let bundleName = "com.ohos.myapplication";
1989
1990try {
1991    bundleManager.cleanBundleCacheFiles(bundleName, err => {
1992        if (err) {
1993            hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1994        } else {
1995            hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1996        }
1997    });
1998} catch (err) {
1999    let message = (err as BusinessError).message;
2000    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
2001}
2002```
2003
2004## bundleManager.cleanBundleCacheFiles
2005
2006cleanBundleCacheFiles(bundleName: string): Promise\<void>
2007
2008Clears the bundle cache based on the given bundle name. This API uses a promise to return the result.
2009
2010No permission is required when the caller clears its own cache.
2011
2012**System API**: This is a system API.
2013
2014**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
2015
2016**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2017
2018**Parameters**
2019
2020| Name    | Type  | Mandatory| Description                                      |
2021| ---------- | ------ | ---- | ------------------------------------------ |
2022| bundleName | string | Yes  | Bundle name.|
2023
2024**Return value**
2025
2026| Type          | Description                                                        |
2027| -------------- | ------------------------------------------------------------ |
2028| Promise\<void> | Promise that returns no value. If clearing the cache files fails, an error object is thrown.|
2029
2030**Error codes**
2031
2032For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2033
2034| ID| Error Message                                                  |
2035| -------- | ---------------------------------------------------------- |
2036| 201 | Permission denied. |
2037| 202 | Permission denied, non-system app called system api. |
2038| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2039| 17700001 | The specified bundleName is not found.                      |
2040| 17700030 | The specified bundle does not support clearing of cache files. |
2041
2042**Example**
2043
2044```ts
2045import { bundleManager } from '@kit.AbilityKit';
2046import { BusinessError } from '@kit.BasicServicesKit';
2047import { hilog } from '@kit.PerformanceAnalysisKit';
2048let bundleName = "com.ohos.myapplication";
2049
2050try {
2051    bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
2052        hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
2053    }).catch((err: BusinessError) => {
2054        hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
2055    });
2056} catch (err) {
2057    let message = (err as BusinessError).message;
2058    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
2059}
2060```
2061
2062## bundleManager.cleanBundleCacheFiles<sup>15+</sup>
2063
2064cleanBundleCacheFiles(bundleName: string, appIndex: number): Promise\<void>
2065
2066Clears the bundle cache based on the given bundle name and application index. This API uses a promise to return the result.
2067
2068No permission is required when the caller clears its own cache.
2069
2070**System API**: This is a system API.
2071
2072**Required permissions**: ohos.permission.REMOVE_CACHE_FILES
2073
2074**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2075
2076**Parameters**
2077
2078| Name    | Type  | Mandatory| Description                                      |
2079| ---------- | ------ | ---- | ------------------------------------------ |
2080| bundleName | string | Yes  | Bundle name.|
2081| appIndex | number | Yes  | Index of the application clone.<br>The value **0** means to clear the cache of the main application. A value greater than 0 means to clear the cache data of the application clone.|
2082
2083**Return value**
2084
2085| Type          | Description                                                        |
2086| -------------- | ------------------------------------------------------------ |
2087| Promise\<void> | Promise that returns no value. If clearing the cache files fails, an error object is thrown.|
2088
2089**Error codes**
2090
2091For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2092
2093| ID| Error Message                                                  |
2094| -------- | ---------------------------------------------------------- |
2095| 201 | Permission denied. |
2096| 202 | Permission denied, non-system app called system api. |
2097| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2098| 17700001 | The specified bundleName is not found.                      |
2099| 17700030 | The specified bundle does not support clearing of cache files. |
2100| 17700061 | AppIndex is not in the valid range. |
2101
2102**Example**
2103
2104```ts
2105import { bundleManager } from '@kit.AbilityKit';
2106import { BusinessError } from '@kit.BasicServicesKit';
2107import { hilog } from '@kit.PerformanceAnalysisKit';
2108let bundleName = "com.ohos.myapplication";
2109let appIndex = 1;
2110
2111try {
2112    bundleManager.cleanBundleCacheFiles(bundleName, appIndex).then(() => {
2113        hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
2114    }).catch((err: BusinessError) => {
2115        hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
2116    });
2117} catch (err) {
2118    let message = (err as BusinessError).message;
2119    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
2120}
2121```
2122
2123## bundleManager.setApplicationEnabled
2124
2125setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void
2126
2127Enables or disables an application. This API uses an asynchronous callback to return the result.
2128
2129**System API**: This is a system API.
2130
2131**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2132
2133**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2134
2135**Parameters**
2136
2137| Name     | Type   | Mandatory| Description                                 |
2138| ---------- | ------- | ---- | ------------------------------------- |
2139| bundleName | string  | Yes  | Bundle name.               |
2140| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable it, and **false** means to disable it.|
2141| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
2142
2143**Error codes**
2144
2145For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2146
2147| ID| Error Message                            |
2148| -------- | -------------------------------------- |
2149| 201 | Permission denied. |
2150| 202 | Permission denied, non-system app called system api. |
2151| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2152| 17700001 | The specified bundleName is not found. |
2153
2154**Example**
2155
2156```ts
2157import { bundleManager } from '@kit.AbilityKit';
2158import { BusinessError } from '@kit.BasicServicesKit';
2159import { hilog } from '@kit.PerformanceAnalysisKit';
2160let bundleName = "com.ohos.myapplication";
2161
2162try {
2163    bundleManager.setApplicationEnabled(bundleName, false, err => {
2164        if (err) {
2165            hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
2166        } else {
2167            hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
2168        }
2169    });
2170} catch (err) {
2171    let message = (err as BusinessError).message;
2172    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
2173}
2174```
2175
2176## bundleManager.setApplicationEnabled
2177
2178setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>
2179
2180Enables or disables an application. This API uses a promise to return the result.
2181
2182**System API**: This is a system API.
2183
2184**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2185
2186**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2187
2188**Parameters**
2189
2190| Name     | Type   | Mandatory| Description                                 |
2191| ---------- | ------- | ---- | ------------------------------------- |
2192| bundleName | string  | Yes  | Bundle name.           |
2193| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable it, and **false** means to disable it.|
2194
2195**Return value**
2196
2197| Type          | Description                                |
2198| -------------- | ------------------------------------ |
2199| Promise\<void> | Promise that returns no value.|
2200
2201**Error codes**
2202
2203For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2204
2205| ID| Error Message                            |
2206| -------- | -------------------------------------- |
2207| 201 | Permission denied. |
2208| 202 | Permission denied, non-system app called system api. |
2209| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2210| 17700001 | The specified bundleName is not found. |
2211
2212**Example**
2213
2214```ts
2215import { bundleManager } from '@kit.AbilityKit';
2216import { BusinessError } from '@kit.BasicServicesKit';
2217import { hilog } from '@kit.PerformanceAnalysisKit';
2218let bundleName = "com.ohos.myapplication";
2219
2220try {
2221    bundleManager.setApplicationEnabled(bundleName, false).then(() => {
2222        hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
2223    }).catch((err: BusinessError) => {
2224        hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
2225    });
2226} catch (err) {
2227    let message = (err as BusinessError).message;
2228    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
2229}
2230```
2231
2232## bundleManager.setApplicationEnabled<sup>12+</sup>
2233
2234setApplicationEnabled(bundleName: string, appIndex: number, isEnabled: boolean): Promise\<void>
2235
2236Enables or disables an application or an application clone. This API uses a promise to return the result.
2237
2238**System API**: This is a system API.
2239
2240**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2241
2242**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2243
2244**Parameters**
2245
2246| Name     | Type   | Mandatory| Description                                 |
2247| ---------- | ------- | ---- | ------------------------------------- |
2248| bundleName | string  | Yes  | Bundle name.           |
2249| appIndex   | number  | Yes  | Index of the application clone.<br>The value **0** means to enable or disable the main application. A value greater than 0 means to enable or disable the application clone.             |
2250| isEnabled  | boolean | Yes  | Whether to enable the application or application clone. The value **true** means to enable it, and **false** means to disable it.|
2251
2252**Return value**
2253
2254| Type          | Description                                |
2255| -------------- | ------------------------------------ |
2256| Promise\<void> | Promise that returns no value.|
2257
2258**Error codes**
2259
2260For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2261
2262| ID| Error Message                            |
2263| -------- | -------------------------------------- |
2264| 201 | Permission denied. |
2265| 202 | Permission denied, non-system app called system api. |
2266| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2267| 17700001 | The specified bundleName is not found. |
2268| 17700061 | AppIndex is not in the valid range. |
2269
2270**Example**
2271
2272```ts
2273import { bundleManager } from '@kit.AbilityKit';
2274import { BusinessError } from '@kit.BasicServicesKit';
2275import { hilog } from '@kit.PerformanceAnalysisKit';
2276let bundleName = "com.ohos.myapplication";
2277
2278try {
2279    bundleManager.setApplicationEnabled(bundleName, 1, false).then(() => {
2280        hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
2281    }).catch((err: BusinessError) => {
2282        hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
2283    });
2284} catch (err) {
2285    let message = (err as BusinessError).message;
2286    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
2287}
2288```
2289
2290## bundleManager.setApplicationEnabledSync<sup>10+</sup>
2291
2292setApplicationEnabledSync(bundleName: string, isEnabled: boolean): void
2293
2294Enables or disables an application. This API returns the result synchronously.
2295
2296**System API**: This is a system API.
2297
2298**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2299
2300**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2301
2302**Parameters**
2303
2304| Name     | Type   | Mandatory| Description                                 |
2305| ---------- | ------- | ---- | ------------------------------------- |
2306| bundleName | string  | Yes  | Bundle name.               |
2307| isEnabled  | boolean | Yes  | Whether to enable the application. The value **true** means to enable it, and **false** means to disable it.|
2308
2309**Error codes**
2310
2311For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2312
2313| ID| Error Message                            |
2314| -------- | -------------------------------------- |
2315| 201 | Permission denied. |
2316| 202 | Permission denied, non-system app called system api. |
2317| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2318| 17700001 | The specified bundleName is not found. |
2319
2320**Example**
2321
2322```ts
2323import { bundleManager } from '@kit.AbilityKit';
2324import { BusinessError } from '@kit.BasicServicesKit';
2325import { hilog } from '@kit.PerformanceAnalysisKit';
2326let bundleName = "com.ohos.myapplication";
2327
2328try {
2329    bundleManager.setApplicationEnabledSync(bundleName, false);
2330    hilog.info(0x0000, 'testTag', 'setApplicationEnabledSync successfully.');
2331} catch (err) {
2332    let message = (err as BusinessError).message;
2333    hilog.error(0x0000, 'testTag', 'setApplicationEnabledSync failed: %{public}s', message);
2334}
2335```
2336
2337## bundleManager.setAbilityEnabled
2338
2339setAbilityEnabled(info: AbilityInfo, isEnabled: boolean, callback: AsyncCallback\<void>): void
2340
2341Enables or disables an ability. This API uses an asynchronous callback to return the result.
2342
2343**System API**: This is a system API.
2344
2345**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2346
2347**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2348
2349**Parameters**
2350
2351| Name   | Type       | Mandatory| Description                                 |
2352| -------- | ----------- | ---- | ------------------------------------- |
2353| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.             |
2354| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable it, and **false** means to disable it.|
2355| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
2356
2357**Error codes**
2358
2359For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2360
2361| ID| Error Message                             |
2362| -------- | ---------------------------------------|
2363| 201 | Permission denied. |
2364| 202 | Permission denied, non-system app called system api. |
2365| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2366| 17700001 | The specified bundleName is not found.  |
2367| 17700003 | The specified abilityInfo is not found. |
2368
2369**Example**
2370
2371```ts
2372import { bundleManager } from '@kit.AbilityKit';
2373import { BusinessError } from '@kit.BasicServicesKit';
2374import { hilog } from '@kit.PerformanceAnalysisKit';
2375import { Want } from '@kit.AbilityKit';
2376let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2377let userId = 100;
2378let want: Want = {
2379    bundleName : "com.example.myapplication",
2380    abilityName : "EntryAbility"
2381};
2382
2383try {
2384    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2385        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2386        let info = abilitiesInfo[0];
2387
2388        bundleManager.setAbilityEnabled(info, false, err => {
2389            if (err) {
2390                hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
2391            } else {
2392                hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
2393            }
2394        });
2395    }).catch((err: BusinessError) => {
2396        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2397    });
2398} catch (err) {
2399    let message = (err as BusinessError).message;
2400    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2401}
2402```
2403
2404## bundleManager.setAbilityEnabled
2405
2406setAbilityEnabled(info: AbilityInfo, isEnabled: boolean): Promise\<void>
2407
2408Enables or disables an ability. This API uses a promise to return the result.
2409
2410**System API**: This is a system API.
2411
2412**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2413
2414**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2415
2416**Parameters**
2417
2418| Name   | Type       | Mandatory| Description                                 |
2419| -------- | ----------- | ---- | ------------------------------------- |
2420| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.                  |
2421| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable it, and **false** means to disable it.|
2422
2423**Return value**
2424
2425| Type          | Description                             |
2426| -------------- | --------------------------------- |
2427| Promise\<void> | Promise that returns no value.|
2428
2429**Error codes**
2430
2431For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2432
2433| ID| Error Message                             |
2434| -------- | -------------------------------------- |
2435| 201 | Permission denied. |
2436| 202 | Permission denied, non-system app called system api. |
2437| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2438| 17700001 | The specified bundleName is not found.  |
2439| 17700003 | The specified abilityInfo is not found. |
2440
2441**Example**
2442
2443```ts
2444import { bundleManager } from '@kit.AbilityKit';
2445import { BusinessError } from '@kit.BasicServicesKit';
2446import { hilog } from '@kit.PerformanceAnalysisKit';
2447import { Want } from '@kit.AbilityKit';
2448let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2449let userId = 100;
2450let want: Want = {
2451    bundleName : "com.example.myapplication",
2452    abilityName : "EntryAbility"
2453};
2454
2455try {
2456    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2457        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2458        let info = abilitiesInfo[0];
2459
2460        bundleManager.setAbilityEnabled(info, false).then(() => {
2461            hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
2462        }).catch((err: BusinessError) => {
2463            hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
2464        });
2465    }).catch((err: BusinessError) => {
2466        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2467    });
2468} catch (err) {
2469    let message = (err as BusinessError).message;
2470    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2471}
2472```
2473
2474## bundleManager.setAbilityEnabled<sup>12+</sup>
2475
2476setAbilityEnabled(info: AbilityInfo, appIndex: number, isEnabled: boolean): Promise\<void>
2477
2478Enables or disables an ability of an application or an application clone. This API uses a promise to return the result.
2479
2480**System API**: This is a system API.
2481
2482**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2483
2484**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2485
2486**Parameters**
2487
2488| Name   | Type       | Mandatory| Description                                 |
2489| -------- | ----------- | ---- | ------------------------------------- |
2490| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.                  |
2491| appIndex   | number    | Yes  | Index of the application clone.<br>The value **0** means to enable or disable the ability of the main application. A value greater than 0 means to enable or disable the ability of the application clone.           |
2492| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable it, and **false** means to disable it.|
2493
2494**Return value**
2495
2496| Type          | Description                             |
2497| -------------- | --------------------------------- |
2498| Promise\<void> | Promise that returns no value.|
2499
2500**Error codes**
2501
2502For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2503
2504| ID| Error Message                             |
2505| -------- | -------------------------------------- |
2506| 201 | Permission denied. |
2507| 202 | Permission denied, non-system app called system api. |
2508| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2509| 17700001 | The specified bundleName is not found.  |
2510| 17700003 | The specified abilityInfo is not found. |
2511| 17700061 | AppIndex is not in the valid range. |
2512
2513**Example**
2514
2515```ts
2516import { bundleManager } from '@kit.AbilityKit';
2517import { BusinessError } from '@kit.BasicServicesKit';
2518import { hilog } from '@kit.PerformanceAnalysisKit';
2519import { Want } from '@kit.AbilityKit';
2520let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2521let userId = 100;
2522let want: Want = {
2523    bundleName : "com.example.myapplication",
2524    abilityName : "EntryAbility"
2525};
2526
2527try {
2528    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2529        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2530        let info = abilitiesInfo[0];
2531
2532        bundleManager.setAbilityEnabled(info, 1, false).then(() => {
2533            hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
2534        }).catch((err: BusinessError) => {
2535            hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
2536        });
2537    }).catch((err: BusinessError) => {
2538        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2539    });
2540} catch (err) {
2541    let message = (err as BusinessError).message;
2542    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2543}
2544```
2545
2546## bundleManager.setAbilityEnabledSync<sup>10+</sup>
2547
2548setAbilityEnabledSync(info: AbilityInfo, isEnabled: boolean): void
2549
2550Enables or disables an ability. This API returns the result synchronously.
2551
2552**System API**: This is a system API.
2553
2554**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2555
2556**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2557
2558**Parameters**
2559
2560| Name   | Type       | Mandatory| Description                                 |
2561| -------- | ----------- | ---- | ------------------------------------- |
2562| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.             |
2563| isEnabled| boolean     | Yes  | Whether to enable the ability. The value **true** means to enable it, and **false** means to disable it.|
2564
2565**Error codes**
2566
2567For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2568
2569| ID| Error Message                             |
2570| -------- | ---------------------------------------|
2571| 201 | Permission denied. |
2572| 202 | Permission denied, non-system app called system api. |
2573| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2574| 17700001 | The specified bundleName is not found.  |
2575| 17700003 | The specified abilityInfo is not found. |
2576
2577**Example**
2578
2579```ts
2580import { bundleManager } from '@kit.AbilityKit';
2581import { BusinessError } from '@kit.BasicServicesKit';
2582import { hilog } from '@kit.PerformanceAnalysisKit';
2583import { Want } from '@kit.AbilityKit';
2584let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2585let userId = 100;
2586let want: Want = {
2587    bundleName : "com.example.myapplication",
2588    abilityName : "EntryAbility"
2589};
2590
2591try {
2592    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2593        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2594        let info = abilitiesInfo[0];
2595
2596        try {
2597            bundleManager.setAbilityEnabledSync(info, false);
2598            hilog.info(0x0000, "testTag", "setAbilityEnabledSync successfully.");
2599        } catch (err) {
2600            let message = (err as BusinessError).message;
2601            hilog.error(0x0000, 'testTag', 'setAbilityEnabledSync failed: %{public}s', message);
2602        }
2603    }).catch((err: BusinessError) => {
2604        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2605    });
2606} catch (err) {
2607    let message = (err as BusinessError).message;
2608    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2609}
2610```
2611
2612## bundleManager.isApplicationEnabled
2613
2614isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void
2615
2616Checks whether an application is enabled. This API uses an asynchronous callback to return the result.
2617
2618**System API**: This is a system API.
2619
2620**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2621
2622**Parameters**
2623
2624| Name     | Type  | Mandatory| Description                      |
2625| ---------- | ------ | ---- | -------------------------- |
2626| bundleName | string | Yes  | Bundle name.|
2627| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.|
2628
2629**Error codes**
2630
2631For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2632
2633| ID| Error Message                            |
2634| -------- | -------------------------------------- |
2635| 202 | Permission denied, non-system app called system api. |
2636| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2637| 17700001 | The specified bundleName is not found. |
2638
2639**Example**
2640
2641```ts
2642import { bundleManager } from '@kit.AbilityKit';
2643import { BusinessError } from '@kit.BasicServicesKit';
2644import { hilog } from '@kit.PerformanceAnalysisKit';
2645let bundleName = 'com.example.myapplication';
2646
2647try {
2648    bundleManager.isApplicationEnabled(bundleName, (err, data) => {
2649        if (err) {
2650            hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message);
2651        } else {
2652            hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', JSON.stringify(data));
2653        }
2654    });
2655} catch (err) {
2656    let message = (err as BusinessError).message;
2657    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', message);
2658}
2659```
2660
2661## bundleManager.isApplicationEnabled
2662
2663isApplicationEnabled(bundleName: string): Promise\<boolean>
2664
2665Checks whether an application is enabled. This API uses a promise to return the result.
2666
2667**System API**: This is a system API.
2668
2669**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2670
2671**Parameters**
2672
2673| Name     | Type  | Mandatory| Description                      |
2674| ---------- | ------ | ---- | -------------------------- |
2675| bundleName | string | Yes  | Bundle name. |
2676
2677**Return value**
2678
2679| Type             | Description                                                        |
2680| ----------------- | ------------------------------------------------------------ |
2681| Promise\<boolean> | Promise used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.|
2682
2683**Error codes**
2684
2685For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2686
2687| ID| Error Message                            |
2688| -------- | -------------------------------------- |
2689| 202 | Permission denied, non-system app called system api. |
2690| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2691| 17700001 | The specified bundleName is not found. |
2692
2693**Example**
2694
2695```ts
2696import { bundleManager } from '@kit.AbilityKit';
2697import { BusinessError } from '@kit.BasicServicesKit';
2698import { hilog } from '@kit.PerformanceAnalysisKit';
2699let bundleName = 'com.example.myapplication';
2700
2701try {
2702    bundleManager.isApplicationEnabled(bundleName).then((data) => {
2703        hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data));
2704    }).catch((err: BusinessError) => {
2705        hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
2706    });
2707} catch (err) {
2708    let message = (err as BusinessError).message;
2709    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message);
2710}
2711```
2712
2713## bundleManager.isApplicationEnabled<sup>12+</sup>
2714
2715isApplicationEnabled(bundleName: string, appIndex: number): Promise\<boolean>
2716
2717Checks whether an application or an application clone is enabled. This API uses a promise to return the result.
2718
2719**System API**: This is a system API.
2720
2721**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2722
2723**Parameters**
2724
2725| Name     | Type  | Mandatory| Description                      |
2726| ---------- | ------ | ---- | -------------------------- |
2727| bundleName | string | Yes  | Bundle name. |
2728| appIndex   | number  | Yes  | Index of the application clone.<br>The value **0** means to obtain the enabled status of the main application. A value greater than 0 means to obtain the enabled status of the application clone.           |
2729
2730**Return value**
2731
2732| Type             | Description                                                        |
2733| ----------------- | ------------------------------------------------------------ |
2734| Promise\<boolean> | Promise used to return the result. The value **true** means that the application or application clone is enabled, and **false** means the opposite.|
2735
2736**Error codes**
2737
2738For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2739
2740| ID| Error Message                            |
2741| -------- | -------------------------------------- |
2742| 202 | Permission denied, non-system app called system api. |
2743| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2744| 17700001 | The specified bundleName is not found. |
2745| 17700061 | AppIndex is not in the valid range. |
2746
2747**Example**
2748
2749```ts
2750import { bundleManager } from '@kit.AbilityKit';
2751import { BusinessError } from '@kit.BasicServicesKit';
2752import { hilog } from '@kit.PerformanceAnalysisKit';
2753let bundleName = 'com.example.myapplication';
2754
2755try {
2756    bundleManager.isApplicationEnabled(bundleName, 1).then((data) => {
2757        hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data));
2758    }).catch((err: BusinessError) => {
2759        hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
2760    });
2761} catch (err) {
2762    let message = (err as BusinessError).message;
2763    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message);
2764}
2765```
2766
2767## bundleManager.isApplicationEnabledSync<sup>10+</sup>
2768
2769isApplicationEnabledSync(bundleName: string): boolean
2770
2771Checks whether an application is enabled. This API returns the result synchronously.
2772
2773**System API**: This is a system API.
2774
2775**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2776
2777**Parameters**
2778
2779| Name     | Type  | Mandatory| Description                      |
2780| ---------- | ------ | ---- | -------------------------- |
2781| bundleName | string | Yes  | Bundle name.|
2782
2783**Return value**
2784
2785| Type   | Description                                                        |
2786| ------- | ------------------------------------------------------------ |
2787| boolean | Returns **true** if the application is enabled; returns **false** otherwise.|
2788
2789**Error codes**
2790
2791For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2792
2793| ID| Error Message                            |
2794| -------- | -------------------------------------- |
2795| 202 | Permission denied, non-system app called system api. |
2796| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2797| 17700001 | The specified bundleName is not found. |
2798
2799**Example**
2800
2801```ts
2802import { bundleManager } from '@kit.AbilityKit';
2803import { BusinessError } from '@kit.BasicServicesKit';
2804import { hilog } from '@kit.PerformanceAnalysisKit';
2805let bundleName = 'com.example.myapplication';
2806
2807try {
2808    let data = bundleManager.isApplicationEnabledSync(bundleName);
2809    hilog.info(0x0000, 'testTag', 'isApplicationEnabledSync successfully: %{public}s', JSON.stringify(data));
2810} catch (err) {
2811    let message = (err as BusinessError).message;
2812    hilog.error(0x0000, 'testTag', 'isApplicationEnabledSync failed: %{public}s', message);
2813}
2814```
2815
2816## bundleManager.isAbilityEnabled
2817
2818isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback\<boolean>): void
2819
2820Checks whether an ability is enabled. This API uses an asynchronous callback to return the result.
2821
2822**System API**: This is a system API.
2823
2824**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2825
2826**Parameters**
2827
2828| Name| Type       | Mandatory| Description                       |
2829| ---- | ----------- | ---- | --------------------------- |
2830| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2831| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
2832
2833**Error codes**
2834
2835For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2836
2837| ID| Error Message                             |
2838| -------- | --------------------------------------- |
2839| 202 | Permission denied, non-system app called system api. |
2840| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2841| 17700001 | The specified bundleName is not found.  |
2842| 17700003 | The specified abilityName is not found. |
2843
2844**Example**
2845
2846```ts
2847import { bundleManager } from '@kit.AbilityKit';
2848import { BusinessError } from '@kit.BasicServicesKit';
2849import { hilog } from '@kit.PerformanceAnalysisKit';
2850import { Want } from '@kit.AbilityKit';
2851let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2852let userId = 100;
2853let want: Want = {
2854    bundleName : "com.example.myapplication",
2855    abilityName : "EntryAbility"
2856};
2857
2858try {
2859    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2860        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2861        let info = abilitiesInfo[0];
2862
2863        bundleManager.isAbilityEnabled(info, (err, data) => {
2864            if (err) {
2865                hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s', err.message);
2866            } else {
2867                hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data));
2868            }
2869        });
2870    }).catch((err: BusinessError) => {
2871        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2872    });
2873} catch (err) {
2874    let message = (err as BusinessError).message;
2875    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2876}
2877```
2878
2879## bundleManager.isAbilityEnabled
2880
2881isAbilityEnabled(info: AbilityInfo): Promise\<boolean>
2882
2883Checks whether an ability is enabled. This API uses a promise to return the result.
2884
2885**System API**: This is a system API.
2886
2887**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2888
2889**Parameters**
2890
2891| Name| Type       | Mandatory| Description                       |
2892| ---- | ----------- | ---- | --------------------------- |
2893| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2894
2895**Return value**
2896
2897| Type             | Description                                                        |
2898| ----------------- | ------------------------------------------------------------ |
2899| Promise\<boolean> | Promise used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
2900
2901**Error codes**
2902
2903For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2904
2905| ID| Error Message                             |
2906| -------- | --------------------------------------- |
2907| 202 | Permission denied, non-system app called system api. |
2908| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2909| 17700001 | The specified bundleName is not found.  |
2910| 17700003 | The specified abilityName is not found. |
2911
2912**Example**
2913
2914```ts
2915import { bundleManager } from '@kit.AbilityKit';
2916import { BusinessError } from '@kit.BasicServicesKit';
2917import { hilog } from '@kit.PerformanceAnalysisKit';
2918import { Want } from '@kit.AbilityKit';
2919let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2920let userId = 100;
2921let want: Want = {
2922    bundleName : "com.example.myapplication",
2923    abilityName : "EntryAbility"
2924};
2925
2926try {
2927    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2928        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2929        let info = abilitiesInfo[0];
2930
2931        bundleManager.isAbilityEnabled(info).then((data) => {
2932            hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data));
2933        }).catch((err: BusinessError) => {
2934            hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message);
2935        });
2936    }).catch((err: BusinessError) => {
2937        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2938    });
2939} catch (err) {
2940    let message = (err as BusinessError).message;
2941    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2942}
2943```
2944
2945## bundleManager.isAbilityEnabled<sup>12+</sup>
2946
2947isAbilityEnabled(info: AbilityInfo, appIndex: number): Promise\<boolean>
2948
2949Checks whether an ability of an application or an application clone is enabled. This API uses a promise to return the result.
2950
2951**System API**: This is a system API.
2952
2953**System capability**: SystemCapability.BundleManager.BundleFramework.Core
2954
2955**Parameters**
2956
2957| Name| Type       | Mandatory| Description                       |
2958| ---- | ----------- | ---- | --------------------------- |
2959| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
2960| appIndex   | number  | Yes  | Index of the application clone.<br>The value **0** means to obtain the enabled status of the ability of the main application. A value greater than 0 means to obtain the enabled status of the ability of the application clone.          |
2961
2962**Return value**
2963
2964| Type             | Description                                                        |
2965| ----------------- | ------------------------------------------------------------ |
2966| Promise\<boolean> | Promise used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
2967
2968**Error codes**
2969
2970For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
2971
2972| ID| Error Message                             |
2973| -------- | --------------------------------------- |
2974| 202 | Permission denied, non-system app called system api. |
2975| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
2976| 17700001 | The specified bundleName is not found.  |
2977| 17700003 | The specified abilityName is not found. |
2978| 17700061 | AppIndex is not in the valid range. |
2979
2980**Example**
2981
2982```ts
2983import { bundleManager } from '@kit.AbilityKit';
2984import { BusinessError } from '@kit.BasicServicesKit';
2985import { hilog } from '@kit.PerformanceAnalysisKit';
2986import { Want } from '@kit.AbilityKit';
2987let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2988let userId = 100;
2989let want: Want = {
2990    bundleName : "com.example.myapplication",
2991    abilityName : "EntryAbility"
2992};
2993
2994try {
2995    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2996        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2997        let info = abilitiesInfo[0];
2998
2999        bundleManager.isAbilityEnabled(info, 1).then((data) => {
3000            hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data));
3001        }).catch((err: BusinessError) => {
3002            hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message);
3003        });
3004    }).catch((err: BusinessError) => {
3005        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
3006    });
3007} catch (err) {
3008    let message = (err as BusinessError).message;
3009    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
3010}
3011```
3012
3013## bundleManager.isAbilityEnabledSync<sup>10+</sup>
3014
3015isAbilityEnabledSync(info: AbilityInfo): boolean
3016
3017Checks whether an ability is enabled. This API returns the result synchronously.
3018
3019**System API**: This is a system API.
3020
3021**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3022
3023**Parameters**
3024
3025| Name| Type       | Mandatory| Description                       |
3026| ---- | ----------- | ---- | --------------------------- |
3027| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes  | Information about the target ability.|
3028
3029**Return value**
3030
3031| Type   | Description                                                                |
3032| ------- | ------------------------------------------------------------------- |
3033| boolean | Returns **true** if the ability is enabled; returns **false** otherwise.|
3034
3035**Error codes**
3036
3037For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3038
3039| ID| Error Message                             |
3040| -------- | --------------------------------------- |
3041| 202 | Permission denied, non-system app called system api. |
3042| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3043| 17700001 | The specified bundleName is not found.  |
3044| 17700003 | The specified abilityName is not found. |
3045
3046**Example**
3047
3048```ts
3049import { bundleManager } from '@kit.AbilityKit';
3050import { BusinessError } from '@kit.BasicServicesKit';
3051import { hilog } from '@kit.PerformanceAnalysisKit';
3052import { Want } from '@kit.AbilityKit';
3053let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
3054let userId = 100;
3055let want: Want = {
3056    bundleName : "com.example.myapplication",
3057    abilityName : "EntryAbility"
3058};
3059
3060try {
3061    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
3062        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
3063        let info = abilitiesInfo[0];
3064
3065        try {
3066            let data = bundleManager.isAbilityEnabledSync(info);
3067            hilog.info(0x0000, 'testTag', 'isAbilityEnabledSync successfully: %{public}s', JSON.stringify(data));
3068        } catch (err) {
3069            let message = (err as BusinessError).message;
3070            hilog.error(0x0000, 'testTag', 'isAbilityEnabledSync failed: %{public}s', message);
3071        }
3072    }).catch((err: BusinessError) => {
3073        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
3074    });
3075} catch (err) {
3076    let message = (err as BusinessError).message;
3077    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
3078}
3079```
3080
3081## bundleManager.getLaunchWantForBundle
3082
3083getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void
3084
3085Obtains 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.
3086
3087**System API**: This is a system API.
3088
3089**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3090
3091**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3092
3093**Parameters**
3094
3095| Name    | Type                | Mandatory| Description                                                        |
3096| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
3097| bundleName | string               | Yes  | Bundle name.                                    |
3098| userId     | number               | Yes  | User ID.                                                  |
3099| 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.|
3100
3101**Error codes**
3102
3103For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3104
3105| ID| Error Message                            |
3106| -------- | --------------------------------------|
3107| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. |
3108| 202 | Permission denied, non-system app called system api. |
3109| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3110| 17700001 | The specified bundleName is not found. |
3111| 17700004 | The specified user ID is not found.     |
3112| 17700026 | The specified bundle is disabled.      |
3113
3114**Example**
3115
3116```ts
3117import { bundleManager } from '@kit.AbilityKit';
3118import { BusinessError } from '@kit.BasicServicesKit';
3119import { hilog } from '@kit.PerformanceAnalysisKit';
3120let bundleName = 'com.example.myapplication';
3121let userId = 100;
3122
3123try {
3124    bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
3125        if (err) {
3126            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
3127        } else {
3128            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
3129        }
3130    });
3131} catch (err) {
3132    let message = (err as BusinessError).message;
3133    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
3134}
3135```
3136
3137## bundleManager.getLaunchWantForBundle
3138
3139getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
3140
3141Obtains the Want used to launch the bundle based on the given bundle name. This API uses an asynchronous callback to return the result.
3142
3143**System API**: This is a system API.
3144
3145**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3146
3147**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3148
3149**Parameters**
3150
3151| Name    | Type                | Mandatory| Description                                                        |
3152| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
3153| bundleName | string               | Yes  | Bundle name.                                    |
3154| 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.|
3155
3156**Error codes**
3157
3158For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3159
3160| ID| Error Message                            |
3161| -------- | --------------------------------------|
3162| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. |
3163| 202 | Permission denied, non-system app called system api. |
3164| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3165| 17700001 | The specified bundleName is not found. |
3166| 17700026 | The specified bundle is disabled.      |
3167
3168**Example**
3169
3170```ts
3171import { bundleManager } from '@kit.AbilityKit';
3172import { BusinessError } from '@kit.BasicServicesKit';
3173import { hilog } from '@kit.PerformanceAnalysisKit';
3174let bundleName = 'com.example.myapplication';
3175
3176try {
3177    bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
3178        if (err) {
3179            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
3180        } else {
3181            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
3182        }
3183    });
3184} catch (err) {
3185    let message = (err as BusinessError).message;
3186    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
3187}
3188```
3189
3190## bundleManager.getLaunchWantForBundle
3191
3192getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>
3193
3194Obtains 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.
3195
3196**System API**: This is a system API.
3197
3198**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3199
3200**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3201
3202**Parameters**
3203
3204| Name    | Type  | Mandatory| Description                      |
3205| ---------- | ------ | ---- | ------------------------- |
3206| bundleName | string | Yes  | Bundle name.|
3207| userId     | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
3208
3209**Return value**
3210
3211| Type          | Description                     |
3212| -------------- | ------------------------- |
3213| Promise\<Want> | Promise used to return the **Want** object obtained.|
3214
3215**Error codes**
3216
3217For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3218
3219| ID| Error Message                            |
3220| -------- | --------------------------------------|
3221| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. |
3222| 202 | Permission denied, non-system app called system api. |
3223| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3224| 17700001 | The specified bundleName is not found. |
3225| 17700004 | The specified user ID is not found.     |
3226| 17700026 | The specified bundle is disabled.      |
3227
3228**Example**
3229
3230```ts
3231import { bundleManager } from '@kit.AbilityKit';
3232import { BusinessError } from '@kit.BasicServicesKit';
3233import { hilog } from '@kit.PerformanceAnalysisKit';
3234let bundleName = 'com.example.myapplication';
3235let userId = 100;
3236
3237try {
3238    bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
3239        hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data));
3240    }).catch((err: BusinessError) => {
3241        hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message);
3242    });
3243} catch (err) {
3244    let message = (err as BusinessError).message;
3245    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', message);
3246}
3247```
3248
3249
3250## bundleManager.getLaunchWantForBundleSync<sup>10+</sup>
3251
3252getLaunchWantForBundleSync(bundleName: string, userId?: number): Want
3253
3254Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API returns the result synchronously.
3255
3256**System API**: This is a system API.
3257
3258**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3259
3260**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3261
3262**Parameters**
3263
3264| Name    | Type  | Mandatory| Description                      |
3265| ---------- | ------ | ---- | ------------------------- |
3266| bundleName | string | Yes  | Bundle name.|
3267| userId     | number | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
3268
3269**Return value**
3270
3271| Type          | Description                     |
3272| -------------- | ------------------------- |
3273| Want | **Want** object.|
3274
3275**Error codes**
3276
3277For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3278
3279| ID| Error Message                            |
3280| -------- | --------------------------------------|
3281| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. |
3282| 202 | Permission denied, non-system app called system api. |
3283| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3284| 17700001 | The specified bundleName is not found. |
3285| 17700004 | The specified user ID is not found.     |
3286| 17700026 | The specified bundle is disabled.      |
3287
3288**Example**
3289
3290```ts
3291import { bundleManager } from '@kit.AbilityKit';
3292import { BusinessError } from '@kit.BasicServicesKit';
3293import { hilog } from '@kit.PerformanceAnalysisKit';
3294import { Want } from '@kit.AbilityKit';
3295let bundleName = 'com.example.myapplication';
3296let userId = 100;
3297
3298try {
3299    let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName, userId);
3300    hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
3301} catch (err) {
3302    let message = (err as BusinessError).message;
3303    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
3304}
3305```
3306
3307```ts
3308import { bundleManager } from '@kit.AbilityKit';
3309import { BusinessError } from '@kit.BasicServicesKit';
3310import { hilog } from '@kit.PerformanceAnalysisKit';
3311import { Want } from '@kit.AbilityKit';
3312let bundleName = 'com.example.myapplication';
3313let userId = 100;
3314
3315try {
3316    let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName);
3317    hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
3318} catch (err) {
3319    let message = (err as BusinessError).message;
3320    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
3321}
3322```
3323
3324## bundleManager.getPermissionDef
3325
3326getPermissionDef(permissionName: string, callback: AsyncCallback\<PermissionDef>): void
3327
3328Obtains the PermissionDef struct based on the given permission name. This API uses an asynchronous callback to return the result.
3329
3330**System API**: This is a system API.
3331
3332**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3333
3334**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3335
3336**Parameters**
3337
3338| Name          | Type                                                        | Mandatory| Description                                                        |
3339| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3340| permissionName | string                                                       | Yes  | Name of the permission.                                              |
3341| callback       | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **PermissionDef** object obtained. Otherwise, **err** is an error object.|
3342
3343**Error codes**
3344
3345For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3346
3347| ID| Error Message                             |
3348| -------- | ------------------------------------- |
3349| 201 | Permission denied. |
3350| 202 | Permission denied, non-system app called system api. |
3351| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3352| 17700006 | The specified permission is not found. |
3353
3354**Example**
3355
3356```ts
3357import { bundleManager } from '@kit.AbilityKit';
3358import { BusinessError } from '@kit.BasicServicesKit';
3359import { hilog } from '@kit.PerformanceAnalysisKit';
3360let permission = "ohos.permission.GET_BUNDLE_INFO";
3361try {
3362    bundleManager.getPermissionDef(permission, (err, data) => {
3363        if (err) {
3364            hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message);
3365        } else {
3366            hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', JSON.stringify(data));
3367        }
3368    });
3369} catch (err) {
3370    let message = (err as BusinessError).message;
3371    hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', message);
3372}
3373```
3374
3375## bundleManager.getPermissionDef
3376
3377getPermissionDef(permissionName: string): Promise\<PermissionDef>
3378
3379Obtains the PermissionDef struct based on the given permission name. This API uses a promise to return the result.
3380
3381**System API**: This is a system API.
3382
3383**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3384
3385**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3386
3387**Parameters**
3388
3389| Name          | Type  | Mandatory| Description          |
3390| -------------- | ------ | ---- | -------------- |
3391| permissionName | string | Yes  | Name of the permission.|
3392
3393**Return value**
3394
3395| Type                                                        | Description                                      |
3396| ------------------------------------------------------------ | ------------------------------------------ |
3397| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)> | Promise used to return the **PermissionDef** object obtained.|
3398
3399**Error codes**
3400
3401For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3402
3403| ID| Error Message                             |
3404| -------- | ------------------------------------- |
3405| 201 | Permission denied. |
3406| 202 | Permission denied, non-system app called system api. |
3407| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3408| 17700006 | The specified permission is not found. |
3409
3410**Example**
3411
3412```ts
3413import { bundleManager } from '@kit.AbilityKit';
3414import { BusinessError } from '@kit.BasicServicesKit';
3415import { hilog } from '@kit.PerformanceAnalysisKit';
3416let permissionName = "ohos.permission.GET_BUNDLE_INFO";
3417try {
3418    bundleManager.getPermissionDef(permissionName).then((data) => {
3419        hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data));
3420    }).catch((err: BusinessError) => {
3421        hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message);
3422    });
3423} catch (err) {
3424    let message = (err as BusinessError).message;
3425    hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', message);
3426}
3427```
3428
3429## bundleManager.getPermissionDefSync<sup>10+</sup>
3430
3431getPermissionDefSync(permissionName: string): PermissionDef;
3432
3433Obtains the **PermissionDef** struct based on the given permission name. This API returns the result synchronously.
3434
3435**System API**: This is a system API.
3436
3437**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3438
3439**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3440
3441**Parameters**
3442
3443| Name          | Type  | Mandatory| Description          |
3444| -------------- | ------ | ---- | -------------- |
3445| permissionName | string | Yes  | Name of the permission.|
3446
3447**Return value**
3448
3449| Type                                                        | Description                                      |
3450| ------------------------------------------------------------ | ------------------------------------------ |
3451|[PermissionDef](js-apis-bundleManager-permissionDef-sys.md) | **PermissionDef** object.|
3452
3453**Error codes**
3454
3455For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3456
3457| ID| Error Message                             |
3458| -------- | ------------------------------------- |
3459| 201 | Permission denied. |
3460| 202 | Permission denied, non-system app called system api. |
3461| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3462| 17700006 | The specified permission is not found. |
3463
3464**Example**
3465
3466```ts
3467import { bundleManager } from '@kit.AbilityKit';
3468import { BusinessError } from '@kit.BasicServicesKit';
3469import { hilog } from '@kit.PerformanceAnalysisKit';
3470let permissionName = "ohos.permission.GET_BUNDLE_INFO";
3471try {
3472    let PermissionDef = bundleManager.getPermissionDefSync(permissionName);
3473    hilog.info(0x0000, 'testTag', 'getPermissionDefSync successfully. Data: %{public}s', JSON.stringify(PermissionDef));
3474} catch (err) {
3475    let message = (err as BusinessError).message;
3476    hilog.error(0x0000, 'testTag', 'getPermissionDefSync failed. Cause: %{public}s', message);
3477}
3478```
3479
3480## bundleManager.getAbilityLabel
3481
3482getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<string>): void
3483
3484Obtains the label based on the given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result.
3485
3486**System API**: This is a system API.
3487
3488**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3489
3490**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
3491
3492**Parameters**
3493
3494| Name     | Type                  | Mandatory| Description                                                        |
3495| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
3496| bundleName  | string                 | Yes  | Bundle name.                                    |
3497| moduleName  | string                 | Yes  | Module name.                                    |
3498| abilityName | string                 | Yes  | Name of the UIAbility component.                                   |
3499| 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.|
3500
3501**Error codes**
3502
3503For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3504
3505| ID| Error Message                              |
3506| -------- | -------------------------------------- |
3507| 201 | Permission denied. |
3508| 202 | Permission denied, non-system app called system api. |
3509| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3510| 801 | Capability not supported. |
3511| 17700001 | The specified bundleName is not found.  |
3512| 17700002 | The specified moduleName is not found.  |
3513| 17700003 | The specified abilityName is not found. |
3514| 17700026 | The specified bundle is disabled.       |
3515| 17700029 | The specified ability is disabled.      |
3516
3517**Example**
3518
3519```ts
3520import { bundleManager } from '@kit.AbilityKit';
3521import { BusinessError } from '@kit.BasicServicesKit';
3522import { hilog } from '@kit.PerformanceAnalysisKit';
3523let bundleName = 'com.example.myapplication';
3524let moduleName = 'entry';
3525let abilityName = 'EntryAbility';
3526
3527try {
3528    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
3529        if (err) {
3530            hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message);
3531        } else {
3532            hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', JSON.stringify(data));
3533        }
3534    });
3535} catch (err) {
3536    let message = (err as BusinessError).message;
3537    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', message);
3538}
3539```
3540
3541## bundleManager.getAbilityLabel
3542
3543getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>
3544
3545Obtains the label based on the given bundle name, module name, and ability name. This API uses a promise to return the result.
3546
3547**System API**: This is a system API.
3548
3549**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3550
3551**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
3552
3553**Parameters**
3554
3555| Name     | Type  | Mandatory| Description                     |
3556| ----------- | ------ | ---- | ------------------------- |
3557| bundleName  | string | Yes  | Bundle name. |
3558| moduleName  | string | Yes  | Module name. |
3559| abilityName | string | Yes  | Name of the UIAbility component.|
3560
3561**Return value**
3562
3563| Type            | Description                               |
3564| ---------------- | ----------------------------------- |
3565| Promise\<string> | Promise used to return the label.|
3566
3567**Error codes**
3568
3569For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3570
3571| ID| Error Message                             |
3572| -------- | --------------------------------------- |
3573| 201 | Permission denied. |
3574| 202 | Permission denied, non-system app called system api. |
3575| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3576| 801 | Capability not supported. |
3577| 17700001 | The specified bundleName is not found.  |
3578| 17700002 | The specified moduleName is not found.  |
3579| 17700003 | The specified abilityName is not found. |
3580| 17700026 | The specified bundle is disabled.       |
3581| 17700029 | The specified ability is disabled.      |
3582
3583**Example**
3584
3585```ts
3586import { bundleManager } from '@kit.AbilityKit';
3587import { BusinessError } from '@kit.BasicServicesKit';
3588import { hilog } from '@kit.PerformanceAnalysisKit';
3589let bundleName = 'com.example.myapplication';
3590let moduleName = 'entry';
3591let abilityName = 'EntryAbility';
3592
3593try {
3594    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
3595        hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data));
3596    }).catch((err: BusinessError) => {
3597        hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message);
3598    });
3599} catch (err) {
3600    let message = (err as BusinessError).message;
3601    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', message);
3602}
3603```
3604
3605## bundleManager.getAbilityLabelSync<sup>10+</sup>
3606
3607getAbilityLabelSync(bundleName: string, moduleName: string, abilityName: string): string
3608
3609Obtains the ability label based on the given bundle name, module name, and ability name. This API returns the result synchronously.
3610
3611**System API**: This is a system API.
3612
3613**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3614
3615**System capability**: SystemCapability.BundleManager.BundleFramework.Resource
3616
3617**Parameters**
3618
3619| Name     | Type  | Mandatory| Description                     |
3620| ----------- | ------ | ---- | ------------------------- |
3621| bundleName  | string | Yes  | Bundle name. |
3622| moduleName  | string | Yes  | Module name. |
3623| abilityName | string | Yes  | Name of the UIAbility component.|
3624
3625**Return value**
3626
3627| Type            | Description                               |
3628| ---------------- | ----------------------------------- |
3629| string | Label of the ability.|
3630
3631**Error codes**
3632
3633For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3634
3635| ID| Error Message                             |
3636| -------- | --------------------------------------- |
3637| 201 | Permission denied. |
3638| 202 | Permission denied, non-system app called system api. |
3639| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3640| 801 | Capability not supported. |
3641| 17700001 | The specified bundleName is not found.  |
3642| 17700002 | The specified moduleName is not found.  |
3643| 17700003 | The specified abilityName is not found. |
3644| 17700026 | The specified bundle is disabled.       |
3645| 17700029 | The specified ability is disabled.      |
3646
3647**Example**
3648
3649```ts
3650import { bundleManager } from '@kit.AbilityKit';
3651import { BusinessError } from '@kit.BasicServicesKit';
3652import { hilog } from '@kit.PerformanceAnalysisKit';
3653let bundleName = 'com.example.myapplication';
3654let moduleName = 'entry';
3655let abilityName = 'EntryAbility';
3656
3657try {
3658    let abilityLabel = bundleManager.getAbilityLabelSync(bundleName, moduleName, abilityName);
3659    hilog.info(0x0000, 'testTag', 'getAbilityLabelSync successfully. Data: %{public}s', abilityLabel);
3660} catch (err) {
3661    let message = (err as BusinessError).message;
3662    hilog.error(0x0000, 'testTag', 'getAbilityLabelSync failed. Cause: %{public}s', message);
3663}
3664```
3665
3666## bundleManager.getApplicationInfoSync
3667
3668getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : ApplicationInfo
3669
3670Obtains the application information based on the given bundle name, application flags, and user ID. This API returns the result synchronously.
3671
3672**System API**: This is a system API.
3673
3674**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3675
3676**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3677
3678**Parameters**
3679
3680| Name      | Type  | Mandatory| Description                                                      |
3681| ----------- | ------ | ---- | ----------------------------------------------------------|
3682| bundleName  | string | Yes  | Bundle name.                                 |
3683| applicationFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.      |
3684| userId      | number | Yes  | User ID.                                        |
3685
3686**Return value**
3687
3688| Type           | Description                     |
3689| --------------- | ------------------------- |
3690| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
3691
3692**Error codes**
3693
3694For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3695
3696| ID| Error Message                            |
3697| -------- | -------------------------------------- |
3698| 201 | Permission denied. |
3699| 202 | Permission denied, non-system app called system api. |
3700| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3701| 17700001 | The specified bundleName is not found. |
3702| 17700004 | The specified user ID is not found.     |
3703| 17700026 | The specified bundle is disabled.      |
3704
3705**Example**
3706
3707```ts
3708import { bundleManager } from '@kit.AbilityKit';
3709import { BusinessError } from '@kit.BasicServicesKit';
3710import { hilog } from '@kit.PerformanceAnalysisKit';
3711let bundleName = 'com.example.myapplication';
3712let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
3713let userId = 100;
3714
3715try {
3716    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
3717    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
3718} catch (err) {
3719    let message = (err as BusinessError).message;
3720    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
3721}
3722```
3723
3724## bundleManager.getApplicationInfoSync
3725
3726getApplicationInfoSync(bundleName: string, applicationFlags: number) : ApplicationInfo
3727
3728Obtains the application information based on the given bundle name and application flags. This API returns the result synchronously.
3729
3730**System API**: This is a system API.
3731
3732**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3733
3734**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3735
3736**Parameters**
3737
3738| Name          | Type                      | Mandatory| Description                                                 |
3739| ---------------- | -------------------------- | ---- | ----------------------------------------------------- |
3740| bundleName       | string                     | Yes  | Bundle name.                           |
3741| applicationFlags | [number](#applicationflag) | Yes  | Type of the application information to obtain.|
3742
3743**Return value**
3744
3745| Type                                                       | Description                     |
3746| ----------------------------------------------------------- | ------------------------- |
3747| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
3748
3749**Error codes**
3750
3751For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3752
3753| ID| Error Message                              |
3754| -------- | -------------------------------------- |
3755| 201 | Permission denied. |
3756| 202 | Permission denied, non-system app called system api. |
3757| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3758| 17700001 | The specified bundleName is not found. |
3759| 17700026 | The specified bundle is disabled.      |
3760
3761**Example**
3762
3763```ts
3764import { bundleManager } from '@kit.AbilityKit';
3765import { BusinessError } from '@kit.BasicServicesKit';
3766import { hilog } from '@kit.PerformanceAnalysisKit';
3767let bundleName = 'com.example.myapplication';
3768let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
3769
3770try {
3771    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
3772    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
3773} catch (err) {
3774    let message = (err as BusinessError).message;
3775    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
3776}
3777```
3778
3779## bundleManager.getBundleInfoSync<sup>14+</sup>
3780
3781getBundleInfoSync(bundleName: string, bundleFlags: number, userId: number): BundleInfo
3782
3783Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API returns the result synchronously.
3784
3785No permission is required for obtaining the caller's own information.
3786
3787**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3788
3789**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3790
3791**Parameters**
3792
3793| Name      | Type  | Mandatory| Description                                                    |
3794| ----------- | ------ | ---- | -------------------------------------------------------- |
3795| bundleName  | string | Yes  | Bundle name.                                |
3796| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
3797| userId      | number | Yes  | User ID.                                            |
3798
3799**Return value**
3800
3801| Type      | Description                |
3802| ---------- | -------------------- |
3803| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
3804
3805**Error codes**
3806
3807For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3808
3809| ID| Error Message                            |
3810| -------- | ------------------------------------- |
3811| 201 | Permission denied. |
3812| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3813| 17700001 | The specified bundleName is not found. |
3814| 17700004 | The specified user ID is not found.     |
3815| 17700026 | The specified bundle is disabled.      |
3816
3817**Example**
3818
3819```ts
3820import { bundleManager } from '@kit.AbilityKit';
3821import { BusinessError } from '@kit.BasicServicesKit';
3822import { hilog } from '@kit.PerformanceAnalysisKit';
3823let bundleName = 'com.example.myapplication';
3824let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
3825let userId = 100;
3826
3827try {
3828    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
3829    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
3830} catch (err) {
3831    let message = (err as BusinessError).message;
3832    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
3833}
3834```
3835
3836## bundleManager.getBundleInfoSync<sup>14+</sup>
3837
3838getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo
3839
3840Obtains the bundle information based on the given bundle name and bundle flags. This API returns the result synchronously.
3841
3842No permission is required for obtaining the caller's own information.
3843
3844**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3845
3846**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3847
3848**Parameters**
3849
3850| Name     | Type                 | Mandatory| Description                                                  |
3851| ----------- | --------------------- | ---- | ------------------------------------------------------ |
3852| bundleName  | string                | Yes  | Bundle name.                            |
3853| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes  | Type of the bundle information to obtain.|
3854
3855**Return value**
3856
3857| Type                                             | Description                |
3858| ------------------------------------------------- | -------------------- |
3859| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
3860
3861**Error codes**
3862
3863For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3864
3865| ID| Error Message                              |
3866| -------- | -------------------------------------- |
3867| 201 | Permission denied. |
3868| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3869| 17700001 | The specified bundleName is not found. |
3870| 17700026 | The specified bundle is disabled.      |
3871
3872**Example**
3873
3874```ts
3875import { bundleManager } from '@kit.AbilityKit';
3876import { BusinessError } from '@kit.BasicServicesKit';
3877import { hilog } from '@kit.PerformanceAnalysisKit';
3878let bundleName = 'com.example.myapplication';
3879let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
3880try {
3881    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
3882    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
3883} catch (err) {
3884    let message = (err as BusinessError).message;
3885    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
3886}
3887```
3888
3889## bundleManager.getSharedBundleInfo<sup>10+</sup>
3890
3891getSharedBundleInfo(bundleName: string,  moduleName: string, callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void
3892
3893Obtains the shared bundle information based on the given bundle name. This API uses an asynchronous callback to return the result.
3894
3895**System API**: This is a system API.
3896
3897**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3898
3899**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3900
3901**Parameters**
3902
3903| Name    | Type                                                        | Mandatory| Description                                                        |
3904| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3905| bundleName | string                                                       | Yes  | Bundle name.                                  |
3906| moduleName | string                                                       | Yes  | Module name.                                  |
3907| callback   | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the shared bundle information obtained.|
3908
3909**Error codes**
3910
3911For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3912
3913| ID| Error Message                              |
3914| -------- | -------------------------------------- |
3915| 201 | Permission denied. |
3916| 202 | Permission denied, non-system app called system api. |
3917| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3918| 17700001 | The specified bundleName is not found. |
3919| 17700002 | The specified moduleName is not found. |
3920
3921**Example**
3922
3923```ts
3924import { bundleManager } from '@kit.AbilityKit';
3925import { BusinessError } from '@kit.BasicServicesKit';
3926import { hilog } from '@kit.PerformanceAnalysisKit';
3927let bundleName = 'com.example.myapplication';
3928let moduleName = 'library';
3929
3930try {
3931    bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => {
3932        if (err) {
3933            hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message);
3934        } else {
3935            hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
3936        }
3937    });
3938} catch (err) {
3939    let message = (err as BusinessError).message;
3940    hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', message);
3941}
3942```
3943
3944## bundleManager.getSharedBundleInfo<sup>10+</sup>
3945
3946getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<SharedBundleInfo\>\>
3947
3948Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result.
3949
3950**System API**: This is a system API.
3951
3952**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3953
3954**System capability**: SystemCapability.BundleManager.BundleFramework.Core
3955
3956**Parameters**
3957
3958| Name    | Type  | Mandatory| Description                      |
3959| ---------- | ------ | ---- | -------------------------- |
3960| bundleName | string | Yes  | Bundle name.|
3961| moduleName | string | Yes  | Module name.|
3962
3963**Return value**
3964
3965| Type                                                        | Description                               |
3966| ------------------------------------------------------------ | ----------------------------------- |
3967| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Promise used to return the shared bundle information obtained.|
3968
3969**Error codes**
3970
3971For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
3972
3973| ID| Error Message                              |
3974| -------- | -------------------------------------- |
3975| 201 | Permission denied. |
3976| 202 | Permission denied, non-system app called system api. |
3977| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
3978| 17700001 | The specified bundleName is not found. |
3979| 17700002 | The specified moduleName is not found. |
3980
3981**Example**
3982
3983```ts
3984import { bundleManager } from '@kit.AbilityKit';
3985import { BusinessError } from '@kit.BasicServicesKit';
3986import { hilog } from '@kit.PerformanceAnalysisKit';
3987let bundleName = 'com.example.myapplication';
3988let moduleName = 'library';
3989
3990try {
3991    bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => {
3992        hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
3993    }).catch((err: BusinessError) => {
3994        hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message);
3995    });
3996} catch (err) {
3997    let message = (err as BusinessError).message;
3998    hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', message);
3999}
4000```
4001
4002## bundleManager.getAllSharedBundleInfo<sup>10+</sup>
4003
4004getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void
4005
4006Obtains all the shared bundle information. This API uses an asynchronous callback to return the result.
4007
4008**System API**: This is a system API.
4009
4010**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4011
4012**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4013
4014**Parameters**
4015
4016| Name  | Type                                                        | Mandatory| Description                                                        |
4017| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4018| callback | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is an array of the shared bundle information obtained.|
4019
4020**Error codes**
4021
4022For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4023
4024| ID| Error Message                            |
4025| -------- | ------------------------------------- |
4026| 201 | Permission denied. |
4027| 202 | Permission denied, non-system app called system api. |
4028
4029**Example**
4030
4031```ts
4032import { bundleManager } from '@kit.AbilityKit';
4033import { BusinessError } from '@kit.BasicServicesKit';
4034import { hilog } from '@kit.PerformanceAnalysisKit';
4035
4036try {
4037    bundleManager.getAllSharedBundleInfo((err, data) => {
4038        if (err) {
4039            hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message);
4040        } else {
4041            hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
4042        }
4043    });
4044} catch (err) {
4045    let message = (err as BusinessError).message;
4046    hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', message);
4047}
4048```
4049
4050## bundleManager.getAllSharedBundleInfo<sup>10+</sup>
4051
4052getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>
4053
4054Obtains all the shared bundle information. This API uses a promise to return the result.
4055
4056**System API**: This is a system API.
4057
4058**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4059
4060**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4061
4062**Return value**
4063
4064| Type                                                        | Description                               |
4065| ------------------------------------------------------------ | ----------------------------------- |
4066| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Promise used to return an array of the shared bundle information obtained.|
4067
4068**Error codes**
4069
4070For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4071
4072| ID| Error Message                            |
4073| -------- | ------------------------------------- |
4074| 201 | Permission denied. |
4075| 202 | Permission denied, non-system app called system api. |
4076
4077**Example**
4078
4079```ts
4080import { bundleManager } from '@kit.AbilityKit';
4081import { BusinessError } from '@kit.BasicServicesKit';
4082import { hilog } from '@kit.PerformanceAnalysisKit';
4083
4084try {
4085    bundleManager.getAllSharedBundleInfo().then((data) => {
4086        hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
4087    }).catch((err: BusinessError) => {
4088        hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
4089    });
4090} catch (err) {
4091    let message = (err as BusinessError).message;
4092    hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', message);
4093}
4094```
4095
4096## bundleManager.getAppProvisionInfo<sup>10+</sup>
4097
4098getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<AppProvisionInfo\>): void
4099
4100Obtains the provision profile based on the given bundle name. This API uses an asynchronous callback to return the result.
4101
4102**System API**: This is a system API.
4103
4104**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4105
4106**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4107
4108**Parameters**
4109
4110| Name  | Type                                                        | Mandatory| Description                                                        |
4111| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4112| bundleName | string | Yes  | Bundle name.|
4113| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the provision profile obtained.|
4114
4115**Error codes**
4116
4117For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4118
4119| ID| Error Message                              |
4120| -------- | -------------------------------------- |
4121| 201 | Permission denied. |
4122| 202 | Permission denied, non-system app called system api. |
4123| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. |
4124| 17700001 | The specified bundleName is not found. |
4125
4126**Example**
4127
4128```ts
4129import { bundleManager } from '@kit.AbilityKit';
4130import { BusinessError } from '@kit.BasicServicesKit';
4131import { hilog } from '@kit.PerformanceAnalysisKit';
4132let bundleName = "com.ohos.myapplication";
4133
4134try {
4135    bundleManager.getAppProvisionInfo(bundleName, (err, data) => {
4136        if (err) {
4137            hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message);
4138        } else {
4139            hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data));
4140        }
4141    });
4142} catch (err) {
4143    let message = (err as BusinessError).message;
4144    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
4145}
4146```
4147
4148## bundleManager.getAppProvisionInfo<sup>10+</sup>
4149
4150getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\<AppProvisionInfo\>): void
4151
4152Obtains the provision profile based on the given bundle name and user ID. This API uses an asynchronous callback to return the result.
4153
4154**System API**: This is a system API.
4155
4156**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4157
4158**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4159
4160**Parameters**
4161
4162| Name  | Type                                                        | Mandatory| Description                                                        |
4163| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4164| bundleName | string | Yes  | Bundle name.|
4165| userId | number | Yes| User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).|
4166| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the provision profile obtained.|
4167
4168
4169**Error codes**
4170
4171For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4172
4173| ID| Error Message                              |
4174| -------- | -------------------------------------- |
4175| 201 | Permission denied. |
4176| 202 | Permission denied, non-system app called system api. |
4177| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. |
4178| 17700001 | The specified bundleName is not found. |
4179| 17700004 | The specified user ID is not found. |
4180
4181**Example**
4182
4183```ts
4184import { bundleManager } from '@kit.AbilityKit';
4185import { BusinessError } from '@kit.BasicServicesKit';
4186import { hilog } from '@kit.PerformanceAnalysisKit';
4187let bundleName = "com.ohos.myapplication";
4188let userId = 100;
4189
4190try {
4191    bundleManager.getAppProvisionInfo(bundleName, userId, (err, data) => {
4192        if (err) {
4193            hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message);
4194        } else {
4195            hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data));
4196        }
4197    });
4198} catch (err) {
4199    let message = (err as BusinessError).message;
4200    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
4201}
4202```
4203
4204## bundleManager.getAppProvisionInfo<sup>10+</sup>
4205
4206getAppProvisionInfo(bundleName: string, userId?: number): Promise\<AppProvisionInfo\>
4207
4208Obtains the provision profile based on the given bundle name and user ID. This API uses a promise to return the result.
4209
4210**System API**: This is a system API.
4211
4212**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4213
4214**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4215
4216**Parameters**
4217
4218| Name  | Type        | Mandatory| Description         |
4219| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4220| bundleName | string | Yes| Bundle name.|
4221| userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9) to obtain the user ID on the current device.|
4222
4223
4224**Return value**
4225
4226| Type                                                        | Description                               |
4227| ------------------------------------------------------------ | ----------------------------------- |
4228| Promise\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Promise used to return the provision profile obtained.|
4229
4230**Error codes**
4231
4232For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4233
4234| ID| Error Message                              |
4235| -------- | -------------------------------------- |
4236| 201 | Permission denied. |
4237| 202 | Permission denied, non-system app called system api. |
4238| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. |
4239| 17700001 | The specified bundleName is not found. |
4240| 17700004 | The specified user ID is not found. |
4241
4242**Example**
4243
4244```ts
4245import { bundleManager } from '@kit.AbilityKit';
4246import { BusinessError } from '@kit.BasicServicesKit';
4247import { hilog } from '@kit.PerformanceAnalysisKit';
4248let bundleName = "com.ohos.myapplication";
4249let userId = 100;
4250
4251try {
4252    bundleManager.getAppProvisionInfo(bundleName).then((data) => {
4253        hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
4254    }).catch((err: BusinessError) => {
4255        hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
4256    });
4257} catch (err) {
4258    let message = (err as BusinessError).message;
4259    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
4260}
4261
4262try {
4263    bundleManager.getAppProvisionInfo(bundleName, userId).then((data) => {
4264        hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
4265    }).catch((err: BusinessError) => {
4266        hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
4267    });
4268} catch (err) {
4269    let message = (err as BusinessError).message;
4270    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
4271}
4272```
4273
4274## bundleManager.getAppProvisionInfoSync<sup>10+</sup>
4275
4276getAppProvisionInfoSync(bundleName: string, userId?: number): AppProvisionInfo
4277
4278Obtains the provision profile based on the given bundle name and user ID. This API returns the result synchronously.
4279
4280**System API**: This is a system API.
4281
4282**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4283
4284**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4285
4286**Parameters**
4287
4288| Name  | Type        | Mandatory| Description         |
4289| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4290| bundleName | string | Yes| Bundle name.|
4291| userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9) to obtain the user ID on the current device.|
4292
4293
4294**Return value**
4295
4296| Type                                                        | Description                               |
4297| ------------------------------------------------------------ | ----------------------------------- |
4298| [AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md) | Provision profile.|
4299
4300**Error codes**
4301
4302For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4303
4304| ID| Error Message                              |
4305| -------- | -------------------------------------- |
4306| 201 | Permission denied. |
4307| 202 | Permission denied, non-system app called system api. |
4308| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. |
4309| 17700001 | The specified bundleName is not found. |
4310| 17700004 | The specified user ID is not found. |
4311
4312**Example**
4313
4314```ts
4315import { bundleManager } from '@kit.AbilityKit';
4316import { BusinessError } from '@kit.BasicServicesKit';
4317import { hilog } from '@kit.PerformanceAnalysisKit';
4318let bundleName = "com.ohos.myapplication";
4319let userId = 100;
4320
4321try {
4322    let data = bundleManager.getAppProvisionInfoSync(bundleName);
4323    hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4324} catch (err) {
4325    let message = (err as BusinessError).message;
4326    hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
4327}
4328
4329try {
4330    let data = bundleManager.getAppProvisionInfoSync(bundleName, userId);
4331    hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4332} catch (err) {
4333    let message = (err as BusinessError).message;
4334    hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
4335}
4336```
4337
4338## bundleManager.getSpecifiedDistributionType<sup>10+</sup>
4339getSpecifiedDistributionType(bundleName: string): string
4340
4341Obtains the [distribution type](../../security/app-provision-structure.md) of a bundle in synchronous mode. The return value is the **specifiedDistributionType** field value in [InstallParam](./js-apis-installer-sys.md#installparam) passed when **install** is called.
4342
4343**System API**: This is a system API.
4344
4345**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4346
4347**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4348
4349**Parameters**
4350
4351| Name        | Type                               | Mandatory| Description                        |
4352| -------------- | ----------------------------------- | ---- | ---------------------------- |
4353| bundleName | string | Yes  | Bundle name.|
4354
4355**Return value**
4356
4357| Type         | Description                                  |
4358| ------------- | -------------------------------------- |
4359| string | [Distribution type](../../security/app-provision-structure.md) of the bundle.|
4360
4361**Error codes**
4362
4363For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4364
4365| ID| Error Message                                                    |
4366| -------- | ------------------------------------------------------------ |
4367| 201 | Permission denied. |
4368| 202 | Permission denied, non-system app called system api. |
4369| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
4370| 17700001 | The specified bundleName is not found. |
4371
4372**Example**
4373```ts
4374import { bundleManager } from '@kit.AbilityKit';
4375import { BusinessError } from '@kit.BasicServicesKit';
4376let bundleName = "com.example.myapplication";
4377
4378try {
4379    let type = bundleManager.getSpecifiedDistributionType(bundleName);
4380    console.info('getSpecifiedDistributionType successfully, type:' + type);
4381} catch (error) {
4382    let message = (error as BusinessError).message;
4383    console.error('getSpecifiedDistributionType failed. Cause: ' + message);
4384}
4385```
4386
4387
4388## bundleManager.getAdditionalInfo<sup>10+</sup>
4389
4390getAdditionalInfo(bundleName: string): string
4391
4392Obtains additional information about a bundle in synchronous mode. The return value is the **additionalInfo** field value in [InstallParam](./js-apis-installer-sys.md#installparam) passed when **install** is called.
4393
4394**System API**: This is a system API.
4395
4396**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4397
4398**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4399
4400**Parameters**
4401
4402| Name        | Type                               | Mandatory| Description                        |
4403| -------------- | ----------------------------------- | ---- | ---------------------------- |
4404| bundleName | string | Yes  | Bundle name.|
4405
4406**Return value**
4407
4408| Type         | Description                                  |
4409| ------------- | -------------------------------------- |
4410| string | Additional information about the bundle.|
4411
4412**Error codes**
4413
4414For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4415
4416| ID| Error Message                                                    |
4417| -------- | ------------------------------------------------------------ |
4418| 201 | Permission denied. |
4419| 202 | Permission denied, non-system app called system api. |
4420| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. |
4421| 17700001 | The specified bundleName is not found. |
4422
4423**Example**
4424
4425```ts
4426import { bundleManager } from '@kit.AbilityKit';
4427import { BusinessError } from '@kit.BasicServicesKit';
4428let bundleName = "com.example.myapplication";
4429
4430try {
4431    let info = bundleManager.getAdditionalInfo(bundleName);
4432    console.info('getAdditionalInfo successfully, additionInfo:' + info);
4433} catch (error) {
4434    let message = (error as BusinessError).message;
4435    console.error('getAdditionalInfo failed. Cause: ' + message);
4436}
4437```
4438
4439## bundleManager.queryExtensionAbilityInfoSync<sup>11+</sup>
4440
4441queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: string, extensionAbilityFlags: number, userId?: number): Array\<ExtensionAbilityInfo>
4442
4443Obtains the ExtensionAbility information based on the given want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API returns the result synchronously.
4444
4445**System API**: This is a system API.
4446
4447**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
4448
4449**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4450
4451**Parameters**
4452
4453| Name               | Type                           | Mandatory| Description                                                     |
4454| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- |
4455| want                  | Want                            | Yes  | Want containing the bundle name to query.                   |
4456| extensionAbilityType  | string                          | Yes  | Type of the custom ExtensionAbility.                       |
4457| extensionAbilityFlags | [number](#extensionabilityflag) | Yes  | Information flags to be contained in the returned **ExtensionAbilityInfo** object.|
4458| userId                | number                          | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
4459
4460**Return value**
4461
4462| Type                                                        | Description                                  |
4463| ------------------------------------------------------------ | -------------------------------------- |
4464| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of **ExtensionAbilityInfo** objects.|
4465
4466**Error codes**
4467
4468For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4469
4470| ID| Error Message                                    |
4471| -------- | -------------------------------------------- |
4472| 201 | Permission denied. |
4473| 202 | Permission denied, non-system app called system api. |
4474| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. |
4475| 17700001 | The specified bundleName is not found.       |
4476| 17700003 | The specified extensionAbility is not found. |
4477| 17700004 | The specified userId is invalid.             |
4478| 17700026 | The specified bundle is disabled.            |
4479
4480**Example**
4481
4482```ts
4483// Call the API with the userId parameter specified.
4484import { bundleManager } from '@kit.AbilityKit';
4485import { hilog } from '@kit.PerformanceAnalysisKit';
4486import { Want } from '@kit.AbilityKit';
4487import { BusinessError } from '@kit.BasicServicesKit';
4488
4489let extensionAbilityType = "form";
4490let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
4491let userId = 100;
4492let want: Want = {
4493    bundleName : "com.example.myapplication",
4494    abilityName : "EntryAbility"
4495};
4496
4497try {
4498    let data = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId)
4499    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4500} catch (err) {
4501    let message = (err as BusinessError).message;
4502    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
4503}
4504```
4505
4506```ts
4507// Call the API without passing in the userId parameter.
4508import { bundleManager } from '@kit.AbilityKit';
4509import { hilog } from '@kit.PerformanceAnalysisKit';
4510import { Want } from '@kit.AbilityKit';
4511import { BusinessError } from '@kit.BasicServicesKit';
4512
4513let extensionAbilityType = "form";
4514let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
4515let want: Want = {
4516    bundleName : "com.example.myapplication",
4517    abilityName : "EntryAbility"
4518};
4519
4520try {
4521    let data = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags);
4522    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4523} catch (err) {
4524    let message = (err as BusinessError).message;
4525    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
4526}
4527```
4528
4529## bundleManager.getJsonProfile<sup>11+</sup>
4530
4531getJsonProfile(profileType: ProfileType, bundleName: string, moduleName?: string, userId?: number): string
4532
4533Obtains the JSON strings of the profile based on the given profile type, bundle name, and module name. This API returns the result synchronously.
4534
4535No permission is required for obtaining the caller's own profile.
4536
4537**System API**: This is a system API.
4538
4539**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
4540
4541**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4542
4543**Parameters**
4544
4545| Name               | Type                           | Mandatory| Description                                                     |
4546| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- |
4547| profileType           | [ProfileType](#profiletype11)     | Yes  | Type of the profile.                                  |
4548| bundleName            | string                          | Yes  | Bundle name of the application.                                 |
4549| moduleName            | string                          | No  | Module name of the application. If this parameter is not passed in, the entry module is used.           |
4550| userId<sup>12+</sup>  | number                          | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
4551
4552**Return value**
4553
4554| Type  | Description                     |
4555| ------ | ------------------------ |
4556| string | JSON string of the profile.|
4557
4558**Error codes**
4559
4560For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4561
4562| ID| Error Message                                    |
4563| -------- | -------------------------------------------- |
4564| 201 | Permission denied. |
4565| 202 | Permission denied, non-system app called system api. |
4566| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
4567| 17700001 | The specified bundleName is not found.       |
4568| 17700002 | The specified moduleName is not found.       |
4569| 17700004 | The specified user ID is not found.      |
4570| 17700024 | Failed to get the profile because the specified profile is not found in the HAP. |
4571| 17700026 | The specified bundle is disabled.            |
4572
4573**Example**
4574
4575```ts
4576import { bundleManager } from '@kit.AbilityKit';
4577import { hilog } from '@kit.PerformanceAnalysisKit';
4578import { BusinessError } from '@kit.BasicServicesKit';
4579
4580let bundleName = 'com.example.myapplication';
4581let moduleName = 'entry';
4582let profileType = bundleManager.ProfileType.INTENT_PROFILE;
4583
4584try {
4585    let data = bundleManager.getJsonProfile(profileType, bundleName, moduleName)
4586    hilog.info(0x0000, 'testTag', 'getJsonProfile successfully. Data: %{public}s', data);
4587} catch (err) {
4588    let message = (err as BusinessError).message;
4589    hilog.error(0x0000, 'testTag', 'getJsonProfile failed: %{public}s', message);
4590}
4591```
4592
4593## bundleManager.getRecoverableApplicationInfo<sup>11+</sup>
4594
4595getRecoverableApplicationInfo(callback: AsyncCallback\<Array\<RecoverableApplicationInfo\>\>): void
4596
4597Obtains information about all preinstalled applications that can be restored. This API uses an asynchronous callback to return the result.
4598
4599**System API**: This is a system API.
4600
4601**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4602
4603**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4604
4605**Parameters**
4606
4607| Name  | Type                                                        | Mandatory| Description                                                        |
4608| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4609| callback | AsyncCallback\<Array\<[RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md)\>\> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is an array of the recoverable application information obtained.|
4610
4611**Error codes**
4612
4613For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4614
4615| ID| Error Message                                    |
4616| -------- | -------------------------------------------- |
4617| 201 | Permission denied. |
4618| 202 | Permission denied, non-system app called system api. |
4619
4620**Example**
4621
4622```ts
4623import { bundleManager } from '@kit.AbilityKit';
4624import { BusinessError } from '@kit.BasicServicesKit';
4625import { hilog } from '@kit.PerformanceAnalysisKit';
4626
4627try {
4628    bundleManager.getRecoverableApplicationInfo((err, data) => {
4629        if (err) {
4630            hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', err.message);
4631        } else {
4632            hilog.info(0x0000, 'testTag', 'getRecoverableApplicationInfo successfully: %{public}s', JSON.stringify(data));
4633        }
4634    });
4635} catch (err) {
4636    let message = (err as BusinessError).message;
4637    hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', message);
4638}
4639```
4640
4641## bundleManager.getRecoverableApplicationInfo<sup>11+</sup>
4642
4643getRecoverableApplicationInfo(): Promise\<Array\<RecoverableApplicationInfo\>\>
4644
4645Obtains information about all preinstalled applications that can be restored. This API uses a promise to return the result.
4646
4647**System API**: This is a system API.
4648
4649**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4650
4651**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4652
4653**Return value**
4654
4655| Type                                                        | Description                               |
4656| ------------------------------------------------------------ | ----------------------------------- |
4657| Promise\<Array\<[RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md)\>\> | Promise used to return the information about all recoverable applications.|
4658
4659**Error codes**
4660
4661For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4662
4663| ID| Error Message                                    |
4664| -------- | -------------------------------------------- |
4665| 201 | Permission denied. |
4666| 202 | Permission denied, non-system app called system api. |
4667
4668**Example**
4669
4670```ts
4671import { bundleManager } from '@kit.AbilityKit';
4672import { BusinessError } from '@kit.BasicServicesKit';
4673import { hilog } from '@kit.PerformanceAnalysisKit';
4674
4675try {
4676    bundleManager.getRecoverableApplicationInfo().then((data) => {
4677        hilog.info(0x0000, 'testTag', 'getRecoverableApplicationInfo successfully: %{public}s', JSON.stringify(data));
4678    }).catch((err: BusinessError) => {
4679        hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', err.message);
4680    });
4681} catch (err) {
4682    let message = (err as BusinessError).message;
4683    hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', message);
4684}
4685```
4686
4687## bundleManager.setAdditionalInfo<sup>11+</sup>
4688
4689setAdditionalInfo(bundleName: string, additionalInfo: string): void
4690
4691Sets additional information for an application. This API can be called only by AppGallery.
4692
4693**System API**: This is a system API.
4694
4695**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4696
4697**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4698
4699**Parameters**
4700
4701| Name               | Type                            | Mandatory| Description                                              |
4702| --------------------- | ------------------------------- | ---- | -------------------------------------------------- |
4703| bundleName            | string                          | Yes  | Bundle name.                                   |
4704| additionalInfo        | string                          | Yes  | Additional information to set.                          |
4705
4706**Error codes**
4707
4708For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4709
4710| ID| Error Message                                                   |
4711| -------- | ---------------------------------------------------------- |
4712| 201 | Permission denied. |
4713| 202 | Permission denied, non-system app called system api. |
4714| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. |
4715| 17700001 | The specified bundleName is not found.                     |
4716| 17700053 | The caller is not AppGallery.                                     |
4717
4718**Example**
4719
4720```ts
4721import { bundleManager } from '@kit.AbilityKit';
4722import { BusinessError } from '@kit.BasicServicesKit';
4723import { hilog } from '@kit.PerformanceAnalysisKit';
4724
4725let bundleName = "com.example.myapplication";
4726let additionalInfo = "xxxxxxxxx,formUpdateLevel:4";
4727
4728try {
4729    bundleManager.setAdditionalInfo(bundleName, additionalInfo);
4730    hilog.info(0x0000, 'testTag', 'setAdditionalInfo successfully.');
4731} catch (err) {
4732    let message = (err as BusinessError).message;
4733    hilog.error(0x0000, 'testTag', 'setAdditionalInfo failed. Cause: %{public}s', message);
4734}
4735```
4736
4737## bundleManager.getAllPreinstalledApplicationInfo<sup>12+</sup>
4738
4739getAllPreinstalledApplicationInfo(): Promise\<Array\<PreinstalledApplicationInfo\>\>
4740
4741Obtains information about all preinstalled applications. This API uses a promise to return the result.
4742
4743**System API**: This is a system API.
4744
4745**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4746
4747**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4748
4749**Return value**
4750
4751| Type                                                        | Description                               |
4752| ------------------------------------------------------------ | ----------------------------------- |
4753| Promise<Array\<[PreinstalledApplicationInfo](js-apis-bundleManager-ApplicationInfo-sys.md)>> | Promise used to return the array of preinstalled applications obtained.|
4754
4755**Error codes**
4756
4757For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4758
4759| ID| Error Message                                                   |
4760| -------- | ---------------------------------------------------------- |
4761| 201 | Permission denied. |
4762| 202 | Permission denied, non-system app called system api. |
4763
4764**Example**
4765
4766```ts
4767import { bundleManager } from '@kit.AbilityKit';
4768import { BusinessError } from '@kit.BasicServicesKit';
4769import { hilog } from '@kit.PerformanceAnalysisKit';
4770
4771try {
4772    let data = bundleManager.getAllPreinstalledApplicationInfo();
4773    hilog.info(0x0000, 'testTag', 'getAllPreinstalledApplicationInfo success, Data: %{public}s', JSON.stringify(data));
4774} catch (err) {
4775    let message = (err as BusinessError).message;
4776    hilog.error(0x0000, 'testTag', 'getAllPreinstalledApplicationInfo failed: %{public}s', message);
4777}
4778```
4779
4780## bundleManager.queryExtensionAbilityInfoSync<sup>11+</sup>
4781
4782queryExtensionAbilityInfoSync(extensionAbilityType: string, extensionAbilityFlags: number, userId?: number): Array\<ExtensionAbilityInfo>
4783
4784Obtains the ExtensionAbility information based on the given ExtensionAbility type, ExtensionAbility flags, and user ID.
4785
4786**System API**: This is a system API.
4787
4788**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
4789
4790**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4791
4792**Parameters**
4793
4794| Name               | Type                           | Mandatory| Description                                                     |
4795| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- |
4796| extensionAbilityType  | string                          | Yes  | Type of the custom ExtensionAbility.                       |
4797| extensionAbilityFlags | [number](#extensionabilityflag) | Yes  | Information flags to be contained in the returned **ExtensionAbilityInfo** object.|
4798| userId                | number                          | No  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
4799
4800**Return value**
4801
4802| Type                                                        | Description                                  |
4803| ------------------------------------------------------------ | -------------------------------------- |
4804| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of **ExtensionAbilityInfo** objects.|
4805
4806**Error codes**
4807
4808For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4809
4810| ID| Error Message                                    |
4811| -------- | -------------------------------------------- |
4812| 201 | Permission denied. |
4813| 202 | Permission denied, non-system app called system api. |
4814| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter extensionAbilityType is empty. |
4815| 17700003 | The specified extensionAbility is not found. |
4816| 17700004 | The specified userId is invalid.             |
4817
4818**Example**
4819
4820```ts
4821// Call the API with the userId parameter specified.
4822import { bundleManager } from '@kit.AbilityKit';
4823import { hilog } from '@kit.PerformanceAnalysisKit';
4824import { BusinessError } from '@kit.BasicServicesKit';
4825
4826let extensionAbilityType = "form";
4827let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
4828let userId = 100;
4829
4830try {
4831    let data = bundleManager.queryExtensionAbilityInfoSync(extensionAbilityType, extensionFlags, userId)
4832    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4833} catch (err) {
4834    let message = (err as BusinessError).message;
4835    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
4836}
4837```
4838
4839```ts
4840// Call the API without passing in the userId parameter.
4841import { bundleManager } from '@kit.AbilityKit';
4842import { hilog } from '@kit.PerformanceAnalysisKit';
4843import { BusinessError } from '@kit.BasicServicesKit';
4844
4845let extensionAbilityType = "form";
4846let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
4847
4848try {
4849    let data = bundleManager.queryExtensionAbilityInfoSync(extensionAbilityType, extensionFlags);
4850    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4851} catch (err) {
4852    let message = (err as BusinessError).message;
4853    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
4854}
4855```
4856
4857## bundleManager.getAllBundleInfoByDeveloperId<sup>12+</sup>
4858
4859getAllBundleInfoByDeveloperId(developerId: string): Array\<BundleInfo>
4860
4861Obtains the information about all bundles of the current user based on the given developer ID.
4862
4863**System API**: This is a system API.
4864
4865**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4866
4867**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4868
4869**Parameters**
4870
4871| Name               | Type     | Mandatory| Description                    |
4872| --------------------- | ---------| ---- | --------------------- |
4873| developerId           | string   | Yes  | Developer ID.      |
4874
4875**Return value**
4876
4877| Type                                                        | Description                                  |
4878| ------------------------------------------------------------ | -------------------------------------- |
4879| Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>    | An array of bundle information.|
4880
4881**Error codes**
4882
4883For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4884
4885| ID| Error Message                                    |
4886| -------- | -------------------------------------------- |
4887| 201 | Permission denied. |
4888| 202 | Permission denied, non-system app called system api. |
4889| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter developerId is empty. |
4890| 17700059 | The specified developerId is invalid.       |
4891
4892**Example**
4893
4894```ts
4895import { bundleManager } from '@kit.AbilityKit';
4896import { hilog } from '@kit.PerformanceAnalysisKit';
4897import { BusinessError } from '@kit.BasicServicesKit';
4898
4899let developerId = "123456.789";
4900
4901try {
4902    let data = bundleManager.getAllBundleInfoByDeveloperId(developerId);
4903    hilog.info(0x0000, 'testTag', 'getAllBundleInfoByDeveloperId successfully. Data: %{public}s', JSON.stringify(data));
4904} catch (err) {
4905    let message = (err as BusinessError).message;
4906    hilog.error(0x0000, 'testTag', 'getAllBundleInfoByDeveloperId failed: %{public}s', message);
4907}
4908```
4909
4910## bundleManager.getDeveloperIds<sup>12+</sup>
4911
4912getDeveloperIds(appDistributionType?: number): Array\<String>
4913
4914Obtains all the developer IDs of the current user based on the given application [distribution type](#appdistributiontype12).
4915
4916**System API**: This is a system API.
4917
4918**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
4919
4920**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4921
4922**Parameters**
4923
4924| Name               | Type     | Mandatory| Description                    |
4925| --------------------- | ---------| ---- | --------------------- |
4926| [appDistributionType](#appdistributiontype12)  | number   | No  | Application distribution type. If this parameter is not specified, a list of developer IDs of all applications is returned.      |
4927
4928**Return value**
4929
4930| Type                                                        | Description                                  |
4931| ------------------------------------------------------------ | -------------------------------------- |
4932| Array\<String>    | An array of strings.|
4933
4934**Error codes**
4935
4936For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4937
4938| ID| Error Message                                    |
4939| -------- | -------------------------------------------- |
4940| 201 | Permission denied. |
4941| 202 | Permission denied, non-system app called system api. |
4942| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
4943
4944**Example**
4945
4946```ts
4947import { bundleManager } from '@kit.AbilityKit';
4948import { hilog } from '@kit.PerformanceAnalysisKit';
4949import { BusinessError } from '@kit.BasicServicesKit';
4950
4951let appDistributionType = bundleManager.AppDistributionType.ENTERPRISE;
4952
4953try {
4954    let data = bundleManager.getDeveloperIds(appDistributionType);
4955    hilog.info(0x0000, 'testTag', 'getDeveloperIds successfully. Data: %{public}s', JSON.stringify(data));
4956} catch (err) {
4957    let message = (err as BusinessError).message;
4958    hilog.error(0x0000, 'testTag', 'getDeveloperIds failed: %{public}s', message);
4959}
4960```
4961
4962## bundleManager.switchUninstallState<sup>12+</sup>
4963
4964switchUninstallState(bundleName: string, state: boolean): void
4965
4966Switches the uninstall state of an application. This API is independent from EDM application interception control.
4967
4968**System API**: This is a system API.
4969
4970**Required permissions**: ohos.permission.CHANGE_BUNDLE_UNINSTALL_STATE
4971
4972**System capability**: SystemCapability.BundleManager.BundleFramework.Core
4973
4974**Parameters**
4975
4976| Name  | Type                                                        | Mandatory| Description                                                        |
4977| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4978| bundleName | string | Yes  | Bundle name of the application.|
4979| state | boolean | Yes  | Whether the application can be uninstalled. The value **true** means that the application can be uninstalled, and **false** means the opposite.|
4980
4981**Error codes**
4982
4983For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
4984
4985| ID| Error Message                              |
4986| -------- | -------------------------------------- |
4987| 201 | Permission denied. |
4988| 202 | Permission denied, non-system app called system api. |
4989| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
4990| 17700001 | The specified bundleName is not found.  |
4991| 17700060 | The specified application cannot be uninstalled.      |
4992
4993**Example**
4994
4995```ts
4996import { bundleManager } from '@kit.AbilityKit';
4997import { hilog } from '@kit.PerformanceAnalysisKit';
4998import { BusinessError } from '@kit.BasicServicesKit';
4999
5000try {
5001    bundleManager.switchUninstallState('com.example.myapplication', false);
5002} catch (err) {
5003    let message = (err as BusinessError).message;
5004    hilog.error(0x0000, 'testTag', 'switchUninstallState failed: %{public}s', message);
5005}
5006```
5007
5008## bundleManager.getExtResource<sup>12+</sup>
5009
5010getExtResource(bundleName: string): Promise\<Array\<string>>;
5011
5012Obtains the module names corresponding to the extended resources based on the given bundle name. This API uses a promise to return the result.
5013
5014**System API**: This is a system API.
5015
5016**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
5017
5018**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5019
5020**Parameters**
5021
5022| Name    | Type  | Mandatory| Description                      |
5023| ----------- | ------ | ---- | ---------------------------- |
5024| bundleName  | string | Yes  | Bundle name based on which the extended resources are to be queried.|
5025
5026**Return value**
5027
5028| Type                                                       | Description                       |
5029| ----------------------------------------------------------- | --------------------------- |
5030| Promise\<Array\<string>> | Promise used to return the API call result and the module names corresponding to the extended resources.|
5031
5032**Error codes**
5033
5034For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5035
5036| ID| Error Message                           |
5037| -------- | --------------------------------------|
5038| 201 | Permission denied. |
5039| 202 | Permission denied, non-system app called system api. |
5040| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5041| 17700001 | The specified bundleName is not found. |
5042| 17700303 | Failed to obtain extended resources. |
5043
5044**Example**
5045
5046```ts
5047import { bundleManager } from '@kit.AbilityKit';
5048import { BusinessError } from '@kit.BasicServicesKit';
5049import { hilog } from '@kit.PerformanceAnalysisKit';
5050let bundleName : string = 'com.ohos.demo';
5051
5052try {
5053    bundleManager.getExtResource(bundleName).then((modules : Array<string>) => {
5054        for (let i = 0; i < modules.length; i++) {
5055            hilog.info(0x0000, 'testTag', 'getExtResource item: %s', modules[i]);
5056        }
5057    }).catch((err: BusinessError) => {
5058        hilog.error(0x0000, 'testTag', 'getExtResource failed. Cause: %{public}s', err.message);
5059    });
5060} catch (err) {
5061    let message = (err as BusinessError).message;
5062    hilog.error(0x0000, 'testTag', 'getExtResource failed. Cause: %{public}s', message);
5063}
5064```
5065
5066## bundleManager.enableDynamicIcon<sup>12+</sup>
5067
5068enableDynamicIcon(bundleName: string, moduleName: string): Promise\<void>;
5069
5070Enables the dynamic icon based on the given bundle name and module name. This API uses a promise to return the result.
5071
5072**System API**: This is a system API.
5073
5074**Required permissions**: ohos.permission.ACCESS_DYNAMIC_ICON
5075
5076**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5077
5078**Parameters**
5079
5080| Name    | Type  | Mandatory| Description                      |
5081| ----------- | ------ | ---- | ---------------------------- |
5082| bundleName  | string | Yes  | Bundle name based on which the dynamic icon is to be enabled.|
5083| moduleName  | string | Yes  | Module name based on which the dynamic icon is to be enabled.|
5084
5085**Return value**
5086
5087| Type                                                       | Description                       |
5088| ----------------------------------------------------------- | --------------------------- |
5089| Promise\<void> | Promise that returns no value.|
5090
5091**Error codes**
5092
5093For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5094
5095| ID| Error Message                           |
5096| -------- | --------------------------------------|
5097| 201 | Permission denied. |
5098| 202 | Permission denied, non-system app called system api. |
5099| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5100| 17700001 | The specified bundleName is not found. |
5101| 17700002 | The specified moduleName is not found. |
5102| 17700304 | Failed to enable the dynamic icon. |
5103
5104**Example**
5105
5106```ts
5107import { bundleManager } from '@kit.AbilityKit';
5108import { BusinessError } from '@kit.BasicServicesKit';
5109import { hilog } from '@kit.PerformanceAnalysisKit';
5110let bundleName : string = 'com.ohos.demo';
5111let moduleName : string = 'moduleTest';
5112
5113try {
5114    bundleManager.enableDynamicIcon(bundleName, moduleName).then((data) => {
5115        hilog.info(0x0000, 'testTag', 'enableDynamicIcon successfully');
5116    }).catch((err: BusinessError) => {
5117        hilog.error(0x0000, 'testTag', 'enableDynamicIcon failed. Cause: %{public}s', err.message);
5118    });
5119} catch (err) {
5120    let message = (err as BusinessError).message;
5121    hilog.error(0x0000, 'testTag', 'enableDynamicIcon failed. Cause: %{public}s', message);
5122}
5123```
5124
5125## bundleManager.disableDynamicIcon<sup>12+</sup>
5126
5127disableDynamicIcon(bundleName: string): Promise\<void>;
5128
5129Disables the dynamic icon based on the given bundle name. This API uses a promise to return the result.
5130
5131**System API**: This is a system API.
5132
5133**Required permissions**: ohos.permission.ACCESS_DYNAMIC_ICON
5134
5135**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5136
5137**Parameters**
5138
5139| Name    | Type  | Mandatory| Description                      |
5140| ----------- | ------ | ---- | ---------------------------- |
5141| bundleName  | string | Yes  | Bundle name based on which the dynamic icon is to be disabled.|
5142
5143**Return value**
5144
5145| Type                                                       | Description                       |
5146| ----------------------------------------------------------- | --------------------------- |
5147| Promise\<void> | Promise that returns no value.|
5148
5149**Error codes**
5150
5151For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5152
5153| ID| Error Message                           |
5154| -------- | --------------------------------------|
5155| 201 | Permission denied. |
5156| 202 | Permission denied, non-system app called system api. |
5157| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5158| 17700001 | The specified bundleName is not found. |
5159| 17700305 | Failed to disable the dynamic icon. |
5160
5161**Example**
5162
5163```ts
5164import { bundleManager } from '@kit.AbilityKit';
5165import { BusinessError } from '@kit.BasicServicesKit';
5166import { hilog } from '@kit.PerformanceAnalysisKit';
5167let bundleName : string = 'com.ohos.demo';
5168
5169try {
5170    bundleManager.disableDynamicIcon(bundleName).then((data) => {
5171        hilog.info(0x0000, 'testTag', 'disableDynamicIcon successfully');
5172    }).catch((err: BusinessError) => {
5173        hilog.error(0x0000, 'testTag', 'disableDynamicIcon failed. Cause: %{public}s', err.message);
5174    });
5175} catch (err) {
5176    let message = (err as BusinessError).message;
5177    hilog.error(0x0000, 'testTag', 'disableDynamicIcon failed. Cause: %{public}s', message);
5178}
5179```
5180
5181## bundleManager.getDynamicIcon<sup>12+</sup>
5182
5183getDynamicIcon(bundleName: string): Promise\<string>;
5184
5185Obtains the module name corresponding to the dynamic icon based on the specified bundle name. This API uses a promise to return the result.
5186
5187**System API**: This is a system API.
5188
5189**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
5190
5191**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5192
5193**Parameters**
5194
5195| Name    | Type  | Mandatory| Description                      |
5196| ----------- | ------ | ---- | ---------------------------- |
5197| bundleName  | string | Yes  | Bundle name based on which the extended resources are to be queried.|
5198
5199**Return value**
5200
5201| Type                                                       | Description                       |
5202| ----------------------------------------------------------- | --------------------------- |
5203| Promise\<string> | Promise used to return the API call result and module name corresponding to the dynamic icon.|
5204
5205**Error codes**
5206
5207For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5208
5209| ID| Error Message                           |
5210| -------- | --------------------------------------|
5211| 201 | Permission denied. |
5212| 202 | Permission denied, non-system app called system api. |
5213| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5214| 17700001 | The specified bundleName is not found. |
5215| 17700306 | Failed to obtain the dynamic icon. |
5216
5217**Example**
5218
5219```ts
5220import { bundleManager } from '@kit.AbilityKit';
5221import { BusinessError } from '@kit.BasicServicesKit';
5222import { hilog } from '@kit.PerformanceAnalysisKit';
5223let bundleName : string = 'com.ohos.demo';
5224
5225try {
5226    bundleManager.getDynamicIcon(bundleName).then((data) => {
5227        hilog.info(0x0000, 'testTag', 'getDynamicIcon successfully %s', JSON.stringify(data));
5228    }).catch((err: BusinessError) => {
5229        hilog.error(0x0000, 'testTag', 'getDynamicIcon failed. Cause: %{public}s', err.message);
5230    });
5231} catch (err) {
5232    let message = (err as BusinessError).message;
5233    hilog.error(0x0000, 'testTag', 'getDynamicIcon failed. Cause: %{public}s', message);
5234}
5235```
5236
5237## bundleManager.getAppCloneIdentity<sup>14+</sup>
5238
5239getAppCloneIdentity(uid: number): Promise\<AppCloneIdentity>;
5240
5241Obtains the bundle name and application index of an application clone based on the given UID. This API uses a promise to return the result.
5242
5243**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
5244
5245**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5246
5247**Parameters**
5248
5249| Name    | Type  | Mandatory| Description                      |
5250| ---------- | ------ | ---- | ---------------------------|
5251|    uid     | number |  Yes |     UID of the application.     |
5252
5253**Return value**
5254
5255| Type                                                       | Description                       |
5256| ----------------------------------------------------------- | --------------------------- |
5257| Promise\<AppCloneIdentity> | Promise used to return \<AppCloneIdentity>.|
5258
5259**Error codes**
5260
5261For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5262
5263| ID| Error Message                           |
5264| -------- | --------------------------------------|
5265| 201 | Permission denied. |
5266| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5267| 17700021 | The uid is not found. |
5268
5269**Example**
5270
5271```ts
5272import { bundleManager } from '@kit.AbilityKit';
5273import { BusinessError } from '@kit.BasicServicesKit';
5274import { hilog } from '@kit.PerformanceAnalysisKit';
5275let uid = 20010005;
5276
5277try {
5278    bundleManager.getAppCloneIdentity(uid).then((res: bundleManager.AppCloneIdentity) => {
5279        hilog.info(0x0000, 'testTag', 'getAppCloneIdentity res = %{public}s', JSON.stringify(res));
5280    }).catch((err: BusinessError) => {
5281        hilog.error(0x0000, 'testTag', 'getAppCloneIdentity failed. Cause: %{public}s', err.message);
5282    });
5283} catch (err) {
5284    let message = (err as BusinessError).message;
5285    hilog.error(0x0000, 'testTag', 'getAppCloneIdentity failed. Cause: %{public}s', message);
5286}
5287```
5288
5289## bundleManager.getAppCloneBundleInfo<sup>12+</sup>
5290
5291getAppCloneBundleInfo(bundleName: string, appIndex: number, bundleFlags: number, userId?: number): Promise\<BundleInfo>;
5292
5293Obtains the bundle information of an application or an application clone based on the given bundle name, app index, [bundleFlags](js-apis-bundleManager.md#bundleflag), and user ID. This API uses a promise to return the result.
5294
5295**System API**: This is a system API.
5296
5297**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
5298
5299**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5300
5301**Parameters**
5302
5303| Name    | Type  | Mandatory| Description                      |
5304| ---------- | ------ | ---- | ---------------------------|
5305|    bundleName     | number |  Yes |       Bundle name.     |
5306|    appIndex     | number |  Yes |       Index of the application clone.<br>The value **0** means to obtain the bundle information of the main application. A value greater than 0 means to obtain the bundle information of the application clone.     |
5307|    [bundleFlags](js-apis-bundleManager.md#bundleflag)     | number |  Yes |       Type of the bundle information to obtain.   |
5308|    userId     | number |  No |       User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.     |
5309
5310**Return value**
5311
5312| Type                                                       | Description                       |
5313| ----------------------------------------------------------- | --------------------------- |
5314| Promise\<BundleInfo> | Promise used to return the bundle information.|
5315
5316**Error codes**
5317
5318For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5319
5320| ID| Error Message                           |
5321| -------- | --------------------------------------|
5322| 201 | Permission denied. |
5323| 202 | Permission denied, non-system app called system api. |
5324| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5325| 17700001 | The specified bundleName is not found. |
5326| 17700004 | The specified userId is invalid. |
5327| 17700026 | The specified bundle is disabled. |
5328| 17700061 | The appIndex is invalid. |
5329
5330**Example**
5331
5332```ts
5333import { bundleManager } from '@kit.AbilityKit';
5334import { BusinessError } from '@kit.BasicServicesKit';
5335import { hilog } from '@kit.PerformanceAnalysisKit';
5336let bundleName = 'com.example.myapplication';
5337let appIndex = 1;
5338let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
5339
5340try {
5341    bundleManager.getAppCloneBundleInfo(bundleName, appIndex, bundleFlags).then((res: bundleManager.BundleInfo) => {
5342        hilog.info(0x0000, 'testTag', 'getAppCloneBundleInfo res: BundleInfo = %{public}s', JSON.stringify(res));
5343    }).catch((err: BusinessError) => {
5344        hilog.error(0x0000, 'testTag', 'getAppCloneBundleInfo failed. Cause: %{public}s', err.message);
5345    });
5346} catch (err) {
5347    let message = (err as BusinessError).message;
5348    hilog.error(0x0000, 'testTag', 'getAppCloneBundleInfo failed. Cause: %{public}s', message);
5349}
5350```
5351
5352## bundleManager.getAllAppCloneBundleInfo<sup>12+</sup>
5353
5354getAllAppCloneBundleInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<Array\<BundleInfo>>;
5355
5356Obtains all the bundle information of applications and application clones based on the given bundle name, [bundleFlags](js-apis-bundleManager.md#bundleflag), and user ID. This API uses a promise to return the result.
5357
5358**System API**: This is a system API.
5359
5360**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
5361
5362**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5363
5364**Parameters**
5365
5366| Name    | Type  | Mandatory| Description                      |
5367| ---------- | ------ | ---- | ---------------------------|
5368|    bundleName     | number |  Yes |       Bundle name.     |
5369|    [bundleFlags](js-apis-bundleManager.md#bundleflag)     | number |  Yes |       Type of the bundle information to obtain.   |
5370|    userId     | number |  No |       User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.     |
5371
5372**Return value**
5373
5374| Type                                                       | Description                       |
5375| ----------------------------------------------------------- | --------------------------- |
5376| Promise\<Array\<BundleInfo>> | Promise used to return all the bundle information.|
5377
5378**Error codes**
5379
5380For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5381
5382| ID| Error Message                           |
5383| -------- | --------------------------------------|
5384| 201 | Permission denied. |
5385| 202 | Permission denied, non-system app called system api. |
5386| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5387| 17700001 | The specified bundleName is not found. |
5388| 17700004 | The specified userId is invalid. |
5389| 17700026 | The specified bundle and clone apps are all disabled. |
5390
5391**Example**
5392
5393```ts
5394import { bundleManager } from '@kit.AbilityKit';
5395import { BusinessError } from '@kit.BasicServicesKit';
5396import { hilog } from '@kit.PerformanceAnalysisKit';
5397let bundleName = 'com.example.myapplication';
5398let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
5399
5400try {
5401    bundleManager.getAllAppCloneBundleInfo(bundleName, bundleFlags).then((res: Array<bundleManager.BundleInfo>) => {
5402        let index = 0;
5403        for (let item of res) {
5404            hilog.info(0x0000, 'testTag', 'getAllAppCloneBundleInfo res: BundleInfo[%{public}d] = %{public}s', index++, JSON.stringify(item));
5405        }
5406    }).catch((err: BusinessError) => {
5407        hilog.error(0x0000, 'testTag', 'getAllAppCloneBundleInfo failed. Cause: %{public}s', err.message);
5408    });
5409} catch (err) {
5410    let message = (err as BusinessError).message;
5411    hilog.error(0x0000, 'testTag', 'getAllAppCloneBundleInfo failed. Cause: %{public}s', message);
5412}
5413```
5414## bundleManager.verifyAbc<sup>11+</sup>
5415
5416verifyAbc(abcPaths: Array\<string>, deleteOriginalFiles: boolean, callback: AsyncCallback\<void>): void
5417
5418Verifies an .abc file. This API uses an asynchronous callback to return the result.
5419
5420**System API**: This is a system API.
5421
5422**Required permissions**: ohos.permission.RUN_DYN_CODE
5423
5424**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5425
5426**Parameters**
5427
5428| Name    | Type  | Mandatory| Description                      |
5429| ----------- | ------ | ---- | ---------------------------- |
5430| abcPaths  | Array\<string> | Yes  | Path of the .abc file.|
5431| deleteOriginalFiles | boolean | Yes  | Whether to delete the .abc file. The value **true** means to delete the file, and **false** means the opposite.|
5432| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the verification is successful, **err** is **undefined**; otherwise, **err** is an error object.|
5433
5434**Error codes**
5435
5436For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5437
5438| ID| Error Message                             |
5439| -------- | ------------------------------------- |
5440| 201 | Permission denied. |
5441| 202 | Permission denied, non-system app called system api. |
5442| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5443| 17700201 | Failed to verify the abc file. |
5444
5445**Example**
5446
5447```ts
5448import { bundleManager } from '@kit.AbilityKit';
5449import { BusinessError } from '@kit.BasicServicesKit';
5450import { hilog } from '@kit.PerformanceAnalysisKit';
5451
5452let abcPaths: Array<string> = ['/data/storage/el2/base/a.abc'];
5453
5454try {
5455  bundleManager.verifyAbc(abcPaths, true, (err, data) => {
5456    if (err) {
5457      hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', err.message);
5458    } else {
5459      hilog.info(0x0000, 'testTag', 'verifyAbc successfully');
5460    }
5461  });
5462} catch (err) {
5463  let message = (err as BusinessError).message;
5464  hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', message);
5465}
5466```
5467
5468## bundleManager.migrateData<sup>18+</sup>
5469
5470migrateData(sourcePaths: Array&lt;string&gt;, destinationPath: string): Promise&lt;void&gt;
5471
5472Migrates files from the source path to the destination path. This API uses a promise to return the result.
5473
5474**System API**: This is a system API.
5475
5476**Required permissions**: ohos.permission.MIGRATE_DATA
5477
5478**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5479
5480**Parameters**
5481
5482| Name      | Type  | Mandatory| Description                                                    |
5483| ----------- | ------ | ---- | -------------------------------------------------------- |
5484| sourcePaths | Array&lt;string&gt; | Yes| Array of source paths. The value can be a single file path such as **/example1/test.txt** or a directory path such as **/example2/test**.|
5485| destinationPath | string | Yes| Destination path. Only one directory path is supported, for example, **/example2/test**.|
5486
5487**Return value**
5488
5489| Type      | Description                |
5490| ---------- | -------------------- |
5491| Promise\<void> | Promise that returns no value.|
5492
5493**Error codes**
5494
5495For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5496
5497| ID| Error Message                            |
5498| -------- | ------------------------------------- |
5499| 201 | Permission denied. |
5500| 202 | Permission denied, non-system app called system api. |
5501| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5502| 17700080 | The source paths are invalid. |
5503| 17700081 | The destination path is invalid. |
5504| 17700082 | User authentication failed. |
5505| 17700083 | Waiting for user authentication timeout. |
5506| 17700084 | There are inaccessible path in the source paths. |
5507| 17700085 | The destination path cannot be accessed. |
5508| 17700086 | System error occurred during copy execution. |
5509
5510**Example**
5511
5512```ts
5513import { bundleManager } from '@kit.AbilityKit';
5514import { BusinessError } from '@kit.BasicServicesKit';
5515
5516try {
5517  // Change the values of source1, source2, and dest to the actual file or directory paths.
5518  let source1: string = "/data/app/el2/100/base/com.example.myapplication/";
5519  let source2: string = "/data/app/el2/101/base/com.example.myapplication/log.txt";
5520  let dest: string = "/data/local/tmp"
5521  let sourcePaths: Array<string> = [source1, source2];
5522
5523  bundleManager.migrateData(sourcePaths, dest)
5524    .then(() => {
5525      console.info(`migrateData succeed`);
5526    })
5527    .catch((err: BusinessError) => {
5528      console.error(`migrateData err : `, JSON.stringify(err));
5529    })
5530} catch(err) {
5531  console.error(`migrateData call err : `, JSON.stringify(err));
5532}
5533```
5534
5535## bundleManager.verifyAbc<sup>11+</sup>
5536
5537verifyAbc(abcPaths: Array\<string>, deleteOriginalFiles: boolean): Promise\<void>
5538
5539Verifies an .abc file. This API uses a promise to return the result.
5540
5541**System API**: This is a system API.
5542
5543**Required permissions**: ohos.permission.RUN_DYN_CODE
5544
5545**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5546
5547**Parameters**
5548
5549| Name    | Type  | Mandatory| Description                      |
5550| ----------- | ------ | ---- | ---------------------------- |
5551| abcPaths  | Array\<string> | Yes  | Path of the .abc file.|
5552| deleteOriginalFiles | boolean | Yes  | Whether to delete the .abc file. The value **true** means to delete the file, and **false** means the opposite.      |
5553
5554**Return value**
5555
5556| Type                                                       | Description                       |
5557| ----------------------------------------------------------- | --------------------------- |
5558| Promise\<void> | Promise that returns no value.|
5559
5560**Error codes**
5561
5562For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5563
5564| ID| Error Message                           |
5565| -------- | --------------------------------------|
5566| 201 | Permission denied. |
5567| 202 | Permission denied, non-system app called system api. |
5568| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5569| 17700201 | Failed to verify the abc file. |
5570
5571**Example**
5572
5573```ts
5574import { bundleManager } from '@kit.AbilityKit';
5575import { BusinessError } from '@kit.BasicServicesKit';
5576import { hilog } from '@kit.PerformanceAnalysisKit';
5577
5578let abcPaths: Array<string> = ['/data/storage/el2/base/a.abc'];
5579
5580try {
5581  bundleManager.verifyAbc(abcPaths, true).then((data) => {
5582    hilog.info(0x0000, 'testTag', 'verifyAbc successfully');
5583  }).catch((err: BusinessError) => {
5584    hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', err.message);
5585  });
5586} catch (err) {
5587  let message = (err as BusinessError).message;
5588  hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', message);
5589}
5590```
5591
5592## bundleManager.deleteAbc<sup>11+</sup>
5593
5594deleteAbc(abcPath: string): Promise\<void>
5595
5596Deletes an .abc file based on the specified file path. This API uses a promise to return the result.
5597
5598**System API**: This is a system API.
5599
5600**Required permissions**: ohos.permission.RUN_DYN_CODE
5601
5602**System capability**: SystemCapability.BundleManager.BundleFramework.Core
5603
5604**Parameters**
5605
5606| Name    | Type  | Mandatory| Description                      |
5607| ----------- | ------ | ---- | ---------------------------- |
5608| abcPath  | string | Yes  | Path of the .abc file.|
5609
5610**Return value**
5611
5612| Type                                                       | Description                       |
5613| ----------------------------------------------------------- | --------------------------- |
5614| Promise\<void> | Promise that returns no value.|
5615
5616**Error codes**
5617
5618For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md).
5619
5620| ID| Error Message                           |
5621| -------- | --------------------------------------|
5622| 201 | Permission denied. |
5623| 202 | Permission denied, non-system app called system api. |
5624| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
5625| 17700202 | Failed to delete the abc file. |
5626
5627**Example**
5628
5629```ts
5630import { bundleManager } from '@kit.AbilityKit';
5631import { BusinessError } from '@kit.BasicServicesKit';
5632import { hilog } from '@kit.PerformanceAnalysisKit';
5633
5634let abcPath: string = '/data/storage/el2/base/a.abc';
5635
5636try {
5637  bundleManager.deleteAbc(abcPath).then((data) => {
5638    hilog.info(0x0000, 'testTag', 'deleteAbc successfully');
5639  }).catch((err: BusinessError) => {
5640    hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', err.message);
5641  });
5642} catch (err) {
5643  let message = (err as BusinessError).message;
5644  hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', message);
5645}
5646```
5647