js-apis-Bundle.md 71.5 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**
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 9
## Modules to Import

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

## Required Permissions

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

23
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
W
wusongqing 已提交
24

25 26 27
## bundle.getApplicationInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead.
W
wusongqing 已提交
28

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

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

W
wusongqing 已提交
33
**Required permissions**
W
wusongqing 已提交
34

W
wusongqing 已提交
35 36 37 38 39
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
40 41 42

**Parameters**

43
| Name     | Type  | Mandatory| Description                                                        |
44 45 46 47
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName  | string | Yes  | Bundle name of an application.                                    |
| bundleFlags | number | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| 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 已提交
48 49 50

**Return value**

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

**Example**

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

69 70 71
## bundle.getApplicationInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead.
W
wusongqing 已提交
72 73 74

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

W
wusongqing 已提交
75
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 已提交
76

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

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

**System capability**

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

**Parameters**

87
| Name     | Type                                                        | Mandatory| Description                                                        |
88 89 90 91 92
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleName  | string                                                       | Yes  | Bundle name of an application.                                    |
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| 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\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
93 94 95 96

**Example**

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

109 110 111 112
## bundle.getApplicationInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead.

W
wusongqing 已提交
113 114 115

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

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

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

128
| Name     | Type                                                        | Mandatory| Description                                                        |
129 130 131 132
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleName  | string                                                       | Yes  | Bundle name of an application.                                    |
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

**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));
 })
```

148

149
## bundle.getAllBundleInfo<sup>deprecated<sup>
150

151
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
W
wusongqing 已提交
152

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

W
wusongqing 已提交
155
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 已提交
156

W
wusongqing 已提交
157
**Required permissions**
W
wusongqing 已提交
158

W
wusongqing 已提交
159 160 161 162 163
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
164 165 166

**Parameters**

167
| Name    | Type      | Mandatory| Description                                                        |
168 169 170
| ---------- | ---------- | ---- | ------------------------------------------------------------ |
| bundleFlag | BundleFlag | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| 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 已提交
171 172 173

**Return value**

W
wusongqing 已提交
174 175
| Type                         | Description                        |
| --------------------------- | -------------------------- |
W
wusongqing 已提交
176
| Promise<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Promise used to return the information of all available bundles.|
W
wusongqing 已提交
177 178 179 180

**Example**

```js
W
wusongqing 已提交
181 182 183 184 185 186 187
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 已提交
188 189 190
})
```

191 192 193 194
## bundle.getAllBundleInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.

W
wusongqing 已提交
195

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

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

W
wusongqing 已提交
200
**Required permissions**
W
wusongqing 已提交
201

W
wusongqing 已提交
202 203 204 205 206
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
207 208 209

**Parameters**

210
| Name    | Type                                                        | Mandatory| Description                                                        |
211 212 213
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleFlag | BundleFlag                                                   | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes  | Callback used to return the information of all available bundles.      |
W
wusongqing 已提交
214 215 216 217

**Example**

```js
W
wusongqing 已提交
218 219 220 221 222 223 224 225 226
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 已提交
227

228 229 230 231
## bundle.getAllBundleInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.

W
wusongqing 已提交
232

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

W
wusongqing 已提交
235
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 已提交
236 237 238

**Required permissions**

W
wusongqing 已提交
239 240 241 242 243
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
244 245 246

**Parameters**

247
| Name    | Type                                                        | Mandatory| Description                                                        |
248 249 250 251
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleFlag | BundleFlag                                                   | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| 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\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes  | Callback used to return the information of all available bundles.      |
W
wusongqing 已提交
252 253 254 255 256 257 258 259 260 261 262 263 264

