js-apis-Bundle.md 99.3 KB
Newer Older
W
wusongqing 已提交
1
# Bundle
W
wusongqing 已提交
2

W
wusongqing 已提交
3
The **Bundle** module provides APIs for querying the information about bundles, applications, abilities, Extension abilities, and application states.
W
wusongqing 已提交
4 5

> **NOTE**
W
wusongqing 已提交
6
> 
W
wusongqing 已提交
7
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
W
wusongqing 已提交
8
> API version 9 is a canary version for trial use. The APIs of this version may be unstable.
W
wusongqing 已提交
9 10
## Modules to Import

W
wusongqing 已提交
11
```js
W
wusongqing 已提交
12 13 14
import bundle from '@ohos.bundle';
```

W
wusongqing 已提交
15
## System Capability
W
wusongqing 已提交
16 17 18 19 20

SystemCapability.BundleManager.BundleFramework

## Required Permissions

W
wusongqing 已提交
21 22 23
| Required Permissions                                      | Permission Level    | Description              |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.GET_BUNDLE_INFO            | normal       | Permission to query information about a specified application.  |
W
wusongqing 已提交
24
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.|
W
wusongqing 已提交
25
| ohos.permission.INSTALL_BUNDLE             | system_core  | Permission to install or uninstall applications.  |
W
wusongqing 已提交
26
| ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core  | Permission to set and query the application disposal status.  |
W
wusongqing 已提交
27

W
wusongqing 已提交
28
For details, see "Permission Levels" in [Access Control Overview](../../security/accesstoken-overview.md).
W
wusongqing 已提交
29 30 31

## bundle.getApplicationInfo

W
wusongqing 已提交
32
getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo>
W
wusongqing 已提交
33

W
wusongqing 已提交
34
Obtains the application information based on a given bundle name. This API uses a promise to return the result.
W
wusongqing 已提交
35

W
wusongqing 已提交
36
**Required permissions**
W
wusongqing 已提交
37

W
wusongqing 已提交
38 39 40 41 42
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
43 44 45

**Parameters**

W
wusongqing 已提交
46
| Name         | Type    | Mandatory  | Description                                     |
W
wusongqing 已提交
47
| ----------- | ------ | ---- | --------------------------------------- |
W
wusongqing 已提交
48
| bundleName  | string | Yes   | Bundle name of an application.                           |
W
wusongqing 已提交
49 50
| bundleFlags | number | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId      | number | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.           |
W
wusongqing 已提交
51 52 53

**Return value**

W
wusongqing 已提交
54 55
| Type                       | Description                |
| ------------------------- | ------------------ |
W
wusongqing 已提交
56
| Promise\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Promise used to return the application information.|
W
wusongqing 已提交
57 58 59 60

**Example**

```js
W
wusongqing 已提交
61 62 63 64 65 66 67 68
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
bundle.getApplicationInfo(bundleName, bundleFlags, userId)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
W
wusongqing 已提交
69 70 71 72 73 74 75
})
```

## bundle.getApplicationInfo

getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void

W
wusongqing 已提交
76
Obtains the application information of the specified user based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
77

W
wusongqing 已提交
78
**Required permissions**
W
wusongqing 已提交
79

W
wusongqing 已提交
80 81 82 83 84
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
85 86 87

**Parameters**

W
wusongqing 已提交
88 89
| Name         | Type                             | Mandatory  | Description                                     |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
90
| bundleName  | string                          | Yes   | Bundle name of an application.                           |
W
wusongqing 已提交
91
| bundleFlags | number                          | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
92
| userId      | number                          | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.           |
W
wusongqing 已提交
93
| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes   | Callback used to return the application information.                |
W
wusongqing 已提交
94 95 96 97

**Example**

```js
W
wusongqing 已提交
98 99 100 101 102 103 104 105 106 107
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
 })
W
wusongqing 已提交
108 109
```

W
wusongqing 已提交
110 111 112 113
## bundle.getApplicationInfo

getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void

W
wusongqing 已提交
114
Obtains the application information based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
115 116 117 118 119 120 121 122 123 124 125

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
126 127
| Name         | Type                             | Mandatory  | Description                                     |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
128
| bundleName  | string                          | Yes   | Bundle name of an application.                           |
W
wusongqing 已提交
129 130
| bundleFlags | number                          | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes   | Callback used to return the application information.                |
W
wusongqing 已提交
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

**Example**

```js
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
 })
```

W
wusongqing 已提交
146 147
## bundle.getAllBundleInfo

W
wusongqing 已提交
148
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>>
W
wusongqing 已提交
149

W
wusongqing 已提交
150
Obtains the information of all available bundles of the specified user in the system. This API uses a promise to return the result.
W
wusongqing 已提交
151

W
wusongqing 已提交
152
**Required permissions**
W
wusongqing 已提交
153

W
wusongqing 已提交
154 155 156 157 158
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
159 160 161

**Parameters**

W
wusongqing 已提交
162 163
| Name        | Type        | Mandatory  | Description                                     |
| ---------- | ---------- | ---- | --------------------------------------- |
W
wusongqing 已提交
164
| bundleFlag | BundleFlag | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
165
| userId     | number     | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.           |
W
wusongqing 已提交
166 167 168

**Return value**

W
wusongqing 已提交
169 170
| Type                         | Description                        |
| --------------------------- | -------------------------- |
W
wusongqing 已提交
171
| Promise<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Promise used to return the information of all available bundles.|
W
wusongqing 已提交
172 173 174 175

**Example**

```js
W
wusongqing 已提交
176 177 178 179 180 181 182
let bundleFlag = 0;
let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
W
wusongqing 已提交
183 184 185 186 187
})
```

## bundle.getAllBundleInfo

W
wusongqing 已提交
188
getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void
W
wusongqing 已提交
189

W
wusongqing 已提交
190
Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
191

W
wusongqing 已提交
192
**Required permissions**
W
wusongqing 已提交
193

W
wusongqing 已提交
194 195 196 197 198
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
199 200 201

**Parameters**

W
wusongqing 已提交
202 203
| Name        | Type                               | Mandatory  | Description                                     |
| ---------- | --------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
204 205
| bundleFlag | BundleFlag                        | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes   | Callback used to return the information of all available bundles.       |
W
wusongqing 已提交
206 207 208 209

**Example**

```js
W
wusongqing 已提交
210 211 212 213 214 215 216 217 218
let bundleFlag = 0;
bundle.getAllBundleInfo(bundleFlag, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
 })
```
W
wusongqing 已提交
219

W
wusongqing 已提交
220 221
## bundle.getAllBundleInfo

W
wusongqing 已提交
222
getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void
W
wusongqing 已提交
223

W
wusongqing 已提交
224
Obtains the information of all available bundles of the specified user in the system. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
225 226 227

**Required permissions**

W
wusongqing 已提交
228 229 230 231 232
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
233 234 235

**Parameters**

W
wusongqing 已提交
236 237
| Name        | Type                               | Mandatory  | Description                                     |
| ---------- | --------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
238
| bundleFlag | BundleFlag                        | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
239
| userId     | number                            | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.           |
W
wusongqing 已提交
240
| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes   | Callback used to return the information of all available bundles.       |
W
wusongqing 已提交
241 242 243 244 245 246 247 248 249 250 251 252 253

**Example**

```js
let bundleFlag = 0;
let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
 })
W
wusongqing 已提交
254 255 256 257
```

## bundle.getBundleInfo

W
wusongqing 已提交
258
getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo>
W
wusongqing 已提交
259

W
wusongqing 已提交
260
Obtains the bundle information based on a given bundle name. This API uses a promise to return the result.
W
wusongqing 已提交
261

W
wusongqing 已提交
262
**Required permissions**
W
wusongqing 已提交
263

W
wusongqing 已提交
264 265 266 267 268
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
269 270 271

**Parameters**

