• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle (Bundle模块)
2
3本模块提供应用信息查询能力,支持[包信息](js-apis-bundle-BundleInfo.md)、[应用信息](js-apis-bundle-ApplicationInfo.md)、[Ability组件信息](js-apis-bundle-AbilityInfo.md)等信息的查询,以及应用禁用状态的查询、设置等。
4
5> **说明:**
6>
7> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> 从API Version 9开始,该模块不再维护,建议使用[`@ohos.bundle.bundleManager`](js-apis-bundleManager.md)替代。
9## 导入模块
10
11```ts
12import bundle from '@ohos.bundle';
13```
14
15## 权限列表
16
17| 权限                                         | 权限等级         | 描述            |
18|--------------------------------------------|--------------|---------------|
19| ohos.permission.CHANGE_ABILITY_ENABLED_STATE | system_basic | 设置禁用使能所需的权限。 |
20| ohos.permission.GET_BUNDLE_INFO | normal | 查询指定应用信息。 |
21| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息。     |
22| ohos.permission.INSTALL_BUNDLE             | system_core  | 可安装、卸载应用。      |
23| ohos.permission.REMOVE_CACHE_FILES | system_basic | 清理应用缓存。 |
24
25权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)。
26
27## bundle.getApplicationInfo<sup>deprecated<sup>
28
29> 从API version 9开始不再维护。
30
31getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo>
32
33以异步方法根据给定的Bundle名称获取ApplicationInfo。使用Promise异步回调。
34
35获取调用方自己的信息时不需要权限。
36
37**需要权限:**
38
39ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
40
41**系统能力:**
42
43SystemCapability.BundleManager.BundleFramework
44
45**参数:**
46
47| 参数名      | 类型   | 必填 | 说明                                                         |
48| ----------- | ------ | ---- | ------------------------------------------------------------ |
49| bundleName  | string | 是   | 要查询的应用Bundle名称。                                     |
50| bundleFlags | number | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围请参考[BundleFlag说明](#bundleflagdeprecated)中应用信息相关flag。 |
51| userId      | number | 否   | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。        |
52
53**返回值:**
54
55| 类型                        | 说明                 |
56| ------------------------- | ------------------ |
57| Promise\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Promise形式返回应用程序信息。 |
58
59**示例:**
60
61```ts
62import bundle from '@ohos.bundle';
63import { BusinessError } from '@ohos.base';
64
65let bundleName: string = "com.example.myapplication";
66let bundleFlags: number = 0;
67let userId: number = 100;
68bundle.getApplicationInfo(bundleName, bundleFlags, userId)
69.then((data) => {
70    console.info('Operation successful. Data: ' + JSON.stringify(data));
71}).catch((error: BusinessError) => {
72    console.error('Operation failed. Cause: ' + JSON.stringify(error));
73})
74```
75
76## bundle.getApplicationInfo<sup>deprecated<sup>
77
78> 从API version 9开始不再维护。
79
80getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void
81
82以异步方法根据给定的Bundle名称获取指定用户下的ApplicationInfo,使用callback形式返回结果。
83
84获取调用方自己的信息时不需要权限。
85
86**需要权限:**
87
88ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
89
90**系统能力:**
91
92SystemCapability.BundleManager.BundleFramework
93
94**参数:**
95
96| 参数名      | 类型                                                         | 必填 | 说明                                                         |
97| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
98| bundleName  | string                                                       | 是   | 要查询的应用Bundle名称。                                     |
99| bundleFlags | number                                                       | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中应用信息相关flag。 |
100| userId      | number                                                       | 是   | 用户ID。取值范围:大于等于0。                                |
101| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | 是   | 程序启动作为入参的回调函数,返回应用程序信息。               |
102
103**示例:**
104
105```ts
106import bundle from '@ohos.bundle';
107
108let bundleName: string = "com.example.myapplication";
109let bundleFlags: number = 0;
110let userId: number = 100;
111bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => {
112    if (err) {
113        console.error('Operation failed. Cause: ' + JSON.stringify(err));
114        return;
115    }
116    console.info('Operation successful. Data:' + JSON.stringify(data));
117 })
118```
119
120## bundle.getApplicationInfo<sup>deprecated<sup>
121
122> 从API version 9开始不再维护。
123
124
125getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void
126
127以异步方法根据给定的Bundle名称获取ApplicationInfo,使用callback形式返回结果。
128
129获取调用方自己的信息时不需要权限。
130
131**需要权限:**
132
133ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
134
135**系统能力:**
136
137SystemCapability.BundleManager.BundleFramework
138
139**参数:**
140
141| 参数名      | 类型                                                         | 必填 | 说明                                                         |
142| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
143| bundleName  | string                                                       | 是   | 要查询的应用Bundle名称。                                     |
144| bundleFlags | number                                                       | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中应用信息相关flag。 |
145| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | 是   | 程序启动作为入参的回调函数,返回应用程序信息。               |
146
147**示例:**
148
149```ts
150import bundle from '@ohos.bundle';
151
152let bundleName: string = "com.example.myapplication";
153let bundleFlags: number = 0;
154bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
155    if (err) {
156        console.error('Operation failed. Cause: ' + JSON.stringify(err));
157        return;
158    }
159    console.info('Operation successful. Data:' + JSON.stringify(data));
160 })
161```
162
163
164## bundle.getAllBundleInfo<sup>deprecated<sup>
165
166> 从API version 9开始不再维护。
167
168getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\<Array\<BundleInfo\>\>
169
170以异步方法获取指定用户所有的BundleInfo,使用Promise形式异步回调,
171
172**需要权限:**
173
174ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
175
176**系统能力:**
177
178SystemCapability.BundleManager.BundleFramework
179
180**参数:**
181
182| 参数名     | 类型       | 必填 | 说明                                                         |
183| ---------- | ---------- | ---- | ------------------------------------------------------------ |
184| bundleFlag | BundleFlag | 是   | 用于指定返回的包信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
185| userId     | number     | 否   | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。        |
186
187**返回值:**
188
189| 类型                          | 说明                         |
190| --------------------------- | -------------------------- |
191| Promise<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Promise形式返回所有可用的BundleInfo |
192
193**示例:**
194
195```ts
196import bundle from '@ohos.bundle';
197import { BusinessError } from '@ohos.base';
198
199let bundleFlag: number = 0;
200let userId: number = 100;
201
202bundle.getAllBundleInfo(bundleFlag, userId)
203.then((data) => {
204    console.info('Operation successful. Data: ' + JSON.stringify(data));
205}).catch((error: BusinessError) => {
206    console.error('Operation failed. Cause: ' + JSON.stringify(error));
207})
208```
209
210## bundle.getAllBundleInfo<sup>deprecated<sup>
211
212> 从API version 9开始不再维护。
213
214
215getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\<Array\<BundleInfo\>\>): void
216
217以异步方法获取当前用户所有的BundleInfo,使用callback形式返回结果。
218
219**需要权限:**
220
221ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
222
223**系统能力:**
224
225SystemCapability.BundleManager.BundleFramework
226
227**参数:**
228
229| 参数名     | 类型                                                         | 必填 | 说明                                                         |
230| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
231| bundleFlag | BundleFlag                                                   | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
232| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | 是   | 程序启动作为入参的回调函数,返回所有可用的BundleInfo。       |
233
234**示例:**
235
236```ts
237import bundle from '@ohos.bundle';
238
239let bundleFlag: number = 0;
240bundle.getAllBundleInfo(bundleFlag, (err, data) => {
241    if (err) {
242        console.error('Operation failed. Cause: ' + JSON.stringify(err));
243        return;
244    }
245    console.info('Operation successful. Data:' + JSON.stringify(data));
246 })
247```
248
249## bundle.getAllBundleInfo<sup>deprecated<sup>
250
251> 从API version 9开始不再维护。
252
253
254getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\<Array\<BundleInfo\>\>): void
255
256以异步方法获取系统中指定用户下所有的BundleInfo,使用callback形式返回结果。
257
258**需要权限:**
259
260ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
261
262**系统能力:**
263
264SystemCapability.BundleManager.BundleFramework
265
266**参数:**
267
268| 参数名        | 类型                                                                | 必填  | 说明                                                                  |
269|------------|-------------------------------------------------------------------|-----|---------------------------------------------------------------------|
270| bundleFlag | BundleFlag                                                        | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
271| userId     | number                                                            | 是   | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。                                        |
272| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | 是   | 程序启动作为入参的回调函数,返回指定用户下所有包的BundleInfo。                                |
273|
274
275**示例:**
276
277```ts
278import bundle from '@ohos.bundle';
279
280let bundleFlag: number = 0;
281let userId: number = 100;
282bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
283    if (err) {
284        console.error('Operation failed. Cause: ' + JSON.stringify(err));
285        return;
286    }
287    console.info('Operation successful. Data:' + JSON.stringify(data));
288 })
289```
290
291## bundle.getBundleInfo<sup>deprecated<sup>
292
293> 从API version 9开始不再维护。
294
295
296getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo>
297
298以异步方法根据给定的Bundle名称获取BundleInfo,使用Promise异步回调。
299
300获取调用方自己的信息时不需要权限。
301
302**需要权限:**
303
304ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
305
306**系统能力:**
307
308SystemCapability.BundleManager.BundleFramework
309
310**参数:**
311
312| 参数名         | 类型            | 必填   | 说明                                                                  |
313| ----------- | ------------- | ---- |---------------------------------------------------------------------|
314| bundleName  | string        | 是    | 要查询的应用Bundle名称。                                                 |
315| bundleFlags | number        | 是    | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
316| options     | [BundleOptions](#bundleoptionsdeprecated) | 否    | 包含userid的查询选项。                                                      |
317
318**返回值:**
319
320| 类型                   | 说明                           |
321| -------------------- | ---------------------------- |
322| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise对象,获取成功时返回包信息。 |
323
324**示例:**
325
326```ts
327import bundle from '@ohos.bundle';
328import { BusinessError } from '@ohos.base';
329
330let bundleName: string = "com.example.myapplication";
331let bundleFlags: number = 1;
332let options: bundle.BundleOptions = {
333    "userId": 100
334};
335bundle.getBundleInfo(bundleName, bundleFlags, options)
336.then((data) => {
337    console.info('Operation successful. Data: ' + JSON.stringify(data));
338}).catch((error: BusinessError) => {
339    console.error('Operation failed. Cause: ' + JSON.stringify(error));
340})
341```
342
343## bundle.getBundleInfo<sup>deprecated<sup>
344
345> 从API version 9开始不再维护。
346
347getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
348
349以异步方法根据给定的Bundle名称获取BundleInfo,使用callback异步回调。
350
351获取调用方自己的信息时不需要权限。
352
353**需要权限:**
354
355ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
356
357**系统能力:**
358
359SystemCapability.BundleManager.BundleFramework
360
361**参数:**
362
363| 参数名      | 类型                                                       | 必填 | 说明                                                         |
364| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
365| bundleName  | string                                                     | 是   | 需要查询的应用Bundle名称。                                   |
366| bundleFlags | number                                                     | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
367| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是   | 程序启动作为入参的回调函数,返回包信息。                     |
368
369**示例:**
370
371```ts
372import bundle from '@ohos.bundle';
373
374let bundleName: string = "com.example.myapplication";
375let bundleFlags: number = 1;
376bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
377    if (err) {
378        console.error('Operation failed. Cause: ' + JSON.stringify(err));
379        return;
380    }
381    console.info('Operation successful. Data:' + JSON.stringify(data));
382})
383```
384
385## bundle.getBundleInfo<sup>deprecated<sup>
386
387> 从API version 9开始不再维护。
388
389getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void
390
391以异步方法根据给定的Bundle名称获取BundleInfo,使用callback异步回调。
392
393获取调用方自己的信息时不需要权限。
394
395**需要权限:**
396
397ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
398
399**系统能力:**
400
401SystemCapability.BundleManager.BundleFramework
402
403**参数:**
404
405| 参数名      | 类型                                                       | 必填 | 说明                                                         |
406| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
407| bundleName  | string                                                     | 是   | 要查询的应用Bundle名称。                                     |
408| bundleFlags | number                                                     | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
409| options     | [BundleOptions](#bundleoptionsdeprecated)                            | 是   | 包含userid。                                                 |
410| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是   | 程序启动作为入参的回调函数,返回包信息。                     |
411
412**示例:**
413
414```ts
415import bundle from '@ohos.bundle';
416
417let bundleName: string = "com.example.myapplication";
418let bundleFlags: number = 1;
419let options: bundle.BundleOptions = {
420    "userId": 100
421};
422bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
423    if (err) {
424        console.error('Operation failed. Cause: ' + JSON.stringify(err));
425        return;
426    }
427    console.info('Operation successful. Data:' + JSON.stringify(data));
428})
429```
430
431
432
433## bundle.getBundleInstaller<sup>deprecated<sup>
434
435> 从API version 9开始不再维护,建议使用[installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller)替代。
436
437getBundleInstaller(): Promise&lt;BundleInstaller&gt;
438
439获取用于安装包的接口,使用Promise异步回调,返回安装接口对象。
440
441**需要权限:**
442
443ohos.permission.INSTALL_BUNDLE
444
445**系统能力:**
446
447SystemCapability.BundleManager.BundleFramework
448
449**系统API:**
450
451此接口为系统接口。
452
453**返回值:**
454
455| 类型                                                         | 说明                                         |
456| ------------------------------------------------------------ | -------------------------------------------- |
457| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise对象,返回安装接口对象。 |
458
459**示例:**
460
461```ts
462import bundle from '@ohos.bundle';
463import { BusinessError } from '@ohos.base';
464
465bundle.getBundleInstaller().then((data) => {
466    console.info('getBundleInstaller successfully.');
467}).catch((error: BusinessError) => {
468    console.error('getBundleInstaller failed.');
469});
470```
471
472## bundle.getBundleInstaller<sup>deprecated<sup>
473
474> 从API version 9开始不再维护,建议使用[installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller)替代。
475
476getBundleInstaller(callback: AsyncCallback&lt;BundleInstaller&gt;): void
477
478获取用于安装包的接口,使用callback异步回调。
479
480**需要权限:**
481
482ohos.permission.INSTALL_BUNDLE
483
484**系统能力:**
485
486SystemCapability.BundleManager.BundleFramework
487
488**系统API:**
489
490此接口为系统接口。
491
492**参数:**
493
494| 参数名   | 类型                                                         | 必填 | 说明             |
495| -------- | ------------------------------------------------------------ | ---- | ---------------- |
496| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 是   | 回调函数,返回安装接口对象。 |
497
498**示例:**
499
500```ts
501import bundle from '@ohos.bundle';
502
503bundle.getBundleInstaller((err, data) => {
504    if (err.code == 0) {
505        console.error('getBundleInstaller failed.');
506    } else {
507        console.info('getBundleInstaller successfully');
508    }
509});
510```
511## bundle.cleanBundleCacheFiles<sup>8+</sup> <sup>deprecated<sup>
512
513> 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。
514
515cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback&lt;void&gt;): void
516
517清除指定应用程序的缓存数据,使用callback异步回调。
518
519**需要权限:**
520
521ohos.permission.REMOVE_CACHE_FILES
522
523**系统能力:**
524
525SystemCapability.BundleManager.BundleFramework
526
527**系统API:**
528
529此接口为系统接口。
530
531**参数:**
532
533| 参数名      | 类型                | 必填 | 说明                                  |
534| ---------- | ------------------- | ---- | ------------------------------------- |
535| bundleName | string              | 是   | 指示要清除其缓存数据的应用Bundle名称。 |
536| callback   | AsyncCallback\<void> | 是   | 回调函数。          |
537
538**示例:**
539
540```ts
541import bundle from '@ohos.bundle';
542
543let bundleName: string = "com.example.myapplication";
544
545bundle.cleanBundleCacheFiles(bundleName, err => {
546    if (err) {
547        console.error('cleanBundleCacheFiles failed.');
548    } else {
549        console.info('cleanBundleCacheFiles successfully.');
550    }
551});
552```
553
554## bundle.cleanBundleCacheFiles<sup>8+</sup> <sup>deprecated<sup>
555
556> 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。
557
558cleanBundleCacheFiles(bundleName: string): Promise&lt;void&gt;
559
560清除指定应用程序的缓存数据,使用Promise异步回调。
561
562**需要权限:**
563
564ohos.permission.REMOVE_CACHE_FILES
565
566**系统能力:**
567
568SystemCapability.BundleManager.BundleFramework
569
570**系统API:**
571
572此接口为系统接口。
573
574**参数:**
575
576| 参数名     | 类型   | 必填 | 说明                                  |
577| ---------- | ------ | ---- | ------------------------------------- |
578| bundleName | string | 是   | 指示要清除其缓存数据的应用Bundle名称。 |
579
580**返回值:**
581
582| 类型          | 说明                                 |
583| ------------- | ------------------------------------ |
584| Promise\<void> | Promise对象,无返回结果的Promise对象。 |
585
586**示例:**
587
588```ts
589import bundle from '@ohos.bundle';
590import { BusinessError } from '@ohos.base';
591
592let bundleName: string = "com.example.myapplication";
593
594bundle.cleanBundleCacheFiles(bundleName).then(()=> {
595    console.info('cleanBundleCacheFiles successfully.');
596}).catch((error: BusinessError) => {
597    console.error('cleanBundleCacheFiles failed.');
598});
599```
600
601## bundle.setApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
602
603> 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。
604
605setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void
606
607设置是否启用指定的应用程序,使用callback异步回调。
608
609**需要权限:**
610
611ohos.permission.CHANGE_ABILITY_ENABLED_STATE
612
613**系统能力:**
614
615SystemCapability.BundleManager.BundleFramework
616
617**系统API:**
618
619此接口为系统接口。
620
621**参数:**
622
623| 参数名      | 类型                | 必填 | 说明                             |
624| ---------- | ------------------- | ---- |--------------------------------|
625| bundleName | string              | 是   | 指示需要启用或禁用的应用Bundle名称。          |
626| isEnable   | boolean             | 是   | 指定是否启用应用程序。true表示启用,false表示禁用。 |
627| callback   | AsyncCallback\<void> | 是   | 回调函数。                          |
628
629**示例:**
630
631```ts
632import bundle from '@ohos.bundle';
633
634let bundleName: string = "com.example.myapplication";
635
636bundle.setApplicationEnabled(bundleName, false, err => {
637    if (err) {
638        console.error('setApplicationEnabled failed.');
639    } else {
640        console.info('setApplicationEnabled successfully.');
641    }
642});
643```
644
645## bundle.setApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
646
647> 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。
648
649setApplicationEnabled(bundleName: string, isEnable: boolean): Promise&lt;void&gt;
650
651设置是否启用指定的应用程序,使用Promise异步回调。
652
653**需要权限:**
654
655ohos.permission.CHANGE_ABILITY_ENABLED_STATE
656
657**系统能力:**
658
659SystemCapability.BundleManager.BundleFramework
660
661**系统API:**
662
663此接口为系统接口。
664
665**参数:**
666
667| 参数名     | 类型    | 必填 | 说明                                            |
668| ---------- | ------- | ---- | ----------------------------------------------- |
669| bundleName | string  | 是   | 指示需要启用或禁用的应用Bundle名称。            |
670| isEnable   | boolean | 是   | 指定是否启用应用程序。true表示启用,false禁用。 |
671
672**返回值:**
673
674| 类型          | 说明                                 |
675| ------------- | ------------------------------------ |
676| Promise\<void> | Promise对象,无返回结果的Promise对象。 |
677
678**示例:**
679
680```ts
681import bundle from '@ohos.bundle';
682import { BusinessError } from '@ohos.base';
683
684let bundleName: string = "com.example.myapplication";
685
686bundle.setApplicationEnabled(bundleName, false).then(()=> {
687    console.info('setApplicationEnabled successfully.');
688}).catch((error: BusinessError) => {
689    console.error('setApplicationEnabled failed.');
690});
691```
692
693## bundle.setAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
694
695> 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。
696
697setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void
698
699设置是否启用指定的Ability组件,使用callback异步回调。
700
701**需要权限:**
702
703ohos.permission.CHANGE_ABILITY_ENABLED_STATE
704
705**系统能力:**
706
707SystemCapability.BundleManager.BundleFramework
708
709**系统API:**
710
711此接口为系统接口。
712
713**参数:**
714
715| 参数名   | 类型                                         | 必填 | 说明                                            |
716| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
717| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是   | Ability信息,指示需要设置启用状态的Ability。                                   |
718| isEnable | boolean                                      | 是   | 指定是否启用应用程序。true表示启用,false禁用。 |
719| callback | AsyncCallback\<void>                         | 是   | 为返回操作结果而调用的回调。                    |
720
721## bundle.setAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
722
723> 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。
724
725setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise&lt;void&gt;
726
727设置是否启用指定的Ability组件,使用Promise异步回调。
728
729**需要权限:**
730
731ohos.permission.CHANGE_ABILITY_ENABLED_STATE
732
733**系统能力:**
734
735SystemCapability.BundleManager.BundleFramework
736
737**系统API:**
738
739此接口为系统接口。
740
741**参数:**
742
743| 参数名   | 类型                                         | 必填 | 说明                                            |
744| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
745| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是   | Ability信息,指示需要设置启用状态的Ability。                                   |
746| isEnable | boolean                                      | 是   | 指定是否启用应用程序。true表示启用,false禁用。 |
747
748**返回值:**
749
750| 类型          | 说明                                 |
751| ------------- | ------------------------------------ |
752| Promise\<void> | Promise对象,无返回结果的Promise对象。 |
753
754**示例:**
755
756```ts
757import bundle from '@ohos.bundle';
758import { BusinessError } from '@ohos.base';
759
760let bundleName: string = "com.example.myapplication";
761let abilityName: string = "EntryAbility";
762
763bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo) => {
764    console.info('getAbilityInfo successfully. Data: ' + JSON.stringify(abilityInfo));
765
766    bundle.setAbilityEnabled(abilityInfo, false).then(data => {
767        console.info('setAbilityEnabled successfully.');
768    }).catch((error: BusinessError) => {
769        console.error('setAbilityEnabled failed:' + JSON.stringify(error));
770    })
771}).catch((error: BusinessError) => {
772    console.error('getAbilityInfo failed. Cause: ' + JSON.stringify(error));
773});
774```
775## bundle.getPermissionDef<sup>8+</sup> <sup>deprecated<sup>
776
777> 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。
778
779getPermissionDef(permissionName: string, callback: AsyncCallback&lt;PermissionDef&gt;): void
780
781按权限名称获取权限的详细信息,使用callback异步回调。
782
783**需要权限:**
784
785ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
786
787**系统能力:**
788
789SystemCapability.BundleManager.BundleFramework
790
791**系统API:**
792
793此接口为系统接口。
794
795**参数:**
796
797| 参数名         | 类型                                                         | 必填 | 说明                                             |
798| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
799| permissionName | string                                                       | 是   | 需要查询的权限的名称。                                 |
800| callback       | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef.md)> | 是   | 程序启动作为入参的回调函数,返回定义的权限信息。 |
801
802**示例:**
803
804```ts
805import bundle from '@ohos.bundle';
806
807let permission: string = "ohos.permission.GET_BUNDLE_INFO";
808bundle.getPermissionDef(permission, (err, data) => {
809    if (err) {
810        console.error('getPermissionDef failed:' + err.message);
811    } else {
812        console.info('getPermissionDef successfully:' + JSON.stringify(data));
813    }
814});
815```
816
817## bundle.getPermissionDef<sup>8+</sup> <sup>deprecated<sup>
818
819> 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。
820
821getPermissionDef(permissionName: string): Promise&lt;PermissionDef&gt;
822
823按权限名称获取权限的详细信息,使用promise异步回调。。
824
825**需要权限:**
826
827ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
828
829**系统能力:**
830
831SystemCapability.BundleManager.BundleFramework
832
833**系统API:**
834
835此接口为系统接口。
836
837**参数:**
838
839| 参数名         | 类型   | 必填 | 说明             |
840| -------------- | ------ | ---- | ---------------- |
841| permissionName | string | 是   | 需要查询的权限的名称。 |
842
843**返回值:**
844
845| 类型                                                   | 说明                                                   |
846| ------------------------------------------------------ | ------------------------------------------------------ |
847| Promise<[PermissionDef](js-apis-bundle-PermissionDef.md)> | Promise对象,获取成功时返回权限详细信息。 |
848
849**示例:**
850
851```ts
852import bundle from '@ohos.bundle';
853import { BusinessError } from '@ohos.base';
854
855let permissionName: string = "ohos.permission.GET_BUNDLE_INFO";
856bundle.getPermissionDef(permissionName).then((data) => {
857    console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data));
858}).catch((error: BusinessError) => {
859    console.error('getPermissionDef failed. Cause: ' + error.message);
860});
861```
862
863## bundle.getAllApplicationInfo<sup>deprecated<sup>
864
865> 从API version 9开始不再维护。
866
867getAllApplicationInfo(bundleFlags: number, userId?: number): Promise\<Array\<ApplicationInfo\>\>
868
869获取指定用户下所有已安装的应用信息,使用promise异步回调。
870
871**需要权限:**
872
873ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
874
875**系统能力:**
876
877SystemCapability.BundleManager.BundleFramework
878
879**参数:**
880
881| 参数名      | 类型   | 必填 | 说明                                                         |
882| ----------- | ------ | ---- | ------------------------------------------------------------ |
883| bundleFlags | number | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中应用信息相关flag。 |
884| userId      | number | 否   | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。        |
885
886**返回值:**
887
888| 类型                               | 说明                              |
889| -------------------------------- | ------------------------------- |
890| Promise<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Promise对象,获取成功时返回应用信息列表。 |
891
892**示例:**
893
894```ts
895import bundle from '@ohos.bundle';
896import { BusinessError } from '@ohos.base';
897
898let bundleFlags: number = 8;
899let userId: number = 100;
900bundle.getAllApplicationInfo(bundleFlags, userId)
901.then((data) => {
902    console.info('Operation successful. Data: ' + JSON.stringify(data));
903}).catch((error: BusinessError) => {
904    console.error('Operation failed. Cause: ' + JSON.stringify(error));
905})
906```
907
908## bundle.getAllApplicationInfo<sup>deprecated<sup>
909
910> 从API version 9开始不再维护。
911
912getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<ApplicationInfo\>\>): void
913
914获取指定用户下所有已安装的应用信息,使用callback异步回调。
915
916**需要权限:**
917
918ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
919
920**系统能力:**
921
922SystemCapability.BundleManager.BundleFramework
923
924**参数:**
925
926| 参数名      | 类型                                                         | 必填 | 说明                                                         |
927| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
928| bundleFlags | number                                                       | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中应用信息相关flag。 |
929| userId      | number                                                       | 是   | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。        |
930| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | 是   | 程序启动作为入参的回调函数,返回应用信息列表。               |
931
932**示例:**
933
934```ts
935import bundle from '@ohos.bundle';
936
937let bundleFlags: number = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
938let userId: number = 100;
939bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
940    if (err) {
941        console.error('Operation failed. Cause: ' + JSON.stringify(err));
942        return;
943    }
944    console.info('Operation successful. Data:' + JSON.stringify(data));
945})
946```
947
948
949## bundle.getAllApplicationInfo<sup>deprecated<sup>
950
951> 从API version 9开始不再维护。
952
953getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback\<Array\<ApplicationInfo\>\>): void
954
955获取调用方所在用户下已安装的应用信息,使用callback异步回调。
956
957**需要权限:**
958
959ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
960
961**系统能力:**
962
963SystemCapability.BundleManager.BundleFramework
964
965**参数:**
966
967| 参数名      | 类型                                                         | 必填 | 说明                                                         |
968| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
969| bundleFlags | number                                                       | 是   | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中应用信息相关flag。 |
970| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | 是   | 程序启动作为入参的回调函数,返回应用信息列表。               |
971
972**示例:**
973
974```ts
975import bundle from '@ohos.bundle';
976
977let bundleFlags: number = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
978bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
979    if (err) {
980        console.error('Operation failed. Cause: ' + JSON.stringify(err));
981        return;
982    }
983    console.info('Operation successful. Data:' + JSON.stringify(data));
984})
985```
986
987## bundle.getBundleArchiveInfo<sup>deprecated<sup>
988
989> 从API version 9开始不再维护。
990
991getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo>
992
993获取有关HAP中包含的应用程序包的信息,使用Promise形式返回结果。
994
995**系统能力:**
996
997SystemCapability.BundleManager.BundleFramework
998
999**参数:**
1000
1001| 参数名        | 类型     | 必填   | 说明           |
1002| ---------- | ------ | ---- | ------------ |
1003| hapFilePath | string | 是    | HAP存放路径。支持当前应用程序的绝对路径和数据目录沙箱路径。 |
1004| bundleFlags | number | 是    | 用于指定要返回的BundleInfo对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
1005
1006**返回值:**
1007| 类型                                                 | 说明                                                         |
1008| ---------------------------------------------------- | ------------------------------------------------------------ |
1009| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 返回值为Promise对象,Promise中包含有关HAP中包含的应用程序的信息。 |
1010
1011**示例:**
1012
1013```ts
1014import bundle from '@ohos.bundle';
1015import { BusinessError } from '@ohos.base';
1016
1017let hapFilePath: string = "/data/storage/el2/base/test.hap";
1018let bundleFlags: number = 0;
1019bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
1020.then((data) => {
1021    console.info('Operation successful. Data: ' + JSON.stringify(data));
1022}).catch((error: BusinessError) => {
1023    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1024})
1025```
1026
1027## bundle.getBundleArchiveInfo<sup>deprecated<sup>
1028
1029> 从API version 9开始不再维护。
1030
1031getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void
1032
1033以异步方法获取有关HAP中包含的应用程序包的信息,使用callback形式返回结果。
1034
1035**系统能力:**
1036
1037SystemCapability.BundleManager.BundleFramework
1038
1039**参数:**
1040
1041| 参数名        | 类型     | 必填   | 说明           |
1042| ---------- | ------ | ---- | ------------ |
1043| hapFilePath | string | 是    | HAP存放路径,支持当前应用程序的绝对路径和数据目录沙箱路径。 |
1044| bundleFlags | number | 是    | 用于指定要返回的BundleInfo对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中包信息相关flag。 |
1045| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是    | 程序启动作为入参的回调函数,返回HAP中包含的应用程序包的信息。 |
1046
1047**示例:**
1048
1049```ts
1050import bundle from '@ohos.bundle';
1051
1052let hapFilePath: string = "/data/storage/el2/base/test.hap";
1053let bundleFlags: number = 0;
1054bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
1055    if (err) {
1056        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1057        return;
1058    }
1059    console.info('Operation successful. Data:' + JSON.stringify(data));
1060})
1061```
1062
1063## bundle.getAbilityInfo<sup>deprecated<sup>
1064
1065> 从API version 9开始不再维护。
1066
1067getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo>
1068
1069通过Bundle名称和组件名获取Ability组件信息,使用Promise形式异步回调。
1070
1071获取调用方自己的信息时不需要权限。
1072
1073**需要权限:**
1074
1075ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1076
1077**系统能力:**
1078
1079SystemCapability.BundleManager.BundleFramework
1080
1081**参数:**
1082
1083| 参数名         | 类型     | 必填   | 说明         |
1084| ----------- | ------ | ---- |------------|
1085| bundleName  | string | 是    | 应用Bundle名称。 |
1086| abilityName | string | 是    | Ability组件名称。 |
1087
1088**返回值:**
1089
1090| 类型                    | 说明                    |
1091| --------------------- | --------------------- |
1092| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise形式返回Ability信息。 |
1093
1094**示例:**
1095
1096```ts
1097import bundle from '@ohos.bundle';
1098import { BusinessError } from '@ohos.base';
1099
1100let bundleName: string = "com.example.myapplication";
1101let abilityName: string = "EntryAbility";
1102bundle.getAbilityInfo(bundleName, abilityName)
1103.then((data) => {
1104    console.info('Operation successful. Data: ' + JSON.stringify(data));
1105}).catch((error: BusinessError) => {
1106    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1107})
1108```
1109
1110## bundle.getAbilityInfo<sup>deprecated<sup>
1111
1112> 从API version 9开始不再维护。
1113
1114getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void
1115
1116通过Bundle名称和组件名获取Ability组件信息,使用callback形式返回结果。
1117
1118获取调用方自己的信息时不需要权限。
1119
1120**需要权限:**
1121
1122ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1123
1124**系统能力:**
1125
1126SystemCapability.BundleManager.BundleFramework
1127
1128**参数:**
1129
1130| 参数名        | 类型     | 必填   | 说明                         |
1131| ----------- | ------------ | ---- |----------------------------|
1132| bundleName  | string | 是    | 应用Bundle名称。                |
1133| abilityName | string | 是    | Ability名称。                 |
1134| callback    | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是    | 程序启动作为入参的回调函数,返回Ability信息。 |
1135
1136**示例:**
1137
1138```ts
1139import bundle from '@ohos.bundle';
1140
1141let bundleName: string = "com.example.myapplication";
1142let abilityName: string = "EntryAbility";
1143bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
1144    if (err) {
1145        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1146        return;
1147    }
1148    console.info('Operation successful. Data:' + JSON.stringify(data));
1149})
1150```
1151
1152## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup>
1153
1154> 从API version 9开始不再维护。
1155
1156getAbilityLabel(bundleName: string, abilityName: string): Promise\<string>
1157
1158通过Bundle名称和ability名称获取应用名称,使用Promise形式返回结果。
1159
1160获取调用方自己的信息时不需要权限。
1161
1162**需要权限:**
1163
1164ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1165
1166**系统能力:**
1167
1168SystemCapability.BundleManager.BundleFramework
1169
1170**参数:**
1171
1172| 参数名      | 类型   | 必填 | 说明             |
1173| ----------- | ------ | ---- | ---------------- |
1174| bundleName  | string | 是   | 应用Bundle名称。 |
1175| abilityName | string | 是   | Ability名称。    |
1176
1177**返回值:**
1178
1179| 类型               | 说明                 |
1180| ---------------- | ------------------ |
1181| Promise\<string> | Promise形式返回应用名称信息。 |
1182
1183**示例:**
1184
1185```ts
1186import bundle from '@ohos.bundle';
1187import { BusinessError } from '@ohos.base';
1188
1189let bundleName: string = "com.example.myapplication";
1190let abilityName: string = "EntryAbility";
1191bundle.getAbilityLabel(bundleName, abilityName)
1192.then((data) => {
1193    console.info('Operation successful. Data: ' + JSON.stringify(data));
1194}).catch((error: BusinessError) => {
1195    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1196})
1197```
1198
1199## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup>
1200
1201> 从API version 9开始不再维护。
1202
1203getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void
1204
1205通过Bundle名称和Ability组件名获取应用名称,使用callback形式返回结果。
1206
1207获取调用方自己的信息时不需要权限。
1208
1209**需要权限:**
1210
1211ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1212
1213**系统能力:**
1214
1215SystemCapability.BundleManager.BundleFramework
1216
1217**参数:**
1218
1219| 参数名      | 类型                   | 必填 | 说明                                           |
1220| ----------- | ---------------------- | ---- | ---------------------------------------------- |
1221| bundleName  | string                 | 是   | 应用Bundle名称。                               |
1222| abilityName | string                 | 是   | Ability名称。                                  |
1223| callback    | AsyncCallback\<string> | 是   | 程序启动作为入参的回调函数,返回应用名称信息。 |
1224
1225**示例:**
1226
1227```ts
1228import bundle from '@ohos.bundle';
1229
1230let bundleName: string = "com.example.myapplication";
1231let abilityName: string = "EntryAbility";
1232bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
1233    if (err) {
1234        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1235        return;
1236    }
1237    console.info('Operation successful. Data:' + JSON.stringify(data));
1238})
1239```
1240
1241## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
1242
1243> 从API version 9开始不再维护。
1244
1245isAbilityEnabled(info: AbilityInfo): Promise\<boolean>
1246
1247以异步方法根据给定的AbilityInfo查询ability是否已经启用,使用Promise形式返回结果。
1248
1249**系统能力:**
1250
1251SystemCapability.BundleManager.BundleFramework
1252
1253**参数:**
1254
1255| 参数名 | 类型                                         | 必填 | 说明              |
1256| ------ | -------------------------------------------- | ---- | ----------------- |
1257| info   | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是   | Ability的配置信息。 |
1258
1259**返回值:**
1260
1261| 类型                | 说明                        |
1262| ----------------- | ------------------------- |
1263| Promise\<boolean> | Promise形式返回boolean代表是否启用。 |
1264
1265**示例:**
1266
1267```ts
1268import bundle from '@ohos.bundle';
1269import { BusinessError } from '@ohos.base';
1270
1271let bundleName: string = "com.example.myapplication";
1272let abilityName: string = "EntryAbility";
1273bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
1274    bundle.isAbilityEnabled(abilityInfo).then((data) => {
1275        console.info('Operation successful. Data: ' + JSON.stringify(data));
1276    }).catch((error: BusinessError) => {
1277        console.error('Operation failed. Cause: ' + JSON.stringify(error));
1278    })
1279})
1280```
1281
1282## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
1283
1284> 从API version 9开始不再维护。
1285
1286isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void
1287
1288以异步方法根据给定的AbilityInfo查询ability是否已经启用,使用callback形式返回结果。
1289
1290**系统能力:**
1291
1292SystemCapability.BundleManager.BundleFramework
1293
1294**参数:**
1295
1296| 参数名   | 类型                                         | 必填 | 说明                    |
1297| -------- | -------------------------------------------- | ---- | ----------------------- |
1298| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是   | Ability的配置信息。       |
1299| callback | AsyncCallback\<boolean>                      | 是   | 回调函数,返回boolean代表是否启用。 |
1300
1301**示例:**
1302
1303```ts
1304import bundle from '@ohos.bundle';
1305
1306let bundleName: string = "com.example.myapplication";
1307let abilityName: string = "EntryAbility";
1308bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
1309    bundle.isAbilityEnabled(abilityInfo, (err, data) => {
1310    if (err) {
1311        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1312        return;
1313    }
1314    console.info('Operation successful. Data:' + JSON.stringify(data));
1315    })
1316})
1317```
1318
1319## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
1320
1321> 从API version 9开始不再维护。
1322
1323isApplicationEnabled(bundleName: string): Promise\<boolean>
1324
1325以异步方法根据给定的bundleName查询指定应用程序是否已经启用,使用Promise形式返回结果。
1326
1327**系统能力:**
1328
1329SystemCapability.BundleManager.BundleFramework
1330
1331**参数:**
1332
1333| 参数名     | 类型   | 必填 | 说明                     |
1334| ---------- | ------ | ---- | ------------------------ |
1335| bundleName | string | 是   | 要查询的应用Bundle名称。 |
1336
1337**返回值:**
1338
1339| 类型                | 说明                        |
1340| ----------------- | ------------------------- |
1341| Promise\<boolean> | Promise形式返回boolean代表是否启用。 |
1342
1343**示例:**
1344
1345```ts
1346import bundle from '@ohos.bundle';
1347import { BusinessError } from '@ohos.base';
1348
1349let bundleName: string = "com.example.myapplication";
1350bundle.isApplicationEnabled(bundleName)
1351.then((data) => {
1352    console.info('Operation successful. Data: ' + JSON.stringify(data));
1353}).catch((error: BusinessError) => {
1354    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1355})
1356```
1357
1358## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
1359
1360> 从API version 9开始不再维护。
1361
1362isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void
1363
1364以异步方法根据给定的bundleName查询指定应用程序是否已经启用,使用callback形式返回结果。
1365
1366**系统能力:**
1367
1368SystemCapability.BundleManager.BundleFramework
1369
1370**参数:**
1371
1372| 参数名     | 类型                    | 必填 | 说明                     |
1373| ---------- | ----------------------- | ---- | ------------------------ |
1374| bundleName | string                  | 是   | 要查询的应用Bundle名称。 |
1375| callback   | AsyncCallback\<boolean> | 是   | 回调函数,返回boolean代表是否启用。 |
1376
1377**示例:**
1378
1379```ts
1380import bundle from '@ohos.bundle';
1381
1382let bundleName: string = "com.example.myapplication";
1383bundle.isApplicationEnabled(bundleName, (err, data) => {
1384    if (err) {
1385        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1386        return;
1387    }
1388    console.info('Operation successful. Data:' + JSON.stringify(data));
1389})
1390```
1391
1392## bundle.queryAbilityByWant<sup>deprecated<sup>
1393
1394> 从API version 9开始不再维护。
1395
1396queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise\<Array\<AbilityInfo\>\>
1397
1398以异步方法根据给定的意图获取Ability组件信息,使用Promise形式返回结果。
1399
1400获取调用方自己的信息时不需要权限。
1401
1402**需要权限:**
1403
1404ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1405
1406**系统能力:**
1407
1408SystemCapability.BundleManager.BundleFramework
1409
1410**参数:**
1411
1412| 参数名         | 类型     | 必填   | 说明                                    |
1413| ----------- | ------ | ---- | ------------------------------------- |
1414| want        | [Want](js-apis-application-want.md)   | 是    | 包含要查询的应用Bundle名称的意图。                  |
1415| bundleFlags | number | 是    | 用于指定返回abilityInfo信息。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中Ability信息相关flag。 |
1416| userId      | number | 否    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。           |
1417
1418**返回值:**
1419
1420| 类型                           | 说明                    |
1421| ---------------------------- | --------------------- |
1422| Promise<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Promise形式返回Ability信息。 |
1423
1424**示例:**
1425
1426```ts
1427import bundle from '@ohos.bundle';
1428import { BusinessError } from '@ohos.base';
1429import Want from '@ohos.app.ability.Want';
1430
1431let bundleFlags: number = 0;
1432let userId: number = 100;
1433let want: Want = {
1434    bundleName : "com.example.myapplication",
1435    abilityName : "EntryAbility"
1436};
1437bundle.queryAbilityByWant(want, bundleFlags, userId)
1438.then((data) => {
1439    console.info('Operation successful. Data: ' + JSON.stringify(data));
1440}).catch((error: BusinessError) => {
1441    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1442})
1443```
1444
1445
1446
1447## bundle.queryAbilityByWant<sup>deprecated<sup>
1448
1449> 从API version 9开始不再维护。
1450
1451queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<AbilityInfo\>\>): void
1452
1453以异步方法根据给定的意图获取指定用户下Ability信息,使用callback形式返回结果。
1454
1455获取调用方自己的信息时不需要权限。
1456
1457**需要权限:**
1458
1459ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1460
1461**系统能力:**
1462
1463SystemCapability.BundleManager.BundleFramework
1464
1465**参数:**
1466
1467| 参数名      | 类型                                                         | 必填 | 说明                                                         |
1468| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1469| want        | [Want](js-apis-application-want.md)                          | 是   | 指示包含要查询的应用Bundle名称的意图。                       |
1470| bundleFlags | number                                                       | 是   | 用于指定返回abilityInfo信息。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中Ability信息相关flag。 |
1471| userId      | number                                                       | 是   | 用户ID。取值范围:大于等于0。                                |
1472| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | 是   | 程序启动作为入参的回调函数,返回Ability信息。                |
1473
1474**示例:**
1475
1476```ts
1477import bundle from '@ohos.bundle';
1478import Want from '@ohos.app.ability.Want';
1479
1480let bundleFlags: number = 0;
1481let userId: number = 100;
1482let want: Want = {
1483    bundleName : "com.example.myapplication",
1484    abilityName : "EntryAbility"
1485};
1486bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
1487    if (err) {
1488        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1489        return;
1490    }
1491    console.info('Operation successful. Data:' + JSON.stringify(data));
1492})
1493```
1494
1495## bundle.queryAbilityByWant<sup>deprecated<sup>
1496
1497> 从API version 9开始不再维护。
1498
1499queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback\<Array\<AbilityInfo\>\>): void
1500
1501以异步方法根据给定的意图获取Ability信息,使用callback形式返回结果。
1502
1503获取调用方自己的信息时不需要权限。
1504
1505**需要权限:**
1506
1507ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1508
1509**系统能力:**
1510
1511SystemCapability.BundleManager.BundleFramework
1512
1513**参数:**
1514
1515| 参数名      | 类型                                                         | 必填 | 说明                                                         |
1516| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1517| want        | [Want](js-apis-application-want.md)                          | 是   | 指示包含要查询的应用Bundle名称的意图。                       |
1518| bundleFlags | number                                                       | 是   | 用于指定返回abilityInfo信息。取值范围:参考[BundleFlag说明](#bundleflagdeprecated)中Ability信息相关flag。 |
1519| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | 是   | 程序启动作为入参的回调函数,返回Ability信息。                |
1520
1521**示例:**
1522
1523```ts
1524import bundle from '@ohos.bundle';
1525import Want from '@ohos.app.ability.Want';
1526
1527let bundleFlags: number = 0;
1528let want: Want = {
1529    bundleName : "com.example.myapplication",
1530    abilityName : "EntryAbility"
1531};
1532bundle.queryAbilityByWant(want, bundleFlags, (err, data) => {
1533    if (err) {
1534        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1535        return;
1536    }
1537    console.info('Operation successful. Data:' + JSON.stringify(data));
1538})
1539```
1540
1541
1542
1543## bundle.getLaunchWantForBundle<sup>deprecated<sup>
1544
1545> 从API version 9开始不再维护。
1546
1547getLaunchWantForBundle(bundleName: string): Promise\<Want>
1548
1549以异步方法查询拉起指定应用的want对象,使用Promise形式返回结果。
1550
1551**需要权限:**
1552
1553ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1554
1555**系统能力:**
1556
1557SystemCapability.BundleManager.BundleFramework
1558
1559**参数:**
1560
1561| 参数名     | 类型   | 必填 | 说明                     |
1562| ---------- | ------ | ---- | ------------------------ |
1563| bundleName | string | 是   | 要查询的应用Bundle名称。 |
1564
1565**返回值:**
1566| 类型             | 说明                                     |
1567| -------------- | -------------------------------------- |
1568| Promise\<[Want](js-apis-application-want.md)> | 返回值为Promise对象,Promise中包含拉起指定应用的Want对象。 |
1569
1570**示例:**
1571
1572```ts
1573import bundle from '@ohos.bundle';
1574import { BusinessError } from '@ohos.base';
1575
1576let bundleName: string = "com.example.myapplication";
1577bundle.getLaunchWantForBundle(bundleName)
1578.then((data) => {
1579    console.info('Operation successful. Data: ' + JSON.stringify(data));
1580}).catch((error: BusinessError) => {
1581    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1582})
1583```
1584
1585## bundle.getLaunchWantForBundle<sup>deprecated<sup>
1586
1587> 从API version 9开始不再维护。
1588
1589getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
1590
1591以异步方法查询拉起指定应用的want对象,使用callback形式返回结果。
1592
1593**需要权限:**
1594
1595ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1596
1597**系统能力:**
1598
1599SystemCapability.BundleManager.BundleFramework
1600
1601**参数:**
1602
1603| 参数名     | 类型                                                | 必填 | 说明                                                     |
1604| ---------- | --------------------------------------------------- | ---- | -------------------------------------------------------- |
1605| bundleName | string                                              | 是   | 要查询的应用Bundle名称。                                 |
1606| callback   | AsyncCallback\<[Want](js-apis-application-want.md)> | 是   | 程序启动作为入参的回调函数,返回拉起指定应用的want对象。 |
1607
1608**示例:**
1609
1610```ts
1611import bundle from '@ohos.bundle';
1612
1613let bundleName: string = "com.example.myapplication";
1614bundle.getLaunchWantForBundle(bundleName, (err, data) => {
1615    if (err) {
1616        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1617        return;
1618    }
1619    console.info('Operation successful. Data:' + JSON.stringify(data));
1620})
1621```
1622
1623
1624## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup>
1625
1626> 从API version 9开始不再维护。
1627
1628getNameForUid(uid: number): Promise\<string>
1629
1630以异步方法通过uid获取对应的Bundle名称,使用Promise形式返回结果。
1631
1632**系统能力:**
1633
1634SystemCapability.BundleManager.BundleFramework
1635
1636**参数:**
1637
1638| 参数名 | 类型   | 必填 | 说明          |
1639| ------ | ------ | ---- | ------------- |
1640| uid    | number | 是   | 要查询的uid。 |
1641
1642**返回值:**
1643| 类型               | 说明                                |
1644| ---------------- | --------------------------------- |
1645| Promise\<string> | 返回值为Promise对象,Promise中包含指定uid的Bundle名称。 |
1646
1647**示例:**
1648
1649```ts
1650import bundle from '@ohos.bundle';
1651import { BusinessError } from '@ohos.base';
1652
1653let uid: number = 20010005;
1654bundle.getNameForUid(uid)
1655.then((data) => {
1656    console.info('Operation successful. Data: ' + JSON.stringify(data));
1657}).catch((error: BusinessError) => {
1658    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1659})
1660```
1661
1662## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup>
1663
1664> 从API version 9开始不再维护。
1665
1666getNameForUid(uid: number, callback: AsyncCallback\<string>) : void
1667
1668以异步方法通过uid获取对应的Bundle名称,使用callback形式返回结果。
1669
1670**系统能力:**
1671
1672SystemCapability.BundleManager.BundleFramework
1673
1674**参数:**
1675
1676| 参数名   | 类型                   | 必填 | 说明                                                  |
1677| -------- | ---------------------- | ---- | ----------------------------------------------------- |
1678| uid      | number                 | 是   | 要查询的uid。                                         |
1679| callback | AsyncCallback\<string> | 是   | 程序启动作为入参的回调函数,返回指定uid的Bundle名称。 |
1680
1681**示例:**
1682
1683```ts
1684import bundle from '@ohos.bundle';
1685
1686let uid: number = 20010005;
1687bundle.getNameForUid(uid, (err, data) => {
1688    if (err) {
1689        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1690        return;
1691    }
1692    console.info('Operation successful. Data:' + JSON.stringify(data));
1693})
1694```
1695
1696
1697## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>
1698
1699> 从API version 9开始不再维护,建议使用[resourceManager.getMediaContent](js-apis-resource-manager.md#getmediacontent9)替代。
1700
1701getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>
1702
1703以异步方法通过bundleName和abilityName获取对应Icon的[PixelMap](js-apis-image.md),使用Promise形式返回结果。
1704
1705获取调用方自己的信息时不需要权限。
1706
1707**需要权限:**
1708
1709ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1710
1711**系统能力:**
1712
1713SystemCapability.BundleManager.BundleFramework
1714
1715**参数:**
1716
1717| 参数名      | 类型   | 必填 | 说明                     |
1718| ----------- | ------ | ---- | ------------------------ |
1719| bundleName  | string | 是   | 要查询的应用Bundle名称。 |
1720| abilityName | string | 是   | 要查询的Ability组件名。  |
1721
1722**返回值:**
1723| 类型                  | 说明                                                         |
1724| --------------------- | ------------------------------------------------------------ |
1725| Promise\<image.PixelMap> | 返回值为[PixelMap](js-apis-image.md)。 |
1726
1727**示例:**
1728
1729```ts
1730import bundle from '@ohos.bundle';
1731import { BusinessError } from '@ohos.base';
1732
1733let bundleName: string = "com.example.myapplication";
1734let abilityName: string = "EntryAbility";
1735bundle.getAbilityIcon(bundleName, abilityName)
1736.then((data) => {
1737    console.info('Operation successful. Data: ' + JSON.stringify(data));
1738}).catch((error: BusinessError) => {
1739    console.error('Operation failed. Cause: ' + JSON.stringify(error));
1740})
1741```
1742
1743## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>
1744
1745> 从API version 9开始不再维护,建议使用[resourceManager.getMediaContent](js-apis-resource-manager.md#getmediacontent9)替代。
1746
1747getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void
1748
1749以异步方法通过bundleName和abilityName获取对应Icon的[PixelMap](js-apis-image.md),使用callback形式返回结果。
1750
1751获取调用方自己的信息时不需要权限。
1752
1753**需要权限:**
1754
1755ohos.permission.GET_BUNDLE_INFO_PRIVILEGEDohos.permission.GET_BUNDLE_INFO
1756
1757
1758**系统能力:**
1759
1760SystemCapability.BundleManager.BundleFramework
1761
1762**参数:**
1763
1764| 参数名         | 类型                                       | 必填   | 说明                                              |
1765| ----------- | ---------------------------------------- | ---- |-------------------------------------------------|
1766| bundleName  | string                                   | 是    | 要查询的应用Bundle名称。                                |
1767| abilityName | string                                   | 是    | 要查询的Ability组件名。                                 |
1768| callback   | AsyncCallback\<image.PixelMap> | 是   | 程序启动作为入参的回调函数,返回指定[PixelMap](js-apis-image.md)。 |
1769
1770**示例:**
1771
1772```ts
1773import bundle from '@ohos.bundle';
1774
1775let bundleName: string = "com.example.myapplication";
1776let abilityName: string = "EntryAbility";
1777bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
1778    if (err) {
1779        console.error('Operation failed. Cause: ' + JSON.stringify(err));
1780        return;
1781    }
1782    console.info('Operation successful. Data:' + JSON.stringify(data));
1783})
1784```
1785
1786## InstallErrorCode<sup>deprecated<sup>
1787> 从API version 9开始不再维护,不推荐使用。
1788
1789 **系统能力:** SystemCapability.BundleManager.BundleFramework
1790
1791| 名称                                                 | 值   | 说明                                             |
1792| ---------------------------------------------------- | ---- | ------------------------------------------------ |
1793| SUCCESS                                              | 0    | 安装成功                                         |
1794| STATUS_INSTALL_FAILURE                               | 1    | 安装失败(不存在安装的应用)                     |
1795| STATUS_INSTALL_FAILURE_ABORTED                       | 2    | 安装中止                                         |
1796| STATUS_INSTALL_FAILURE_INVALID                       | 3    | 安装参数无效                                     |
1797| STATUS_INSTALL_FAILURE_CONFLICT                      | 4    | 安装冲突 (常见于升级和已有应用基本信息不一致)  |
1798| STATUS_INSTALL_FAILURE_STORAGE                       | 5    | 存储包信息失败                                   |
1799| STATUS_INSTALL_FAILURE_INCOMPATIBLE                  | 6    | 安装不兼容(常见于版本降级安装或者签名信息错误) |
1800| STATUS_UNINSTALL_FAILURE                             | 7    | 卸载失败 (不存在卸载的应用)                    |
1801| STATUS_UNINSTALL_FAILURE_BLOCKED                     | 8    | 卸载中止 (没有使用)                            |
1802| STATUS_UNINSTALL_FAILURE_ABORTED                     | 9    | 卸载中止 (参数无效导致)                        |
1803| STATUS_UNINSTALL_FAILURE_CONFLICT                    | 10   | 卸载冲突 (卸载系统应用失败, 结束应用进程失败) |
1804| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT              | 0x0B | 安装失败 (下载超时)                            |
1805| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED               | 0x0C | 安装失败 (下载失败)                            |
1806| STATUS_RECOVER_FAILURE_INVALID<sup>8+</sup>          | 0x0D | 恢复预置应用失败                                 |
1807| STATUS_ABILITY_NOT_FOUND                             | 0x40 | Ability未找到                                    |
1808| STATUS_BMS_SERVICE_ERROR                             | 0x41 | BMS服务错误                                      |
1809| STATUS_FAILED_NO_SPACE_LEFT<sup>8+</sup>             | 0x42 | 设备空间不足                                     |
1810| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED<sup>8+</sup> | 0x43 | 应用授权失败                                     |
1811| STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup>        | 0x44 | 缺少安装权限                                     |
1812| STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup>      | 0x45 | 缺少卸载权限                                     |
1813
1814## BundleFlag<sup>deprecated<sup>
1815
1816> 从API version 9开始不再维护,建议使用[bundleManager.BundleFlag](js-apis-bundleManager.md#bundleflag)替代。
1817
1818包信息标志,指示需要获取的包信息的内容。
1819
1820当接口与标志不匹配时,该标志会被忽略,例如获取application时使用GET_ABILITY_INFO_WITH_PERMISSION对结果不会产生影响。
1821
1822标志可以叠加使用,例如使用GET_APPLICATION_INFO_WITH_PERMISSION + GET_APPLICATION_INFO_WITH_DISABLE可以使结果同时包含应用权限信息和被禁用的应用信息。
1823
1824 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1825
1826| 名称                                            | 值         | 说明                            |
1827| ----------------------------------------------- | ---------- | ------------------------------- |
1828| GET_BUNDLE_DEFAULT                              | 0x00000000 | 获取默认的应用信息              |
1829| GET_BUNDLE_WITH_ABILITIES                       | 0x00000001 | 获取包括Ability信息的包信息     |
1830| GET_ABILITY_INFO_WITH_PERMISSION                | 0x00000002 | 获取包括权限的Ability信息       |
1831| GET_ABILITY_INFO_WITH_APPLICATION               | 0x00000004 | 获取包括Application的ability信息       |
1832| GET_APPLICATION_INFO_WITH_PERMISSION            | 0x00000008 | 获取包括权限的应用信息          |
1833| GET_BUNDLE_WITH_REQUESTED_PERMISSION            | 0x00000010 | 获取包括所需权限的包信息        |
1834| GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup>     | 0x00000020 | 获取ability的元数据信息         |
1835| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | 获取应用的元数据信息            |
1836| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup>    | 0x00000080 | 获取仅包括系统应用的ability信息 |
1837| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup>      | 0x00000100 | 获取包括被禁用的ability信息     |
1838| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup>  | 0x00000200 | 获取包括被禁用的应用信息        |
1839| GET_ALL_APPLICATION_INFO                        | 0xFFFF0000 | 获取应用所有的信息              |
1840
1841## BundleOptions<sup>deprecated<sup>
1842> 从API version 9开始不再维护,不推荐使用。
1843
1844查询选项,包含userId。
1845
1846 **系统能力:** SystemCapability.BundleManager.BundleFramework
1847
1848| 名称   | 类型   | 可读 | 可写 | 说明                                                  |
1849| ------ | ------ | ---- | ---- | ----------------------------------------------------- |
1850| userId | number | 是   | 是   | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
1851
1852## AbilityType<sup>deprecated<sup>
1853
1854> 从API version 9开始不再维护,建议使用[bundleManager.AbilityType](js-apis-bundleManager.md#abilitytype)替代。
1855
1856Ability组件类型。
1857
1858 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1859
1860| 名称 | 值 | 说明                        |
1861| ------- | ---- | --------------------------- |
1862| UNKNOWN | 无   | 未知Ability类型             |
1863| PAGE    | 无   | 表示基于Page模板开发的FA,用于提供与用户交互的能力        |
1864| SERVICE | 无   | 表示基于Service模板开发的PA,用于提供后台运行任务的能力           |
1865| DATA    | 无   | 表示基于Data模板开发的PA,用于对外部提供统一的数据访问对象 |
1866
1867## DisplayOrientation<sup>deprecated<sup>
1868
1869> 从API version 9开始不再维护,建议使用[bundleManager.DisplayOrientation](js-apis-bundleManager.md#displayorientation)替代。
1870
1871屏幕显示方向。
1872
1873 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1874
1875| 名称          | 值   | 说明                     |
1876| ------------- | ---- | ------------------------ |
1877| UNSPECIFIED   | 无   | 屏幕方向--不指定         |
1878| LANDSCAPE     | 无   | 屏幕方向--横屏           |
1879| PORTRAIT      | 无   | 屏幕方向--竖屏           |
1880| FOLLOW_RECENT | 无   | 屏幕方向--紧跟上一个组件 |
1881## LaunchMode<sup>deprecated<sup>
1882
1883> 从API version 9开始不再维护,建议使用[bundleManager.LaunchType](js-apis-bundleManager.md#launchtype)替代。
1884
1885Ability组件的启动模式。
1886
1887 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1888
1889| 名称      | 值   | 说明                |
1890| --------- | ---- | ------------------- |
1891| SINGLETON | 0    | Ability只有一个实例 |
1892| STANDARD  | 1    | Ability有多个实例   |
1893
1894## AbilitySubType<sup>deprecated<sup>
1895> 从API version 9开始不再维护,不推荐使用。
1896
1897Ability组件的子类型。
1898
1899 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1900
1901| 名称        | 值   | 说明                          |
1902| ----------- | ---- | ----------------------------- |
1903| UNSPECIFIED | 0    | 未定义Ability子类型           |
1904| CA          | 1    | Ability子类型是带有 UI 的服务 |
1905
1906## ColorMode<sup>deprecated<sup>
1907> 从API version 9开始不再维护,不推荐使用。
1908
1909应用、卡片等的颜色模式。
1910
1911 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1912
1913| 名称       | 值   | 说明     |
1914| ---------- | ---- | -------- |
1915| AUTO_MODE  | -1   | 自动模式 |
1916| DARK_MODE  | 0    | 黑色模式 |
1917| LIGHT_MODE | 1    | 亮度模式 |
1918
1919
1920## GrantStatus<sup>deprecated<sup>
1921
1922> 从API version 9开始不再维护,建议使用[bundleManager.PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate)替代。
1923
1924权限授予状态。
1925
1926 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
1927
1928| 名称               | 值   | 说明         |
1929| ------------------ | ---- | ------------ |
1930| PERMISSION_DENIED  | -1   | 拒绝授予权限 |
1931| PERMISSION_GRANTED | 0    | 授予权限     |
1932