**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 已提交
265 266
```

267 268 269 270
## bundle.getBundleInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo) instead.

W
wusongqing 已提交
271

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

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

W
wusongqing 已提交
276
**Required permissions**
W
wusongqing 已提交
277

W
wusongqing 已提交
278 279 280 281 282
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
283 284 285

**Parameters**

286
| Name        | Type           | Mandatory  | Description                                     |
W
wusongqing 已提交
287
| ----------- | ------------- | ---- | --------------------------------------- |
W
wusongqing 已提交
288
| bundleName  | string        | Yes   | Bundle name of an application.                                     |
289
| bundleFlags | number        | Yes   | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
W
wusongqing 已提交
290
| options     | [BundleOptions](#bundleoptions) | No   | Includes **userId**.                              |
W
wusongqing 已提交
291 292 293

**Return value**

W
wusongqing 已提交
294 295
| Type                  | Description                          |
| -------------------- | ---------------------------- |
W
wusongqing 已提交
296
| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the bundle information.|
W
wusongqing 已提交
297 298 299 300

**Example**

```js
W
wusongqing 已提交
301 302 303
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
304
  "userId" : 100
W
wusongqing 已提交
305 306 307 308 309 310
};
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 已提交
311 312 313
})
```

314 315 316
## bundle.getBundleInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo) instead.
W
wusongqing 已提交
317 318 319

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

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

W
wusongqing 已提交
322
**Required permissions**
W
wusongqing 已提交
323

W
wusongqing 已提交
324 325 326 327 328
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
329 330 331

**Parameters**

332
| Name     | Type                                                      | Mandatory| Description                                                        |
333 334 335 336
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName  | string                                                     | Yes  | Bundle name of an application.                                                        |
| bundleFlags | number                                                     | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes  | Callback used to return the bundle information.                    |
W
wusongqing 已提交
337 338 339 340

**Example**

```js
W
wusongqing 已提交
341 342 343 344 345 346 347 348 349
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 已提交
350 351 352
```


353 354 355
## bundle.getBundleInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo) instead.
W
wusongqing 已提交
356 357 358

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

W
wusongqing 已提交
359
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 已提交
360 361 362

**Required permissions**

W
wusongqing 已提交
363 364 365 366 367
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
368 369 370

**Parameters**

371
| Name     | Type                                                      | Mandatory| Description                                                        |
372 373 374 375 376
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName  | string                                                     | Yes  | Bundle name of an application.                                                        |
| bundleFlags | number                                                     | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| options     | [BundleOptions](#bundleoptions)                            | Yes  | Includes **userId**.                                                |
| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes  | Callback used to return the bundle information.                    |
W
wusongqing 已提交
377 378 379 380 381 382 383

**Example**

```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
384
  "userId" : 100
