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