W
wusongqing 已提交
272 273
| Name         | Type           | Mandatory  | Description                                     |
| ----------- | ------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
274
| bundleName  | string        | Yes   | Bundle name of an application.                                     |
W
wusongqing 已提交
275 276
| bundleFlags | number        | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| options     | [BundleOptions](#bundleoptions) | No   | Includes **userId**.                              |
W
wusongqing 已提交
277 278 279

**Return value**

W
wusongqing 已提交
280 281
| Type                  | Description                          |
| -------------------- | ---------------------------- |
W
wusongqing 已提交
282
| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the bundle information.|
W
wusongqing 已提交
283 284 285 286

**Example**

```js
W
wusongqing 已提交
287 288 289
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
290
  "userId" : 100
W
wusongqing 已提交
291 292 293 294 295 296
};
bundle.getBundleInfo(bundleName, bundleFlags, options)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
W
wusongqing 已提交
297 298 299 300 301 302 303
})
```

## bundle.getBundleInfo

getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void

W
wusongqing 已提交
304
Obtains the bundle information based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
305

W
wusongqing 已提交
306
**Required permissions**
W
wusongqing 已提交
307

W
wusongqing 已提交
308 309 310 311 312
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
313 314 315

**Parameters**

W
wusongqing 已提交
316 317
| Name         | Type                        | Mandatory  | Description                                     |
| ----------- | -------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
318
| bundleName  | string                     | Yes   | Bundle name of an application.                                     |
W
wusongqing 已提交
319 320
| bundleFlags | number                     | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes   | Callback used to return the bundle information.                   |
W
wusongqing 已提交
321 322 323 324

**Example**

```js
W
wusongqing 已提交
325 326 327 328 329 330 331 332 333
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
W
wusongqing 已提交
334 335 336
```


W
wusongqing 已提交
337 338 339 340
## bundle.getBundleInfo

getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void

W
wusongqing 已提交
341
Obtains the bundle information based on a given bundle name and bundle options. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
342 343 344

**Required permissions**

W
wusongqing 已提交
345 346 347 348 349
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
350 351 352

**Parameters**

W
wusongqing 已提交
353 354
| Name         | Type                        | Mandatory  | Description                                     |
| ----------- | -------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
355
| bundleName  | string                     | Yes   | Bundle name of an application.                                     |
W
wusongqing 已提交
356 357 358
| bundleFlags | number                     | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| options     | [BundleOptions](#bundleoptions)              | Yes   | Includes **userId**.                              |
| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes   | Callback used to return the bundle information.                   |
W
wusongqing 已提交
359 360 361 362 363 364 365

**Example**

```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
366
  "userId" : 100
W
wusongqing 已提交
367 368 369 370 371 372 373 374 375 376
};
bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```

W
wusongqing 已提交
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
## bundle.getBundleInstaller

getBundleInstaller(): Promise&lt;BundleInstaller&gt;;

Obtains the installation package information. This API uses a promise to return the result.

**Required permissions**

ohos.permission.INSTALL_BUNDLE

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Return value**

| Type                                                        | Description                                        |
| ------------------------------------------------------------ | -------------------------------------------- |
| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise used to return the installation package information.|

## bundle.getBundleInstaller

getBundleInstaller(callback: AsyncCallback&lt;BundleInstaller&gt;): void;

Obtains the installation package information. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.INSTALL_BUNDLE

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                                        | Mandatory| Description            |
| -------- | ------------------------------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes  | Callback used to return the installation package information.|

## bundle.cleanBundleCacheFiles<sup>8+</sup>

cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback&lt;void&gt;): void;

Clears the cache data of an application. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.REMOVE_CACHE_FILES

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name      | Type               | Mandatory| Description                                 |
| ---------- | ------------------- | ---- | ------------------------------------- |
| bundleName | string              | Yes  | Bundle name of an application.|
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result.         |

## bundle.cleanBundleCacheFiles<sup>8+</sup>

cleanBundleCacheFiles(bundleName: string): Promise&lt;void&gt;

Clears the cache data of an application. This API uses a promise to return the result.

**Required permissions**

ohos.permission.REMOVE_CACHE_FILES

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name      | Type  | Mandatory| Description                                 |
| ---------- | ------ | ---- | ------------------------------------- |
| bundleName | string | Yes  | Bundle name of an application.|

**Return value**

| Type         | Description                                |
| ------------- | ------------------------------------ |
| Promise\<void> | Promise that returns no value.|

## bundle.setApplicationEnabled<sup>8+</sup>

setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void;

Sets whether to enable an application. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.CHANGE_ABILITY_ENABLED_STATE

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name      | Type               | Mandatory| Description                                           |
| ---------- | ------------------- | ---- | ----------------------------------------------- |
| bundleName | string              | Yes  | Bundle name of an application.                               |
| isEnable   | boolean             | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result.                   |

## bundle.setApplicationEnabled<sup>8+</sup>

setApplicationEnabled(bundleName: string, isEnable: boolean): Promise&lt;void&gt;

Sets whether to enable an application. This API uses a promise to return the result.

**Required permissions**

ohos.permission.CHANGE_ABILITY_ENABLED_STATE

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name      | Type   | Mandatory| Description                                           |
| ---------- | ------- | ---- | ----------------------------------------------- |
| bundleName | string  | Yes  | Bundle name of an application.                               |
| isEnable   | boolean | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|

**Return value**

| Type         | Description                                |
| ------------- | ------------------------------------ |
| Promise\<void> | Promise that returns no value.|

## bundle.setAbilityEnabled<sup>8+</sup>

setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void;

Sets whether to enable an ability. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.CHANGE_ABILITY_ENABLED_STATE

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                        | Mandatory| Description                                           |
| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.                                  |
| isEnable | boolean                                      | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means the opposite.|
| callback | AsyncCallback\<void>                          | Yes  | Callback used to return the result.                   |

## bundle.setAbilityEnabled<sup>8+</sup>

setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise&lt;void&gt;

Sets whether to enable an ability. This API uses a promise to return the result.

**Required permissions**

ohos.permission.CHANGE_ABILITY_ENABLED_STATE

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                        | Mandatory| Description                                           |
| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.                                  |
| isEnable | boolean                                      | Yes  | Whether to enable the ability. The value **true** means to enable the ability, and **false** means the opposite.|

**Return value**

| Type         | Description                                |
| ------------- | ------------------------------------ |
| Promise\<void> | Promise that returns no value.|

## bundle.getPermissionDef<sup>8+</sup>

getPermissionDef(permissionName: string, callback: AsyncCallback&lt;PermissionDef&gt;): void;

Obtains the permission details by permission name. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name          | Type                                                        | Mandatory| Description                                            |
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
| permissionName | string                                                       | Yes  | Name of the permission.                                |
| callback       | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | Yes  | Callback used to return the permission details.|

## bundle.getPermissionDef<sup>8+</sup>

getPermissionDef(permissionName: string): Promise&lt;PermissionDef&gt;

Obtains the permission details by permission name. This API uses a promise to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name          | Type  | Mandatory| Description            |
| -------------- | ------ | ---- | ---------------- |
| permissionName | string | Yes  | Name of the permission.|

**Return value**

| Type                                                  | Description                                                  |
| ------------------------------------------------------ | ------------------------------------------------------ |
| Promise<[PermissionDef](js-apis-bundle-PermissionDef)> | Promise used to return the permission details.|

## bundle.setModuleUpgradeFlag<sup>9+</sup>

setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback&lt;void&gt;):void;

Sets whether the module needs an upgrade. This API uses an asynchronous callback to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name       | Type                       | Mandatory| Description                        |
| ----------- | --------------------------- | ---- | ---------------------------- |
| bundleName  | string                      | Yes  | Bundle name of an application.            |
| moduleName  | string                      | Yes  | Module name of the application.          |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes  | Upgrade flag, which is used only by the internal system.      |
| callback    | AsyncCallback\<void>         | Yes  | Callback used to return the result.|

## bundle.setModuleUpgradeFlag<sup>9+</sup>

setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise&lt;void&gt;

Sets whether the module needs an upgrade. This API uses a promise to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name       | Type                       | Mandatory| Description                  |
| ----------- | --------------------------- | ---- | ---------------------- |
| bundleName  | string                      | Yes  | Bundle name of an application.      |
| moduleName  | string                      | Yes  | Module name of the application.    |
| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes  | Upgrade flag, which is used only by the internal system.|

**Return value**

| Type         | Description                                |
| ------------- | ------------------------------------ |
| Promise\<void> | Promise that returns no value.|

## bundle.isModuleRemovable<sup>9+</sup>

isModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback&lt;boolean&gt;): void;

Checks whether a module is removable. This API uses an asynchronous callback to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name      | Type                  | Mandatory| Description                                         |
| ---------- | ---------------------- | ---- | --------------------------------------------- |
| bundleName | string                 | Yes  | Bundle name of an application.                             |
| moduleName | string                 | Yes  | Module name of the application.                           |
| callback   | AsyncCallback<boolean> | Yes  | Callback used to return the result. If the module is removable, **true** is returned. Otherwise, **false** is returned.|

## bundle.isModuleRemovable<sup>9+</sup>

isModuleRemovable(bundleName: string, moduleName: string): Promise&lt;boolean&gt;

Checks whether a module is removable. This API uses a promise to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name      | Type  | Mandatory| Description              |
| ---------- | ------ | ---- | ------------------ |
| bundleName | string | Yes  | Bundle name of an application.  |
| moduleName | string | Yes  | Module name of the application.|

**Return value**

| Type            | Description                        |
| ---------------- | ---------------------------- |
| Promise<boolean> | Promise used to return the result. If the module is removable, **true** is returned. Otherwise, **false** is returned.|

