• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.bundleManager (bundleManager模块)(系统接口)
2
3本模块提供应用信息查询能力,支持BundleInfo、ApplicationInfo、Ability、ExtensionAbility等信息的查询。
4
5> **说明:**
6>
7> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8>
9> 当前页面仅包含本模块的系统接口,其他公开接口参见[`@ohos.bundle.bundleManager`](js-apis-bundleManager.md)。
10
11## 导入模块
12
13```ts
14import bundleManager from '@ohos.bundle.bundleManager';
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权限等级参考[权限等级说明](../../security/AccessToken/app-permission-mgmt-overview.md#权限apl等级)。
28
29## 枚举
30
31### ApplicationFlag
32
33应用信息标志,指示需要获取的应用信息的内容。
34
35 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core36
37 **系统接口:** 此接口为系统接口。
38
39| 名称                                 | 值         | 说明                                                         |
40| ------------------------------------ | ---------- | ------------------------------------------------------------ |
41| GET_APPLICATION_INFO_DEFAULT         | 0x00000000 | 用于获取默认的applicationInfo,获取的applicationInfo不包含permission和metadata信息。 |
42| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | 用于获取包含permission的applicationInfo。                    |
43| GET_APPLICATION_INFO_WITH_METADATA   | 0x00000002 | 用于获取包含metadata的applicationInfo。                      |
44| GET_APPLICATION_INFO_WITH_DISABLE    | 0x00000004 | 用于获取包含禁用应用程序的applicationInfo。                  |
45
46### AbilityFlag
47
48Ability组件信息标志,指示需要获取的Ability组件信息的内容。
49
50 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core51
52 **系统接口:** 此接口为系统接口。
53
54| 名称                              | 值         | 说明                                                         |
55| --------------------------------- | ---------- | ------------------------------------------------------------ |
56| GET_ABILITY_INFO_DEFAULT          | 0x00000000 | 用于获取默认abilityInfo,获取的abilityInfo不包含permission、metadata和禁用的abilityInfo。 |
57| GET_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | 用于获取包含permission的abilityInfo。                          |
58| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | 用于获取包含applicationInfo的abilityInfo。                     |
59| GET_ABILITY_INFO_WITH_METADATA    | 0x00000004 | 用于获取包含metadata的abilityInfo。                            |
60| GET_ABILITY_INFO_WITH_DISABLE     | 0x00000008 | 用于获取包含禁用的abilityInfo的abilityInfo。                   |
61| GET_ABILITY_INFO_ONLY_SYSTEM_APP  | 0x00000010 | 用于仅为系统应用程序获取abilityInfo。                         |
62
63### ExtensionAbilityFlag
64
65扩展组件信息标志,指示需要获取的扩展组件信息的内容。
66
67 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core68
69 **系统接口:** 此接口为系统接口。
70
71| 名称                                        | 值         | 说明                                                         |
72| ------------------------------------------- | ---------- | ------------------------------------------------------------ |
73| GET_EXTENSION_ABILITY_INFO_DEFAULT          | 0x00000000 | 用于获取默认extensionAbilityInfo。获取的extensionAbilityInfo不包含permission、metadata 和禁用的abilityInfo。 |
74| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION  | 0x00000001 | 用于获取包含permission的extensionAbilityInfo。               |
75| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | 用于获取包含applicationInfo的extensionAbilityInfo。         |
76| GET_EXTENSION_ABILITY_INFO_WITH_METADATA    | 0x00000004 | 用于获取包含metadata的extensionAbilityInfo。                 |
77
78### ProfileType<sup>11+</sup>
79
80标识配置文件类型。
81
82 **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
83
84 **系统接口:** 此接口为系统接口。
85
86| 名称           | 值   | 说明            |
87| -------------- | ---- | --------------- |
88| INTENT_PROFILE  | 1    | 意图框架配置文件。    |
89
90## 接口
91
92### bundleManager.getBundleInfo
93
94getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void
95
96以异步方法根据给定的bundleName、bundleFlags和userId获取BundleInfo,使用callback形式返回结果。
97
98获取调用方自己的信息时不需要权限。
99
100**系统接口:** 此接口为系统接口。
101
102**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
103
104**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
105
106**参数:**
107
108| 参数名  | 类型   | 必填 | 说明                       |
109| ----------- | ------ | ---- | ---------------------------- |
110| bundleName  | string | 是   | 表示要查询的应用Bundle名称。 |
111| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 指定返回的BundleInfo所包含的信息。|
112| userId      | number | 是   | 表示用户ID。  |
113| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的bundleInfo;否则为错误对象。 |
114
115**错误码:**
116
117以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
118
119| 错误码ID | 错误信息                              |
120| -------- | ------------------------------------- |
121| 17700001 | The specified bundleName is not found. |
122| 17700004 | The specified user ID is not found.     |
123| 17700026 | The specified bundle is disabled.      |
124
125**示例:**
126
127```ts
128// 额外获取AbilityInfo
129import bundleManager from '@ohos.bundle.bundleManager';
130import { BusinessError } from '@ohos.base';
131import hilog from '@ohos.hilog';
132let bundleName = 'com.example.myapplication';
133let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
134let userId = 100;
135
136try {
137    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
138        if (err) {
139            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
140        } else {
141            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
142        }
143    });
144} catch (err) {
145    let message = (err as BusinessError).message;
146    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
147}
148```
149
150```ts
151// 额外获取ApplicationInfo中的metadata
152import bundleManager from '@ohos.bundle.bundleManager';
153import { BusinessError } from '@ohos.base';
154import hilog from '@ohos.hilog';
155let bundleName = 'com.example.myapplication';
156let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA;
157let userId = 100;
158
159try {
160    bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
161        if (err) {
162            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
163        } else {
164            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
165        }
166    });
167} catch (err) {
168    let message = (err as BusinessError).message;
169    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
170}
171```
172
173### bundleManager.getBundleInfo
174
175getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
176
177以异步方法根据给定的bundleName和bundleFlags获取BundleInfo,使用callback形式返回结果。
178
179获取调用方自己的信息时不需要权限。
180
181**系统接口:** 此接口为系统接口。
182
183**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
184
185**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
186
187**参数:**
188
189| 参数名     | 类型   | 必填 | 说明                       |
190| ----------- | ------ | ---- | ---------------------------- |
191| bundleName  | string | 是   | 表示要查询的应用Bundle名称。 |
192| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 指定返回的BundleInfo所包含的信息。|
193| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleInfo;否则为错误对象。 |
194
195**错误码:**
196
197以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
198
199| 错误码ID | 错误信息                              |
200| -------- | ------------------------------------- |
201| 17700001 | The specified bundleName is not found. |
202| 17700026 | The specified bundle is disabled.      |
203
204**示例:**
205
206```ts
207// 额外获取extensionAbility
208import bundleManager from '@ohos.bundle.bundleManager';
209import { BusinessError } from '@ohos.base';
210import hilog from '@ohos.hilog';
211let bundleName = 'com.example.myapplication';
212let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY;
213
214try {
215    bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => {
216        if (err) {
217            hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message);
218        } else {
219            hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data));
220        }
221    });
222} catch (err) {
223    let message = (err as BusinessError).message;
224    hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message);
225}
226```
227
228### bundleManager.getBundleInfo
229
230getBundleInfo(bundleName: string, bundleFlags: [number](js-apis-bundleManager.md#bundleflag), userId?: number): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>
231
232以异步方法根据给定的bundleName、bundleFlags和userId获取BundleInfo,使用Promise形式返回结果。
233
234获取调用方自己的信息时不需要权限。
235
236**系统接口:** 此接口为系统接口。
237
238**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
239
240**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
241
242**参数:**
243
244| 参数名     | 类型   | 必填 | 说明                       |
245| ----------- | ------ | ---- | ---------------------------- |
246| bundleName  | string | 是   | 表示要查询的应用Bundle名称。 |
247| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 指定返回的BundleInfo所包含的信息。       |
248| userId      | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。  |
249
250**返回值:**
251
252| 类型                                                        | 说明                        |
253| ----------------------------------------------------------- | --------------------------- |
254| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回BundleInfo。 |
255
256**错误码:**
257
258以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
259
260| 错误码ID | 错误信息                            |
261| -------- | --------------------------------------|
262| 17700001 | The specified bundleName is not found. |
263| 17700004 | The specified user ID is not found.     |
264| 17700026 | The specified bundle is disabled.      |
265
266**示例:**
267
268```ts
269// 额外获取ApplicationInfo和SignatureInfo
270import bundleManager from '@ohos.bundle.bundleManager';
271import { BusinessError } from '@ohos.base';
272import hilog from '@ohos.hilog';
273let bundleName = 'com.example.myapplication';
274let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
275let userId = 100;
276
277try {
278    bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => {
279        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
280    }).catch((err: BusinessError) => {
281        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
282    });
283} catch (err) {
284    let message = (err as BusinessError).message;
285    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
286}
287```
288
289```ts
290import bundleManager from '@ohos.bundle.bundleManager';
291import { BusinessError } from '@ohos.base';
292import hilog from '@ohos.hilog';
293let bundleName = 'com.example.myapplication';
294let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
295
296try {
297    bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => {
298        hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
299    }).catch((err: BusinessError) => {
300        hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message);
301    });
302} catch (err) {
303    let message = (err as BusinessError).message;
304    hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message);
305}
306
307```
308
309### bundleManager.getApplicationInfo
310
311getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void
312
313以异步方法根据给定的bundleName、appFlags和userId获取ApplicationInfo,使用callback形式返回结果。
314
315获取调用方自己的信息时不需要权限。
316
317**系统接口:** 此接口为系统接口。
318
319**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
320
321**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
322
323**参数:**
324
325| 参数名    | 类型   | 必填 | 说明                       |
326| ---------- | ------ | ---- | ---------------------------- |
327| bundleName | string | 是   | 表示要查询的应用Bundle名称。 |
328| appFlags   | [number](#applicationflag) | 是   | 指定返回的ApplicationInfo所包含的信息。    |
329| userId     | number | 是   | 表示用户ID。  |
330| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象。 |
331
332**错误码:**
333
334以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
335
336| 错误码ID | 错误信息                             |
337| -------- | --------------------------------------|
338| 17700001 | The specified bundleName is not found. |
339| 17700004 | The specified user ID is not found.     |
340| 17700026 | The specified bundle is disabled.      |
341
342**示例:**
343
344```ts
345import bundleManager from '@ohos.bundle.bundleManager';
346import { BusinessError } from '@ohos.base';
347import hilog from '@ohos.hilog';
348let bundleName = 'com.example.myapplication';
349let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
350let userId = 100;
351
352try {
353    bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => {
354        if (err) {
355            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
356        } else {
357            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
358        }
359    });
360} catch (err) {
361    let message = (err as BusinessError).message;
362    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
363}
364```
365
366### bundleManager.getApplicationInfo
367
368getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void
369
370以异步方法根据给定的bundleName和appFlags获取ApplicationInfo,使用callback形式返回结果。
371
372获取调用方自己的信息时不需要权限。
373
374**系统接口:** 此接口为系统接口。
375
376**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
377
378**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
379
380**参数:**
381
382| 参数名    | 类型   | 必填 | 说明                       |
383| ---------- | ------ | ---- | ---------------------------- |
384| bundleName | string | 是   | 表示要查询的应用Bundle名称。 |
385| appFlags   | [number](#applicationflag) | 是   | 指定返回的ApplicationInfo所包含的信息。    |
386| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的ApplicationInfo;否则为错误对象。 |
387
388**错误码:**
389
390以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
391
392| 错误码ID | 错误信息                             |
393| -------- | --------------------------------------|
394| 17700001 | The specified bundleName is not found. |
395| 17700026 | The specified bundle is disabled.      |
396
397**示例:**
398
399```ts
400import bundleManager from '@ohos.bundle.bundleManager';
401import { BusinessError } from '@ohos.base';
402import hilog from '@ohos.hilog';
403let bundleName = 'com.example.myapplication';
404let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
405
406try {
407    bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => {
408        if (err) {
409            hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message);
410        } else {
411            hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data));
412        }
413    });
414} catch (err) {
415    let message = (err as BusinessError).message;
416    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message);
417}
418```
419
420### bundleManager.getApplicationInfo
421
422getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId?: number): Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>
423
424以异步方法根据给定的bundleName、appFlags和userId获取ApplicationInfo,使用Promise形式返回结果。
425
426获取调用方自己的信息时不需要权限。
427
428**系统接口:** 此接口为系统接口。
429
430**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
431
432**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
433
434**参数:**
435
436| 参数名    | 类型   | 必填 | 说明                       |
437| ---------- | ------ | ---- | ---------------------------- |
438| bundleName | string | 是   | 表示要查询的应用Bundle名称。 |
439| appFlags   | [number](#applicationflag) | 是   | 指定返回的ApplicationInfo所包含的信息。    |
440| userId     | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。 |
441
442**返回值:**
443
444| 类型                                                         | 说明                             |
445| ------------------------------------------------------------ | -------------------------------- |
446| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise对象,返回ApplicationInfo。 |
447
448**错误码:**
449
450以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
451
452| 错误码ID | 错误信息                             |
453| -------- | ------------------------------------- |
454| 17700001 | The specified bundleName is not found. |
455| 17700004 | The specified user ID is not found.     |
456| 17700026 | The specified bundle is disabled.      |
457
458**示例:**
459
460```ts
461import bundleManager from '@ohos.bundle.bundleManager';
462import { BusinessError } from '@ohos.base';
463import hilog from '@ohos.hilog';
464let bundleName = 'com.example.myapplication';
465let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
466let userId = 100;
467
468try {
469    bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => {
470        hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
471    }).catch((err: BusinessError) => {
472        hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message);
473    });
474} catch (err) {
475    let message = (err as BusinessError).message;
476    hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', message);
477}
478```
479
480### bundleManager.getAllBundleInfo
481
482getAllBundleInfo(bundleFlags: [number](js-apis-bundleManager.md#bundleflag), userId: number, callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void
483
484以异步方法根据给定的bundleFlags和userId获取系统中所有的BundleInfo,使用callback形式返回结果。
485
486**系统接口:** 此接口为系统接口。
487
488**需要权限:** ohos.permission.GET_INSTALLED_BUNDLE_LIST
489
490**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
491
492**参数:**
493
494| 参数名     | 类型   | 必填 | 说明                                             |
495| ----------- | ------ | ---- | -------------------------------------------------- |
496| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 指定返回的BundleInfo所包含的信息。                    |
497| userId      | number | 是   | 表示用户ID。                      |
498| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<BundleInfo>;否则为错误对象。 |
499
500**错误码:**
501
502以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
503
504| 错误码ID | 错误信息                         |
505| -------- | --------------------------------- |
506| 17700004 | The specified user ID is not found. |
507
508**示例:**
509
510```ts
511import bundleManager from '@ohos.bundle.bundleManager';
512import { BusinessError } from '@ohos.base';
513import hilog from '@ohos.hilog';
514let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
515let userId = 100;
516
517try {
518    bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => {
519        if (err) {
520            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
521        } else {
522            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
523        }
524    });
525} catch (err) {
526    let message = (err as BusinessError).message;
527    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
528}
529```
530
531### bundleManager.getAllBundleInfo
532
533getAllBundleInfo(bundleFlags: [number](js-apis-bundleManager.md#bundleflag), callback: AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>): void
534
535以异步方法根据给定的bundleFlags获取系统中所有的BundleInfo,使用callback形式返回结果。
536
537**系统接口:** 此接口为系统接口。
538
539**需要权限:** ohos.permission.GET_INSTALLED_BUNDLE_LIST
540
541**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
542
543**参数:**
544
545| 参数名     | 类型   | 必填 | 说明                                             |
546| ----------- | ------ | ---- | -------------------------------------------------- |
547| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 指定返回的BundleInfo所包含的信息。   |
548| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<BundleInfo>;否则为错误对象。 |
549
550**示例:**
551
552```ts
553import bundleManager from '@ohos.bundle.bundleManager';
554import { BusinessError } from '@ohos.base';
555import hilog from '@ohos.hilog';
556let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
557
558try {
559    bundleManager.getAllBundleInfo(bundleFlags, (err, data) => {
560        if (err) {
561            hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message);
562        } else {
563            hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data));
564        }
565    });
566} catch (err) {
567    let message = (err as BusinessError).message;
568    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message);
569}
570```
571
572### bundleManager.getAllBundleInfo
573
574getAllBundleInfo(bundleFlags: [number](js-apis-bundleManager.md#bundleflag), userId?: number): Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>>
575
576以异步方法根据给定的bundleFlags和userId获取系统中所有的BundleInfo,使用Promise形式返回结果。
577
578**系统接口:** 此接口为系统接口。
579
580**需要权限:** ohos.permission.GET_INSTALLED_BUNDLE_LIST
581
582**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
583
584**参数:**
585
586| 参数名     | 类型   | 必填 | 说明                                             |
587| ----------- | ------ | ---- | -------------------------------------------------- |
588| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 指定返回的BundleInfo所包含的信息。                   |
589| userId      | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。                      |
590
591**返回值:**
592
593| 类型                                                         | 说明                                |
594| ------------------------------------------------------------ | ----------------------------------- |
595| Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Promise对象,返回Array\<BundleInfo>。 |
596
597**错误码:**
598
599以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
600
601| 错误码ID | 错误信息                         |
602| -------- | ---------------------------------- |
603| 17700004 | The specified user ID is not found. |
604
605**示例:**
606
607```ts
608import bundleManager from '@ohos.bundle.bundleManager';
609import { BusinessError } from '@ohos.base';
610import hilog from '@ohos.hilog';
611let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
612
613try {
614    bundleManager.getAllBundleInfo(bundleFlags).then((data) => {
615        hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
616    }).catch((err: BusinessError) => {
617        hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message);
618    });
619} catch (err) {
620    let message = (err as BusinessError).message;
621    hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', message);
622}
623```
624
625### bundleManager.getAllApplicationInfo
626
627getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void
628
629以异步方法根据给定的appFlags和userId获取系统中所有的ApplicationInfo,使用callback形式返回结果。
630
631**系统接口:** 此接口为系统接口。
632
633**需要权限:** ohos.permission.GET_INSTALLED_BUNDLE_LIST
634
635**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
636
637**参数:**
638
639| 参数名  | 类型   | 必填 | 说明                                                      |
640| -------- | ------ | ---- | ----------------------------------------------------------- |
641| appFlags | [number](#applicationflag) | 是   | 指定返回的ApplicationInfo所包含的信息。                       |
642| userId   | number | 是   | 表示用户ID。         |
643| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<ApplicationInfo>;否则为错误对象。 |
644
645**错误码:**
646
647以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
648
649| 错误码ID | 错误信息                         |
650| -------- | ---------------------------------- |
651| 17700004 | The specified user ID is not found. |
652
653**示例:**
654
655```ts
656import bundleManager from '@ohos.bundle.bundleManager';
657import { BusinessError } from '@ohos.base';
658import hilog from '@ohos.hilog';
659let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
660let userId = 100;
661
662try {
663    bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => {
664        if (err) {
665            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
666        } else {
667            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
668        }
669    });
670} catch (err) {
671    let message = (err as BusinessError).message;
672    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
673}
674```
675
676### bundleManager.getAllApplicationInfo
677
678getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>): void
679
680以异步方法根据给定的appFlags获取系统中所有的ApplicationInfo,使用callback形式返回结果。
681
682**系统接口:** 此接口为系统接口。
683
684**需要权限:** ohos.permission.GET_INSTALLED_BUNDLE_LIST
685
686**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
687
688**参数:**
689
690| 参数名  | 类型   | 必填 | 说明                                                      |
691| -------- | ------ | ---- | ----------------------------------------------------------- |
692| appFlags | [number](#applicationflag) | 是   | 指定返回的ApplicationInfo所包含的信息。                       |
693| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<ApplicationInfo>;否则为错误对象。 |
694
695**示例:**
696
697```ts
698import bundleManager from '@ohos.bundle.bundleManager';
699import { BusinessError } from '@ohos.base';
700import hilog from '@ohos.hilog';
701let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
702
703try {
704    bundleManager.getAllApplicationInfo(appFlags, (err, data) => {
705        if (err) {
706            hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message);
707        } else {
708            hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data));
709        }
710    });
711} catch (err) {
712    let message = (err as BusinessError).message;
713    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message);
714}
715```
716
717### bundleManager.getAllApplicationInfo
718
719getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>>
720
721以异步方法根据给定的appFlags和userId获取系统中所有的ApplicationInfo,使用Promise形式返回结果。
722
723**系统接口:** 此接口为系统接口。
724
725**需要权限:** ohos.permission.GET_INSTALLED_BUNDLE_LIST
726
727**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
728
729**参数:**
730
731| 参数名  | 类型   | 必填 | 说明                                                      |
732| -------- | ------ | ---- | ---------------------------------------------------------- |
733| appFlags | [number](#applicationflag) | 是   | 指定返回的ApplicationInfo所包含的信息。                       |
734| userId   | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。                        |
735
736**返回值:**
737
738| 类型                                                         | 说明                                     |
739| ------------------------------------------------------------ | ---------------------------------------- |
740| Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Promise对象,返回Array\<ApplicationInfo>。 |
741
742**错误码:**
743
744以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
745
746| 错误码ID | 错误信息                         |
747| -------- | ---------------------------------- |
748| 17700004 | The specified user ID is not found. |
749
750**示例:**
751
752```ts
753import bundleManager from '@ohos.bundle.bundleManager';
754import { BusinessError } from '@ohos.base';
755import hilog from '@ohos.hilog';
756let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
757
758try {
759    bundleManager.getAllApplicationInfo(appFlags).then((data) => {
760        hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data));
761    }).catch((err: BusinessError) => {
762        hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message);
763    });
764} catch (err) {
765    let message = (err as BusinessError).message;
766    hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', message);
767}
768
769```
770
771### bundleManager.queryAbilityInfo
772
773queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: number, callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void
774
775以异步方法根据给定的want、abilityFlags和userId获取多个AbilityInfo,使用callback形式返回结果。
776
777**系统接口:** 此接口为系统接口。
778
779**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
780
781**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
782
783**参数:**
784
785| 参数名      | 类型   | 必填 | 说明                                                  |
786| ------------ | ------ | ---- | ------------------------------------------------------- |
787| want         | Want   | 是   | 表示包含要查询的应用Bundle名称的Want。                 |
788| abilityFlags | [number](#abilityflag) | 是   | 指定返回的AbilityInfo所包含的信息。                       |
789| userId       | number | 是   | 表示用户ID。                               |
790| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象。 |
791
792**错误码:**
793
794以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
795
796| 错误码ID | 错误信息                             |
797| -------- | -------------------------------------- |
798| 17700001 | The specified bundleName is not found. |
799| 17700003 | The specified ability is not found.    |
800| 17700004 | The specified userId is invalid.       |
801| 17700026 | The specified bundle is disabled.      |
802| 17700029 | The specified ability is disabled.     |
803
804**示例:**
805
806```ts
807import bundleManager from '@ohos.bundle.bundleManager';
808import { BusinessError } from '@ohos.base';
809import hilog from '@ohos.hilog';
810import Want from '@ohos.app.ability.Want';
811let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
812let userId = 100;
813let want: Want = {
814    bundleName : "com.example.myapplication",
815    abilityName : "EntryAbility"
816};
817
818try {
819    bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => {
820        if (err) {
821            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
822        } else {
823            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
824        }
825    });
826} catch (err) {
827    let message = (err as BusinessError).message;
828    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
829}
830```
831
832### bundleManager.queryAbilityInfo
833
834queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>): void
835
836以异步方法根据给定的want和abilityFlags获取一个或多个AbilityInfo,使用callback形式返回结果。
837
838**系统接口:** 此接口为系统接口。
839
840**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
841
842**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
843
844**参数:**
845
846| 参数名      | 类型   | 必填 | 说明                                                  |
847| ------------ | ------ | ---- | -------------------------------------------------------|
848| want         | Want   | 是   | 表示包含要查询的应用Bundle名称的Want。                 |
849| abilityFlags | [number](#abilityflag) | 是   | 指定返回的AbilityInfo所包含的信息。       |
850| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<AbilityInfo>;否则为错误对象。 |
851
852**错误码:**
853
854以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
855
856| 错误码ID | 错误信息                             |
857| -------- | -------------------------------------- |
858| 17700001 | The specified bundleName is not found. |
859| 17700003 | The specified ability is not found.    |
860| 17700026 | The specified bundle is disabled.      |
861| 17700029 | The specified ability is disabled.     |
862
863**示例:**
864
865```ts
866import bundleManager from '@ohos.bundle.bundleManager';
867import { BusinessError } from '@ohos.base';
868import hilog from '@ohos.hilog';
869import Want from '@ohos.app.ability.Want';
870let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
871let want: Want = {
872    bundleName : "com.example.myapplication",
873    abilityName : "EntryAbility"
874};
875
876try {
877    bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => {
878        if (err) {
879            hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message);
880        } else {
881            hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data));
882        }
883    });
884} catch (err) {
885    let message = (err as BusinessError).message;
886    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message);
887}
888```
889
890### bundleManager.queryAbilityInfo
891
892queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>>
893
894以异步方法根据给定的want、abilityFlags和userId获取一个或多个AbilityInfo,使用Promise形式返回结果。
895
896**系统接口:** 此接口为系统接口。
897
898**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
899
900**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
901
902**参数:**
903
904| 参数名      | 类型   | 必填 | 说明                                                  |
905| ------------ | ------ | ---- | ------------------------------------------------------- |
906| want         | Want   | 是   | 表示包含要查询的应用Bundle名称的Want。                 |
907| abilityFlags | [number](#abilityflag) | 是   | 表示指定返回的AbilityInfo所包含的信息。 |
908| userId       | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。                       |
909
910**返回值:**
911
912| 类型                                                         | 说明                                 |
913| ------------------------------------------------------------ | ------------------------------------ |
914| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise对象,返回Array\<AbilityInfo>。 |
915
916**错误码:**
917
918以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
919
920| 错误码ID | 错误信息                             |
921| -------- | ------------------------------------- |
922| 17700001 | The specified bundleName is not found. |
923| 17700003 | The specified ability is not found.    |
924| 17700004 | The specified userId is invalid.       |
925| 17700026 | The specified bundle is disabled.      |
926| 17700029 | The specified ability is disabled.     |
927
928**示例:**
929
930```ts
931import bundleManager from '@ohos.bundle.bundleManager';
932import { BusinessError } from '@ohos.base';
933import hilog from '@ohos.hilog';
934import Want from '@ohos.app.ability.Want';
935let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
936let userId = 100;
937let want: Want = {
938    bundleName : "com.example.myapplication",
939    abilityName : "EntryAbility"
940};
941
942try {
943    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => {
944        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
945    }).catch((err: BusinessError) => {
946        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
947    });
948} catch (err) {
949    let message = (err as BusinessError).message;
950    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
951}
952```
953
954```ts
955import bundleManager from '@ohos.bundle.bundleManager';
956import { BusinessError } from '@ohos.base';
957import hilog from '@ohos.hilog';
958import Want from '@ohos.app.ability.Want';
959let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
960let want: Want = {
961    bundleName : "com.example.myapplication",
962    abilityName : "EntryAbility"
963};
964
965try {
966    bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => {
967        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
968    }).catch((err: BusinessError) => {
969        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
970    })
971} catch (err) {
972    let message = (err as BusinessError).message;
973    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
974}
975```
976
977### bundleManager.queryAbilityInfoSync<sup>10+</sup>
978
979queryAbilityInfoSync(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>
980
981以同步方法根据给定的want、abilityFlags和userId获取一个或多个AbilityInfo。
982
983**系统接口:** 此接口为系统接口。
984
985**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
986
987**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
988
989**参数:**
990
991| 参数名      | 类型   | 必填 | 说明                                                  |
992| ------------ | ------ | ---- | ------------------------------------------------------- |
993| want         | Want   | 是   | 表示包含要查询的应用Bundle名称的Want。                 |
994| abilityFlags | [number](#abilityflag) | 是   | 表示指定返回的AbilityInfo所包含的信息。 |
995| userId       | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。                       |
996
997**返回值:**
998
999| 类型                                                         | 说明                                 |
1000| ------------------------------------------------------------ | ------------------------------------ |
1001| Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | Array\<AbilityInfo>信息。 |
1002
1003**错误码:**
1004
1005以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1006
1007| 错误码ID | 错误信息                             |
1008| -------- | ------------------------------------- |
1009| 17700001 | The specified bundleName is not found. |
1010| 17700003 | The specified ability is not found.    |
1011| 17700004 | The specified userId is invalid.       |
1012| 17700026 | The specified bundle is disabled.      |
1013| 17700029 | The specified ability is disabled.     |
1014
1015**示例:**
1016
1017```ts
1018import bundleManager from '@ohos.bundle.bundleManager';
1019import { BusinessError } from '@ohos.base';
1020import hilog from '@ohos.hilog';
1021import Want from '@ohos.app.ability.Want';
1022let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1023let userId = 100;
1024let want: Want = {
1025    bundleName : "com.example.myapplication",
1026    abilityName : "EntryAbility"
1027};
1028
1029try {
1030
1031    let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags, userId);
1032    hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
1033} catch (err) {
1034    let message = (err as BusinessError).message;
1035    hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
1036}
1037```
1038
1039```ts
1040import bundleManager from '@ohos.bundle.bundleManager';
1041import { BusinessError } from '@ohos.base';
1042import hilog from '@ohos.hilog';
1043import Want from '@ohos.app.ability.Want';
1044let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1045let want: Want = {
1046    bundleName : "com.example.myapplication",
1047    abilityName : "EntryAbility"
1048};
1049
1050try {
1051    let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags);
1052    hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos));
1053} catch (err) {
1054    let message = (err as BusinessError).message;
1055    hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message);
1056}
1057```
1058
1059### bundleManager.queryExtensionAbilityInfo
1060
1061queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId: number, callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void
1062
1063以异步方法根据给定的want、extensionAbilityType、extensionAbilityFlags和userId获取一个或多个ExtensionAbilityInfo,使用callback形式返回结果。
1064
1065**系统接口:** 此接口为系统接口。
1066
1067**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1068
1069**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1070
1071**参数:**
1072
1073| 参数名                | 类型                                                         | 必填 | 说明                                                         |
1074| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1075| want                  | Want                                                         | 是   | 表示包含要查询的应用Bundle名称的Want。                       |
1076| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype)                | 是   | 标识extensionAbility的类型。                                 |
1077| extensionAbilityFlags | [number](#extensionabilityflag)                              | 是   | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。    |
1078| userId                | number                                                       | 是   | 表示用户ID。                                                 |
1079| callback              | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是   | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象。 |
1080
1081**错误码:**
1082
1083以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1084
1085| 错误码ID | 错误信息                                    |
1086| -------- | ------------------------------------------- |
1087| 17700001 | The specified bundleName is not found.       |
1088| 17700003 | The specified extensionAbility is not found. |
1089| 17700004 | The specified userId is invalid.             |
1090| 17700026 | The specified bundle is disabled.            |
1091
1092**示例:**
1093
1094```ts
1095import bundleManager from '@ohos.bundle.bundleManager';
1096import { BusinessError } from '@ohos.base';
1097import hilog from '@ohos.hilog';
1098import Want from '@ohos.app.ability.Want';
1099let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1100let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1101let userId = 100;
1102let want: Want = {
1103    bundleName : "com.example.myapplication",
1104    abilityName : "EntryAbility"
1105};
1106
1107try {
1108    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => {
1109        if (err) {
1110            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1111        } else {
1112            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1113        }
1114    });
1115} catch (err) {
1116    let message = (err as BusinessError).message;
1117    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
1118}
1119```
1120
1121### bundleManager.queryExtensionAbilityInfo
1122
1123queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), callback: AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>): void
1124
1125以异步方法根据给定的want、extensionAbilityType和extensionAbilityFlags获取一个或多个ExtensionAbilityInfo,使用callback形式返回结果。
1126
1127**系统接口:** 此接口为系统接口。
1128
1129**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1130
1131**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1132
1133**参数:**
1134
1135| 参数名                | 类型                                                         | 必填 | 说明                                                         |
1136| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1137| want                  | Want                                                         | 是   | 表示包含要查询的应用Bundle名称的Want。                       |
1138| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype)                | 是   | 标识extensionAbility的类型。                                 |
1139| extensionAbilityFlags | [number](#extensionabilityflag)                              | 是   | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。    |
1140| callback              | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | 是   | 回调函数,当获取成功时,err为null,data为获取到Array\<ExtensionAbilityInfo>;否则为错误对象。 |
1141
1142**错误码:**
1143
1144以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1145
1146| 错误码ID | 错误信息                                     |
1147| -------- | -------------------------------------------- |
1148| 17700001 | The specified bundleName is not found.       |
1149| 17700003 | The specified extensionAbility is not found. |
1150| 17700026 | The specified bundle is disabled.            |
1151
1152**示例:**
1153
1154```ts
1155import bundleManager from '@ohos.bundle.bundleManager';
1156import { BusinessError } from '@ohos.base';
1157import hilog from '@ohos.hilog';
1158import Want from '@ohos.app.ability.Want';
1159let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1160let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1161let want: Want = {
1162    bundleName : "com.example.myapplication",
1163    abilityName : "EntryAbility"
1164};
1165
1166try {
1167    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => {
1168        if (err) {
1169            hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message);
1170        } else {
1171            hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data));
1172        }
1173    });
1174} catch (err) {
1175    let message = (err as BusinessError).message;
1176    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message);
1177}
1178```
1179
1180### bundleManager.queryExtensionAbilityInfo
1181
1182queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>>
1183
1184以异步方法根据给定的want、extensionAbilityType、extensionAbilityFlags和userId获取ExtensionAbilityInfo,使用Promise形式返回结果。
1185
1186**系统接口:** 此接口为系统接口。
1187
1188**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1189
1190**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1191
1192**参数:**
1193
1194| 参数名                | 类型                                          | 必填 | 说明                                                      |
1195| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1196| want                  | Want                                          | 是   | 表示包含要查询的应用Bundle名称的Want。                    |
1197| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype) | 是   | 标识extensionAbility的类型。                              |
1198| extensionAbilityFlags | [number](#extensionabilityflag)               | 是   | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 |
1199| userId                | number                                        | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。                                              |
1200
1201**返回值:**
1202
1203| 类型                                                         | 说明                                          |
1204| ------------------------------------------------------------ | --------------------------------------------- |
1205| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Promise对象,返回Array\<ExtensionAbilityInfo>。 |
1206
1207**错误码:**
1208
1209以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1210
1211| 错误码ID | 错误信息                             |
1212| -------- | --------------------------------------|
1213| 17700001 | The specified bundleName is not found. |
1214| 17700003 | The specified extensionAbility is not found.    |
1215| 17700004 | The specified userId is invalid.       |
1216| 17700026 | The specified bundle is disabled.      |
1217
1218**示例:**
1219
1220```ts
1221import bundleManager from '@ohos.bundle.bundleManager';
1222import { BusinessError } from '@ohos.base';
1223import hilog from '@ohos.hilog';
1224import Want from '@ohos.app.ability.Want';
1225
1226let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1227let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1228let userId = 100;
1229let want: Want = {
1230    bundleName : "com.example.myapplication",
1231    abilityName : "EntryAbility"
1232};
1233
1234try {
1235    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => {
1236        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1237    }).catch((err: BusinessError) => {
1238        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1239    });
1240} catch (err) {
1241    let message = (err as BusinessError).message;
1242    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
1243}
1244```
1245
1246```ts
1247import bundleManager from '@ohos.bundle.bundleManager';
1248import { BusinessError } from '@ohos.base';
1249import hilog from '@ohos.hilog';
1250import Want from '@ohos.app.ability.Want';
1251let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1252let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1253let want: Want = {
1254    bundleName : "com.example.myapplication",
1255    abilityName : "EntryAbility"
1256};
1257
1258try {
1259    bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => {
1260        hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data));
1261    }).catch((err: BusinessError) => {
1262        hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message);
1263    })
1264} catch (err) {
1265    let message = (err as BusinessError).message;
1266    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message);
1267}
1268```
1269
1270### bundleManager.queryExtensionAbilityInfoSync<sup>10+</sup>
1271
1272queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>
1273
1274以同步方法根据给定的want、extensionAbilityType、extensionAbilityFlags和userId获取ExtensionAbilityInfo。
1275
1276**系统接口:** 此接口为系统接口。
1277
1278**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1279
1280**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1281
1282**参数:**
1283
1284| 参数名                | 类型                                          | 必填 | 说明                                                      |
1285| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- |
1286| want                  | Want                                          | 是   | 表示包含要查询的应用Bundle名称的Want。                    |
1287| extensionAbilityType  | [ExtensionAbilityType](js-apis-bundleManager-sys.md#extensionabilitytype) | 是   | 标识extensionAbility的类型。                              |
1288| extensionAbilityFlags | [number](#extensionabilityflag)               | 是   | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志。 |
1289| userId                | number                                        | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。                                              |
1290
1291**返回值:**
1292
1293| 类型                                                         | 说明                                          |
1294| ------------------------------------------------------------ | --------------------------------------------- |
1295| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | Array\<ExtensionAbilityInfo>信息。 |
1296
1297**错误码:**
1298
1299以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1300
1301| 错误码ID | 错误信息                             |
1302| -------- | --------------------------------------|
1303| 17700001 | The specified bundleName is not found. |
1304| 17700003 | The specified extensionAbility is not found.    |
1305| 17700004 | The specified userId is invalid.       |
1306| 17700026 | The specified bundle is disabled.      |
1307
1308**示例:**
1309
1310```ts
1311import bundleManager from '@ohos.bundle.bundleManager';
1312import { BusinessError } from '@ohos.base';
1313import hilog from '@ohos.hilog';
1314import Want from '@ohos.app.ability.Want';
1315
1316let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1317let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1318let userId = 100;
1319let want: Want = {
1320    bundleName : "com.example.myapplication",
1321    abilityName : "EntryAbility"
1322};
1323
1324try {
1325    let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId);
1326    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
1327} catch (err) {
1328    let message = (err as BusinessError).message;
1329    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
1330}
1331```
1332
1333```ts
1334import bundleManager from '@ohos.bundle.bundleManager';
1335import { BusinessError } from '@ohos.base';
1336import hilog from '@ohos.hilog';
1337import Want from '@ohos.app.ability.Want';
1338let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM;
1339let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
1340let want: Want = {
1341    bundleName : "com.example.myapplication",
1342    abilityName : "EntryAbility"
1343};
1344
1345try {
1346    let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags);
1347    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos));
1348} catch (err) {
1349    let message = (err as BusinessError).message;
1350    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message);
1351}
1352```
1353
1354### bundleManager.getBundleNameByUid
1355
1356getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void
1357
1358以异步方法根据给定的uid获取对应的bundleName,使用callback形式返回结果。
1359
1360**系统接口:** 此接口为系统接口。
1361
1362**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1363
1364**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1365
1366**参数:**
1367
1368| 参数名   | 类型                   | 必填 | 说明                                                         |
1369| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1370| uid      | number                 | 是   | 表示应用程序的UID。                                            |
1371| callback | AsyncCallback\<string> | 是   | 回调函数,当获取成功时,err为null,data为获取到的BundleName;否则为错误对象。 |
1372
1373**错误码:**
1374
1375以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1376
1377| 错误码ID | 错误信息            |
1378| -------- | --------------------- |
1379| 17700021 | The uid is not found. |
1380
1381**示例:**
1382
1383```ts
1384import bundleManager from '@ohos.bundle.bundleManager';
1385import { BusinessError } from '@ohos.base';
1386import hilog from '@ohos.hilog';
1387let uid = 20010005;
1388try {
1389    bundleManager.getBundleNameByUid(uid, (err, data) => {
1390        if (err) {
1391            hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message);
1392        } else {
1393            hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', JSON.stringify(data));
1394        }
1395    });
1396} catch (err) {
1397    let message = (err as BusinessError).message;
1398    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', message);
1399}
1400```
1401
1402### bundleManager.getBundleNameByUid
1403
1404getBundleNameByUid(uid: number): Promise\<string>
1405
1406以异步方法根据给定的uid获取对应的bundleName,使用Promise形式返回结果。
1407
1408**系统接口:** 此接口为系统接口。
1409
1410**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1411
1412**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1413
1414**参数:**
1415
1416| 参数名 | 类型   | 必填 | 说明                |
1417| ---- | ------ | ---- | ------------------ |
1418| uid  | number | 是   | 表示应用程序的UID。 |
1419
1420**返回值:**
1421
1422| 类型             | 说明                        |
1423| ---------------- | --------------------------- |
1424| Promise\<string> | Promise对象,返回bundleName。 |
1425
1426**错误码:**
1427
1428以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1429
1430| 错误码ID | 错误信息            |
1431| -------- | ---------------------|
1432| 17700021 | The uid is not found. |
1433
1434**示例:**
1435
1436```ts
1437import bundleManager from '@ohos.bundle.bundleManager';
1438import { BusinessError } from '@ohos.base';
1439import hilog from '@ohos.hilog';
1440let uid = 20010005;
1441try {
1442    bundleManager.getBundleNameByUid(uid).then((data) => {
1443        hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data));
1444    }).catch((err: BusinessError) => {
1445        hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message);
1446    });
1447} catch (err) {
1448    let message = (err as BusinessError).message;
1449    hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', message);
1450}
1451```
1452
1453### bundleManager.getBundleNameByUidSync<sup>10+</sup>
1454
1455getBundleNameByUidSync(uid: number): string
1456
1457以同步方法根据给定的uid获取对应的bundleName。
1458
1459**系统接口:** 此接口为系统接口。
1460
1461**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
1462
1463**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1464
1465**参数:**
1466
1467| 参数名 | 类型   | 必填 | 说明                |
1468| ---- | ------ | ---- | ------------------ |
1469| uid  | number | 是   | 表示应用程序的UID。 |
1470
1471**返回值:**
1472
1473| 类型             | 说明                        |
1474| ---------------- | --------------------------- |
1475| string | 返回获取到的bundleName。 |
1476
1477**错误码:**
1478
1479以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1480
1481| 错误码ID | 错误信息            |
1482| -------- | ---------------------|
1483| 17700021 | The uid is not found. |
1484
1485**示例:**
1486
1487```ts
1488import bundleManager from '@ohos.bundle.bundleManager';
1489import { BusinessError } from '@ohos.base';
1490import hilog from '@ohos.hilog';
1491let uid = 20010005;
1492try {
1493    let data = bundleManager.getBundleNameByUidSync(uid);
1494    hilog.info(0x0000, 'testTag', 'getBundleNameByUidSync successfully. Data: %{public}s', JSON.stringify(data));
1495} catch (err) {
1496    let message = (err as BusinessError).message;
1497    hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', message);
1498}
1499```
1500
1501### bundleManager.getBundleArchiveInfo
1502
1503getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](js-apis-bundleManager.md#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void
1504
1505以异步方法根据给定的hapFilePath和bundleFlags获取BundleInfo,使用callback形式返回结果。
1506
1507**系统接口:** 此接口为系统接口。
1508
1509**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1510
1511**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1512
1513**参数:**
1514
1515| 参数名       | 类型   | 必填 | 说明                                                         |
1516| ----------- | ------ | ---- | ----------------------------------------------------------- |
1517| hapFilePath | string | 是   | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径。 |
1518| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 表示用于指定要返回的BundleInfo对象中包含的信息的标志。       |
1519| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleInfo;否则为错误对象。 |
1520
1521**错误码:**
1522
1523以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1524
1525| 错误码ID | 错误信息                  |
1526| -------- | --------------------------- |
1527| 17700022 | The hapFilePath is invalid. |
1528
1529**示例:**
1530
1531```ts
1532import bundleManager from '@ohos.bundle.bundleManager';
1533import { BusinessError } from '@ohos.base';
1534import hilog from '@ohos.hilog';
1535let hapFilePath = "/data/xxx/test.hap";
1536let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1537
1538try {
1539    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
1540        if (err) {
1541            hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1542        } else {
1543            hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', JSON.stringify(data));
1544        }
1545    });
1546} catch (err) {
1547    let message = (err as BusinessError).message;
1548    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
1549}
1550```
1551
1552### bundleManager.getBundleArchiveInfo
1553
1554getBundleArchiveInfo(hapFilePath: string,  bundleFlags: [number](js-apis-bundleManager.md#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>
1555
1556以异步方法根据给定的hapFilePath和bundleFlags获取BundleInfo,使用Promise形式返回结果。
1557
1558**系统接口:** 此接口为系统接口。
1559
1560**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1561
1562**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1563
1564**参数:**
1565
1566| 参数名       | 类型   | 必填 | 说明                                                         |
1567| ----------- | ------ | ---- | ------------------------------------------------------------ |
1568| hapFilePath | string | 是   | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径。 |
1569| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 表示用于指定要返回的BundleInfo对象中包含的信息的标志。       |
1570
1571**返回值:**
1572
1573| 类型                                                        | 说明                        |
1574| ----------------------------------------------------------- | --------------------------- |
1575| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回BundleInfo。 |
1576
1577**错误码:**
1578
1579以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1580
1581| 错误码ID | 错误信息                   |
1582| -------- | -------------------------- |
1583| 17700022 | The hapFilePath is invalid. |
1584
1585**示例:**
1586
1587```ts
1588import bundleManager from '@ohos.bundle.bundleManager';
1589import { BusinessError } from '@ohos.base';
1590import hilog from '@ohos.hilog';
1591let hapFilePath = "/data/xxx/test.hap";
1592let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1593
1594try {
1595    bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => {
1596        hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data));
1597    }).catch((err: BusinessError) => {
1598        hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message);
1599    });
1600} catch (err) {
1601    let message = (err as BusinessError).message;
1602    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message);
1603}
1604```
1605
1606### bundleManager.getBundleArchiveInfoSync<sup>10+</sup>
1607
1608getBundleArchiveInfoSync(hapFilePath: string, bundleFlags: number): BundleInfo
1609
1610以同步方法根据给定的hapFilePath和bundleFlags获取BundleInfo对象。
1611
1612**系统接口:** 此接口为系统接口。
1613
1614**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1615
1616**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1617
1618**参数:**
1619
1620| 参数名       | 类型   | 必填 | 说明                                                         |
1621| ----------- | ------ | ---- | ------------------------------------------------------------ |
1622| hapFilePath | string | 是   | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径。 |
1623| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 表示用于指定要返回的BundleInfo对象中包含的信息的标志。       |
1624
1625**返回值:**
1626
1627| 类型                                                        | 说明                        |
1628| ----------------------------------------------------------- | --------------------------- |
1629| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 返回BundleInfo对象。 |
1630
1631**错误码:**
1632
1633以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1634
1635| 错误码ID | 错误信息                   |
1636| -------- | -------------------------- |
1637| 17700022 | The hapFilePath is invalid. |
1638
1639**示例:**
1640
1641```ts
1642import bundleManager from '@ohos.bundle.bundleManager';
1643import { BusinessError } from '@ohos.base';
1644import hilog from '@ohos.hilog';
1645let hapFilePath = "/data/xxx/test.hap";
1646let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
1647
1648try {
1649    let data = bundleManager.getBundleArchiveInfoSync(hapFilePath, bundleFlags)
1650    hilog.info(0x0000, 'testTag', 'getBundleArchiveInfoSync successfully. Data: %{public}s', JSON.stringify(data));
1651} catch (err) {
1652    let message = (err as BusinessError).message;
1653    hilog.error(0x0000, 'testTag', 'getBundleArchiveInfoSync failed. Cause: %{public}s', message);
1654}
1655```
1656
1657### bundleManager.cleanBundleCacheFiles
1658
1659cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void
1660
1661以异步方法根据给定的bundleName清理BundleCache,使用callback形式返回结果。
1662
1663**系统接口:** 此接口为系统接口。
1664
1665**需要权限:** ohos.permission.REMOVE_CACHE_FILES
1666
1667**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1668
1669**参数:**
1670
1671| 参数名     | 类型                 | 必填 | 说明                                                         |
1672| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
1673| bundleName | string               | 是   | 表示要清理其缓存数据的应用程序的bundleName。                   |
1674| callback   | AsyncCallback\<void> | 是   | 回调函数,当清理应用缓存目录数据成功,err为null,否则为错误对象。 |
1675
1676**错误码:**
1677
1678以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1679
1680| 错误码ID | 错误信息                                                     |
1681| -------- | ------------------------------------------------------------ |
1682| 17700001 | The specified bundleName is not found.                        |
1683| 17700030 | The specified bundle does not support clearing of cache files. |
1684
1685**示例:**
1686
1687```ts
1688import bundleManager from '@ohos.bundle.bundleManager';
1689import { BusinessError } from '@ohos.base';
1690import hilog from '@ohos.hilog';
1691let bundleName = "com.ohos.myapplication";
1692
1693try {
1694    bundleManager.cleanBundleCacheFiles(bundleName, err => {
1695        if (err) {
1696            hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1697        } else {
1698            hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1699        }
1700    });
1701} catch (err) {
1702    let message = (err as BusinessError).message;
1703    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
1704}
1705```
1706
1707### bundleManager.cleanBundleCacheFiles
1708
1709cleanBundleCacheFiles(bundleName: string): Promise\<void>
1710
1711以异步方法根据给定的bundleName清理BundleCache,使用Promise形式返回结果。
1712
1713**系统接口:** 此接口为系统接口。
1714
1715**需要权限:** ohos.permission.REMOVE_CACHE_FILES
1716
1717**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1718
1719**参数:**
1720
1721| 参数名     | 类型   | 必填 | 说明                                       |
1722| ---------- | ------ | ---- | ------------------------------------------ |
1723| bundleName | string | 是   | 表示要清理其缓存数据的应用程序的bundleName。 |
1724
1725**返回值:**
1726
1727| 类型           | 说明                                                         |
1728| -------------- | ------------------------------------------------------------ |
1729| Promise\<void> | 无返回结果的Promise对象。当清理应用缓存目录数据失败会抛出错误对象。 |
1730
1731**错误码:**
1732
1733以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1734
1735| 错误码ID | 错误信息                                                   |
1736| -------- | ---------------------------------------------------------- |
1737| 17700001 | The specified bundleName is not found.                      |
1738| 17700030 | The specified bundle does not support clearing of cache files. |
1739
1740**示例:**
1741
1742```ts
1743import bundleManager from '@ohos.bundle.bundleManager';
1744import { BusinessError } from '@ohos.base';
1745import hilog from '@ohos.hilog';
1746let bundleName = "com.ohos.myapplication";
1747
1748try {
1749    bundleManager.cleanBundleCacheFiles(bundleName).then(() => {
1750        hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.');
1751    }).catch((err: BusinessError) => {
1752        hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message);
1753    });
1754} catch (err) {
1755    let message = (err as BusinessError).message;
1756    hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message);
1757}
1758```
1759
1760### bundleManager.setApplicationEnabled
1761
1762setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void
1763
1764设置指定应用的禁用或使能状态,使用callback形式返回结果。
1765
1766**系统接口:** 此接口为系统接口。
1767
1768**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1769
1770**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1771
1772**参数:**
1773
1774| 参数名      | 类型    | 必填 | 说明                                  |
1775| ---------- | ------- | ---- | ------------------------------------- |
1776| bundleName | string  | 是   | 指定应用的bundleName。                |
1777| isEnabled  | boolean | 是   | 值为true表示使能,值为false表示禁用。 |
1778| callback | AsyncCallback\<void> | 是 | 回调函数,当设置应用禁用或使能状态成功时,err为null,否则为错误对象。 |
1779
1780**错误码:**
1781
1782以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1783
1784| 错误码ID | 错误信息                             |
1785| -------- | -------------------------------------- |
1786| 17700001 | The specified bundleName is not found. |
1787
1788**示例:**
1789
1790```ts
1791import bundleManager from '@ohos.bundle.bundleManager';
1792import { BusinessError } from '@ohos.base';
1793import hilog from '@ohos.hilog';
1794let bundleName = "com.ohos.myapplication";
1795
1796try {
1797    bundleManager.setApplicationEnabled(bundleName, false, err => {
1798        if (err) {
1799            hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
1800        } else {
1801            hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.');
1802        }
1803    });
1804} catch (err) {
1805    let message = (err as BusinessError).message;
1806    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
1807}
1808```
1809
1810### bundleManager.setApplicationEnabled
1811
1812setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void>
1813
1814设置指定应用的禁用或使能状态,使用Promise形式返回结果。
1815
1816**系统接口:** 此接口为系统接口。
1817
1818**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1819
1820**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1821
1822**参数:**
1823
1824| 参数名      | 类型    | 必填 | 说明                                  |
1825| ---------- | ------- | ---- | ------------------------------------- |
1826| bundleName | string  | 是   | 表示应用程序的bundleName。            |
1827| isEnabled  | boolean | 是   | 值为true表示使能,值为false表示禁用。 |
1828
1829**返回值:**
1830
1831| 类型           | 说明                                 |
1832| -------------- | ------------------------------------ |
1833| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
1834
1835**错误码:**
1836
1837以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1838
1839| 错误码ID | 错误信息                             |
1840| -------- | -------------------------------------- |
1841| 17700001 | The specified bundleName is not found. |
1842
1843**示例:**
1844
1845```ts
1846import bundleManager from '@ohos.bundle.bundleManager';
1847import { BusinessError } from '@ohos.base';
1848import hilog from '@ohos.hilog';
1849let bundleName = "com.ohos.myapplication";
1850
1851try {
1852    bundleManager.setApplicationEnabled(bundleName, false).then(() => {
1853        hilog.info(0x0000, "testTag", "setApplicationEnabled successfully.");
1854    }).catch((err: BusinessError) => {
1855        hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message);
1856    });
1857} catch (err) {
1858    let message = (err as BusinessError).message;
1859    hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message);
1860}
1861```
1862
1863### bundleManager.setApplicationEnabledSync<sup>10+</sup>
1864
1865setApplicationEnabledSync(bundleName: string, isEnabled: boolean): void
1866
1867以同步方法设置指定应用的禁用或使能状态。
1868
1869**系统接口:** 此接口为系统接口。
1870
1871**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1872
1873**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1874
1875**参数:**
1876
1877| 参数名      | 类型    | 必填 | 说明                                  |
1878| ---------- | ------- | ---- | ------------------------------------- |
1879| bundleName | string  | 是   | 指定应用的bundleName。                |
1880| isEnabled  | boolean | 是   | 值为true表示使能,值为false表示禁用。 |
1881
1882**错误码:**
1883
1884以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1885
1886| 错误码ID | 错误信息                             |
1887| -------- | -------------------------------------- |
1888| 17700001 | The specified bundleName is not found. |
1889
1890**示例:**
1891
1892```ts
1893import bundleManager from '@ohos.bundle.bundleManager';
1894import { BusinessError } from '@ohos.base';
1895import hilog from '@ohos.hilog';
1896let bundleName = "com.ohos.myapplication";
1897
1898try {
1899    bundleManager.setApplicationEnabledSync(bundleName, false);
1900    hilog.info(0x0000, 'testTag', 'setApplicationEnabledSync successfully.');
1901} catch (err) {
1902    let message = (err as BusinessError).message;
1903    hilog.error(0x0000, 'testTag', 'setApplicationEnabledSync failed: %{public}s', message);
1904}
1905```
1906
1907### bundleManager.setAbilityEnabled
1908
1909setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\<void>): void
1910
1911设置指定组件的禁用或使能状态,使用callback形式返回结果。
1912
1913**系统接口:** 此接口为系统接口。
1914
1915**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1916
1917**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1918
1919**参数:**
1920
1921| 参数名    | 类型        | 必填 | 说明                                  |
1922| -------- | ----------- | ---- | ------------------------------------- |
1923| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是   | 需要被设置的组件。              |
1924| isEnabled| boolean     | 是   | 值为true表示使能,值为false表示禁用。 |
1925| callback | AsyncCallback\<void> | 是 | 回调函数,当设置组件禁用或使能状态成功时,err为null,否则为错误对象。 |
1926
1927**错误码:**
1928
1929以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1930
1931| 错误码ID | 错误信息                              |
1932| -------- | ---------------------------------------|
1933| 17700001 | The specified bundleName is not found.  |
1934| 17700003 | The specified abilityInfo is not found. |
1935
1936**示例:**
1937
1938```ts
1939import bundleManager from '@ohos.bundle.bundleManager';
1940import { BusinessError } from '@ohos.base';
1941import hilog from '@ohos.hilog';
1942import Want from '@ohos.app.ability.Want';
1943let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
1944let userId = 100;
1945let want: Want = {
1946    bundleName : "com.example.myapplication",
1947    abilityName : "EntryAbility"
1948};
1949
1950try {
1951    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
1952        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
1953        let info = abilitiesInfo[0];
1954
1955        bundleManager.setAbilityEnabled(info, false, err => {
1956            if (err) {
1957                hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
1958            } else {
1959                hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
1960            }
1961        });
1962    }).catch((err: BusinessError) => {
1963        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
1964    });
1965} catch (err) {
1966    let message = (err as BusinessError).message;
1967    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
1968}
1969```
1970
1971### bundleManager.setAbilityEnabled
1972
1973setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\<void>
1974
1975设置指定组件的禁用或使能状态,使用Promise形式返回结果。
1976
1977**系统接口:** 此接口为系统接口。
1978
1979**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
1980
1981**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
1982
1983**参数:**
1984
1985| 参数名    | 类型        | 必填 | 说明                                  |
1986| -------- | ----------- | ---- | ------------------------------------- |
1987| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是   | 需要被设置的组件。                   |
1988| isEnabled| boolean     | 是   | 值为true表示使能,值为false表示禁用。 |
1989
1990**返回值:**
1991
1992| 类型           | 说明                              |
1993| -------------- | --------------------------------- |
1994| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
1995
1996**错误码:**
1997
1998以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
1999
2000| 错误码ID | 错误信息                              |
2001| -------- | -------------------------------------- |
2002| 17700001 | The specified bundleName is not found.  |
2003| 17700003 | The specified abilityInfo is not found. |
2004
2005**示例:**
2006
2007```ts
2008import bundleManager from '@ohos.bundle.bundleManager';
2009import { BusinessError } from '@ohos.base';
2010import hilog from '@ohos.hilog';
2011import Want from '@ohos.app.ability.Want';
2012let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2013let userId = 100;
2014let want: Want = {
2015    bundleName : "com.example.myapplication",
2016    abilityName : "EntryAbility"
2017};
2018
2019try {
2020    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2021        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2022        let info = abilitiesInfo[0];
2023
2024        bundleManager.setAbilityEnabled(info, false).then(() => {
2025            hilog.info(0x0000, "testTag", "setAbilityEnabled successfully.");
2026        }).catch((err: BusinessError) => {
2027            hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message);
2028        });
2029    }).catch((err: BusinessError) => {
2030        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2031    });
2032} catch (err) {
2033    let message = (err as BusinessError).message;
2034    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2035}
2036```
2037
2038### bundleManager.setAbilityEnabledSync<sup>10+</sup>
2039
2040setAbilityEnabledSync(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): void
2041
2042以同步方法设置指定组件的禁用或使能状态。
2043
2044**系统接口:** 此接口为系统接口。
2045
2046**需要权限:** ohos.permission.CHANGE_ABILITY_ENABLED_STATE
2047
2048**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2049
2050**参数:**
2051
2052| 参数名    | 类型        | 必填 | 说明                                  |
2053| -------- | ----------- | ---- | ------------------------------------- |
2054| info     | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是   | 需要被设置的组件。              |
2055| isEnabled| boolean     | 是   | 值为true表示使能,值为false表示禁用。 |
2056
2057**错误码:**
2058
2059以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2060
2061| 错误码ID | 错误信息                              |
2062| -------- | ---------------------------------------|
2063| 17700001 | The specified bundleName is not found.  |
2064| 17700003 | The specified abilityInfo is not found. |
2065
2066**示例:**
2067
2068```ts
2069import bundleManager from '@ohos.bundle.bundleManager';
2070import { BusinessError } from '@ohos.base';
2071import hilog from '@ohos.hilog';
2072import Want from '@ohos.app.ability.Want';
2073let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2074let userId = 100;
2075let want: Want = {
2076    bundleName : "com.example.myapplication",
2077    abilityName : "EntryAbility"
2078};
2079
2080try {
2081    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2082        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2083        let info = abilitiesInfo[0];
2084
2085        try {
2086            bundleManager.setAbilityEnabledSync(info, false);
2087            hilog.info(0x0000, "testTag", "setAbilityEnabledSync successfully.");
2088        } catch (err) {
2089            let message = (err as BusinessError).message;
2090            hilog.error(0x0000, 'testTag', 'setAbilityEnabledSync failed: %{public}s', message);
2091        }
2092    }).catch((err: BusinessError) => {
2093        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2094    });
2095} catch (err) {
2096    let message = (err as BusinessError).message;
2097    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2098}
2099```
2100
2101### bundleManager.isApplicationEnabled
2102
2103isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void
2104
2105以异步的方法获取指定应用的禁用或使能状态,使用callback形式返回结果。
2106
2107**系统接口:** 此接口为系统接口。
2108
2109**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2110
2111**参数:**
2112
2113| 参数名      | 类型   | 必填 | 说明                       |
2114| ---------- | ------ | ---- | -------------------------- |
2115| bundleName | string | 是   | 表示应用程序的bundleName。 |
2116| callback | AsyncCallback\<boolean> | 是 | 回调函数,返回true表示当前应用为使能状态,返回false表示应用为禁用状态。 |
2117
2118**错误码:**
2119
2120以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2121
2122| 错误码ID | 错误信息                             |
2123| -------- | -------------------------------------- |
2124| 17700001 | The specified bundleName is not found. |
2125
2126**示例:**
2127
2128```ts
2129import bundleManager from '@ohos.bundle.bundleManager';
2130import { BusinessError } from '@ohos.base';
2131import hilog from '@ohos.hilog';
2132let bundleName = 'com.example.myapplication';
2133
2134try {
2135    bundleManager.isApplicationEnabled(bundleName, (err, data) => {
2136        if (err) {
2137            hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message);
2138        } else {
2139            hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', JSON.stringify(data));
2140        }
2141    });
2142} catch (err) {
2143    let message = (err as BusinessError).message;
2144    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', message);
2145}
2146```
2147
2148### bundleManager.isApplicationEnabled
2149
2150isApplicationEnabled(bundleName: string): Promise\<boolean>
2151
2152以异步的方法获取指定应用的禁用或使能状态,使用Promise形式返回结果。
2153
2154**系统接口:** 此接口为系统接口。
2155
2156**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2157
2158**参数:**
2159
2160| 参数名      | 类型   | 必填 | 说明                       |
2161| ---------- | ------ | ---- | -------------------------- |
2162| bundleName | string | 是   | 表示应用程序的bundleName。  |
2163
2164**返回值:**
2165
2166| 类型              | 说明                                                         |
2167| ----------------- | ------------------------------------------------------------ |
2168| Promise\<boolean> | Promise对象,返回true表示当前应用为使能状态,返回false表示当前应用为禁用状态。 |
2169
2170**错误码:**
2171
2172以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2173
2174| 错误码ID | 错误信息                             |
2175| -------- | -------------------------------------- |
2176| 17700001 | The specified bundleName is not found. |
2177
2178**示例:**
2179
2180```ts
2181import bundleManager from '@ohos.bundle.bundleManager';
2182import { BusinessError } from '@ohos.base';
2183import hilog from '@ohos.hilog';
2184let bundleName = 'com.example.myapplication';
2185
2186try {
2187    bundleManager.isApplicationEnabled(bundleName).then((data) => {
2188        hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data));
2189    }).catch((err: BusinessError) => {
2190        hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message);
2191    });
2192} catch (err) {
2193    let message = (err as BusinessError).message;
2194    hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message);
2195}
2196```
2197
2198### bundleManager.isApplicationEnabledSync<sup>10+</sup>
2199
2200isApplicationEnabledSync(bundleName: string): boolean
2201
2202以同步方法获取指定应用的禁用或使能状态。
2203
2204**系统接口:** 此接口为系统接口。
2205
2206**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2207
2208**参数:**
2209
2210| 参数名      | 类型   | 必填 | 说明                       |
2211| ---------- | ------ | ---- | -------------------------- |
2212| bundleName | string | 是   | 表示应用程序的bundleName。 |
2213
2214**返回值:**
2215
2216| 类型    | 说明                                                         |
2217| ------- | ------------------------------------------------------------ |
2218| boolean | 返回true表示当前应用为使能状态,返回false表示当前应用为禁用状态。 |
2219
2220**错误码:**
2221
2222以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2223
2224| 错误码ID | 错误信息                             |
2225| -------- | -------------------------------------- |
2226| 17700001 | The specified bundleName is not found. |
2227
2228**示例:**
2229
2230```ts
2231import bundleManager from '@ohos.bundle.bundleManager';
2232import { BusinessError } from '@ohos.base';
2233import hilog from '@ohos.hilog';
2234let bundleName = 'com.example.myapplication';
2235
2236try {
2237    let data = bundleManager.isApplicationEnabledSync(bundleName);
2238    hilog.info(0x0000, 'testTag', 'isApplicationEnabledSync successfully: %{public}s', JSON.stringify(data));
2239} catch (err) {
2240    let message = (err as BusinessError).message;
2241    hilog.error(0x0000, 'testTag', 'isApplicationEnabledSync failed: %{public}s', message);
2242}
2243```
2244
2245### bundleManager.isAbilityEnabled
2246
2247isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\<boolean>): void
2248
2249以异步的方法获取指定组件的禁用或使能状态,使用callback形式返回结果。
2250
2251**系统接口:** 此接口为系统接口。
2252
2253**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2254
2255**参数:**
2256
2257| 参数名 | 类型        | 必填 | 说明                        |
2258| ---- | ----------- | ---- | --------------------------- |
2259| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是   | 表示关于检查ability的信息。 |
2260| callback | AsyncCallback\<boolean> | 是 | 回调函数,返回true表示当前应用组件为使能状态,返回false表示应用组件为禁用状态。 |
2261
2262**错误码:**
2263
2264以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2265
2266| 错误码ID | 错误信息                              |
2267| -------- | --------------------------------------- |
2268| 17700001 | The specified bundleName is not found.  |
2269| 17700003 | The specified abilityName is not found. |
2270
2271**示例:**
2272
2273```ts
2274import bundleManager from '@ohos.bundle.bundleManager';
2275import { BusinessError } from '@ohos.base';
2276import hilog from '@ohos.hilog';
2277import Want from '@ohos.app.ability.Want';
2278let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2279let userId = 100;
2280let want: Want = {
2281    bundleName : "com.example.myapplication",
2282    abilityName : "EntryAbility"
2283};
2284
2285try {
2286    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2287        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2288        let info = abilitiesInfo[0];
2289
2290        bundleManager.isAbilityEnabled(info, (err, data) => {
2291            if (err) {
2292                hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s', err.message);
2293            } else {
2294                hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data));
2295            }
2296        });
2297    }).catch((err: BusinessError) => {
2298        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2299    });
2300} catch (err) {
2301    let message = (err as BusinessError).message;
2302    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2303}
2304```
2305
2306### bundleManager.isAbilityEnabled
2307
2308isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\<boolean>
2309
2310以异步的方法获取指定组件的禁用或使能状态,使用Promise形式返回结果。
2311
2312**系统接口:** 此接口为系统接口。
2313
2314**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2315
2316**参数:**
2317
2318| 参数名 | 类型        | 必填 | 说明                        |
2319| ---- | ----------- | ---- | --------------------------- |
2320| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是   | 表示关于检查ability的信息。 |
2321
2322**返回值:**
2323
2324| 类型              | 说明                                                         |
2325| ----------------- | ------------------------------------------------------------ |
2326| Promise\<boolean> | Promise对象,返回true表示当前应用组件为使能状态,返回false表示当前应用组件为禁用状态。 |
2327
2328**错误码:**
2329
2330以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2331
2332| 错误码ID | 错误信息                              |
2333| -------- | --------------------------------------- |
2334| 17700001 | The specified bundleName is not found.  |
2335| 17700003 | The specified abilityName is not found. |
2336
2337**示例:**
2338
2339```ts
2340import bundleManager from '@ohos.bundle.bundleManager';
2341import { BusinessError } from '@ohos.base';
2342import hilog from '@ohos.hilog';
2343import Want from '@ohos.app.ability.Want';
2344let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2345let userId = 100;
2346let want: Want = {
2347    bundleName : "com.example.myapplication",
2348    abilityName : "EntryAbility"
2349};
2350
2351try {
2352    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2353        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2354        let info = abilitiesInfo[0];
2355
2356        bundleManager.isAbilityEnabled(info).then((data) => {
2357            hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data));
2358        }).catch((err: BusinessError) => {
2359            hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message);
2360        });
2361    }).catch((err: BusinessError) => {
2362        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2363    });
2364} catch (err) {
2365    let message = (err as BusinessError).message;
2366    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2367}
2368```
2369
2370### bundleManager.isAbilityEnabledSync<sup>10+</sup>
2371
2372isAbilityEnabledSync(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): boolean
2373
2374以同步方法获取指定组件的禁用或使能状态。
2375
2376**系统接口:** 此接口为系统接口。
2377
2378**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2379
2380**参数:**
2381
2382| 参数名 | 类型        | 必填 | 说明                        |
2383| ---- | ----------- | ---- | --------------------------- |
2384| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是   | 表示关于检查ability的信息。 |
2385
2386**返回值:**
2387
2388| 类型    | 说明                                                                 |
2389| ------- | ------------------------------------------------------------------- |
2390| boolean | 返回true表示当前应用组件为使能状态,返回false表示当前应用组件为禁用状态。 |
2391
2392**错误码:**
2393
2394以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2395
2396| 错误码ID | 错误信息                              |
2397| -------- | --------------------------------------- |
2398| 17700001 | The specified bundleName is not found.  |
2399| 17700003 | The specified abilityName is not found. |
2400
2401**示例:**
2402
2403```ts
2404import bundleManager from '@ohos.bundle.bundleManager';
2405import { BusinessError } from '@ohos.base';
2406import hilog from '@ohos.hilog';
2407import Want from '@ohos.app.ability.Want';
2408let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT;
2409let userId = 100;
2410let want: Want = {
2411    bundleName : "com.example.myapplication",
2412    abilityName : "EntryAbility"
2413};
2414
2415try {
2416    bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => {
2417        hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo));
2418        let info = abilitiesInfo[0];
2419
2420        try {
2421            let data = bundleManager.isAbilityEnabledSync(info);
2422            hilog.info(0x0000, 'testTag', 'isAbilityEnabledSync successfully: %{public}s', JSON.stringify(data));
2423        } catch (err) {
2424            let message = (err as BusinessError).message;
2425            hilog.error(0x0000, 'testTag', 'isAbilityEnabledSync failed: %{public}s', message);
2426        }
2427    }).catch((err: BusinessError) => {
2428        hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message);
2429    });
2430} catch (err) {
2431    let message = (err as BusinessError).message;
2432    hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message);
2433}
2434```
2435
2436### bundleManager.getLaunchWantForBundle
2437
2438getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void
2439
2440以异步方法根据给定的bundleName和userId获取用于启动应用程序的Want参数,使用callback形式返回结果。
2441
2442**系统接口:** 此接口为系统接口。
2443
2444**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2445
2446**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2447
2448**参数:**
2449
2450| 参数名     | 类型                 | 必填 | 说明                                                         |
2451| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
2452| bundleName | string               | 是   | 表示应用程序的bundleName。                                     |
2453| userId     | number               | 是   | 表示用户ID。                                                   |
2454| callback   | AsyncCallback\<Want> | 是   | 回调函数,当获取成功时,err为null,data为获取到的Want;否则为错误对象。 |
2455
2456**错误码:**
2457
2458以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2459
2460| 错误码ID | 错误信息                             |
2461| -------- | --------------------------------------|
2462| 17700001 | The specified bundleName is not found. |
2463| 17700004 | The specified user ID is not found.     |
2464| 17700026 | The specified bundle is disabled.      |
2465
2466**示例:**
2467
2468```ts
2469import bundleManager from '@ohos.bundle.bundleManager';
2470import { BusinessError } from '@ohos.base';
2471import hilog from '@ohos.hilog';
2472let bundleName = 'com.example.myapplication';
2473let userId = 100;
2474
2475try {
2476    bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => {
2477        if (err) {
2478            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2479        } else {
2480            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
2481        }
2482    });
2483} catch (err) {
2484    let message = (err as BusinessError).message;
2485    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
2486}
2487```
2488
2489### bundleManager.getLaunchWantForBundle
2490
2491getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
2492
2493以异步方法根据给定的bundleName获取用于启动应用程序的Want参数,使用callback形式返回结果。
2494
2495**系统接口:** 此接口为系统接口。
2496
2497**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2498
2499**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2500
2501**参数:**
2502
2503| 参数名     | 类型                 | 必填 | 说明                                                         |
2504| ---------- | -------------------- | ---- | ------------------------------------------------------------ |
2505| bundleName | string               | 是   | 表示应用程序的bundleName。                                     |
2506| callback   | AsyncCallback\<Want> | 是   | 回调函数,当获取成功时,err为null,data为获取到的Want;否则为错误对象。 |
2507
2508**错误码:**
2509
2510以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2511
2512| 错误码ID | 错误信息                             |
2513| -------- | --------------------------------------|
2514| 17700001 | The specified bundleName is not found. |
2515| 17700026 | The specified bundle is disabled.      |
2516
2517**示例:**
2518
2519```ts
2520import bundleManager from '@ohos.bundle.bundleManager';
2521import { BusinessError } from '@ohos.base';
2522import hilog from '@ohos.hilog';
2523let bundleName = 'com.example.myapplication';
2524
2525try {
2526    bundleManager.getLaunchWantForBundle(bundleName, (err, data) => {
2527        if (err) {
2528            hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message);
2529        } else {
2530            hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data));
2531        }
2532    });
2533} catch (err) {
2534    let message = (err as BusinessError).message;
2535    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message);
2536}
2537```
2538
2539### bundleManager.getLaunchWantForBundle
2540
2541getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>
2542
2543以异步方法根据给定的bundleName和userId获取用于启动应用程序的Want参数,使用Promise形式返回结果。
2544
2545**系统接口:** 此接口为系统接口。
2546
2547**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2548
2549**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2550
2551**参数:**
2552
2553| 参数名     | 类型   | 必填 | 说明                       |
2554| ---------- | ------ | ---- | ------------------------- |
2555| bundleName | string | 是   | 表示应用程序的bundleName。 |
2556| userId     | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。  |
2557
2558**返回值:**
2559
2560| 类型           | 说明                      |
2561| -------------- | ------------------------- |
2562| Promise\<Want> | Promise对象,返回Want对象。 |
2563
2564**错误码:**
2565
2566以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2567
2568| 错误码ID | 错误信息                             |
2569| -------- | --------------------------------------|
2570| 17700001 | The specified bundleName is not found. |
2571| 17700004 | The specified user ID is not found.     |
2572| 17700026 | The specified bundle is disabled.      |
2573
2574**示例:**
2575
2576```ts
2577import bundleManager from '@ohos.bundle.bundleManager';
2578import { BusinessError } from '@ohos.base';
2579import hilog from '@ohos.hilog';
2580let bundleName = 'com.example.myapplication';
2581let userId = 100;
2582
2583try {
2584    bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => {
2585        hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data));
2586    }).catch((err: BusinessError) => {
2587        hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message);
2588    });
2589} catch (err) {
2590    let message = (err as BusinessError).message;
2591    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', message);
2592}
2593```
2594
2595
2596### bundleManager.getLaunchWantForBundleSync<sup>10+</sup>
2597
2598getLaunchWantForBundleSync(bundleName: string, userId?: number): Want
2599
2600以同步方法根据给定的bundleName和userId获取用于启动应用程序的Want参数。
2601
2602**系统接口:** 此接口为系统接口。
2603
2604**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2605
2606**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2607
2608**参数:**
2609
2610| 参数名     | 类型   | 必填 | 说明                       |
2611| ---------- | ------ | ---- | ------------------------- |
2612| bundleName | string | 是   | 表示应用程序的bundleName。 |
2613| userId     | number | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。  |
2614
2615**返回值:**
2616
2617| 类型           | 说明                      |
2618| -------------- | ------------------------- |
2619| Want | Want对象。 |
2620
2621**错误码:**
2622
2623以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2624
2625| 错误码ID | 错误信息                             |
2626| -------- | --------------------------------------|
2627| 17700001 | The specified bundleName is not found. |
2628| 17700004 | The specified user ID is not found.     |
2629| 17700026 | The specified bundle is disabled.      |
2630
2631**示例:**
2632
2633```ts
2634import bundleManager from '@ohos.bundle.bundleManager';
2635import { BusinessError } from '@ohos.base';
2636import hilog from '@ohos.hilog';
2637import Want from '@ohos.app.ability.Want';
2638let bundleName = 'com.example.myapplication';
2639let userId = 100;
2640
2641try {
2642    let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName, userId);
2643    hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
2644} catch (err) {
2645    let message = (err as BusinessError).message;
2646    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
2647}
2648```
2649
2650```ts
2651import bundleManager from '@ohos.bundle.bundleManager';
2652import { BusinessError } from '@ohos.base';
2653import hilog from '@ohos.hilog';
2654import Want from '@ohos.app.ability.Want';
2655let bundleName = 'com.example.myapplication';
2656let userId = 100;
2657
2658try {
2659    let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName);
2660    hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want));
2661} catch (err) {
2662    let message = (err as BusinessError).message;
2663    hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message);
2664}
2665```
2666
2667### bundleManager.getPermissionDef
2668
2669getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)>): void
2670
2671以异步方法根据给定的permissionName获取权限定义结构体PermissionDef信息,使用callback形式返回结果。
2672
2673**系统接口:** 此接口为系统接口。
2674
2675**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2676
2677**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2678
2679**参数:**
2680
2681| 参数名           | 类型                                                         | 必填 | 说明                                                         |
2682| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2683| permissionName | string                                                       | 是   | 表示权限名称。                                               |
2684| callback       | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)> | 是   | 回调函数,当获取成功时,err为null,data为获取到的Array\<PermissionDef>;否则为错误对象。 |
2685
2686**错误码:**
2687
2688以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2689
2690| 错误码ID | 错误信息                              |
2691| -------- | ------------------------------------- |
2692| 17700006 | The specified permission is not found. |
2693
2694**示例:**
2695
2696```ts
2697import bundleManager from '@ohos.bundle.bundleManager';
2698import { BusinessError } from '@ohos.base';
2699import hilog from '@ohos.hilog';
2700let permission = "ohos.permission.GET_BUNDLE_INFO";
2701try {
2702    bundleManager.getPermissionDef(permission, (err, data) => {
2703        if (err) {
2704            hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message);
2705        } else {
2706            hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', JSON.stringify(data));
2707        }
2708    });
2709} catch (err) {
2710    let message = (err as BusinessError).message;
2711    hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', message);
2712}
2713```
2714
2715### bundleManager.getPermissionDef
2716
2717getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)>
2718
2719以异步方法根据给定的permissionName获取权限定义结构体PermissionDef信息,使用Promise形式返回结果。
2720
2721**系统接口:** 此接口为系统接口。
2722
2723**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2724
2725**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2726
2727**参数:**
2728
2729| 参数名           | 类型   | 必填 | 说明           |
2730| -------------- | ------ | ---- | -------------- |
2731| permissionName | string | 是   | 表示权限参数名。 |
2732
2733**返回值:**
2734
2735| 类型                                                         | 说明                                       |
2736| ------------------------------------------------------------ | ------------------------------------------ |
2737| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)> | Promise对象,返回Array\<PermissionDef>对象。 |
2738
2739**错误码:**
2740
2741以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2742
2743| 错误码ID | 错误信息                              |
2744| -------- | ------------------------------------- |
2745| 17700006 | The specified permission is not found. |
2746
2747**示例:**
2748
2749```ts
2750import bundleManager from '@ohos.bundle.bundleManager';
2751import { BusinessError } from '@ohos.base';
2752import hilog from '@ohos.hilog';
2753let permissionName = "ohos.permission.GET_BUNDLE_INFO";
2754try {
2755    bundleManager.getPermissionDef(permissionName).then((data) => {
2756        hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data));
2757    }).catch((err: BusinessError) => {
2758        hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message);
2759    });
2760} catch (err) {
2761    let message = (err as BusinessError).message;
2762    hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', message);
2763}
2764```
2765
2766### bundleManager.getPermissionDefSync<sup>10+</sup>
2767
2768getPermissionDefSync(permissionName: string): [PermissionDef](js-apis-bundleManager-permissionDef-sys.md);
2769
2770以同步方法根据给定的permissionName获取权限定义结构体PermissionDef信息。
2771
2772**系统接口:** 此接口为系统接口。
2773
2774**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
2775
2776**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
2777
2778**参数:**
2779
2780| 参数名           | 类型   | 必填 | 说明           |
2781| -------------- | ------ | ---- | -------------- |
2782| permissionName | string | 是   | 表示权限参数名。 |
2783
2784**返回值:**
2785
2786| 类型                                                         | 说明                                       |
2787| ------------------------------------------------------------ | ------------------------------------------ |
2788|[PermissionDef](js-apis-bundleManager-permissionDef-sys.md) | PermissionDef对象。 |
2789
2790**错误码:**
2791
2792以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2793
2794| 错误码ID | 错误信息                              |
2795| -------- | ------------------------------------- |
2796| 17700006 | The specified permission is not found. |
2797
2798**示例:**
2799
2800```ts
2801import bundleManager from '@ohos.bundle.bundleManager';
2802import { BusinessError } from '@ohos.base';
2803import hilog from '@ohos.hilog';
2804let permissionName = "ohos.permission.GET_BUNDLE_INFO";
2805try {
2806    let PermissionDef = bundleManager.getPermissionDefSync(permissionName);
2807    hilog.info(0x0000, 'testTag', 'getPermissionDefSync successfully. Data: %{public}s', JSON.stringify(PermissionDef));
2808} catch (err) {
2809    let message = (err as BusinessError).message;
2810    hilog.error(0x0000, 'testTag', 'getPermissionDefSync failed. Cause: %{public}s', message);
2811}
2812```
2813
2814### bundleManager.getAbilityLabel
2815
2816getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<string>): void
2817
2818以异步的方法获取指定bundleName、moduleName和abilityName的label,使用callback形式返回结果。
2819
2820**系统接口:** 此接口为系统接口。
2821
2822**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2823
2824**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
2825
2826**参数:**
2827
2828| 参数名      | 类型                   | 必填 | 说明                                                         |
2829| ----------- | ---------------------- | ---- | ------------------------------------------------------------ |
2830| bundleName  | string                 | 是   | 表示应用程序的bundleName。                                     |
2831| moduleName  | string                 | 是   | 表示Module名称。                                     |
2832| abilityName | string                 | 是   | 表示UIAbility组件的名称。                                    |
2833| callback    | AsyncCallback\<string> | 是   | 回调函数,当获取成功时,err为null,data为获指定组件的Label值;否则为错误对象。 |
2834
2835**错误码:**
2836
2837以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2838
2839| 错误码ID | 错误信息                               |
2840| -------- | -------------------------------------- |
2841| 17700001 | The specified bundleName is not found.  |
2842| 17700002 | The specified moduleName is not found.  |
2843| 17700003 | The specified abilityName is not found. |
2844| 17700026 | The specified bundle is disabled.       |
2845| 17700029 | The specified ability is disabled.      |
2846
2847**示例:**
2848
2849```ts
2850import bundleManager from '@ohos.bundle.bundleManager';
2851import { BusinessError } from '@ohos.base';
2852import hilog from '@ohos.hilog';
2853let bundleName = 'com.example.myapplication';
2854let moduleName = 'entry';
2855let abilityName = 'EntryAbility';
2856
2857try {
2858    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
2859        if (err) {
2860            hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message);
2861        } else {
2862            hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', JSON.stringify(data));
2863        }
2864    });
2865} catch (err) {
2866    let message = (err as BusinessError).message;
2867    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', message);
2868}
2869```
2870
2871### bundleManager.getAbilityLabel
2872
2873getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>
2874
2875以异步的方法获取指定bundleName、moduleName和abilityName的label,使用Promise形式返回结果。
2876
2877**系统接口:** 此接口为系统接口。
2878
2879**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2880
2881**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
2882
2883**参数:**
2884
2885| 参数名      | 类型   | 必填 | 说明                      |
2886| ----------- | ------ | ---- | ------------------------- |
2887| bundleName  | string | 是   | 表示应用程序的bundleName。  |
2888| moduleName  | string | 是   | 表示Module名称。  |
2889| abilityName | string | 是   | 表示UIAbility组件的名称。 |
2890
2891**返回值:**
2892
2893| 类型             | 说明                                |
2894| ---------------- | ----------------------------------- |
2895| Promise\<string> | Promise对象,返回指定组件的Lablel值。 |
2896
2897**错误码:**
2898
2899以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2900
2901| 错误码ID | 错误信息                              |
2902| -------- | --------------------------------------- |
2903| 17700001 | The specified bundleName is not found.  |
2904| 17700002 | The specified moduleName is not found.  |
2905| 17700003 | The specified abilityName is not found. |
2906| 17700026 | The specified bundle is disabled.       |
2907| 17700029 | The specified ability is disabled.      |
2908
2909**示例:**
2910
2911```ts
2912import bundleManager from '@ohos.bundle.bundleManager';
2913import { BusinessError } from '@ohos.base';
2914import hilog from '@ohos.hilog';
2915let bundleName = 'com.example.myapplication';
2916let moduleName = 'entry';
2917let abilityName = 'EntryAbility';
2918
2919try {
2920    bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => {
2921        hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data));
2922    }).catch((err: BusinessError) => {
2923        hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message);
2924    });
2925} catch (err) {
2926    let message = (err as BusinessError).message;
2927    hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', message);
2928}
2929```
2930
2931### bundleManager.getAbilityLabelSync<sup>10+</sup>
2932
2933getAbilityLabelSync(bundleName: string, moduleName: string, abilityName: string): string
2934
2935以同步的方法获取指定bundleName、moduleName和abilityName的label。
2936
2937**系统接口:** 此接口为系统接口。
2938
2939**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2940
2941**系统能力:** SystemCapability.BundleManager.BundleFramework.Resource
2942
2943**参数:**
2944
2945| 参数名      | 类型   | 必填 | 说明                      |
2946| ----------- | ------ | ---- | ------------------------- |
2947| bundleName  | string | 是   | 表示应用程序的bundleName。  |
2948| moduleName  | string | 是   | 表示Module名称。  |
2949| abilityName | string | 是   | 表示UIAbility组件的名称。 |
2950
2951**返回值:**
2952
2953| 类型             | 说明                                |
2954| ---------------- | ----------------------------------- |
2955| string | 指定组件的Lablel值。 |
2956
2957**错误码:**
2958
2959以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
2960
2961| 错误码ID | 错误信息                              |
2962| -------- | --------------------------------------- |
2963| 17700001 | The specified bundleName is not found.  |
2964| 17700002 | The specified moduleName is not found.  |
2965| 17700003 | The specified abilityName is not found. |
2966| 17700026 | The specified bundle is disabled.       |
2967| 17700029 | The specified ability is disabled.      |
2968
2969**示例:**
2970
2971```ts
2972import bundleManager from '@ohos.bundle.bundleManager';
2973import { BusinessError } from '@ohos.base';
2974import hilog from '@ohos.hilog';
2975let bundleName = 'com.example.myapplication';
2976let moduleName = 'entry';
2977let abilityName = 'EntryAbility';
2978
2979try {
2980    let abilityLabel = bundleManager.getAbilityLabelSync(bundleName, moduleName, abilityName);
2981    hilog.info(0x0000, 'testTag', 'getAbilityLabelSync successfully. Data: %{public}s', abilityLabel);
2982} catch (err) {
2983    let message = (err as BusinessError).message;
2984    hilog.error(0x0000, 'testTag', 'getAbilityLabelSync failed. Cause: %{public}s', message);
2985}
2986```
2987
2988### bundleManager.getApplicationInfoSync
2989
2990getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md)
2991
2992以同步方法根据给定的bundleName、applicationFlags和userId获取ApplicationInfo。
2993
2994**系统接口:** 此接口为系统接口。
2995
2996**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
2997
2998**系统能力:** SystemCapability.BundleManager.BundleFramework.Core2999
3000**参数:**
3001
3002| 参数名       | 类型   | 必填 | 说明                                                       |
3003| ----------- | ------ | ---- | ----------------------------------------------------------|
3004| bundleName  | string | 是   | 表示应用程序的bundleName。                                  |
3005| applicationFlags | [number](#applicationflag) | 是   | 表示用于指定将返回的ApplicationInfo对象中包含的信息。       |
3006| userId      | number | 是   | 表示用户ID。                                         |
3007
3008**返回值:**
3009
3010| 类型            | 说明                      |
3011| --------------- | ------------------------- |
3012| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 返回ApplicationInfo对象。 |
3013
3014**错误码:**
3015
3016以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3017
3018| 错误码ID | 错误信息                             |
3019| -------- | -------------------------------------- |
3020| 17700001 | The specified bundleName is not found. |
3021| 17700004 | The specified user ID is not found.     |
3022| 17700026 | The specified bundle is disabled.      |
3023
3024**示例:**
3025
3026```ts
3027import bundleManager from '@ohos.bundle.bundleManager';
3028import { BusinessError } from '@ohos.base';
3029import hilog from '@ohos.hilog';
3030let bundleName = 'com.example.myapplication';
3031let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
3032let userId = 100;
3033
3034try {
3035    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId);
3036    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
3037} catch (err) {
3038    let message = (err as BusinessError).message;
3039    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
3040}
3041```
3042
3043### bundleManager.getApplicationInfoSync
3044
3045getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md)
3046
3047以同步方法根据给定的bundleName、applicationFlags获取ApplicationInfo。
3048
3049**系统接口:** 此接口为系统接口。
3050
3051**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3052
3053**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3054
3055**参数:**
3056
3057| 参数名           | 类型                       | 必填 | 说明                                                  |
3058| ---------------- | -------------------------- | ---- | ----------------------------------------------------- |
3059| bundleName       | string                     | 是   | 表示应用程序的bundleName。                            |
3060| applicationFlags | [number](#applicationflag) | 是   | 表示用于指定将返回的ApplicationInfo对象中包含的信息。 |
3061
3062**返回值:**
3063
3064| 类型                                                        | 说明                      |
3065| ----------------------------------------------------------- | ------------------------- |
3066| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 返回ApplicationInfo对象。 |
3067
3068**错误码:**
3069
3070以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3071
3072| 错误码ID | 错误信息                               |
3073| -------- | -------------------------------------- |
3074| 17700001 | The specified bundleName is not found. |
3075| 17700026 | The specified bundle is disabled.      |
3076
3077**示例:**
3078
3079```ts
3080import bundleManager from '@ohos.bundle.bundleManager';
3081import { BusinessError } from '@ohos.base';
3082import hilog from '@ohos.hilog';
3083let bundleName = 'com.example.myapplication';
3084let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
3085
3086try {
3087    let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags);
3088    hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data));
3089} catch (err) {
3090    let message = (err as BusinessError).message;
3091    hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message);
3092}
3093```
3094
3095### bundleManager.getBundleInfoSync
3096
3097getBundleInfoSync(bundleName: string, bundleFlags: [number](js-apis-bundleManager.md#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md)
3098
3099以同步方法根据给定的bundleName、bundleFlags和userId获取BundleInfo。
3100
3101**系统接口:** 此接口为系统接口。
3102
3103**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3104
3105**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3106
3107**参数:**
3108
3109| 参数名       | 类型   | 必填 | 说明                                                     |
3110| ----------- | ------ | ---- | -------------------------------------------------------- |
3111| bundleName  | string | 是   | 表示应用程序的bundleName。                                 |
3112| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 表示用于指定将返回的BundleInfo对象中包含的信息的标志。 |
3113| userId      | number | 是   | 表示用户ID。                                             |
3114
3115**返回值:**
3116
3117| 类型       | 说明                 |
3118| ---------- | -------------------- |
3119| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 返回BundleInfo对象。 |
3120
3121**错误码:**
3122
3123以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3124
3125| 错误码ID | 错误信息                             |
3126| -------- | ------------------------------------- |
3127| 17700001 | The specified bundleName is not found. |
3128| 17700004 | The specified user ID is not found.     |
3129| 17700026 | The specified bundle is disabled.      |
3130
3131**示例:**
3132
3133```ts
3134import bundleManager from '@ohos.bundle.bundleManager';
3135import { BusinessError } from '@ohos.base';
3136import hilog from '@ohos.hilog';
3137let bundleName = 'com.example.myapplication';
3138let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
3139let userId = 100;
3140
3141try {
3142    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId);
3143    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
3144} catch (err) {
3145    let message = (err as BusinessError).message;
3146    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
3147}
3148```
3149
3150### bundleManager.getBundleInfoSync
3151
3152getBundleInfoSync(bundleName: string, bundleFlags: [number](js-apis-bundleManager.md#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md)
3153
3154以同步方法根据给定的bundleName、bundleFlags获取BundleInfo。
3155
3156**系统接口:** 此接口为系统接口。
3157
3158**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3159
3160**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3161
3162**参数:**
3163
3164| 参数名      | 类型                  | 必填 | 说明                                                   |
3165| ----------- | --------------------- | ---- | ------------------------------------------------------ |
3166| bundleName  | string                | 是   | 表示应用程序的bundleName。                             |
3167| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | 是   | 表示用于指定将返回的BundleInfo对象中包含的信息的标志。 |
3168
3169**返回值:**
3170
3171| 类型                                              | 说明                 |
3172| ------------------------------------------------- | -------------------- |
3173| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 返回BundleInfo对象。 |
3174
3175**错误码:**
3176
3177以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3178
3179| 错误码ID | 错误信息                               |
3180| -------- | -------------------------------------- |
3181| 17700001 | The specified bundleName is not found. |
3182| 17700026 | The specified bundle is disabled.      |
3183
3184**示例:**
3185
3186```ts
3187import bundleManager from '@ohos.bundle.bundleManager';
3188import { BusinessError } from '@ohos.base';
3189import hilog from '@ohos.hilog';
3190let bundleName = 'com.example.myapplication';
3191let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
3192try {
3193    let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags);
3194    hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data));
3195} catch (err) {
3196    let message = (err as BusinessError).message;
3197    hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message);
3198}
3199```
3200
3201### bundleManager.getSharedBundleInfo<sup>10+</sup>
3202
3203getSharedBundleInfo(bundleName: string,  moduleName: string, callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void
3204
3205以异步的方法获取指定的共享包信息,使用callback形式返回结果。
3206
3207**系统接口:** 此接口为系统接口。
3208
3209**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3210
3211**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3212
3213**参数:**
3214
3215| 参数名     | 类型                                                         | 必填 | 说明                                                         |
3216| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3217| bundleName | string                                                       | 是   | 表示应用程序的bundleName。                                   |
3218| moduleName | string                                                       | 是   | 表示被查询的module的name。                                   |
3219| callback   | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | 是   | 回调函数,当获取成功时,err为null,data为获取的指定共享包信息。 |
3220
3221**错误码:**
3222
3223以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3224
3225| 错误码ID | 错误信息                               |
3226| -------- | -------------------------------------- |
3227| 17700001 | The specified bundleName is not found. |
3228| 17700002 | The specified moduleName is not found. |
3229
3230**示例:**
3231
3232```ts
3233import bundleManager from '@ohos.bundle.bundleManager';
3234import { BusinessError } from '@ohos.base';
3235import hilog from '@ohos.hilog';
3236let bundleName = 'com.example.myapplication';
3237let moduleName = 'library';
3238
3239try {
3240    bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => {
3241        if (err) {
3242            hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message);
3243        } else {
3244            hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
3245        }
3246    });
3247} catch (err) {
3248    let message = (err as BusinessError).message;
3249    hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', message);
3250}
3251```
3252
3253### bundleManager.getSharedBundleInfo<sup>10+</sup>
3254
3255getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<SharedBundleInfo\>\>
3256
3257以异步的方法获取指定的共享包信息,使用Promise形式返回结果。
3258
3259**系统接口:** 此接口为系统接口
3260
3261**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3262
3263**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3264
3265**参数:**
3266
3267| 参数名     | 类型   | 必填 | 说明                       |
3268| ---------- | ------ | ---- | -------------------------- |
3269| bundleName | string | 是   | 表示应用程序的bundleName。 |
3270| moduleName | string | 是   | 表示被查询的module的name。 |
3271
3272**返回值:**
3273
3274| 类型                                                         | 说明                                |
3275| ------------------------------------------------------------ | ----------------------------------- |
3276| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Promise对象,返回指定的共享包信息。 |
3277
3278**错误码:**
3279
3280以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3281
3282| 错误码ID | 错误信息                               |
3283| -------- | -------------------------------------- |
3284| 17700001 | The specified bundleName is not found. |
3285| 17700002 | The specified moduleName is not found. |
3286
3287**示例:**
3288
3289```ts
3290import bundleManager from '@ohos.bundle.bundleManager';
3291import { BusinessError } from '@ohos.base';
3292import hilog from '@ohos.hilog';
3293let bundleName = 'com.example.myapplication';
3294let moduleName = 'library';
3295
3296try {
3297    bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => {
3298        hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
3299    }).catch((err: BusinessError) => {
3300        hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message);
3301    });
3302} catch (err) {
3303    let message = (err as BusinessError).message;
3304    hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', message);
3305}
3306```
3307
3308### bundleManager.getAllSharedBundleInfo<sup>10+</sup>
3309
3310getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void
3311
3312以异步的方法获取所有的共享包信息,使用callback形式返回结果。
3313
3314**系统接口:** 此接口为系统接口。
3315
3316**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3317
3318**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3319
3320**参数:**
3321
3322| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3323| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3324| callback | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | 是   | 回调函数,当获取成功时,err为null,data为获所有的共享包信息。 |
3325
3326**示例:**
3327
3328```ts
3329import bundleManager from '@ohos.bundle.bundleManager';
3330import { BusinessError } from '@ohos.base';
3331import hilog from '@ohos.hilog';
3332
3333try {
3334    bundleManager.getAllSharedBundleInfo((err, data) => {
3335        if (err) {
3336            hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message);
3337        } else {
3338            hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
3339        }
3340    });
3341} catch (err) {
3342    let message = (err as BusinessError).message;
3343    hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', message);
3344}
3345```
3346
3347### bundleManager.getAllSharedBundleInfo<sup>10+</sup>
3348
3349getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>
3350
3351以异步的方法获取所有的共享包信息,使用Promise形式返回结果。
3352
3353**系统接口:** 此接口为系统接口
3354
3355**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3356
3357**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3358
3359**返回值:**
3360
3361| 类型                                                         | 说明                                |
3362| ------------------------------------------------------------ | ----------------------------------- |
3363| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Promise对象,返回所有的共享包信息。 |
3364
3365**示例:**
3366
3367```ts
3368import bundleManager from '@ohos.bundle.bundleManager';
3369import { BusinessError } from '@ohos.base';
3370import hilog from '@ohos.hilog';
3371
3372try {
3373    bundleManager.getAllSharedBundleInfo().then((data) => {
3374        hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
3375    }).catch((err: BusinessError) => {
3376        hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
3377    });
3378} catch (err) {
3379    let message = (err as BusinessError).message;
3380    hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', message);
3381}
3382```
3383
3384### bundleManager.getAppProvisionInfo<sup>10+</sup>
3385
3386getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\>): void
3387
3388以异步的方法获取指定bundleName的provision配置文件信息,使用callback形式返回结果。
3389
3390**系统接口:** 此接口为系统接口。
3391
3392**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3393
3394**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3395
3396**参数:**
3397
3398| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3399| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3400| bundleName | string | 是   | 指定应用的bundleName。 |
3401| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | 是   | 回调函数,当获取成功时,err为null,data为指定bundleName的provision配置文件信息。 |
3402
3403**错误码:**
3404
3405以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3406
3407| 错误码ID | 错误信息                               |
3408| -------- | -------------------------------------- |
3409| 17700001 | The specified bundleName is not found. |
3410
3411**示例:**
3412
3413```ts
3414import bundleManager from '@ohos.bundle.bundleManager';
3415import { BusinessError } from '@ohos.base';
3416import hilog from '@ohos.hilog';
3417let bundleName = "com.ohos.myapplication";
3418
3419try {
3420    bundleManager.getAppProvisionInfo(bundleName, (err, data) => {
3421        if (err) {
3422            hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message);
3423        } else {
3424            hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data));
3425        }
3426    });
3427} catch (err) {
3428    let message = (err as BusinessError).message;
3429    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
3430}
3431```
3432
3433### bundleManager.getAppProvisionInfo<sup>10+</sup>
3434
3435getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\>): void
3436
3437以异步的方法获取指定bundleName和userId的provision配置文件信息,使用callback形式返回结果。
3438
3439**系统接口:** 此接口为系统接口。
3440
3441**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3442
3443**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3444
3445**参数:**
3446
3447| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3448| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3449| bundleName | string | 是   | 指定应用的bundleName。 |
3450| userId | number | 是 | 指定用户ID, 可以通过接口[getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9)获取当前设备上的用户ID。 |
3451| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | 是   | 回调函数,当获取成功时,err为null,data为指定bundleName的provision配置文件信息。 |
3452
3453
3454**错误码:**
3455
3456以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3457
3458| 错误码ID | 错误信息                               |
3459| -------- | -------------------------------------- |
3460| 17700001 | The specified bundleName is not found. |
3461| 17700004 | The specified user ID is not found. |
3462
3463**示例:**
3464
3465```ts
3466import bundleManager from '@ohos.bundle.bundleManager';
3467import { BusinessError } from '@ohos.base';
3468import hilog from '@ohos.hilog';
3469let bundleName = "com.ohos.myapplication";
3470let userId = 100;
3471
3472try {
3473    bundleManager.getAppProvisionInfo(bundleName, userId, (err, data) => {
3474        if (err) {
3475            hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message);
3476        } else {
3477            hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data));
3478        }
3479    });
3480} catch (err) {
3481    let message = (err as BusinessError).message;
3482    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message);
3483}
3484```
3485
3486### bundleManager.getAppProvisionInfo<sup>10+</sup>
3487
3488getAppProvisionInfo(bundleName: string, userId?: number): Promise\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\>
3489
3490以异步的方法根据bundleName和userId获取应用的provision配置文件信息,使用Promise形式返回结果。
3491
3492**系统接口:** 此接口为系统接口
3493
3494**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3495
3496**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3497
3498**参数:**
3499
3500| 参数名   | 类型         | 必填 | 说明          |
3501| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3502| bundleName | string | 是 | 指定的bundleName。 |
3503| userId | number | 否 | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0,可以通过接口[getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9)获取当前设备上的用户ID。 |
3504
3505
3506**返回值:**
3507
3508| 类型                                                         | 说明                                |
3509| ------------------------------------------------------------ | ----------------------------------- |
3510| Promise\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Promise对象,返回应用的provision配置文件信息。 |
3511
3512**错误码:**
3513
3514以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3515
3516| 错误码ID | 错误信息                               |
3517| -------- | -------------------------------------- |
3518| 17700001 | The specified bundleName is not found. |
3519| 17700004 | The specified user ID is not found. |
3520
3521**示例:**
3522
3523```ts
3524import bundleManager from '@ohos.bundle.bundleManager';
3525import { BusinessError } from '@ohos.base';
3526import hilog from '@ohos.hilog';
3527let bundleName = "com.ohos.myapplication";
3528let userId = 100;
3529
3530try {
3531    bundleManager.getAppProvisionInfo(bundleName).then((data) => {
3532        hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
3533    }).catch((err: BusinessError) => {
3534        hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
3535    });
3536} catch (err) {
3537    let message = (err as BusinessError).message;
3538    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
3539}
3540
3541try {
3542    bundleManager.getAppProvisionInfo(bundleName, userId).then((data) => {
3543        hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data));
3544    }).catch((err: BusinessError) => {
3545        hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
3546    });
3547} catch (err) {
3548    let message = (err as BusinessError).message;
3549    hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message);
3550}
3551```
3552
3553### bundleManager.getAppProvisionInfoSync<sup>10+</sup>
3554
3555getAppProvisionInfoSync(bundleName: string, userId?: number): AppProvisionInfo
3556
3557以同步方法根据bundleName和userId获取应用的provision配置文件信息并返回结果。
3558
3559**系统接口:** 此接口为系统接口
3560
3561**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3562
3563**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3564
3565**参数:**
3566
3567| 参数名   | 类型         | 必填 | 说明          |
3568| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3569| bundleName | string | 是 | 指定的bundleName。 |
3570| userId | number | 否 | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0,可以通过接口[getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9)获取当前设备上的用户ID。 |
3571
3572
3573**返回值:**
3574
3575| 类型                                                         | 说明                                |
3576| ------------------------------------------------------------ | ----------------------------------- |
3577| [AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md) | AppProvisionInfo对象,返回应用的provision配置文件信息。 |
3578
3579**错误码:**
3580
3581以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3582
3583| 错误码ID | 错误信息                               |
3584| -------- | -------------------------------------- |
3585| 17700001 | The specified bundleName is not found. |
3586| 17700004 | The specified user ID is not found. |
3587
3588**示例:**
3589
3590```ts
3591import bundleManager from '@ohos.bundle.bundleManager';
3592import { BusinessError } from '@ohos.base';
3593import hilog from '@ohos.hilog';
3594let bundleName = "com.ohos.myapplication";
3595let userId = 100;
3596
3597try {
3598    let data = bundleManager.getAppProvisionInfoSync(bundleName);
3599    hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
3600} catch (err) {
3601    let message = (err as BusinessError).message;
3602    hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
3603}
3604
3605try {
3606    let data = bundleManager.getAppProvisionInfoSync(bundleName, userId);
3607    hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data));
3608} catch (err) {
3609    let message = (err as BusinessError).message;
3610    hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message);
3611}
3612```
3613
3614### bundleManager.getSpecifiedDistributionType<sup>10+</sup>
3615getSpecifiedDistributionType(bundleName: string): string
3616
3617以同步的方法查询指定bundleName的分发类型,该返回值是在调用install接口时传入的[InstallParam](./js-apis-installer-sys.md#installparam)中的specifiedDistributionType字段。
3618
3619**系统接口:** 此接口为系统接口。
3620
3621**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3622
3623**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3624
3625**参数:**
3626
3627| 参数名         | 类型                                | 必填 | 说明                         |
3628| -------------- | ----------------------------------- | ---- | ---------------------------- |
3629| bundleName | string | 是   | 指定的bundleName。 |
3630
3631**返回值:**
3632
3633| 类型          | 说明                                   |
3634| ------------- | -------------------------------------- |
3635| string | 返回指定bundleName的分发类型。 |
3636
3637**错误码:**
3638
3639以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3640
3641| 错误码ID | 错误信息                                                     |
3642| -------- | ------------------------------------------------------------ |
3643| 17700001 | The specified bundleName is not found. |
3644
3645**示例:**
3646```ts
3647import bundleManager from '@ohos.bundle.bundleManager';
3648import { BusinessError } from '@ohos.base';
3649let bundleName = "com.example.myapplication";
3650
3651try {
3652    let type = bundleManager.getSpecifiedDistributionType(bundleName);
3653    console.info('getSpecifiedDistributionType successfully, type:' + type);
3654} catch (error) {
3655    let message = (error as BusinessError).message;
3656    console.error('getSpecifiedDistributionType failed. Cause: ' + message);
3657}
3658```
3659
3660
3661### bundleManager.getAdditionalInfo<sup>10+</sup>
3662
3663getAdditionalInfo(bundleName: string): string
3664
3665以同步接口查询指定bundleName的额外信息。该返回值是在调用install接口时传入的[InstallParam](./js-apis-installer-sys.md#installparam)中的additionalInfo字段。
3666
3667**系统接口:** 此接口为系统接口。
3668
3669**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3670
3671**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3672
3673**参数:**
3674
3675| 参数名         | 类型                                | 必填 | 说明                         |
3676| -------------- | ----------------------------------- | ---- | ---------------------------- |
3677| bundleName | string | 是   | 指定的bundleName。 |
3678
3679**返回值:**
3680
3681| 类型          | 说明                                   |
3682| ------------- | -------------------------------------- |
3683| string | 返回指定bundleName的额外信息。 |
3684
3685**错误码:**
3686
3687以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3688
3689| 错误码ID | 错误信息                                                     |
3690| -------- | ------------------------------------------------------------ |
3691| 17700001 | The specified bundleName is not found. |
3692
3693**示例:**
3694
3695```ts
3696import bundleManager from '@ohos.bundle.bundleManager';
3697import { BusinessError } from '@ohos.base';
3698let bundleName = "com.example.myapplication";
3699
3700try {
3701    let info = bundleManager.getAdditionalInfo(bundleName);
3702    console.info('getAdditionalInfo successfully, additionInfo:' + info);
3703} catch (error) {
3704    let message = (error as BusinessError).message;
3705    console.error('getAdditionalInfo failed. Cause: ' + message);
3706}
3707```
3708
3709### bundleManager.queryExtensionAbilityInfoSync<sup>11+</sup>
3710
3711queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: string, extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>
3712
3713根据给定的want、extensionAbilityType、extensionAbilityFlags和userId获取ExtensionAbilityInfo,使用同步方式返回结果。
3714
3715**系统接口:** 此接口为系统接口。
3716
3717**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3718
3719**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3720
3721**参数:**
3722
3723| 参数名                | 类型                            | 必填 | 说明                                                      |
3724| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- |
3725| want                  | Want                            | 是   | 表示包含要查询的应用Bundle名称的Want。                    |
3726| extensionAbilityType  | string                          | 是   | 表示自定义extensionAbility的类型。                        |
3727| extensionAbilityFlags | [number](#extensionabilityflag) | 是   | 表示返回的ExtensionInfo对象中需要包含的信息标志。 |
3728| userId                | number                          | 否   | 表示用户ID,默认值:调用方所在用户,取值范围:大于等于0。 |
3729
3730**返回值:**
3731
3732| 类型                                                         | 说明                                   |
3733| ------------------------------------------------------------ | -------------------------------------- |
3734| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | 同步返回Array\<ExtensionAbilityInfo>。 |
3735
3736**错误码:**
3737
3738以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3739
3740| 错误码ID | 错误信息                                     |
3741| -------- | -------------------------------------------- |
3742| 17700001 | The specified bundleName is not found.       |
3743| 17700003 | The specified extensionAbility is not found. |
3744| 17700004 | The specified userId is invalid.             |
3745| 17700026 | The specified bundle is disabled.            |
3746
3747**示例:**
3748
3749```ts
3750// 示例接口带userId参数查询
3751import bundleManager from '@ohos.bundle.bundleManager';
3752import hilog from '@ohos.hilog';
3753import Want from '@ohos.app.ability.Want';
3754import { BusinessError } from '@ohos.base';
3755
3756let extensionAbilityType = "form";
3757let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
3758let userId = 100;
3759let want: Want = {
3760    bundleName : "com.example.myapplication",
3761    abilityName : "EntryAbility"
3762};
3763
3764try {
3765    let data = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId)
3766    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
3767} catch (err) {
3768    let message = (err as BusinessError).message;
3769    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
3770}
3771```
3772
3773```ts
3774// 示例接口不带userId参数查询
3775import bundleManager from '@ohos.bundle.bundleManager';
3776import hilog from '@ohos.hilog';
3777import Want from '@ohos.app.ability.Want';
3778import { BusinessError } from '@ohos.base';
3779
3780let extensionAbilityType = "form";
3781let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
3782let want: Want = {
3783    bundleName : "com.example.myapplication",
3784    abilityName : "EntryAbility"
3785};
3786
3787try {
3788    let data = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags);
3789    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
3790} catch (err) {
3791    let message = (err as BusinessError).message;
3792    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
3793}
3794```
3795
3796### bundleManager.getJsonProfile<sup>11+</sup>
3797
3798getJsonProfile(profileType: [ProfileType](#profiletype11), bundleName: string, moduleName?: string): string
3799
3800以同步的方法根据给定的profileType、bundleName和moduleName查询相应配置文件的JSON字符串。
3801
3802获取调用方自己的配置文件时不需要权限。
3803
3804**系统接口:** 此接口为系统接口。
3805
3806**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3807
3808**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3809
3810**参数:**
3811
3812| 参数名                | 类型                            | 必填 | 说明                                                      |
3813| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- |
3814| profileType           | [ProfileType](#profiletype11)     | 是   | 表示要查询的配置文件类型。                                   |
3815| bundleName            | string                          | 是   | 表示要查询应用程序的bundleName。                                  |
3816| moduleName            | string                          | 否   | 表示要查询应用程序的module的名称,缺省时在入口模块中查找。            |
3817
3818**返回值:**
3819
3820| 类型   | 说明                      |
3821| ------ | ------------------------ |
3822| string | 返回配置文件的JSON字符串。 |
3823
3824**错误码:**
3825
3826以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3827
3828| 错误码ID | 错误信息                                     |
3829| -------- | -------------------------------------------- |
3830| 17700001 | The specified bundleName is not found.       |
3831| 17700002 | The specified moduleName is not found.       |
3832| 17700024 | Failed to get the profile because the specified profile is not found in the HAP. |
3833| 17700026 | The specified bundle is disabled.            |
3834
3835**示例:**
3836
3837```ts
3838import bundleManager from '@ohos.bundle.bundleManager';
3839import hilog from '@ohos.hilog';
3840import { BusinessError } from '@ohos.base';
3841
3842let bundleName = 'com.example.myapplication';
3843let moduleName = 'entry';
3844let profileType = bundleManager.ProfileType.INTENT_PROFILE;
3845
3846try {
3847    let data = bundleManager.getJsonProfile(profileType, bundleName, moduleName)
3848    hilog.info(0x0000, 'testTag', 'getJsonProfile successfully. Data: %{public}s', data);
3849} catch (err) {
3850    let message = (err as BusinessError).message;
3851    hilog.error(0x0000, 'testTag', 'getJsonProfile failed: %{public}s', message);
3852}
3853```
3854
3855### bundleManager.getRecoverableApplicationInfo<sup>11+</sup>
3856
3857getRecoverableApplicationInfo(callback: AsyncCallback\<Array\<RecoverableApplicationInfo\>\>): void
3858
3859以异步的方法获取所有可恢复的预置应用信息,使用callback异步回调。
3860
3861**系统接口:** 此接口为系统接口。
3862
3863**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3864
3865**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3866
3867**参数:**
3868
3869| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3870| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3871| callback | AsyncCallback\<Array\<[RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md)\>\> | 是   | 回调函数,当获取成功时,err为null,data为获所有可恢复的预置应用信息。 |
3872
3873**示例:**
3874
3875```ts
3876import bundleManager from '@ohos.bundle.bundleManager';
3877import { BusinessError } from '@ohos.base';
3878import hilog from '@ohos.hilog';
3879
3880try {
3881    bundleManager.getRecoverableApplicationInfo((err, data) => {
3882        if (err) {
3883            hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', err.message);
3884        } else {
3885            hilog.info(0x0000, 'testTag', 'getRecoverableApplicationInfo successfully: %{public}s', JSON.stringify(data));
3886        }
3887    });
3888} catch (err) {
3889    let message = (err as BusinessError).message;
3890    hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', message);
3891}
3892```
3893
3894### bundleManager.getRecoverableApplicationInfo<sup>11+</sup>
3895
3896getRecoverableApplicationInfo(): Promise\<Array\<RecoverableApplicationInfo\>\>
3897
3898以异步的方法获取所有可恢复的预置应用信息,使用Promise异步回调。
3899
3900**系统接口:** 此接口为系统接口。
3901
3902**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3903
3904**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3905
3906**返回值:**
3907
3908| 类型                                                         | 说明                                |
3909| ------------------------------------------------------------ | ----------------------------------- |
3910| Promise\<Array\<[RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md)\>\> | Promise对象,返回所有可恢复的预置应用信息。 |
3911
3912**示例:**
3913
3914```ts
3915import bundleManager from '@ohos.bundle.bundleManager';
3916import { BusinessError } from '@ohos.base';
3917import hilog from '@ohos.hilog';
3918
3919try {
3920    bundleManager.getRecoverableApplicationInfo().then((data) => {
3921        hilog.info(0x0000, 'testTag', 'getRecoverableApplicationInfo successfully: %{public}s', JSON.stringify(data));
3922    }).catch((err: BusinessError) => {
3923        hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', err.message);
3924    });
3925} catch (err) {
3926    let message = (err as BusinessError).message;
3927    hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', message);
3928}
3929```
3930
3931### bundleManager.setAdditionalInfo<sup>11+</sup>
3932
3933setAdditionalInfo(bundleName: string, additionalInfo: string): void
3934
3935设置指定应用的额外信息。此接口仅供应用市场调用。
3936
3937**系统接口:** 此接口为系统接口。
3938
3939**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
3940
3941**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3942
3943**参数:**
3944
3945| 参数名                | 类型                             | 必填 | 说明                                               |
3946| --------------------- | ------------------------------- | ---- | -------------------------------------------------- |
3947| bundleName            | string                          | 是   | 指定应用的包名。                                    |
3948| additionalInfo        | string                          | 是   | 需要设置的应用的额外信息。                           |
3949
3950**错误码:**
3951
3952以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
3953
3954| 错误码ID | 错误信息                                                    |
3955| -------- | ---------------------------------------------------------- |
3956| 17700001 | The specified bundleName is not found.                     |
3957| 17700053 | Not app gallery call.                                      |
3958
3959**示例:**
3960
3961```ts
3962import bundleManager from '@ohos.bundle.bundleManager';
3963import { BusinessError } from '@ohos.base';
3964import hilog from '@ohos.hilog';
3965
3966let bundleName = "com.example.myapplication";
3967let additionalInfo = "xxxxxxxxx,formUpdateLevel:4";
3968
3969try {
3970    bundleManager.setAdditionalInfo(bundleName, additionalInfo);
3971    hilog.info(0x0000, 'testTag', 'setAdditionalInfo successfully.');
3972} catch (err) {
3973    let message = (err as BusinessError).message;
3974    hilog.error(0x0000, 'testTag', 'setAdditionalInfo failed. Cause: %{public}s', message);
3975}
3976```
3977
3978### bundleManager.queryExtensionAbilityInfoSync<sup>11+</sup>
3979
3980queryExtensionAbilityInfoSync(extensionAbilityType: string, extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>
3981
3982根据给定的extensionAbilityType、extensionAbilityFlags和userId获取ExtensionAbilityInfo。
3983
3984**系统接口:** 此接口为系统接口。
3985
3986**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
3987
3988**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
3989
3990**参数:**
3991
3992| 参数名                | 类型                            | 必填 | 说明                                                      |
3993| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- |
3994| extensionAbilityType  | string                          | 是   | 表示自定义extensionAbility的类型。                        |
3995| extensionAbilityFlags | [number](#extensionabilityflag) | 是   | 表示返回的ExtensionInfo对象中需要包含的信息标志。 |
3996| userId                | number                          | 否   | 表示用户ID,默认值:调用方所在用户ID。取值范围:大于等于0。 |
3997
3998**返回值:**
3999
4000| 类型                                                         | 说明                                   |
4001| ------------------------------------------------------------ | -------------------------------------- |
4002| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | 同步返回Array\<ExtensionAbilityInfo>。 |
4003
4004**错误码:**
4005
4006以下错误码的详细介绍请参见[ohos.bundle错误码](errorcode-bundle.md)。
4007
4008| 错误码ID | 错误信息                                     |
4009| -------- | -------------------------------------------- |
4010| 17700003 | The specified extensionAbility is not found. |
4011| 17700004 | The specified userId is invalid.             |
4012
4013**示例:**
4014
4015```ts
4016// 示例接口带userId参数查询
4017import bundleManager from '@ohos.bundle.bundleManager';
4018import hilog from '@ohos.hilog';
4019import { BusinessError } from '@ohos.base';
4020
4021let extensionAbilityType = "form";
4022let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
4023let userId = 100;
4024
4025try {
4026    let data = bundleManager.queryExtensionAbilityInfoSync(extensionAbilityType, extensionFlags, userId)
4027    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4028} catch (err) {
4029    let message = (err as BusinessError).message;
4030    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
4031}
4032```
4033
4034```ts
4035// 示例接口不带userId参数查询
4036import bundleManager from '@ohos.bundle.bundleManager';
4037import hilog from '@ohos.hilog';
4038import { BusinessError } from '@ohos.base';
4039
4040let extensionAbilityType = "form";
4041let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT;
4042
4043try {
4044    let data = bundleManager.queryExtensionAbilityInfoSync(extensionAbilityType, extensionFlags);
4045    hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data));
4046} catch (err) {
4047    let message = (err as BusinessError).message;
4048    hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message);
4049}
4050```