js-apis-Bundle.md 66.6 KB
Newer Older
W
wusongqing 已提交
1 2
# Bundle Module (JavaScript SDK APIs)

3
> **NOTE**<br>
W
wusongqing 已提交
4
> 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 已提交
5
> API version 9 is a canary version for trial use. The APIs of this version may be unstable.
W
wusongqing 已提交
6 7 8 9 10 11
## Modules to Import

```
import bundle from '@ohos.bundle';
```

W
wusongqing 已提交
12
## System Capability
W
wusongqing 已提交
13 14 15 16 17

SystemCapability.BundleManager.BundleFramework

## Required Permissions

W
wusongqing 已提交
18 19
| Required Permissions                                      | Permission Level        | Description       |
| ---------------------------------------- | ------------ | --------- |
W
wusongqing 已提交
20 21
| ohos.permission.GET_BUNDLE_INFO          | normal       | Permission to query information about the current application.|
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.|
W
wusongqing 已提交
22
| ohos.permission.INSTALL_BUNDLE           | system_core  | Permission to install or uninstall applications. |
W
wusongqing 已提交
23 24 25

## bundle.getApplicationInfo

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

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

W
wusongqing 已提交
30
**Required permissions**
W
wusongqing 已提交
31

W
wusongqing 已提交
32 33 34 35 36
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
37 38 39

**Parameters**

W
wusongqing 已提交
40
| Name         | Type    | Mandatory  | Description                                     |
W
wusongqing 已提交
41
| ----------- | ------ | ---- | --------------------------------------- |
W
wusongqing 已提交
42 43 44
| bundleName  | string | Yes   | Bundle name of the application.                           |
| 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 已提交
45 46 47

**Return value**

W
wusongqing 已提交
48 49
| Type                       | Description                |
| ------------------------- | ------------------ |
W
wusongqing 已提交
50
| Promise\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Promise used to return the application information.|
W
wusongqing 已提交
51 52 53 54

**Example**

```js
W
wusongqing 已提交
55 56 57 58 59 60 61 62
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 已提交
63 64 65 66 67 68 69 70 71
})
```



## bundle.getApplicationInfo

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

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

W
wusongqing 已提交
74
**Required permissions**
W
wusongqing 已提交
75

W
wusongqing 已提交
76 77 78 79 80
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
81 82 83

**Parameters**

W
wusongqing 已提交
84 85 86
| Name         | Type                             | Mandatory  | Description                                     |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
| bundleName  | string                          | Yes   | Bundle name of the application.                           |
W
wusongqing 已提交
87
| 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 已提交
88
| 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 已提交
89
| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes   | Callback used to return the application information.                |
W
wusongqing 已提交
90 91 92 93

**Example**

```js
W
wusongqing 已提交
94 95 96 97 98 99 100 101 102 103
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 已提交
104 105 106
```


W
wusongqing 已提交
107 108 109 110
## bundle.getApplicationInfo

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

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

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
123 124 125
| Name         | Type                             | Mandatory  | Description                                     |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
| bundleName  | string                          | Yes   | Bundle name of the application.                           |
W
wusongqing 已提交
126 127
| 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 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142

**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 已提交
143 144 145

## bundle.getAllBundleInfo

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

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

W
wusongqing 已提交
150
**Required permissions**
W
wusongqing 已提交
151

W
wusongqing 已提交
152 153 154 155 156
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
157 158 159

**Parameters**

W
wusongqing 已提交
160 161
| Name        | Type        | Mandatory  | Description                                     |
| ---------- | ---------- | ---- | --------------------------------------- |
W
wusongqing 已提交
162
| 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 已提交
163
| 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 已提交
164 165 166

**Return value**

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

**Example**

```js
W
wusongqing 已提交
174 175 176 177 178 179 180
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 已提交
181 182 183 184 185 186 187 188 189
})
```



## bundle.getAllBundleInfo

getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void

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 222 223 224

## bundle.getAllBundleInfo

getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void

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

**Required permissions**

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

**System capability**

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

**Parameters**