W
wusongqing 已提交
385 386 387 388 389 390 391 392 393 394
};
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));
})
```

395 396


397
## bundle.getBundleInstaller<sup>deprecated<sup>
398

399
> This API is deprecated since API version 9. You are advised to use [installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller) instead.
W
wusongqing 已提交
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422

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

423 424 425
## bundle.getBundleInstaller<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller) instead.
W
wusongqing 已提交
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444

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

445
| Name  | Type                                                        | Mandatory| Description            |
W
wusongqing 已提交
446 447 448
| -------- | ------------------------------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes  | Callback used to return the installation package information.|

449 450 451
## bundle.cleanBundleCacheFiles<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles) instead.
W
wusongqing 已提交
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470

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

471
| Name     | Type               | Mandatory| Description                                 |
W
wusongqing 已提交
472 473 474 475
| ---------- | ------------------- | ---- | ------------------------------------- |
| bundleName | string              | Yes  | Bundle name of an application.|
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result.         |

476 477 478
## bundle.cleanBundleCacheFiles<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles) instead.
W
wusongqing 已提交
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497

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

498
| Name    | Type  | Mandatory| Description                                 |
W
wusongqing 已提交
499 500 501 502 503 504 505 506 507
| ---------- | ------ | ---- | ------------------------------------- |
| bundleName | string | Yes  | Bundle name of an application.|

**Return value**

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

508 509 510
## bundle.setApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled) instead.
W
wusongqing 已提交
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529

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

530
| Name     | Type               | Mandatory| Description                                           |
W
wusongqing 已提交
531 532 533 534 535
| ---------- | ------------------- | ---- | ----------------------------------------------- |
| 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.                   |

536 537 538
## bundle.setApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled) instead.
W
wusongqing 已提交
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557

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

558
| Name    | Type   | Mandatory| Description                                           |
W
wusongqing 已提交
559 560 561 562 563 564 565 566 567 568
| ---------- | ------- | ---- | ----------------------------------------------- |
| 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.|

569 570 571
## bundle.setAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled) instead.
W
wusongqing 已提交
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590

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

591
| Name  | Type                                        | Mandatory| Description                                           |
W
wusongqing 已提交
592 593
| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.                                  |
594 595 596 597
| 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.setAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
W
wusongqing 已提交
598

599
> This API is deprecated since API version 9. You are advised to use [bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled) instead.
W
wusongqing 已提交
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618

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

619
| Name  | Type                                        | Mandatory| Description                                           |
W
wusongqing 已提交
620 621
| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.                                  |
622
| isEnable | boolean                                      | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|
W
wusongqing 已提交
623 624 625 626 627 628 629

**Return value**

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

630 631 632
## bundle.getPermissionDef<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef) instead.
W
wusongqing 已提交
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651

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

652
| Name        | Type                                                        | Mandatory| Description                                            |
W
wusongqing 已提交
653 654 655 656
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
| permissionName | string                                                       | Yes  | Name of the permission.                                |
| callback       | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | Yes  | Callback used to return the permission details.|

657 658 659
## bundle.getPermissionDef<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef) instead.
W
wusongqing 已提交
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678

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

679
| Name        | Type  | Mandatory| Description            |
W
wusongqing 已提交
680 681 682 683 684 685 686 687 688 689
| -------------- | ------ | ---- | ---------------- |
| permissionName | string | Yes  | Name of the permission.|

**Return value**

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


690
## bundle.getAllApplicationInfo<sup>deprecated<sup>
W
wusongqing 已提交
691

692
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
W
wusongqing 已提交
693

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

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

W
wusongqing 已提交
698
**Required permissions**
W
wusongqing 已提交
699

W
wusongqing 已提交
700 701 702 703 704
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
705 706 707

**Parameters**

708
| Name     | Type  | Mandatory| Description                                                        |
709 710
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleFlags | number | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
711
| 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 已提交
712 713 714

**Return value**

W
wusongqing 已提交
715 716
| Type                              | Description                             |
| -------------------------------- | ------------------------------- |
W
wusongqing 已提交
717
| Promise<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Promise used to return the application information.|
W
wusongqing 已提交
718 719 720 721

**Example**

```js
W
wusongqing 已提交
722 723 724 725 726 727 728
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 已提交
729 730 731
})
```

732
## bundle.getAllApplicationInfo<sup>deprecated<sup>
W
wusongqing 已提交
733

734
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
W
wusongqing 已提交
735 736 737

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

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

W
wusongqing 已提交
740
**Required permissions**
W
wusongqing 已提交
741

W
wusongqing 已提交
742 743 744 745 746
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
747 748 749

**Parameters**

750
| Name     | Type                                                        | Mandatory| Description                                                        |
751 752
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
753
| 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.       |
754
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
755 756 757 758

**Example**

```js
W
wusongqing 已提交
759 760 761 762 763 764 765 766 767
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 已提交
768 769 770
```


771 772 773
## bundle.getAllApplicationInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
W
wusongqing 已提交
774

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

W
wusongqing 已提交
777
Obtains the information about all applications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
778 779 780 781 782 783 784 785 786 787 788

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

789
| Name     | Type                                                        | Mandatory| Description                                                        |
790 791 792
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
793 794 795 796 797 798 799 800 801 802 803 804 805 806

**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));
})
```

807 808 809
## bundle.getBundleArchiveInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleArchiveInfo](js-apis-bundleManager.md#bundlemanagergetbundlearchiveinfo) instead.
W
wusongqing 已提交
810