## bundle.getBundlePackInfo<sup>9+</sup>

getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback&lt;pack.BundlePackInfo&gt;): void;

Obtains the bundle package information based on a given bundle name and bundle flags. This API uses an asynchronous callback to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name          | Type                              | Mandatory| Description                                                |
| -------------- | ---------------------------------- | ---- | ---------------------------------------------------- |
| bundleName     | string                             | Yes  | Bundle name of an application.                                    |
| bundlePackFlag | pack.BundlePackFlag                | Yes  | Flags of the bundle package.                              |
| callback       | AsyncCallback<pack.BundlePackInfo> | Yes  | Callback used to return the bundle package information.|

## bundle.getBundlePackInfo<sup>9+</sup>

getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): Promise&lt;pack.BundlePackInfo&gt;;

Obtains the bundle package information based on a given bundle name and bundle flags. This API uses a promise to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name          | Type               | Mandatory| Description                  |
| -------------- | ------------------- | ---- | ---------------------- |
| bundleName     | string              | Yes  | Bundle name of an application.      |
| bundlePackFlag | pack.BundlePackFlag | Yes  | Flags of the bundle package.|

**Return value**

| Type                        | Description                               |
| ---------------------------- | ----------------------------------- |
| Promise<pack.BundlePackInfo> | Promise used to return the bundle package information.|

## bundle.getDispatcherVersion<sup>9+</sup>

getDispatcherVersion(callback: AsyncCallback&lt;DispatchInfo&gt;): void;

Obtains the dispatcher version. This API uses an asynchronous callback to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                                  | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<[DispatchInfo](js-apis-dispatchInfo.md)> | Yes  | Callback used to return the [DispatchInfo](js-apis-dispatchInfo.md).|

## bundle.getDispatcherVersion<sup>9+</sup>

getDispatcherVersion(): Promise&lt;DispatchInfo&gt;;

Obtains the dispatcher version. This API uses a promise to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**System API**

This is a system API and cannot be called by third-party applications.

**Return value**

| Type                                            | Description                                                        |
| ------------------------------------------------ | ------------------------------------------------------------ |
| Promise<[DispatchInfo](js-apis-dispatchInfo.md)> | Promise used to return the [DispatchInfo](js-apis-dispatchInfo.md).|
W
wusongqing 已提交
837 838 839

## bundle.getAllApplicationInfo

W
wusongqing 已提交
840
getAllApplicationInfo(bundleFlags: number, userId?: number): Promise<Array\<ApplicationInfo>>
W
wusongqing 已提交
841

W
wusongqing 已提交
842
Obtains the information about all applications of the specified user. This API uses a promise to return the result.
W
wusongqing 已提交
843

W
wusongqing 已提交
844
**Required permissions**
W
wusongqing 已提交
845

W
wusongqing 已提交
846 847 848 849 850
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
851 852 853

**Parameters**

W
wusongqing 已提交
854 855
| Name         | Type    | Mandatory  | Description                                     |
| ----------- | ------ | ---- | --------------------------------------- |
W
wusongqing 已提交
856
| bundleFlags | number | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
857
| userId      | number | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.           |
W
wusongqing 已提交
858 859 860

**Return value**

W
wusongqing 已提交
861 862
| Type                              | Description                             |
| -------------------------------- | ------------------------------- |
W
wusongqing 已提交
863
| Promise<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Promise used to return the application information.|
W
wusongqing 已提交
864 865 866 867

**Example**

```js
W
wusongqing 已提交
868 869 870 871 872 873 874
let bundleFlags = 8;
let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
W
wusongqing 已提交
875 876 877 878 879 880 881 882 883
})
```



## bundle.getAllApplicationInfo

getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void

W
wusongqing 已提交
884
Obtains the information about all applications of the specified user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
885

W
wusongqing 已提交
886
**Required permissions**
W
wusongqing 已提交
887

W
wusongqing 已提交
888 889 890 891 892
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
893 894 895

**Parameters**

W
wusongqing 已提交
896 897
| Name         | Type                                    | Mandatory  | Description                                     |
| ----------- | -------------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
898
| bundleFlags | number                                 | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
899
| userId      | number                                 | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.           |
W
wusongqing 已提交
900
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes   | Callback used to return the application information.                |
W
wusongqing 已提交
901 902 903 904

**Example**

```js
W
wusongqing 已提交
905 906 907 908 909 910 911 912 913
let bundleFlags = 8;
let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
W
wusongqing 已提交
914 915 916
```


W
wusongqing 已提交
917 918
## bundle.getAllApplicationInfo

W
wusongqing 已提交
919
getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void;
W
wusongqing 已提交
920

W
wusongqing 已提交
921
Obtains the information about all applications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
922 923 924 925 926 927 928 929 930 931 932

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
933 934
| Name         | Type                                    | Mandatory  | Description                                     |
| ----------- | -------------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
935 936
| bundleFlags | number                                 | Yes   | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes   | Callback used to return the application information.                |
W
wusongqing 已提交
937 938 939 940 941 942 943 944 945 946 947 948 949 950

**Example**

```js
let bundleFlags = 8;
bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```

W
wusongqing 已提交
951 952
## bundle.getBundleArchiveInfo

W
wusongqing 已提交
953
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo>
W
wusongqing 已提交
954 955 956 957 958 959 960 961 962 963 964 965

Obtains information about the bundles contained in a HAP file. This API uses a promise to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name        | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
| hapFilePath | string | Yes   | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.|
W
wusongqing 已提交
966
| bundleFlags | number | Yes   | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987

**Return value**
| Type            | Description                                    |
| -------------- | -------------------------------------- |
| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the information about the bundles.|

**Example**

```js
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = 0;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

## bundle.getBundleArchiveInfo

W
wusongqing 已提交
988
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void
W
wusongqing 已提交
989 990 991 992 993 994 995 996 997 998 999 1000

Obtains information about the bundles contained in a HAP file. This API uses an asynchronous callback to return the result.

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name        | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
| hapFilePath | string | Yes   | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.|
W
wusongqing 已提交
1001 1002
| bundleFlags | number | Yes   | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes   | Callback used to return the information about the bundles.|
W
wusongqing 已提交
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018

**Example**

```js
let hapFilePath = "/data/xxx/test.hap";
let bundleFlags = 0;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```


W
wusongqing 已提交
1019 1020 1021 1022
## bundle.getAbilityInfo

getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo>

W
wusongqing 已提交
1023
Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1035 1036
| Name         | Type    | Mandatory  | Description              |
| ----------- | ------ | ---- | ---------------- |
W
wusongqing 已提交
1037
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1038
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
1039 1040 1041

**Return value**

W
wusongqing 已提交
1042 1043
| Type                   | Description                   |
| --------------------- | --------------------- |
W
wusongqing 已提交
1044
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|
W
wusongqing 已提交
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060

**Example**

```js
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

## bundle.getAbilityInfo

W
wusongqing 已提交
1061
getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;
W
wusongqing 已提交
1062

W
wusongqing 已提交
1063
Obtains the ability information based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1075 1076
| Name        | Type    | Mandatory  | Description           |
| ----------- | ------------ | ---- | ---------------- |
W
wusongqing 已提交
1077
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1078 1079
| abilityName | string | Yes   | Ability name.|
| callback    | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes   | Callback used to return the ability information.|
W
wusongqing 已提交
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093

**Example**

```js
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
## bundle.getAbilityInfo<sup>9+</sup>

getAbilityInfo(bundleName: string, moduleName: string, abilityName: string): Promise\<AbilityInfo>

Obtains the ability information based on a given bundle name, module name, and ability name. This API uses a promise to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name         | Type    | Mandatory  | Description              |
| ----------- | ------ | ---- | ---------------- |
W
wusongqing 已提交
1112
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
| moduleName  | string | Yes   | Module name of the application.    |
| abilityName | string | Yes   | Ability name.|

**Return value**

| Type                   | Description                   |
| --------------------- | --------------------- |
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|

**Example**

```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, moduleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

## bundle.getAbilityInfo<sup>9+</sup>