W
wusongqing 已提交
237 238
| Name        | Type                               | Mandatory  | Description                                     |
| ---------- | --------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
239
| 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 已提交
240
| 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 已提交
241
| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes   | Callback used to return the information of all available bundles.       |
W
wusongqing 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254

**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 已提交
255 256 257 258 259 260
```



## bundle.getBundleInfo

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

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

W
wusongqing 已提交
265
**Required permissions**
W
wusongqing 已提交
266

W
wusongqing 已提交
267 268 269 270 271
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
272 273 274

**Parameters**

W
wusongqing 已提交
275 276
| Name         | Type           | Mandatory  | Description                                     |
| ----------- | ------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
277 278 279
| bundleName  | string        | Yes   | Bundle name of the application.                                     |
| 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 已提交
280 281 282

**Return value**

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

**Example**

```js
W
wusongqing 已提交
290 291 292
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
293
  "userId" : 100
W
wusongqing 已提交
294 295 296 297 298 299
};
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 已提交
300 301 302 303 304 305 306 307 308
})
```



## bundle.getBundleInfo

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

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

W
wusongqing 已提交
311
**Required permissions**
W
wusongqing 已提交
312

W
wusongqing 已提交
313 314 315 316 317
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
318 319 320

**Parameters**

W
wusongqing 已提交
321 322
| Name         | Type                        | Mandatory  | Description                                     |
| ----------- | -------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
323 324 325
| bundleName  | string                     | Yes   | Bundle name of the application.                                     |
| 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 已提交
326 327 328 329

**Example**

```js
W
wusongqing 已提交
330 331 332 333 334 335 336 337 338
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 已提交
339 340 341
```


W
wusongqing 已提交
342 343 344 345
## bundle.getBundleInfo

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

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

**Required permissions**

W
wusongqing 已提交
350 351 352 353 354
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
355 356 357

**Parameters**

W
wusongqing 已提交
358 359
| Name         | Type                        | Mandatory  | Description                                     |
| ----------- | -------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
360 361 362 363
| bundleName  | string                     | Yes   | Bundle name of the application.                                     |
| 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 已提交
364 365 366 367 368 369 370

**Example**

```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
371
  "userId" : 100
W
wusongqing 已提交
372 373 374 375 376 377 378 379 380 381
};
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 已提交
382 383 384

## bundle.getAllApplicationInfo

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

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

W
wusongqing 已提交
389
**Required permissions**
W
wusongqing 已提交
390

W
wusongqing 已提交
391 392 393 394 395
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
396 397 398

**Parameters**

W
wusongqing 已提交
399 400
| Name         | Type    | Mandatory  | Description                                     |
| ----------- | ------ | ---- | --------------------------------------- |
W
wusongqing 已提交
401
| 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 已提交
402
| 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 已提交
403 404 405

**Return value**

W
wusongqing 已提交
406 407
| Type                              | Description                             |
| -------------------------------- | ------------------------------- |
W
wusongqing 已提交
408
| Promise<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Promise used to return the application information.|
W
wusongqing 已提交
409 410 411 412

**Example**

```js
W
wusongqing 已提交
413 414 415 416 417 418 419
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 已提交
420 421 422 423 424 425 426 427 428
})
```



## bundle.getAllApplicationInfo

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

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

W
wusongqing 已提交
431
**Required permissions**
W
wusongqing 已提交
432

W
wusongqing 已提交
433 434 435 436 437
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
438 439 440

**Parameters**

W
wusongqing 已提交
441 442
| Name         | Type                                    | Mandatory  | Description                                     |
| ----------- | -------------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
443
| 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 已提交
444
| 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 已提交
445
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes   | Callback used to return the application information.                |
W
wusongqing 已提交
446 447 448 449

**Example**

```js
W
wusongqing 已提交
450 451 452 453 454 455 456 457 458
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 已提交
459 460 461
```


W
wusongqing 已提交
462 463
## bundle.getAllApplicationInfo

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

W
wusongqing 已提交
466
Obtains the information about all applications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
467 468 469 470 471 472 473 474 475 476 477

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
478 479
| Name         | Type                                    | Mandatory  | Description                                     |
| ----------- | -------------------------------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
480 481
| 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 已提交
482 483 484 485 486 487 488 489 490 491 492 493 494 495