W
wusongqing 已提交
811
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo>
W
wusongqing 已提交
812 813 814 815 816 817 818 819 820

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

821
| Name       | Type    | Mandatory  | Description          |
W
wusongqing 已提交
822 823
| ---------- | ------ | ---- | ------------ |
| 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.|
824
| bundleFlags | number | Yes   | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
W
wusongqing 已提交
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843

**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));
})
```

844 845 846
## bundle.getBundleArchiveInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleArchiveInfo](js-apis-bundleManager.md#bundlemanagergetbundlearchiveinfo) instead.
W
wusongqing 已提交
847

W
wusongqing 已提交
848
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void
W
wusongqing 已提交
849 850 851 852 853 854 855 856 857

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

858
| Name       | Type    | Mandatory  | Description          |
W
wusongqing 已提交
859 860
| ---------- | ------ | ---- | ------------ |
| 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.|
861
| bundleFlags | number | Yes   | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
W
wusongqing 已提交
862
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes   | Callback used to return the information about the bundles.|
W
wusongqing 已提交
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878

**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));
})
```


879 880 881
## bundle.getAbilityInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
W
wusongqing 已提交
882 883 884

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

W
wusongqing 已提交
885
Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
886 887 888 889 890 891 892 893 894 895 896

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

897
| Name        | Type    | Mandatory  | Description              |
W
wusongqing 已提交
898
| ----------- | ------ | ---- | ---------------- |
W
wusongqing 已提交
899
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
900
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
901 902 903

**Return value**

W
wusongqing 已提交
904 905
| Type                   | Description                   |
| --------------------- | --------------------- |
W
wusongqing 已提交
906
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|
W
wusongqing 已提交
907 908 909 910 911 912 913 914 915 916 917 918 919 920

**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));
})
```

921 922 923
## bundle.getAbilityInfo<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
W
wusongqing 已提交
924

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

W
wusongqing 已提交
927
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 已提交
928 929 930 931 932 933 934 935 936 937 938

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

939
| Name       | Type    | Mandatory  | Description           |
W
wusongqing 已提交
940
| ----------- | ------------ | ---- | ---------------- |
W
wusongqing 已提交
941
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
942 943
| abilityName | string | Yes   | Ability name.|
| callback    | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes   | Callback used to return the ability information.|
W
wusongqing 已提交
944 945 946 947 948 949 950 951 952 953 954 955 956 957

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

959
## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup>
W
wusongqing 已提交
960

961
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel) instead.
W
wusongqing 已提交
962

963
getAbilityLabel(bundleName: string, abilityName: string): Promise\<string>
W
wusongqing 已提交
964

W
wusongqing 已提交
965
Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
966 967 968 969 970 971 972 973 974 975 976

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

977
| Name        | Type    | Mandatory  | Description              |
W
wusongqing 已提交
978
| ----------- | ------ | ---- | ---------------- |
W
wusongqing 已提交
979
| bundleName  | string | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
980
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
981 982 983

**Return value**

W
wusongqing 已提交
984 985
| Type              | Description                |
| ---------------- | ------------------ |
W
wusongqing 已提交
986
| Promise\<string> | Promise used to return the application name.|
W
wusongqing 已提交
987 988 989 990 991 992 993 994 995 996 997 998 999 1000

**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));
})
```

1001 1002 1003
## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel) instead.
W
wusongqing 已提交
1004 1005 1006

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

W
wusongqing 已提交
1007
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 已提交
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1019
| Name        | Type                    | Mandatory  | Description              |
W
wusongqing 已提交
1020
| ----------- | ---------------------- | ---- | ---------------- |
W
wusongqing 已提交
1021
| bundleName  | string                 | Yes   | Bundle name of an application.    |
W
wusongqing 已提交
1022
| abilityName | string                 | Yes   | Ability name.|
W
wusongqing 已提交
1023
| callback    | AsyncCallback\<string> | Yes   | Callback used to return the application name.       |
W
wusongqing 已提交
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037

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

