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