**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 已提交
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
## bundle.getBundleArchiveInfo

getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise<BundleInfo>

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.|
| 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 0.|

**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

getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>) : void

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.|
| 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 0.|
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes   | Callback used to return the information about the bundles. |

**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 已提交
564 565 566 567
## bundle.getAbilityInfo

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

W
wusongqing 已提交
568
Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
569 570 571 572 573 574 575 576 577 578 579

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
580 581 582
| Name         | Type    | Mandatory  | Description              |
| ----------- | ------ | ---- | ---------------- |
| bundleName  | string | Yes   | Bundle name of the application.    |
W
wusongqing 已提交
583
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
584 585 586

**Return value**

W
wusongqing 已提交
587 588
| Type                   | Description                   |
| --------------------- | --------------------- |
W
wusongqing 已提交
589
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|
W
wusongqing 已提交
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605

**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 已提交
606
getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;
W
wusongqing 已提交
607

W
wusongqing 已提交
608
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 已提交
609 610 611 612 613 614 615 616 617 618 619

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
620 621 622
| Name        | Type    | Mandatory  | Description           |
| ----------- | ------------ | ---- | ---------------- |
| bundleName  | string | Yes   | Bundle name of the application.    |
W
wusongqing 已提交
623 624
| abilityName | string | Yes   | Ability name.|
| callback    | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes   | Callback used to return the ability information.|
W
wusongqing 已提交
625 626 627 628 629 630 631 632 633 634 635 636 637 638

**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 已提交
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
## 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              |
| ----------- | ------ | ---- | ---------------- |
| bundleName  | string | Yes   | Bundle name of the application.    |
| 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           |
| ----------- | ------------ | ---- | ---------------- |
| bundleName  | string | Yes   | Bundle name of the application.    |
| 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 已提交
718

W
wusongqing 已提交
719
## bundle.getAbilityLabel<sup>8+</sup>
W
wusongqing 已提交
720 721 722

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

W
wusongqing 已提交
723
Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
724 725 726 727 728 729 730 731 732 733 734

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
735 736 737
| Name         | Type    | Mandatory  | Description              |
| ----------- | ------ | ---- | ---------------- |
| bundleName  | string | Yes   | Bundle name of the application.    |
W
wusongqing 已提交
738
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
739 740 741

**Return value**

W
wusongqing 已提交
742 743
| Type              | Description                |
| ---------------- | ------------------ |
W
wusongqing 已提交
744
| Promise\<string> | Promise used to return the application name.|
W
wusongqing 已提交
745 746 747 748 749 750 751 752 753 754 755 756 757 758

**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 已提交
759
## bundle.getAbilityLabel<sup>8+</sup>
W
wusongqing 已提交
760 761 762

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

W
wusongqing 已提交
763
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 已提交
764 765 766 767 768 769 770 771 772 773 774

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
775 776 777
| Name         | Type                    | Mandatory  | Description              |
| ----------- | ---------------------- | ---- | ---------------- |
| bundleName  | string                 | Yes   | Bundle name of the application.    |
W
wusongqing 已提交
778
| abilityName | string                 | Yes   | Ability name.|
W
wusongqing 已提交
779
| callback    | AsyncCallback\<string> | Yes   | Callback used to return the application name.       |
W
wusongqing 已提交
780 781 782 783 784 785 786 787 788 789 790 791 792 793

**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 已提交
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 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872
## 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              |
| ----------- | ------ | ---- | ---------------- |
| bundleName  | string | Yes   | Bundle name of the application.    |
| 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              |
| ----------- | ---------------------- | ---- | ---------------- |
| bundleName  | string                 | Yes   | Bundle name of the application.    |
| 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 已提交
873

W
wusongqing 已提交
874
## bundle.isAbilityEnabled<sup>8+</sup>
W
wusongqing 已提交
875 876 877

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

W
wusongqing 已提交
878
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses a promise to return the result.
W
wusongqing 已提交
879 880 881 882 883 884 885 886 887 888 889