1039
## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
W
wusongqing 已提交
1040

1041
> This API is deprecated since API version 9. You are advised to use [bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled) instead.
W
wusongqing 已提交
1042 1043 1044

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

W
wusongqing 已提交
1045
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses a promise to return the result.
W
wusongqing 已提交
1046 1047 1048 1049 1050 1051 1052

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1053 1054 1055
| Name| Type                                        | Mandatory| Description             |
| ------ | -------------------------------------------- | ---- | ----------------- |
| info   | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.|
W
wusongqing 已提交
1056 1057 1058

**Return value**

W
wusongqing 已提交
1059 1060
| Type               | Description                       |
| ----------------- | ------------------------- |
W
wusongqing 已提交
1061
| 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 已提交
1062 1063 1064 1065

**Example**

```js
W
wusongqing 已提交
1066 1067 1068 1069 1070 1071 1072 1073
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 已提交
1074 1075 1076
})
```

1077 1078 1079
## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled) instead.
W
wusongqing 已提交
1080 1081 1082

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

W
wusongqing 已提交
1083
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1084 1085 1086 1087 1088 1089 1090

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1091 1092 1093 1094
| Name  | Type                                        | Mandatory| Description                   |
| -------- | -------------------------------------------- | ---- | ----------------------- |
| 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 已提交
1095 1096 1097 1098

**Example**

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

1112 1113 1114
## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled) instead.
W
wusongqing 已提交
1115 1116 1117

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

W
wusongqing 已提交
1118
Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result.
W
wusongqing 已提交
1119 1120 1121 1122 1123 1124 1125

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1126 1127 1128
| Name    | Type  | Mandatory| Description                    |
| ---------- | ------ | ---- | ------------------------ |
| bundleName | string | Yes  | Bundle name of an application.|
W
wusongqing 已提交
1129 1130 1131

**Return value**

W
wusongqing 已提交
1132 1133
| Type               | Description                       |
| ----------------- | ------------------------- |
W
wusongqing 已提交
1134
| 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 已提交
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147

**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));
})
```

1148 1149 1150
## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled) instead.
W
wusongqing 已提交
1151 1152 1153

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

W
wusongqing 已提交
1154
Checks whether an application is enabled based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1155 1156 1157 1158 1159 1160 1161

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1162 1163 1164 1165
| Name    | Type                   | Mandatory| Description                    |
| ---------- | ----------------------- | ---- | ------------------------ |
| bundleName | string                  | Yes  | Bundle name of an application.|
| 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 已提交
1166 1167 1168 1169

**Example**

```js
W
wusongqing 已提交
1170
let bundleName = "com.example.myapplication";
W
wusongqing 已提交
1171 1172 1173 1174 1175 1176 1177 1178
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 已提交
1179

1180 1181 1182
## bundle.queryAbilityByWant<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
W
wusongqing 已提交
1183 1184 1185

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

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

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

W
wusongqing 已提交
1190 1191 1192 1193 1194
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

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

**Parameters**

1198
| Name        | Type    | Mandatory  | Description                                   |
W
wusongqing 已提交
1199
| ----------- | ------ | ---- | ------------------------------------- |
W
wusongqing 已提交
1200
| want        | [Want](js-apis-application-Want.md)   | Yes   | Want that contains the bundle name.                    |
1201
| bundleFlags | number | Yes   | Ability information to be returned. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).|
W
wusongqing 已提交
1202
| 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 已提交
1203 1204 1205

**Return value**

W
wusongqing 已提交
1206 1207
| Type                          | Description                   |
| ---------------------------- | --------------------- |
W
wusongqing 已提交
1208
| Promise<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Promise used to return the ability information.|
W
wusongqing 已提交
1209 1210 1211 1212

**Example**

```js
W
wusongqing 已提交
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
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 已提交
1224 1225 1226 1227 1228
})
```



1229 1230 1231
## bundle.queryAbilityByWant<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
W
wusongqing 已提交
1232

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