getAbilityInfo(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;

Obtains the ability information based on a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name        | Type    | Mandatory  | Description           |
| ----------- | ------------ | ---- | ---------------- |
W
wusongqing 已提交
1154
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172
| moduleName  | string | Yes   | Module name of the application.    |
| abilityName | string | Yes   | Ability name.|
| callback    | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes   | Callback used to return the ability information.|

**Example**

```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, moduleName, abilityName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1173

W
wusongqing 已提交
1174
## bundle.getAbilityLabel<sup>8+</sup>
W
wusongqing 已提交
1175 1176 1177

getAbilityLabel(bundleName: string, abilityName: string): Promise\<string>

W
wusongqing 已提交
1178
Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1190 1191
| Name         | Type    | Mandatory  | Description              |
| ----------- | ------ | ---- | ---------------- |
W
wusongqing 已提交
1192
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1193
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
1194 1195 1196

**Return value**

W
wusongqing 已提交
1197 1198
| Type              | Description                |
| ---------------- | ------------------ |
W
wusongqing 已提交
1199
| Promise\<string> | Promise used to return the application name.|
W
wusongqing 已提交
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213

**Example**

```js
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

W
wusongqing 已提交
1214
## bundle.getAbilityLabel<sup>8+</sup>
W
wusongqing 已提交
1215 1216 1217

getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void

W
wusongqing 已提交
1218
Obtains the application name based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1230 1231
| Name         | Type                    | Mandatory  | Description              |
| ----------- | ---------------------- | ---- | ---------------- |
W
wusongqing 已提交
1232
| bundleName  | string                 | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1233
| abilityName | string                 | Yes   | Ability name.|
W
wusongqing 已提交
1234
| callback    | AsyncCallback\<string> | Yes   | Callback used to return the application name.       |
W
wusongqing 已提交
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248

**Example**

```js
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
## bundle.getAbilityLabel<sup>9+</sup>

getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string>

Obtains the application name based on a given bundle name, module name, and ability name. This API uses a promise to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name         | Type    | Mandatory  | Description              |
| ----------- | ------ | ---- | ---------------- |
W
wusongqing 已提交
1267
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
| moduleName  | string | Yes   | Module name of the application.    |
| abilityName | string | Yes   | Ability name.|

**Return value**

| Type              | Description                |
| ---------------- | ------------------ |
| Promise\<string> | Promise used to return the application name.|

**Example**

```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, moduleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

## bundle.getAbilityLabel<sup>9+</sup>

getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback : AsyncCallback\<string>): void

Obtains the application name based on a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name         | Type                    | Mandatory  | Description              |
| ----------- | ---------------------- | ---- | ---------------- |
W
wusongqing 已提交
1309
| bundleName  | string                 | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
| moduleName  | string | Yes   | Module name of the application.    |
| abilityName | string                 | Yes   | Ability name.|
| callback    | AsyncCallback\<string> | Yes   | Callback used to return the application name.       |

**Example**

```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1328

W
wusongqing 已提交
1329
## bundle.isAbilityEnabled<sup>8+</sup>
W
wusongqing 已提交
1330 1331 1332

isAbilityEnabled(info: AbilityInfo): Promise\<boolean>

W
wusongqing 已提交
1333
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses a promise to return the result.
W
wusongqing 已提交
1334 1335 1336 1337 1338 1339 1340

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1341 1342
| Name  | Type         | Mandatory  | Description          |
| ---- | ----------- | ---- | ------------ |
W
wusongqing 已提交
1343
| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes   | Ability information.|
W
wusongqing 已提交
1344 1345 1346

**Return value**

W
wusongqing 已提交
1347 1348
| Type               | Description                       |
| ----------------- | ------------------------- |
W
wusongqing 已提交
1349
| Promise\<boolean> | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1350 1351 1352 1353

**Example**

```js
W
wusongqing 已提交
1354 1355 1356 1357 1358 1359 1360 1361
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
    bundle.isAbilityEnabled(abilityInfo).then((data) => {
        console.info('Operation successful. Data: ' + JSON.stringify(data));
    }).catch((error) => {
        console.error('Operation failed. Cause: ' + JSON.stringify(error));
    })
W
wusongqing 已提交
1362 1363 1364
})
```

W
wusongqing 已提交
1365
## bundle.isAbilityEnabled<sup>8+</sup>
W
wusongqing 已提交
1366 1367 1368

isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void

W
wusongqing 已提交
1369
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1370 1371 1372 1373 1374 1375 1376

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1377 1378
| Name      | Type                     | Mandatory  | Description             |
| -------- | ----------------------- | ---- | --------------- |
W
wusongqing 已提交
1379 1380
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md)             | Yes   | Ability information.   |
| callback | AsyncCallback\<boolean> | Yes   | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1381 1382 1383 1384

**Example**

```js
W
wusongqing 已提交
1385 1386 1387 1388
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
    bundle.isAbilityEnabled(abilityInfo, (err, data) => {
W
wusongqing 已提交
1389 1390 1391 1392 1393
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
W
wusongqing 已提交
1394
    })