**Required permissions**

None

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
890 891
| Name  | Type         | Mandatory  | Description          |
| ---- | ----------- | ---- | ------------ |
W
wusongqing 已提交
892
| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes   | Ability information.|
W
wusongqing 已提交
893 894 895

**Return value**

W
wusongqing 已提交
896 897
| Type               | Description                       |
| ----------------- | ------------------------- |
W
wusongqing 已提交
898
| 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 已提交
899 900 901 902

**Example**

```js
W
wusongqing 已提交
903 904 905 906 907 908 909 910
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 已提交
911 912 913
})
```

W
wusongqing 已提交
914
## bundle.isAbilityEnabled<sup>8+</sup>
W
wusongqing 已提交
915 916 917

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

W
wusongqing 已提交
918
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
919 920 921 922 923 924 925 926 927 928 929

**Required permissions**

None

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
930 931
| Name      | Type                     | Mandatory  | Description             |
| -------- | ----------------------- | ---- | --------------- |
W
wusongqing 已提交
932 933
| 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 已提交
934 935 936 937

**Example**

```js
W
wusongqing 已提交
938 939 940 941
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
    bundle.isAbilityEnabled(abilityInfo, (err, data) => {
W
wusongqing 已提交
942 943 944 945 946
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
W
wusongqing 已提交
947
    })
W
wusongqing 已提交
948 949 950
})
```

W
wusongqing 已提交
951
## bundle.isApplicationEnabled<sup>8+</sup>
W
wusongqing 已提交
952 953 954

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

W
wusongqing 已提交
955
Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result.
W
wusongqing 已提交
956 957 958 959 960 961 962 963 964 965 966

**Required permissions**

None

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
967 968
| Name        | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
W
wusongqing 已提交
969
| bundleName | string | Yes   | Bundle name of the application.|
W
wusongqing 已提交
970 971 972

**Return value**

W
wusongqing 已提交
973 974
| Type               | Description                       |
| ----------------- | ------------------------- |
W
wusongqing 已提交
975
| 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 已提交
976 977 978 979 980 981 982 983 984 985 986 987 988

**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 已提交
989
## bundle.isApplicationEnabled<sup>8+</sup>
W
wusongqing 已提交
990 991 992

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

W
wusongqing 已提交
993
Checks whether an application is enabled based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
994 995 996 997 998 999 1000 1001 1002 1003 1004

**Required permissions**

None

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1005 1006 1007
| Name        | Type                     | Mandatory  | Description             |
| ---------- | ----------------------- | ---- | --------------- |
| bundleName | string                  | Yes   | Bundle name of the application.   |
W
wusongqing 已提交
1008
| 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 已提交
1009 1010 1011 1012

**Example**