W
wusongqing 已提交
1235 1236 1237 1238 1239
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 已提交
1240 1241 1242 1243

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1244 1245 1246

**Parameters**

1247
| Name     | Type                                                        | Mandatory| Description                                                        |
1248 1249 1250 1251 1252
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| 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**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).|
| 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\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes  | Callback used to return the ability information.               |
W
wusongqing 已提交
1253 1254 1255 1256

**Example**

```js
W
wusongqing 已提交
1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
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 已提交
1270 1271
```

1272 1273 1274
## bundle.queryAbilityByWant<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
W
wusongqing 已提交
1275

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

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

W
wusongqing 已提交
1280 1281 1282 1283
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

W
wusongqing 已提交
1284 1285 1286 1287
**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1288 1289
**Parameters**

1290
| Name     | Type                                                        | Mandatory| Description                                                        |
1291 1292 1293 1294
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| 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**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).|
| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes  | Callback used to return the ability information.               |
W
wusongqing 已提交
1295 1296 1297 1298

**Example**

```js
W
wusongqing 已提交
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
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 已提交
1310 1311 1312 1313 1314
})
```



1315 1316 1317
## bundle.getLaunchWantForBundle<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getLaunchWantForBundle](js-apis-bundleManager.md#bundlemanagergetlaunchwantforbundle) instead.
W
wusongqing 已提交
1318 1319 1320

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

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

W
wusongqing 已提交
1323 1324
**Required permissions**

W
wusongqing 已提交
1325 1326 1327 1328 1329
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1330 1331 1332

**Parameters**

1333 1334 1335
| Name    | Type  | Mandatory| Description                    |
| ---------- | ------ | ---- | ------------------------ |
| bundleName | string | Yes  | Bundle name of an application.|
W
wusongqing 已提交
1336 1337

**Return value**
W
wusongqing 已提交
1338 1339
| Type            | Description                                    |
| -------------- | -------------------------------------- |
W
wusongqing 已提交
1340
| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the **Want** object.|
W
wusongqing 已提交
1341 1342 1343 1344

**Example**

```js
W
wusongqing 已提交
1345 1346 1347 1348 1349 1350 1351
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 已提交
1352 1353
```

1354 1355 1356
## bundle.getLaunchWantForBundle<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getLaunchWantForBundle](js-apis-bundleManager.md#bundlemanagergetlaunchwantforbundle) instead.
W
wusongqing 已提交
1357

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

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

W
wusongqing 已提交
1362
**Required permissions**
W
wusongqing 已提交
1363

W
wusongqing 已提交
1364 1365 1366 1367 1368
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1369 1370 1371

**Parameters**

1372 1373 1374 1375
| Name    | Type                                               | Mandatory| Description                                                    |
| ---------- | --------------------------------------------------- | ---- | -------------------------------------------------------- |
| bundleName | string                                              | Yes  | Bundle name of an application.                                |
| callback   | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes  | Callback used to return the **Want** object.|
W
wusongqing 已提交
1376 1377 1378 1379

**Example**

```js
W
wusongqing 已提交
1380 1381 1382 1383 1384 1385 1386 1387
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 已提交
1388 1389 1390
```


1391 1392 1393
## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) instead.
W
wusongqing 已提交
1394 1395

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

W
wusongqing 已提交
1397
Obtains the bundle name based on a UID. This API uses a promise to return the result.
W
wusongqing 已提交
1398 1399 1400 1401

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1402 1403 1404

**Parameters**

1405 1406 1407
| Name| Type  | Mandatory| Description         |
| ------ | ------ | ---- | ------------- |
| uid    | number | Yes  | UID based on which the bundle name is to obtain.|
W
wusongqing 已提交
1408 1409

**Return value**
W
wusongqing 已提交
1410 1411
| Type              | Description                               |
| ---------------- | --------------------------------- |
W
wusongqing 已提交
1412
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
1413 1414 1415 1416

**Example**