W
wusongqing 已提交
1395 1396 1397
})
```

W
wusongqing 已提交
1398
## bundle.isApplicationEnabled<sup>8+</sup>
W
wusongqing 已提交
1399 1400 1401

isApplicationEnabled(bundleName: string): Promise\<boolean>

W
wusongqing 已提交
1402
Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result.
W
wusongqing 已提交
1403 1404 1405 1406 1407 1408 1409

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1410 1411
| Name        | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
W
wusongqing 已提交
1412
| bundleName | string | Yes   | Bundle name of an application.|
W
wusongqing 已提交
1413 1414 1415

**Return value**

W
wusongqing 已提交
1416 1417
| Type               | Description                       |
| ----------------- | ------------------------- |
W
wusongqing 已提交
1418
| Promise\<boolean> | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431

**Example**

```js
let bundleName = "com.example.myapplication";
bundle.isApplicationEnabled(bundleName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

W
wusongqing 已提交
1432
## bundle.isApplicationEnabled<sup>8+</sup>
W
wusongqing 已提交
1433 1434 1435

isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void

W
wusongqing 已提交
1436
Checks whether an application is enabled based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1437 1438 1439 1440 1441 1442 1443

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1444 1445
| Name        | Type                     | Mandatory  | Description             |
| ---------- | ----------------------- | ---- | --------------- |
W
wusongqing 已提交
1446
| bundleName | string                  | Yes   | Bundle name of an application.   |
W
wusongqing 已提交
1447
| callback   | AsyncCallback\<boolean> | Yes   | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1448 1449 1450 1451

**Example**

```js
W
wusongqing 已提交
1452
let bundleName = "com.example.myapplication";
W
wusongqing 已提交
1453 1454 1455 1456 1457 1458 1459 1460
bundle.isApplicationEnabled(bundleName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1461 1462 1463 1464 1465

## bundle.queryAbilityByWant

queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise<Array\<AbilityInfo>>

W
wusongqing 已提交
1466
Obtains the ability information based on a given want. This API uses a promise to return the result.
W
wusongqing 已提交
1467

W
wusongqing 已提交
1468
**Required permissions**
W
wusongqing 已提交
1469

W
wusongqing 已提交
1470 1471 1472 1473 1474
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1475 1476 1477

**Parameters**

W
wusongqing 已提交
1478 1479
| Name         | Type    | Mandatory  | Description                                   |
| ----------- | ------ | ---- | ------------------------------------- |
W
wusongqing 已提交
1480 1481
| want        | [Want](js-apis-application-Want.md)   | Yes   | Want that contains the bundle name.                    |
| bundleFlags | number | Yes   | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
1482
| userId      | number | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.          |
W
wusongqing 已提交
1483 1484 1485

**Return value**

W
wusongqing 已提交
1486 1487
| Type                          | Description                   |
| ---------------------------- | --------------------- |
W
wusongqing 已提交
1488
| Promise<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Promise used to return the ability information.|
W
wusongqing 已提交
1489 1490 1491 1492

**Example**

```js
W
wusongqing 已提交
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503
let bundleFlags = 0;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryAbilityByWant(want, bundleFlags, userId)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
W
wusongqing 已提交
1504 1505 1506 1507 1508 1509 1510
})
```



## bundle.queryAbilityByWant

W
wusongqing 已提交
1511
queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void
W
wusongqing 已提交
1512

W
wusongqing 已提交
1513 1514 1515 1516 1517
Obtains the ability information of the specified user based on a given want. This API uses an asynchronous callback to return the result.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1518 1519 1520 1521

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1522 1523 1524

**Parameters**

W
wusongqing 已提交
1525 1526
| Name         | Type                                | Mandatory  | Description                                   |
| ----------- | ---------------------------------- | ---- | ------------------------------------- |
W
wusongqing 已提交
1527 1528
| want        | [Want](js-apis-application-Want.md)                               | Yes   | Want that contains the bundle name.                  |
| bundleFlags | number                             | Yes   | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
W
wusongqing 已提交
1529
| userId      | number                             | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.          |
W
wusongqing 已提交
1530
| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes   | Callback used to return the ability information.           |
W
wusongqing 已提交
1531 1532 1533 1534

**Example**

```js
W
wusongqing 已提交
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547
let bundleFlags = 0;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
W
wusongqing 已提交
1548 1549 1550 1551
```

## bundle.queryAbilityByWant

W
wusongqing 已提交
1552
queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback<Array\<AbilityInfo>>): void;
W
wusongqing 已提交
1553

W
wusongqing 已提交
1554
Obtains the ability information based on a given want. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1555

W
wusongqing 已提交
1556 1557 1558 1559
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

W
wusongqing 已提交
1560 1561 1562 1563
**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1564 1565
**Parameters**

W
wusongqing 已提交
1566 1567
| Name         | Type                                | Mandatory  | Description                                   |
| ----------- | ---------------------------------- | ---- | ------------------------------------- |
W
wusongqing 已提交
1568 1569 1570
| want        | [Want](js-apis-application-Want.md)                               | Yes   | Want that contains the bundle name.                  |
| bundleFlags | number                             | Yes   | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes   | Callback used to return the ability information.           |
W
wusongqing 已提交
1571 1572 1573 1574

**Example**

```js
W
wusongqing 已提交
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585
let bundleFlags = 0;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryAbilityByWant(want, bundleFlags, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
W
wusongqing 已提交
1586 1587 1588 1589 1590
})
```



W
wusongqing 已提交
1591 1592 1593 1594
## bundle.getLaunchWantForBundle

getLaunchWantForBundle(bundleName: string): Promise\<Want>

W
wusongqing 已提交
1595
Obtains the **Want** object that launches the specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1596

W
wusongqing 已提交
1597 1598
**Required permissions**

W
wusongqing 已提交
1599 1600 1601 1602 1603
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1604 1605 1606

**Parameters**

W
wusongqing 已提交
1607 1608
| Name        | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
W
wusongqing 已提交
1609
| bundleName | string | Yes   | Bundle name of an application.|
W
wusongqing 已提交
1610 1611

**Return value**
W
wusongqing 已提交
1612 1613
| Type            | Description                                    |
| -------------- | -------------------------------------- |
W
wusongqing 已提交
1614
| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the **Want** object.|
W
wusongqing 已提交
1615 1616 1617 1618

**Example**

```js
W
wusongqing 已提交
1619 1620 1621 1622 1623 1624 1625
let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
W
wusongqing 已提交
1626 1627
```

W
wusongqing 已提交
1628
## bundle.getLaunchWantForBundle
W
wusongqing 已提交
1629

W
wusongqing 已提交
1630
getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void;
W
wusongqing 已提交
1631

W
wusongqing 已提交
1632
Obtains the **Want** object that launches the specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1633

W
wusongqing 已提交
1634
**Required permissions**
W
wusongqing 已提交
1635

W
wusongqing 已提交
1636 1637 1638 1639 1640
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1641 1642 1643

**Parameters**

W
wusongqing 已提交
1644 1645
| Name        | Type                  | Mandatory  | Description                            |
| ---------- | -------------------- | ---- | ------------------------------ |
W
wusongqing 已提交
1646
| bundleName | string               | Yes   | Bundle name of an application.                  |
W
wusongqing 已提交
1647
| callback   | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes   | Callback used to return the **Want** object.|
W
wusongqing 已提交
1648 1649 1650 1651

**Example**

```js
W
wusongqing 已提交
1652 1653 1654 1655 1656 1657 1658 1659
let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
W
wusongqing 已提交
1660 1661 1662
```


W
wusongqing 已提交
1663
## bundle.getNameForUid<sup>8+</sup>
W
wusongqing 已提交
1664 1665

getNameForUid(uid: number): Promise\<string>
W
wusongqing 已提交
1666

W
wusongqing 已提交
1667
Obtains the bundle name based on a UID. This API uses a promise to return the result.
W
wusongqing 已提交
1668 1669 1670 1671

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1672 1673 1674

**Parameters**

W
wusongqing 已提交
1675 1676
| Name  | Type    | Mandatory  | Description      |
| ---- | ------ | ---- | -------- |
W
wusongqing 已提交
1677
| uid  | number | Yes   | UID based on which the bundle name is to obtain.|
W
wusongqing 已提交
1678 1679

**Return value**
W
wusongqing 已提交
1680 1681
| Type              | Description                               |
| ---------------- | --------------------------------- |
W
wusongqing 已提交
1682
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
1683 1684 1685 1686

**Example**

```js
W
wusongqing 已提交
1687 1688 1689 1690 1691 1692 1693
let uid = 20010005;
bundle.getNameForUid(uid)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
W
wusongqing 已提交
1694 1695
```

W
wusongqing 已提交
1696
## bundle.getNameForUid<sup>8+</sup>
W
wusongqing 已提交
1697

W
wusongqing 已提交
1698
getNameForUid(uid: number, callback: AsyncCallback\<string>) : void
W
wusongqing 已提交
1699

W
wusongqing 已提交
1700
Obtains the bundle name based on a UID. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1701

W
wusongqing 已提交
1702 1703 1704
**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1705 1706 1707

**Parameters**

W
wusongqing 已提交
1708 1709 1710
| Name      | Type                    | Mandatory  | Description                       |
| -------- | ---------------------- | ---- | ------------------------- |
| uid      | number                 | Yes   | UID based on which the bundle name is to obtain.                 |
W
wusongqing 已提交
1711
| callback | AsyncCallback\<string> | Yes   | Callback used to return the bundle name.|
W
wusongqing 已提交
1712 1713 1714 1715

**Example**

```js
W
wusongqing 已提交
1716 1717 1718 1719 1720 1721 1722 1723
let uid = 20010005;
bundle.getNameForUid(uid, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
W
wusongqing 已提交
1724 1725
```

W
wusongqing 已提交
1726

W
wusongqing 已提交
1727
## bundle.getAbilityIcon<sup>8+</sup>
W
wusongqing 已提交
1728

W
wusongqing 已提交
1729
getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>;
W
wusongqing 已提交
1730

W
wusongqing 已提交
1731
Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
1732

W
wusongqing 已提交
1733 1734
**Required permissions**

W
wusongqing 已提交
1735
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1736 1737 1738 1739 1740

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1741 1742
**Parameters**

W
wusongqing 已提交
1743 1744 1745 1746
| Name         | Type                                      | Mandatory  | Description                                      |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName  | string                                   | Yes   | Bundle name based on which the pixel map is to obtain.                         |
| abilityName | string                                   | Yes   | Ability name based on which the pixel map is to obtain.                        |
W
wusongqing 已提交
1747 1748 1749 1750

**Return value**
| Type                 | Description                                                        |
| --------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1751
| Promise\<image.PixelMap> | Promise used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1752 1753 1754 1755

**Example**

```js
W
wusongqing 已提交
1756 1757
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1758 1759 1760 1761 1762 1763 1764 1765
bundle.getAbilityIcon(bundleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

W
wusongqing 已提交
1766
## bundle.getAbilityIcon<sup>8+</sup>
W
wusongqing 已提交
1767

W
wusongqing 已提交
1768
getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void;
W
wusongqing 已提交
1769

W
wusongqing 已提交
1770
Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1771

W
wusongqing 已提交
1772 1773
**Required permissions**

W
wusongqing 已提交
1774
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1775 1776 1777 1778 1779

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1780 1781
**Parameters**

W
wusongqing 已提交
1782 1783 1784 1785
| Name         | Type                                      | Mandatory  | Description                                      |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName  | string                                   | Yes   | Bundle name based on which the pixel map is to obtain.                         |
| abilityName | string                                   | Yes   | Ability name based on which the pixel map is to obtain.                        |
W
wusongqing 已提交
1786
| callback   | AsyncCallback\<image.PixelMap> | Yes  | Callback used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1787 1788 1789 1790

**Example**

```js
W
wusongqing 已提交
1791 1792
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1793 1794 1795 1796 1797 1798 1799 1800 1801
bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```

W
wusongqing 已提交
1802 1803 1804 1805
## bundle.getAbilityIcon<sup>9+</sup>

getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise\<image.PixelMap>;

W
wusongqing 已提交
1806
Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
1807 1808 1809

**Required permissions**

W
wusongqing 已提交
1810
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name         | Type                                      | Mandatory  | Description                                      |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName  | string                                   | Yes   | Bundle name based on which the pixel map is to obtain.                         |
| moduleName  | string                                   | Yes   | Module name based on which the pixel map is to obtain.                         |
| abilityName | string                                   | Yes   | Ability name based on which the pixel map is to obtain.                        |

**Return value**
| Type                 | Description                                                        |
| --------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1827
| Promise\<image.PixelMap> | Promise used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846

**Example**

```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, moduleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

## bundle.getAbilityIcon<sup>9+</sup>

getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void;

W
wusongqing 已提交
1847
Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1848 1849 1850

**Required permissions**

W
wusongqing 已提交
1851
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name         | Type                                      | Mandatory  | Description                                      |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName  | string                                   | Yes   | Bundle name based on which the pixel map is to obtain.                         |
| moduleName  | string                                   | Yes   | Module name based on which the pixel map is to obtain.                         |
| abilityName | string                                   | Yes   | Ability name based on which the pixel map is to obtain.                        |
W
wusongqing 已提交
1864
| callback   | AsyncCallback\<image.PixelMap> | Yes  | Callback used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879

**Example**

```js
let bundleName = "com.example.myapplication";
let moduleName = "entry";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1880

W
wusongqing 已提交
1881
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
W
wusongqing 已提交
1882

W
wusongqing 已提交
1883
queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId?: number): Promise<Array\<ExtensionAbilityInfo>>
W
wusongqing 已提交
1884

W
wusongqing 已提交
1885
Obtains the Extension ability information based on a given want. This API uses a promise to return the result.
W
wusongqing 已提交
1886 1887 1888

**Required permissions**

W
wusongqing 已提交
1889
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1890 1891 1892 1893 1894 1895 1896

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1897 1898
| Name            | Type    | Mandatory  | Description                                      |
| -------------- | ------ | ---- | ---------------------------------------- |
W
wusongqing 已提交
1899 1900 1901
| want           | [Want](js-apis-application-Want.md)   | Yes   | Want that contains the bundle name.                       |
| extensionType  | number | Yes   | Type of the Extension ability information to obtain. The default value is **0**. For details on the available enumerated values, see [ExtensionAbilityType](#ExtensionAbilityType9).|
| extensionFlags | number | Yes   | Extension ability information to be returned. The default value is **0**. For details on the available enumerated values, see [ExtensionFlags](#ExtensionFlag9).|
W
wusongqing 已提交
1902
| userId         | number | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.             |
W
wusongqing 已提交
1903 1904 1905

**Return value**

W
wusongqing 已提交
1906 1907
| Type                                   | Description                            |
| ------------------------------------- | ------------------------------ |
W
wusongqing 已提交
1908
| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | Promise used to return the Extension ability information.|
W
wusongqing 已提交
1909 1910 1911 1912

**Example**

```js
W
wusongqing 已提交
1913
let extensionType = 0;
W
wusongqing 已提交
1914 1915 1916 1917 1918 1919
let extensionFlags = 0;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
W
wusongqing 已提交
1920
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId)
W
wusongqing 已提交
1921 1922 1923 1924 1925 1926 1927 1928 1929
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```



W
wusongqing 已提交
1930
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
W
wusongqing 已提交
1931

W
wusongqing 已提交
1932
queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void
W
wusongqing 已提交
1933

W
wusongqing 已提交
1934
Obtains the Extension ability information of the specified user based on a given want. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1935

W
wusongqing 已提交
1936 1937
**Required permissions**

W
wusongqing 已提交
1938
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1939

W
wusongqing 已提交
1940 1941 1942 1943 1944 1945
**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1946 1947 1948 1949 1950 1951 1952
| Name          | Type                                                        | Mandatory| Description                                                        |
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want           | [Want](js-apis-application-Want.md)                                                        | Yes  | Want that contains the bundle name.                      |
| extensionType  | number                                                       | Yes  | Type of the Extension ability information to obtain. The default value is **0**. For details on the available enumerated values, see [ExtensionAbilityType](#ExtensionAbilityType9).|
| extensionFlags | number                                                       | Yes  | Extension ability information to be returned. The default value is **0**. For details on the available enumerated values, see [ExtensionFlags](#ExtensionFlag9).|
| userId         | number                                                       | Yes  | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.         |
| callback       | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | Yes  | Callback used to return the Extension ability information.      |
W
wusongqing 已提交
1953 1954 1955 1956

**Example**

```js
W
wusongqing 已提交
1957
let extensionType = 0;
W
wusongqing 已提交
1958 1959 1960 1961 1962 1963
let extensionFlags = 0;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
W
wusongqing 已提交
1964 1965 1966 1967 1968 1969 1970
const receiver = function onReceive(err, data) {
    var errValue = JSON.stringify(err)
    var dataValue = JSON.stringify(data)
    console.error('Operation failed. Cause: ' + errValue);
    console.error('Operation failed. Cause: ' + dataValue);
}
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId, receiver)
W
wusongqing 已提交
1971 1972
```

W
wusongqing 已提交
1973
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
W
wusongqing 已提交
1974

W
wusongqing 已提交
1975
queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void;
W
wusongqing 已提交
1976

W
wusongqing 已提交
1977
Obtains the Extension ability information based on a given want. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1978

W
wusongqing 已提交
1979 1980
**Required permissions**

W
wusongqing 已提交
1981
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1982

W
wusongqing 已提交
1983 1984 1985 1986 1987 1988
**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1989 1990
| Name            | Type                                      | Mandatory  | Description                                      |
| -------------- | ---------------------------------------- | ---- | ---------------------------------------- |
W
wusongqing 已提交
1991 1992 1993 1994
| want           | [Want](js-apis-application-Want.md)                                     | Yes   | Want that contains the bundle name.                     |
| extensionType  | number                                   | Yes   | Type of the Extension ability information to obtain. The default value is **0**. For details on the available enumerated values, see [ExtensionAbilityType](#ExtensionAbilityType9).|
| extensionFlags | number                                   | Yes   | Extension ability information to be returned. The default value is **0**. For details on the available enumerated values, see [ExtensionFlags](#ExtensionFlag9).|
| callback       | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | Yes   | Callback used to return the Extension ability information.     |
W
wusongqing 已提交
1995 1996 1997 1998

**Example**

```js
W
wusongqing 已提交
1999
let extensionType = 0;
W
wusongqing 已提交
2000 2001 2002 2003 2004
let extensionFlags = 0;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
W
wusongqing 已提交
2005 2006 2007 2008 2009 2010 2011
const receiver = function onReceive(err, data) {
    var errValue = JSON.stringify(err)
    var dataValue = JSON.stringify(data)
    console.error('Operation failed. Cause: ' + errValue);
    console.error('Operation failed. Cause: ' + dataValue);
}
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, receiver)
W
wusongqing 已提交
2012 2013
```

W
wusongqing 已提交
2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145
## bundle.getProfileByAbility<sup>9+</sup>

getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;

Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, ability name, and metadata name. This API uses an asynchronous callback to return the result. This API cannot be used to obtain the JSON string array of another application.

**System capability**: SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName     | string                               | Yes   | Module to which the configuration file to be obtained belongs.             |
| abilityName    | string                               | Yes   | Ability to which the configuration file to be obtained belongs.            |
| metadataName   | string                               | Yes   | Metadata to which the configuration file to be obtained belongs.           |
| callback       | AsyncCallback\<Array\<string>>        | Yes   | Callback used to return the JSON string array of the configuration file.  |

**Example**

```js
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'ohos.ability.shortcuts';
const caller = function callback(err, data) {
    console.error('Operation errcode is: ' + err);
    console.error('Operation result is: ' + data);
}
bundle.getProfileByAbility(moduleName, abilityName, metadataName, caller)
```

## bundle.getProfileByAbility<sup>9+</sup>

getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string>>;

Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, ability name, and metadata name. This API uses a promise to return the result. This API cannot be used to obtain the JSON string array of another application.

**System capability**: SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName     | string                               | Yes   | Module to which the configuration file to be obtained belongs.             |
| abilityName    | string                               | Yes   | Ability to which the configuration file to be obtained belongs.            |
| metadataName   | string                               | No   | Metadata to which the configuration file to be obtained belongs.           |

**Return value**

| Type                                   | Description                            |
| ------------------------------------- | ------------------------------ |
| Promise\<Array\<string>> | Promise used to return the JSON string array of the configuration file.|

**Example**

```js
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'ohos.ability.shortcuts';

bundle.getProfileByAbility(moduleName, abilityName, metadataName).then(data=>{
    console.error('Operation result is: ' + data);
}).catch(err=>{
    console.error('Operation errcode is: ' + err);
})
```

## bundle.getProfileByExtensionAbility<sup>9+</sup>

getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;

Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result. This API cannot be used to obtain the JSON string array of another application.

**System capability**: SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName     | string                               | Yes   | Module to which the configuration file to be obtained belongs.             |
| extensionAbilityName    | string                               | Yes   | Extension ability to which the configuration file to be obtained belongs.            |
| metadataName   | string                               | Yes   | Metadata to which the configuration file to be obtained belongs.           |
| callback       | AsyncCallback\<Array\<string>>        | Yes   | Callback used to return the JSON string array of the configuration file.  |

**Example**

```js
let moduleName = 'entry';
let extensionAbilityName = 'Form';
let metadataName = 'ohos.extension.form';
const caller = function callback(err, data) {
    console.error('Operation errcode is: ' + err);
    console.error('Operation result is: ' + data);
}
bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, caller)
```

## bundle.getProfileByExtensionAbility<sup>9+</sup>

getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string>>;

Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, Extension ability name, and metadata name. This API uses a promise to return the result. This API cannot be used to obtain the JSON string array of another application.

**System capability**: SystemCapability.BundleManager.BundleFramework

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName     | string                               | Yes   | Module to which the configuration file to be obtained belongs.             |
| extensionAbilityName    | string                               | Yes   | Extension ability to which the configuration file to be obtained belongs.            |
| metadataName   | string                               | No   | Metadata to which the configuration file to be obtained belongs.           |

**Return value**

| Type                                   | Description                            |
| ------------------------------------- | ------------------------------ |
| Promise\<Array\<string>> | Promise used to return the JSON string array of the configuration file.|

**Example**

```js
let moduleName = 'entry';
let extensionAbilityName = 'Form';
let metadataName = 'ohos.extension.form';

bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then(data=>{
    console.error('Operation result is: ' + data);
}).catch(err=>{
    console.error('Operation errcode is: ' + err);
})
```

W
wusongqing 已提交
2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281
## bundle.setDisposedStatus<sup>9+</sup>

setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback\<void>): void;

Sets the disposal status for an application based on a given bundle name. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS

**System capability**: SystemCapability.BundleManager.BundleFramework

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName     | string                               | Yes   | Bundle name of an application.             |
| status    | number                               | Yes   | Disposal status to set. This parameter is reserved for the application market. The default value is **0**, indicating that no disposal is performed.            |
| callback       | AsyncCallback\<void>        | Yes   | Callback that returns no value.  |

**Example**

```js
let bundleName = 'com.ohos.camera';
let status = 1;
const caller = function callback(err, data) {
    console.error('Operation err is: ' + err);
    console.error('Operation result is: ' + data);
}
bundle.setDisposedStatus(bundleName, status, caller)
```

## bundle.setDisposedStatus<sup>9+</sup>

setDisposedStatus(bundleName: string, status: number): Promise\<void>;

Sets the disposal status for an application based on a given bundle name. This API uses a promise to return the result.

**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS

**System capability**: SystemCapability.BundleManager.BundleFramework

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName     | string                               | Yes   | Bundle name of an application.             |
| status    | number                               | Yes   | Disposal status to set. This parameter is reserved for the application market. The default value is **0**, indicating that no disposal is performed.            |

**Return value**

| Type                                   | Description                            |
| ------------------------------------- | ------------------------------ |
| Promise\<void> | Promise that returns no value.|

**Example**

```js
let bundleName = 'com.ohos.camera';
let status = 1;

bundle.setDisposedStatus(bundleName, status).then(data=>{
    console.error('Operation result is: ' + data);
}).catch(err=>{
    console.error('Operation err is: ' + err);
})
```

## bundle.getDisposedStatus<sup>9+</sup>

getDisposedStatus(bundleName: string, callback: AsyncCallback\<number>): void;

Obtains the disposal status of an application based on a given bundle name. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS

**System capability**: SystemCapability.BundleManager.BundleFramework

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName     | string                               | Yes   | Bundle name of an application.             |
| callback       | AsyncCallback\<number>        | Yes   | Callback used to return the disposal status.  |

**Example**

```js
let bundleName = 'com.ohos.camera';
const caller = function callback(err, data) {
    console.error('Operation err is: ' + err);
    console.error('Operation result is: ' + data);
}
bundle.getDisposedStatus(bundleName, caller)
```

## bundle.getDisposedStatus<sup>9+</sup>

getDisposedStatus(bundleName: string): Promise\<number>;

Obtains the disposal status of an application based on a given bundle name. This API uses a promise to return the result.

**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS

**System capability**: SystemCapability.BundleManager.BundleFramework

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name            | Type                               | Mandatory  | Description                                      |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| bundleName     | string                               | Yes   | Bundle name of an application.             |

**Return value**

| Type                                   | Description                            |
| ------------------------------------- | ------------------------------ |
| Promise\<number> | Promise used to return the disposal status.|

**Example**

```js
let bundleName = 'com.ohos.camera';

bundle.getDisposedStatus(bundleName).then(data=>{
    console.error('Operation result is: ' + data);
}).catch(err=>{
    console.error('Operation err is: ' + err);
})
```

W
wusongqing 已提交
2282
## InstallErrorCode
W
wusongqing 已提交
2283

W
wusongqing 已提交
2284 2285
 **System capability**: SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
2286 2287 2288
| Name                                      | Default Value | Description                       |
| ---------------------------------------- | ---- | ------------------------- |
| SUCCESS                                  | 0    | Installation succeeded.                     |
W
wusongqing 已提交
2289
| STATUS_INSTALL_FAILURE                   | 1    | Installation failed. (The application to be installed is not found.)           |
W
wusongqing 已提交
2290 2291
| STATUS_INSTALL_FAILURE_ABORTED           | 2    | Installation aborted.                     |
| STATUS_INSTALL_FAILURE_INVALID           | 3    | Invalid installation parameter.                   |
W
wusongqing 已提交
2292
| STATUS_INSTALL_FAILURE_CONFLICT          | 4    | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) |
W
wusongqing 已提交
2293
| STATUS_INSTALL_FAILURE_STORAGE           | 5    | Failed to store the bundle information.                  |
W
wusongqing 已提交
2294 2295
| STATUS_INSTALL_FAILURE_INCOMPATIBLE      | 6    | Installation incompatibility. (A downgrade occurs or the signature information is incorrect.) |
| STATUS_UNINSTALL_FAILURE                 | 7    | Uninstallation failed. (The application to be uninstalled is not found.)          |
W
wusongqing 已提交
2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307
| STATUS_UNINSTALL_FAILURE_BLOCKED         | 8    | Uninstallation aborted. (This error code is not in use.)              |
| STATUS_UNINSTALL_FAILURE_ABORTED         | 9    | Uninstallation aborted. (Invalid parameters.)            |
| STATUS_UNINSTALL_FAILURE_CONFLICT        | 10   | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)|
| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT  | 0x0B | Installation failed. (Download timed out.)              |
| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED   | 0x0C | Installation failed. (Download failed.)              |
| STATUS_RECOVER_FAILURE_INVALID<sup>8+</sup> | 0x0D | Failed to restore the pre-installed application.                 |
| STATUS_ABILITY_NOT_FOUND                 | 0x40 | Ability not found.               |
| STATUS_BMS_SERVICE_ERROR                 | 0x41 | BMS service error.                  |
| STATUS_FAILED_NO_SPACE_LEFT<sup>8+</sup> | 0x42 | Insufficient device space.                   |
| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED<sup>8+</sup> | 0x43 | Application authorization failed.                   |
| STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x44 | Installation permission denied.                   |
| STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x45 | Uninstallation permission denied.                   |
W
wusongqing 已提交
2308 2309 2310

## BundleFlag

W
wusongqing 已提交
2311 2312 2313
Enumerates bundle flags.

 **System capability**: SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
2314

W
wusongqing 已提交
2315 2316 2317 2318 2319 2320 2321 2322 2323
| Name                                      | Default Value       | Description                 |
| ---------------------------------------- | ---------- | ------------------- |
| GET_BUNDLE_DEFAULT                       | 0x00000000 | Obtains the default application information.          |
| GET_BUNDLE_WITH_ABILITIES                | 0x00000001 | Obtains the bundle information with the ability information.  |
| GET_ABILITY_INFO_WITH_PERMISSION         | 0x00000002 | Obtains the ability information with the permission information.   |
| GET_ABILITY_INFO_WITH_APPLICATION        | 0x00000004 | Obtains the ability information with the application information.   |
| GET_APPLICATION_INFO_WITH_PERMISSION     | 0x00000008 | Obtains the application information with the permission information.        |
| GET_BUNDLE_WITH_REQUESTED_PERMISSION     | 0x00000010 | Obtains the bundle information with the information about the required permissions.       |
| GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | Obtains the ability metadata information.    |
W
wusongqing 已提交
2324
| GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | Obtains the bundle information with the Extension ability information.|
W
wusongqing 已提交
2325
| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information.         |
W
wusongqing 已提交
2326
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information of system applications.|
W
wusongqing 已提交
2327 2328
| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities.  |
| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications.       |
W
wusongqing 已提交
2329
| GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT <sup>9+</sup> | 0x00000400 | Obtains the signing certificate fingerprint of the application.       |
W
wusongqing 已提交
2330
| GET_ALL_APPLICATION_INFO                 | 0xFFFF0000 | Obtains all application information.          |
W
wusongqing 已提交
2331
| GET_BUNDLE_WITH_HASH_VALUE<sup>9+</sup> | 0x00000030 | Obtains information about the bundle that contains a hash value.      |
W
wusongqing 已提交
2332 2333 2334 2335 2336

## BundleOptions

Describes the bundle options.

W
wusongqing 已提交
2337 2338
 **System capability**: SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
2339 2340
| Name    | Type    | Readable  | Writable  | Description                          |
| ------ | ------ | ---- | ---- | ---------------------------- |
W
wusongqing 已提交
2341
| userId | number | Yes   | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
W
wusongqing 已提交
2342 2343 2344

## AbilityType

W
wusongqing 已提交
2345 2346 2347
Enumerates ability types.

 **System capability**: SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
2348

W
wusongqing 已提交
2349 2350 2351 2352 2353
| Name     | Type  | Description               |
| ------- | ---- | ----------------- |
| UNKNOWN | None   | Unknown ability type.      |
| PAGE    | None   | Ability that has a UI.   |
| SERVICE | None   | Ability that does not have a UI.    |
W
wusongqing 已提交
2354
| DATA    | None   | Ability that is used to provide data access services.|
W
wusongqing 已提交
2355 2356 2357

## DisplayOrientation

W
wusongqing 已提交
2358 2359 2360
Enumerates display orientations.

 **System capability**: SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
2361

W
wusongqing 已提交
2362 2363
| Name           | Type  | Description           |
| ------------- | ---- | ------------- |
W
wusongqing 已提交
2364
| UNSPECIFIED   | None   | Unspecified display orientation.    |
W
wusongqing 已提交
2365 2366
| LANDSCAPE     | None   | Landscape orientation.     |
| PORTRAIT      | None   | Portrait orientation.     |
W
wusongqing 已提交
2367
| FOLLOW_RECENT | None   | Orientation same as that of the nearest ability in the stack.|
W
wusongqing 已提交
2368 2369 2370 2371 2372 2373 2374 2375 2376
| LANDSCAPE_INVERTED<sup>9+</sup> |None   | Reverse landscape orientation.    |
| PORTRAIT_INVERTED<sup>9+</sup> |None   | Reverse portrait orientation.    |
| AUTO_ROTATION<sup>9+</sup> |None   | Orientation determined by the sensor.    |
| AUTO_ROTATION_LANDSCAPE<sup>9+</sup> |None   | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape.    |
| AUTO_ROTATION_PORTRAIT<sup>9+</sup> |None   | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait.    |
| AUTO_ROTATION_RESTRICTED<sup>9+</sup> |None   | Orientation determined by the sensor when the sensor switch is enabled.    |
| AUTO_ROTATION_LANDSCAPE_RESTRICTED<sup>9+</sup> |None   | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape, when the sensor switch is enabled.    |
| AUTO_ROTATION_PORTRAIT_RESTRICTED<sup>9+</sup> |None   | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait, when the sensor switch is enabled.    |
| LOCKED<sup>9+</sup> |None   | Auto rotate disabled.    |
W
wusongqing 已提交
2377 2378
## LaunchMode

W
wusongqing 已提交
2379 2380 2381
Enumerates launch modes.

 **System capability**: SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
2382

W
wusongqing 已提交
2383 2384
| Name       | Type  | Description           |
| --------- | ---- | ------------- |
W
wusongqing 已提交
2385
| SINGLETON | 0    | The ability has only one instance.|
W
wusongqing 已提交
2386
| STANDARD  | 1    | The ability can have multiple instances. |
W
wusongqing 已提交
2387 2388 2389

## AbilitySubType

W
wusongqing 已提交
2390 2391 2392
Enumerates ability subtypes.

 **System capability**: SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
2393

W
wusongqing 已提交
2394 2395 2396
| Name         | Type  | Description                  |
| ----------- | ---- | -------------------- |
| UNSPECIFIED | 0    | Undefined ability subtype.       |
W
wusongqing 已提交
2397
| CA          | 1    | Ability that has a UI.|
W
wusongqing 已提交
2398

W
wusongqing 已提交
2399
## ExtensionAbilityType<sup>9+</sup>
W
wusongqing 已提交
2400

W
wusongqing 已提交
2401
Enumerates Extension ability types.
W
wusongqing 已提交
2402 2403 2404

 **System capability**: SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
2405 2406
| Name                            | Type  | Description                       |
| ------------------------------ | ---- | ------------------------- |
W
wusongqing 已提交
2407
| FORM<sup>9+</sup>              | 0    | Form (widget) included.  |
W
wusongqing 已提交
2408
| WORK_SCHEDULER<sup>9+</sup>    | 1    | Work scheduler included.|
W
wusongqing 已提交
2409 2410 2411
| INPUT_METHOD<sup>9+</sup>      | 2    | Input method included. |
| SERVICE<sup>9+</sup>           | 3    | Service included.  |
| ACCESSIBILITY<sup>9+</sup>     | 4    | Accessibility included. |
W
wusongqing 已提交
2412 2413
| DATA_SHARE<sup>9+</sup>        | 5    | Data sharing included.|
| FILE_SHARE<sup>9+</sup>        | 6    | File sharing included.|
W
wusongqing 已提交
2414 2415
| STATIC_SUBSCRIBER<sup>9+</sup> | 7    | Subscribers included. |
| WALLPAPER<sup>9+</sup>         | 8    | Wallpaper included.  |
W
wusongqing 已提交
2416 2417
| BACKUP<sup>9+</sup> | 9    | Data backup and restore included.|
| WINDOW<sup>9+</sup> | 10 | Window type extension information included.|
W
wusongqing 已提交
2418
| ENTERPRISE_ADMIN<sup>9+</sup>  | 11   | Enterprise administrators included.  |
W
wusongqing 已提交
2419 2420 2421
| THUMBNAIL<sup>9+</sup> | 13 | Thumbnails included.|
| PREVIEW<sup>9+</sup> | 14 | Preview included.|
| UNSPECIFIED<sup>9+</sup>       | 255   | Unspecified type.    |
W
wusongqing 已提交
2422 2423

## ExtensionFlag<sup>9+</sup>
W
wusongqing 已提交
2424

W
wusongqing 已提交
2425
Enumerates Extension flags.
W
wusongqing 已提交
2426 2427 2428

 **System capability**: SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
2429 2430 2431 2432 2433
| Name                                      | Default Value       | Description                            |
| ---------------------------------------- | ---------- | ------------------------------ |
| GET_EXTENSION_INFO_DEFAULT<sup>9+</sup>  | 0x00000000 | Obtains the default Extension ability information.     |
| GET_EXTENSION_INFO_WITH_PERMISSION<sup>9+</sup> | 0x00000002 | Obtains the Extension ability information that carries permission information. |
| GET_EXTENSION_INFO_WITH_APPLICATION<sup>9+</sup> | 0x00000004 | Obtains the Extension ability information that carries application information. |
W
wusongqing 已提交
2434
| GET_EXTENSION_INFO_WITH_METADATA<sup>9+</sup> | 0x00000020 | Obtains the Extension ability information that carries metadata information.|
W
wusongqing 已提交
2435 2436 2437 2438 2439 2440 2441

## ColorMode

Enumerates color modes.

 **System capability**: SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
2442 2443
| Name        | Type  | Description  |
| ---------- | ---- | ---- |
W
wusongqing 已提交
2444 2445 2446
| AUTO_MODE  | -1   | Automatic mode.|
| DARK_MODE  | 0    | Dark mode.|
| LIGHT_MODE | 1    | Light mode.|
W
wusongqing 已提交
2447 2448


W
wusongqing 已提交
2449 2450
## GrantStatus

W
wusongqing 已提交
2451
Enumerates permission grant states.
W
wusongqing 已提交
2452 2453 2454

 **System capability**: SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
2455 2456
| Name                | Type  | Description  |
| ------------------ | ---- | ---- |
W
wusongqing 已提交
2457
| PERMISSION_DENIED  | -1   | Permission denied.|
W
wusongqing 已提交
2458
| PERMISSION_GRANTED | 0    | Permission granted.  |
W
wusongqing 已提交
2459 2460 2461 2462 2463 2464 2465 2466 2467

## SupportWindowMode

Enumerates window modes.

 **System capability**: SystemCapability.BundleManager.BundleFramework

| Name                | Type  | Description  |
| ------------------ | ---- | ---- |
W
wusongqing 已提交
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484
| FULL_SCREEN<sup>9+</sup> | 0   | Full screen.|
| SPLIT<sup>9+</sup> | 1    | Split-screen.  |
| FLOATING<sup>9+</sup> | 2    | Floating.  |

## UpgradeFlag

Enumerates the upgrade flags, which are for internal use only.

**System API**: This is a system API and cannot be called by third-party applications.

**System capability**: SystemCapability.BundleManager.BundleFramework

| Name                         | Value  | Description            |
| ----------------------------- | ---- | ---------------- |
| NOT_UPGRADE<sup>9+</sup>      | 0    | No module needs an upgrade.    |
| SINGLE_UPGRADE<sup>9+</sup>   | 1    | A single module needs an upgrade.|
| RELATION_UPGRADE<sup>9+</sup> | 2    | The module that has a relationship with the current one needs an upgrade.|