```js
W
wusongqing 已提交
1013
let bundleName = "com.example.myapplication";
W
wusongqing 已提交
1014 1015 1016 1017 1018 1019 1020 1021
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 已提交
1022 1023 1024 1025 1026

## bundle.queryAbilityByWant

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

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

W
wusongqing 已提交
1029
**Required permissions**
W
wusongqing 已提交
1030

W
wusongqing 已提交
1031 1032 1033 1034 1035
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1036 1037 1038

**Parameters**

W
wusongqing 已提交
1039 1040
| Name         | Type    | Mandatory  | Description                                   |
| ----------- | ------ | ---- | ------------------------------------- |
W
wusongqing 已提交
1041 1042
| 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 已提交
1043
| 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 已提交
1044 1045 1046

**Return value**

W
wusongqing 已提交
1047 1048
| Type                          | Description                   |
| ---------------------------- | --------------------- |
W
wusongqing 已提交
1049
| Promise<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Promise used to return the ability information.|
W
wusongqing 已提交
1050 1051 1052 1053

**Example**

```js
W
wusongqing 已提交
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
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 已提交
1065 1066 1067 1068 1069 1070 1071 1072 1073
})
```



## bundle.queryAbilityByWant

queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<AbilityInfo>>): void

W
wusongqing 已提交
1074
Obtains the ability information based on a given want. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1075 1076 1077 1078

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1079 1080 1081

**Parameters**

W
wusongqing 已提交
1082 1083
| Name         | Type                                | Mandatory  | Description                                   |
| ----------- | ---------------------------------- | ---- | ------------------------------------- |
W
wusongqing 已提交
1084 1085
| 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 已提交
1086
| 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 已提交
1087
| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes   | Callback used to return the ability information.           |
W
wusongqing 已提交
1088 1089 1090 1091

**Example**

```js
W
wusongqing 已提交
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
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 已提交
1105 1106 1107 1108
```

## bundle.queryAbilityByWant

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

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

W
wusongqing 已提交
1113 1114 1115 1116
**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1117 1118
**Parameters**

W
wusongqing 已提交
1119 1120
| Name         | Type                                | Mandatory  | Description                                   |
| ----------- | ---------------------------------- | ---- | ------------------------------------- |
W
wusongqing 已提交
1121 1122 1123
| 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 已提交
1124 1125 1126 1127

**Example**

```js
W
wusongqing 已提交
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
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 已提交
1139 1140 1141 1142 1143
})
```



W
wusongqing 已提交
1144 1145 1146 1147
## bundle.getLaunchWantForBundle

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

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

W
wusongqing 已提交
1150 1151
**Required permissions**

W
wusongqing 已提交
1152 1153 1154 1155 1156
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1157 1158 1159

**Parameters**

W
wusongqing 已提交
1160 1161
| Name        | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
W
wusongqing 已提交
1162
| bundleName | string | Yes   | Bundle name of the application.|
W
wusongqing 已提交
1163 1164

**Return value**
W
wusongqing 已提交
1165 1166
| Type            | Description                                    |
| -------------- | -------------------------------------- |
W
wusongqing 已提交
1167
| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the **Want** object.|
W
wusongqing 已提交
1168 1169 1170 1171

**Example**

```js
W
wusongqing 已提交
1172 1173 1174 1175 1176 1177 1178
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 已提交
1179 1180
```

W
wusongqing 已提交
1181
## bundle.getLaunchWantForBundle
W
wusongqing 已提交
1182

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

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

W
wusongqing 已提交
1187
**Required permissions**
W
wusongqing 已提交
1188

W
wusongqing 已提交
1189 1190 1191 1192 1193
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1194 1195 1196

**Parameters**

W
wusongqing 已提交
1197 1198 1199
| Name        | Type                  | Mandatory  | Description                            |
| ---------- | -------------------- | ---- | ------------------------------ |
| bundleName | string               | Yes   | Bundle name of the application.                  |
W
wusongqing 已提交
1200
| callback   | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes   | Callback used to return the **Want** object.|
W
wusongqing 已提交
1201 1202 1203 1204

**Example**

```js
W
wusongqing 已提交
1205 1206 1207 1208 1209 1210 1211 1212
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 已提交
1213 1214 1215
```


W
wusongqing 已提交
1216
## bundle.getNameForUid<sup>8+</sup>
W
wusongqing 已提交
1217 1218

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

W
wusongqing 已提交
1220
Obtains the bundle name based on a UID. This API uses a promise to return the result.
W
wusongqing 已提交
1221 1222 1223 1224

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1225 1226 1227

**Parameters**

W
wusongqing 已提交
1228 1229
| Name  | Type    | Mandatory  | Description      |
| ---- | ------ | ---- | -------- |
W
wusongqing 已提交
1230
| uid  | number | Yes   | UID based on which the bundle name is to obtain.|
W
wusongqing 已提交
1231 1232

**Return value**
W
wusongqing 已提交
1233 1234
| Type              | Description                               |
| ---------------- | --------------------------------- |
W
wusongqing 已提交
1235
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
1236 1237 1238 1239

**Example**

```js
W
wusongqing 已提交
1240 1241 1242 1243 1244 1245 1246
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 已提交
1247 1248
```

W
wusongqing 已提交
1249
## bundle.getNameForUid<sup>8+</sup>
W
wusongqing 已提交
1250

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

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

W
wusongqing 已提交
1255 1256 1257
**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1258 1259 1260

**Parameters**

W
wusongqing 已提交
1261 1262 1263
| Name      | Type                    | Mandatory  | Description                       |
| -------- | ---------------------- | ---- | ------------------------- |
| uid      | number                 | Yes   | UID based on which the bundle name is to obtain.                 |
W
wusongqing 已提交
1264
| callback | AsyncCallback\<string> | Yes   | Callback used to return the bundle name.|
W
wusongqing 已提交
1265 1266 1267 1268

**Example**

```js
W
wusongqing 已提交
1269 1270 1271 1272 1273 1274 1275 1276
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 已提交
1277 1278
```

W
wusongqing 已提交
1279

W
wusongqing 已提交
1280
## bundle.getAbilityIcon<sup>8+</sup>
W
wusongqing 已提交
1281

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

W
wusongqing 已提交
1284
Obtains the [PixelMap](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 已提交
1285

W
wusongqing 已提交
1286 1287 1288 1289 1290 1291 1292 1293
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1294 1295
**Parameters**

W
wusongqing 已提交
1296 1297 1298 1299
| 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 已提交
1300 1301 1302 1303

**Return value**
| Type                 | Description                                                        |
| --------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1304
| Promise\<image.PixelMap> | Promise used to return the [PixelMap](js-apis-image.md).|
W
wusongqing 已提交
1305 1306 1307 1308

**Example**

```js
W
wusongqing 已提交
1309 1310
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1311 1312 1313 1314 1315 1316 1317 1318
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 已提交
1319
## bundle.getAbilityIcon<sup>8+</sup>
W
wusongqing 已提交
1320

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