```js
W
wusongqing 已提交
1417 1418 1419 1420 1421 1422 1423
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 已提交
1424 1425
```

1426 1427 1428
## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) instead.
W
wusongqing 已提交
1429

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

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

W
wusongqing 已提交
1434 1435 1436
**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1437 1438 1439

**Parameters**

1440 1441 1442 1443
| Name  | Type                  | Mandatory| Description                                           |
| -------- | ---------------------- | ---- | ----------------------------------------------- |
| uid      | number                 | Yes  | UID based on which the bundle name is to obtain.                                  |
| callback | AsyncCallback\<string> | Yes  | Callback used to return the bundle name.|
W
wusongqing 已提交
1444 1445 1446 1447

**Example**

```js
W
wusongqing 已提交
1448 1449 1450 1451 1452 1453 1454 1455
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 已提交
1456 1457
```

W
wusongqing 已提交
1458

1459 1460 1461
## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon) instead.
W
wusongqing 已提交
1462

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

W
wusongqing 已提交
1465
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 已提交
1466

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

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

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1475 1476
**Parameters**

1477 1478 1479 1480
| 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 已提交
1481 1482 1483 1484

**Return value**
| Type                 | Description                                                        |
| --------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1485
| Promise\<image.PixelMap> | Promise used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1486 1487 1488 1489

**Example**