W
wusongqing 已提交
1323
Obtains the [PixelMap](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 已提交
1324

W
wusongqing 已提交
1325 1326 1327 1328 1329 1330 1331 1332
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1333 1334
**Parameters**

W
wusongqing 已提交
1335 1336 1337 1338
| 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 已提交
1339
| callback   | AsyncCallback\<image.PixelMap> | Yes  | Callback used to return the [PixelMap](js-apis-image.md).|
W
wusongqing 已提交
1340 1341 1342 1343

**Example**

```js
W
wusongqing 已提交
1344 1345
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1346 1347 1348 1349 1350 1351 1352 1353 1354
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 已提交
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
## bundle.getAbilityIcon<sup>9+</sup>

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

Obtains the [PixelMap](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.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

**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 已提交
1380
| Promise\<image.PixelMap> | Promise used to return the [PixelMap](js-apis-image.md).|
W
wusongqing 已提交
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416

**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;

Obtains the [PixelMap](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.

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

**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 已提交
1417
| callback   | AsyncCallback\<image.PixelMap> | Yes  | Callback used to return the [PixelMap](js-apis-image.md).|
W
wusongqing 已提交
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432

**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 已提交
1433

W
wusongqing 已提交
1434
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
W
wusongqing 已提交
1435

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

W
wusongqing 已提交
1438
Obtains the Extension ability information based on a given want. This API uses a promise to return the result.
W
wusongqing 已提交
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1450 1451
| Name            | Type    | Mandatory  | Description                                      |
| -------------- | ------ | ---- | ---------------------------------------- |
W
wusongqing 已提交
1452 1453 1454
| 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 已提交
1455
| 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 已提交
1456 1457 1458

**Return value**

W
wusongqing 已提交
1459 1460
| Type                                   | Description                            |
| ------------------------------------- | ------------------------------ |
W
wusongqing 已提交
1461
| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | Promise used to return the Extension ability information.|
W
wusongqing 已提交
1462 1463 1464 1465

**Example**

```js
W
wusongqing 已提交
1466
let extensionType = 0;
W
wusongqing 已提交
1467 1468 1469 1470 1471 1472
let extensionFlags = 0;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
W
wusongqing 已提交
1473
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId)
W
wusongqing 已提交
1474 1475 1476 1477 1478 1479 1480 1481 1482
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```



W
wusongqing 已提交
1483
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
W
wusongqing 已提交
1484

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

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

W
wusongqing 已提交
1489 1490 1491 1492
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

W
wusongqing 已提交
1493 1494 1495 1496 1497 1498
**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1499 1500 1501 1502 1503 1504 1505
| 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 已提交
1506 1507 1508 1509

**Example**

```js
W
wusongqing 已提交
1510
let extensionType = 0;
W
wusongqing 已提交
1511 1512 1513 1514 1515 1516
let extensionFlags = 0;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
W
wusongqing 已提交
1517 1518 1519 1520 1521 1522 1523
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 已提交
1524 1525
```

W
wusongqing 已提交
1526
## bundle.queryExtensionAbilityInfos<sup>9+</sup>
W
wusongqing 已提交
1527

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

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

W
wusongqing 已提交
1532 1533 1534 1535
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO

W
wusongqing 已提交
1536 1537 1538 1539 1540 1541
**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

W
wusongqing 已提交
1542 1543
| Name            | Type                                      | Mandatory  | Description                                      |
| -------------- | ---------------------------------------- | ---- | ---------------------------------------- |
W
wusongqing 已提交
1544 1545 1546 1547
| 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 已提交
1548 1549 1550 1551

**Example**

```js
W
wusongqing 已提交
1552
let extensionType = 0;
W
wusongqing 已提交
1553 1554 1555 1556 1557
let extensionFlags = 0;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};
W
wusongqing 已提交
1558 1559 1560 1561 1562 1563 1564
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 已提交
1565 1566
```

W
wusongqing 已提交
1567
## InstallErrorCode
W
wusongqing 已提交
1568

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

W
wusongqing 已提交
1571 1572 1573
| Name                                      | Default Value | Description                       |
| ---------------------------------------- | ---- | ------------------------- |
| SUCCESS                                  | 0    | Installation succeeded.                     |
W
wusongqing 已提交
1574
| STATUS_INSTALL_FAILURE                   | 1    | Installation failed. (The application to be installed is not found.)           |
W
wusongqing 已提交
1575 1576
| STATUS_INSTALL_FAILURE_ABORTED           | 2    | Installation aborted.                     |
| STATUS_INSTALL_FAILURE_INVALID           | 3    | Invalid installation parameter.                   |
W
wusongqing 已提交
1577
| 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 已提交
1578
| STATUS_INSTALL_FAILURE_STORAGE           | 5    | Failed to store the bundle information.                  |
W
wusongqing 已提交
1579 1580
| 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 已提交
1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592
| 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 已提交
1593 1594 1595

## BundleFlag

W
wusongqing 已提交
1596 1597 1598
Enumerates bundle flags.

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

W
wusongqing 已提交
1600 1601 1602 1603 1604 1605 1606 1607 1608
| 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 已提交
1609
| GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | Obtains the bundle information with the Extension ability information.|
W
wusongqing 已提交
1610
| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information.         |
W
wusongqing 已提交
1611
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information of system applications.|
W
wusongqing 已提交
1612 1613 1614
| 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.       |
| GET_ALL_APPLICATION_INFO                 | 0xFFFF0000 | Obtains all application information.          |
W
wusongqing 已提交
1615 1616 1617 1618 1619

## BundleOptions

Describes the bundle options.

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

W
wusongqing 已提交
1622 1623
| Name    | Type    | Readable  | Writable  | Description                          |
| ------ | ------ | ---- | ---- | ---------------------------- |
W
wusongqing 已提交
1624
| 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 已提交
1625 1626 1627

## AbilityType

W
wusongqing 已提交
1628 1629 1630
Enumerates ability types.

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

W
wusongqing 已提交
1632 1633 1634 1635 1636
| 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 已提交
1637
| DATA    | None   | Ability that is used to provide data access services.|
W
wusongqing 已提交
1638 1639 1640

## DisplayOrientation

W
wusongqing 已提交
1641 1642 1643
Enumerates display orientations.

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

W
wusongqing 已提交
1645 1646 1647 1648 1649
| Name           | Type  | Description           |
| ------------- | ---- | ------------- |
| UNSPECIFIED   | None   | The system automatically determines the display orientation.    |
| LANDSCAPE     | None   | Landscape orientation.     |
| PORTRAIT      | None   | Portrait orientation.     |
W
wusongqing 已提交
1650
| FOLLOW_RECENT | None   | The page ability orientation is the same as that of the nearest ability in the stack.|
W
wusongqing 已提交
1651 1652 1653

## LaunchMode

W
wusongqing 已提交
1654 1655 1656
Enumerates launch modes.

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

W
wusongqing 已提交
1658 1659
| Name       | Type  | Description           |
| --------- | ---- | ------------- |
W
wusongqing 已提交
1660
| SINGLETON | 0    | The ability has only one instance.|
W
wusongqing 已提交
1661
| STANDARD  | 1    | The ability can have multiple instances. |
W
wusongqing 已提交
1662 1663 1664

## AbilitySubType

W
wusongqing 已提交
1665 1666 1667
Enumerates ability subtypes.

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

W
wusongqing 已提交
1669 1670 1671
| Name         | Type  | Description                  |
| ----------- | ---- | -------------------- |
| UNSPECIFIED | 0    | Undefined ability subtype.       |
W
wusongqing 已提交
1672
| CA          | 1    | Ability that has a UI.|
W
wusongqing 已提交
1673

W
wusongqing 已提交
1674
## ExtensionAbilityType<sup>9+</sup>
W
wusongqing 已提交
1675

W
wusongqing 已提交
1676
Enumerates Extension ability types.
W
wusongqing 已提交
1677 1678 1679

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

W
wusongqing 已提交
1680 1681 1682
| Name                            | Type  | Description                       |
| ------------------------------ | ---- | ------------------------- |
| FORM<sup>9+</sup>              | 0    | Form included.  |
W
wusongqing 已提交
1683
| WORK_SCHEDULER<sup>9+</sup>    | 1    | Work scheduler included.|
W
wusongqing 已提交
1684 1685 1686
| 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 已提交
1687 1688
| DATA_SHARE<sup>9+</sup>        | 5    | Data sharing included.|
| FILE_SHARE<sup>9+</sup>        | 6    | File sharing included.|
W
wusongqing 已提交
1689 1690
| STATIC_SUBSCRIBER<sup>9+</sup> | 7    | Subscribers included. |
| WALLPAPER<sup>9+</sup>         | 8    | Wallpaper included.  |
W
wusongqing 已提交
1691 1692
| BACKUP<sup>9+</sup>            | 9    | Data backup and restore included.  |
| UNSPECIFIED<sup>9+</sup>       | 20    | Unspecified type.    |
W
wusongqing 已提交
1693 1694

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

W
wusongqing 已提交
1696
Enumerates Extension flags.
W
wusongqing 已提交
1697 1698 1699

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

W
wusongqing 已提交
1700 1701 1702 1703 1704
| 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 已提交
1705
| GET_EXTENSION_INFO_WITH_METADATA<sup>9+</sup> | 0x00000020 | Obtains the Extension ability information that carries metadata information.|
W
wusongqing 已提交
1706 1707 1708 1709 1710 1711 1712

## ColorMode

Enumerates color modes.

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

W
wusongqing 已提交
1713 1714
| Name        | Type  | Description  |
| ---------- | ---- | ---- |
W
wusongqing 已提交
1715 1716 1717
| AUTO_MODE  | -1   | Automatic mode.|
| DARK_MODE  | 0    | Dark mode.|
| LIGHT_MODE | 1    | Light mode.|
W
wusongqing 已提交
1718 1719


W
wusongqing 已提交
1720 1721
## GrantStatus

W
wusongqing 已提交
1722
Enumerates permission grant states.
W
wusongqing 已提交
1723 1724 1725

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

W
wusongqing 已提交
1726 1727
| Name                | Type  | Description  |
| ------------------ | ---- | ---- |
W
wusongqing 已提交
1728
| PERMISSION_DENIED  | -1   | Permission denied.|
W
wusongqing 已提交
1729
| PERMISSION_GRANTED | 0    | Permission granted.  |