```js
W
wusongqing 已提交
1490 1491
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1492 1493 1494 1495 1496 1497 1498 1499
bundle.getAbilityIcon(bundleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

1500 1501 1502
## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon) instead.
W
wusongqing 已提交
1503

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

W
wusongqing 已提交
1506
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 已提交
1507

W
wusongqing 已提交
1508 1509
**Required permissions**

W
wusongqing 已提交
1510
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1511 1512 1513 1514 1515

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1516 1517
**Parameters**

1518
| Name        | Type                                      | Mandatory  | Description                                      |
W
wusongqing 已提交
1519 1520 1521
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| 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 已提交
1522
| callback   | AsyncCallback\<image.PixelMap> | Yes  | Callback used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1523 1524 1525 1526

**Example**

```js
W
wusongqing 已提交
1527 1528
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1529 1530 1531 1532 1533 1534 1535 1536 1537
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));
})
```

1538 1539
## InstallErrorCode<sup>deprecated<sup>
> This API is deprecated since API version 9. You are not advised to use it anymore.
W
wusongqing 已提交
1540

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

1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568
| Name                                                | Value  | Description                                            |
| ---------------------------------------------------- | ---- | ------------------------------------------------ |
| SUCCESS                                              | 0    | Installation succeeded.                                        |
| STATUS_INSTALL_FAILURE                               | 1    | Installation failed. (The application to be installed is not found.)                    |
| STATUS_INSTALL_FAILURE_ABORTED                       | 2    | Installation aborted.                                        |
| STATUS_INSTALL_FAILURE_INVALID                       | 3    | Invalid installation parameter.                                    |
| STATUS_INSTALL_FAILURE_CONFLICT                      | 4    | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) |
| STATUS_INSTALL_FAILURE_STORAGE                       | 5    | Failed to store the bundle information.                                  |
| 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.)                   |
| 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 | No installation permission.                                    |
| STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup>      | 0x45 | No uninstallation permission.                                    |

## BundleFlag<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.BundleFlag](js-apis-bundleManager.md#bundleflag) instead.
W
wusongqing 已提交
1569

W
wusongqing 已提交
1570 1571 1572
Enumerates bundle flags.

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

1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590
| Name                                           | 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.        |
| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information.           |
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup>    | 0x00000080 | Obtains the ability information of system applications.|
| 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.             |

## BundleOptions<sup>deprecated<sup>
> This API is deprecated since API version 9. You are not advised to use it anymore.
W
wusongqing 已提交
1591 1592 1593

Describes the bundle options.

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

1596 1597 1598 1599 1600
| Name  | Type  | Readable| Writable| Description                                                 |
| ------ | ------ | ---- | ---- | ----------------------------------------------------- |
| 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.|

## AbilityType<sup>deprecated<sup>
W
wusongqing 已提交
1601

1602
> This API is deprecated since API version 9. You are advised to use [bundleManager.AbilityType](js-apis-bundleManager.md#abilitytype) instead.
W
wusongqing 已提交
1603

W
wusongqing 已提交
1604 1605 1606
Enumerates ability types.

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

1608 1609 1610 1611 1612 1613 1614 1615
| Name| Value| Description                       |
| ------- | ---- | --------------------------- |
| UNKNOWN | None  | Unknown ability type.            |
| PAGE    | None  | FA developed using the Page template to provide the capability of interacting with users.       |
| SERVICE | None  | PA developed using the Service template to provide the capability of running tasks in the background.          |
| DATA    | None  | PA developed using the Data template to provide unified data access for external systems.|

## DisplayOrientation<sup>deprecated<sup>
W
wusongqing 已提交
1616

1617
> This API is deprecated since API version 9. You are advised to use [bundleManager.DisplayOrientation](js-apis-bundleManager.md#displayorientation) instead.
W
wusongqing 已提交
1618

W
wusongqing 已提交
1619 1620 1621
Enumerates display orientations.

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

1623 1624 1625 1626 1627 1628 1629 1630 1631
| Name         | Value  | Description                    |
| ------------- | ---- | ------------------------ |
| UNSPECIFIED   | None  | Unspecified display orientation.        |
| LANDSCAPE     | None  | Landscape orientation.          |
| PORTRAIT      | None  | Portrait orientation.          |
| FOLLOW_RECENT | None  | Orientation same as that of the nearest ability in the stack.|
## LaunchMode<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.LaunchType](js-apis-bundleManager.md#launchtype) instead.
W
wusongqing 已提交
1632

W
wusongqing 已提交
1633 1634 1635
Enumerates launch modes.

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

1637 1638
| Name     | Value  | Description               |
| --------- | ---- | ------------------- |
W
wusongqing 已提交
1639
| SINGLETON | 0    | The ability has only one instance.|
1640
| STANDARD  | 1    | The ability can have multiple instances.  |
W
wusongqing 已提交
1641

1642 1643
## AbilitySubType<sup>deprecated<sup>
> This API is deprecated since API version 9. You are not advised to use it anymore.
W
wusongqing 已提交
1644

W
wusongqing 已提交
1645 1646 1647
Enumerates ability subtypes.

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

1649 1650 1651
| Name       | Value  | Description                         |
| ----------- | ---- | ----------------------------- |
| UNSPECIFIED | 0    | Undefined ability subtype.          |
W
wusongqing 已提交
1652
| CA          | 1    | Ability that has a UI.|
W
wusongqing 已提交
1653

1654 1655
## ColorMode<sup>deprecated<sup>
> This API is deprecated since API version 9. You are not advised to use it anymore.
W
wusongqing 已提交
1656 1657 1658 1659 1660

Enumerates color modes.

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

1661 1662
| Name      | Value  | Description    |
| ---------- | ---- | -------- |
W
wusongqing 已提交
1663 1664 1665
| AUTO_MODE  | -1   | Automatic mode.|
| DARK_MODE  | 0    | Dark mode.|
| LIGHT_MODE | 1    | Light mode.|
W
wusongqing 已提交
1666 1667


1668 1669 1670
## GrantStatus<sup>deprecated<sup>

> This API is deprecated since API version 9. You are advised to use [bundleManager.PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate) instead.
W
wusongqing 已提交
1671

W
wusongqing 已提交
1672
Enumerates permission grant states.
W
wusongqing 已提交
1673 1674 1675

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

1676 1677
| Name              | Value  | Description        |
| ------------------ | ---- | ------------ |
W
wusongqing 已提交
1678
| PERMISSION_DENIED  | -1   | Permission denied.|
1679
| PERMISSION_GRANTED | 0    | Permission granted.    |