js-apis-Bundle.md 75.5 KB
Newer Older
G
Gloria 已提交
1
# @ohos.bundle (Bundle)
W
wusongqing 已提交
2

3
The **bundle** module provides APIs for obtaining information about an application, including [bundle information](js-apis-bundle-BundleInfo.md), [application information](js-apis-bundle-ApplicationInfo.md), and [ability information](js-apis-bundle-AbilityInfo.md). It also provides APIs to obtain and set the application disabling state.
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

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

## Required Permissions

16 17
| Required Permissions                                        | Permission Level        | Description           |
|--------------------------------------------|--------------|---------------|
G
Gloria 已提交
18
| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about a specified bundle.|
19 20
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all bundles.    |
| ohos.permission.INSTALL_BUNDLE             | system_core  | Permission to install or uninstall bundles.     |
G
Gloria 已提交
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

33 34
No permission is required for obtaining the caller's own information.

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

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

**System capability**

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

**Parameters**

45
| Name     | Type  | Mandatory| Description                                                        |
46
| ----------- | ------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
47
| bundleName  | string | Yes  | Bundle name.                                    |
48
| bundleFlags | number | Yes  | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
49
| 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 已提交
50 51 52

**Return value**

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

**Example**

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

71 72 73
## 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 已提交
74 75 76

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

W
wusongqing 已提交
77
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 已提交
78

79 80
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
81
**Required permissions**
W
wusongqing 已提交
82

W
wusongqing 已提交
83 84 85 86 87
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
88 89 90

**Parameters**

91
| Name     | Type                                                        | Mandatory| Description                                                        |
92
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
93 94 95
| bundleName  | string                                                       | Yes  | Bundle name.                                    |
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
| userId      | number                                                       | Yes  | User ID. The value must be greater than or equal to 0.                               |
96
| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
97 98 99

**Example**

100
```ts
W
wusongqing 已提交
101 102 103 104 105 106 107 108 109 110
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 已提交
111 112
```

113 114 115 116
## 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 已提交
117 118 119

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

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

122 123
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
124 125 126 127 128 129 130 131 132 133
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

134
| Name     | Type                                                        | Mandatory| Description                                                        |
135
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
136 137
| bundleName  | string                                                       | Yes  | Bundle name.                                    |
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
138
| callback    | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
139 140 141

**Example**

142
```ts
W
wusongqing 已提交
143 144 145 146 147 148 149 150 151 152 153
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));
 })
```

154

155
## bundle.getAllBundleInfo<sup>deprecated<sup>
156

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

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

161
Obtains the information of all bundles of the specified user. This API uses a promise to return the result.
W
wusongqing 已提交
162

W
wusongqing 已提交
163
**Required permissions**
W
wusongqing 已提交
164

W
wusongqing 已提交
165 166 167 168 169
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
170 171 172

**Parameters**

173
| Name    | Type      | Mandatory| Description                                                        |
174
| ---------- | ---------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
175
| bundleFlag | BundleFlag | Yes  | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
176
| 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 已提交
177 178 179

**Return value**

W
wusongqing 已提交
180 181
| Type                         | Description                        |
| --------------------------- | -------------------------- |
G
Gloria 已提交
182
| Promise<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Promise used to return the information of all bundles.|
W
wusongqing 已提交
183 184 185

**Example**

186
```ts
W
wusongqing 已提交
187 188 189 190 191 192 193
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 已提交
194 195 196
})
```

197 198 199 200
## 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 已提交
201

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

204
Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
205

W
wusongqing 已提交
206
**Required permissions**
W
wusongqing 已提交
207

W
wusongqing 已提交
208 209 210 211 212
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
213 214 215

**Parameters**

216
| Name    | Type                                                        | Mandatory| Description                                                        |
217
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
218
| bundleFlag | BundleFlag                                                   | Yes  | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
219
| callback   | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes  | Callback used to return the information of all bundles.      |
W
wusongqing 已提交
220 221 222

**Example**

223
```ts
W
wusongqing 已提交
224 225 226 227 228 229 230 231 232
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 已提交
233

234 235 236 237
## 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 已提交
238

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

241
Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
242 243 244

**Required permissions**

W
wusongqing 已提交
245 246 247 248 249
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
250 251 252

**Parameters**

253 254
| Name       | Type                                                               | Mandatory | Description                                                                 |
|------------|-------------------------------------------------------------------|-----|---------------------------------------------------------------------|
G
Gloria 已提交
255
| bundleFlag | BundleFlag                                                        | Yes  | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
256 257 258
| 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 bundles.                               |
|
W
wusongqing 已提交
259 260 261

**Example**

262
```ts
W
wusongqing 已提交
263 264 265 266 267 268 269 270 271
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 已提交
272 273
```

274 275 276 277
## 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 已提交
278

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

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

283 284
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
285
**Required permissions**
W
wusongqing 已提交
286

W
wusongqing 已提交
287 288 289 290 291
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
292 293 294

**Parameters**

295 296
| Name        | Type           | Mandatory  | Description                                                                 |
| ----------- | ------------- | ---- |---------------------------------------------------------------------|
G
Gloria 已提交
297 298 299
| bundleName  | string        | Yes   | Bundle name.                                                |
| bundleFlags | number        | Yes   | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
| options     | [BundleOptions](#bundleoptionsdeprecated) | No   | Options that contain the user ID.                                                     |
W
wusongqing 已提交
300 301 302

**Return value**

W
wusongqing 已提交
303 304
| Type                  | Description                          |
| -------------------- | ---------------------------- |
W
wusongqing 已提交
305
| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the bundle information.|
W
wusongqing 已提交
306 307 308

**Example**

309
```ts
W
wusongqing 已提交
310 311 312
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
313
  "userId" : 100
W
wusongqing 已提交
314 315 316 317 318 319
};
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 已提交
320 321 322
})
```

323 324 325
## 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 已提交
326 327 328

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

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

331 332
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
333
**Required permissions**
W
wusongqing 已提交
334

W
wusongqing 已提交
335 336 337 338 339
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
340 341 342

**Parameters**

G
Gloria 已提交
343 344 345 346 347
| Name     | Type                                                      | Mandatory| Description                                                        |
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName  | string                                                     | Yes  | Bundle name.                                  |
| bundleFlags | number                                                     | Yes  | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes  | Callback used to return the bundle information.                    |
W
wusongqing 已提交
348 349 350

**Example**

351
```ts
W
wusongqing 已提交
352 353 354 355 356 357 358 359 360
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 已提交
361 362 363
```


364 365 366
## 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 已提交
367 368 369

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

W
wusongqing 已提交
370
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 已提交
371

372 373
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
374 375
**Required permissions**

W
wusongqing 已提交
376 377 378 379 380
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
381 382 383

**Parameters**

384
| Name     | Type                                                      | Mandatory| Description                                                        |
385
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
386 387 388
| bundleName  | string                                                     | Yes  | Bundle name.                                    |
| bundleFlags | number                                                     | Yes  | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
| options     | [BundleOptions](#bundleoptionsdeprecated)                            | Yes  | Includes **userId**.                                                |
389
| callback    | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes  | Callback used to return the bundle information.                    |
W
wusongqing 已提交
390 391 392

**Example**

393
```ts
W
wusongqing 已提交
394 395 396
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
W
wusongqing 已提交
397
  "userId" : 100
W
wusongqing 已提交
398 399 400 401 402 403 404 405 406 407
};
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));
})
```

408 409


410
## bundle.getBundleInstaller<sup>deprecated<sup>
411

412
> This API is deprecated since API version 9. You are advised to use [installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller) instead.
W
wusongqing 已提交
413 414 415

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

416
Obtains the installation package. This API uses a promise to return the result.
W
wusongqing 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433

**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                                        |
| ------------------------------------------------------------ | -------------------------------------------- |
434 435 436 437 438 439 440 441 442 443 444
| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise used to return the installation package.|

**Example**

```ts
bundle.getBundleInstaller().then((data) => {
    console.info('getBundleInstaller successfully.');
}).catch((error) => {
    console.error('getBundleInstaller failed.');
});
```
W
wusongqing 已提交
445

446 447 448
## 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 已提交
449 450 451

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

452
Obtains the installation package. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467

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

468
| Name  | Type                                                        | Mandatory| Description            |
W
wusongqing 已提交
469
| -------- | ------------------------------------------------------------ | ---- | ---------------- |
470 471 472
| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes  | Callback used to return the installation package.|

**Example**
W
wusongqing 已提交
473

474 475 476 477 478 479 480 481 482
```ts
bundle.getBundleInstaller((err, data) => {
    if (err.code == 0) {
        console.error('getBundleInstaller failed.');
    } else {
        console.info('getBundleInstaller successfully');
    }
});
```
483 484 485
## 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 已提交
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504

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

505
| Name     | Type               | Mandatory| Description                                 |
W
wusongqing 已提交
506
| ---------- | ------------------- | ---- | ------------------------------------- |
G
Gloria 已提交
507
| bundleName | string              | Yes  | Bundle name.|
W
wusongqing 已提交
508 509
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result.         |

510 511 512 513 514 515 516 517 518 519 520 521 522 523
**Example**

```ts
let bundleName = "com.example.myapplication";

bundle.cleanBundleCacheFiles(bundleName, err => {
    if (err) {
        console.error('cleanBundleCacheFiles failed.');
    } else {
        console.info('cleanBundleCacheFiles successfully.');
    }
});
```

524 525 526
## 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 已提交
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545

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

546
| Name    | Type  | Mandatory| Description                                 |
W
wusongqing 已提交
547
| ---------- | ------ | ---- | ------------------------------------- |
G
Gloria 已提交
548
| bundleName | string | Yes  | Bundle name.|
W
wusongqing 已提交
549 550 551 552 553 554 555

**Return value**

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

556 557 558 559 560 561 562 563 564 565 566 567
**Example**

```ts
let bundleName = "com.example.myapplication";

bundle.cleanBundleCacheFiles(bundleName).then(()=> {
    console.info('cleanBundleCacheFiles successfully.');
}).catch(err=> {
    console.error('cleanBundleCacheFiles failed.');
});
```

568 569 570
## 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 已提交
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589

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

590 591
| Name     | Type               | Mandatory| Description                            |
| ---------- | ------------------- | ---- |--------------------------------|
G
Gloria 已提交
592
| bundleName | string              | Yes  | Bundle name.         |
W
wusongqing 已提交
593
| isEnable   | boolean             | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result.                         |

**Example**

```ts
let bundleName = "com.example.myapplication";

bundle.setApplicationEnabled(bundleName, false, err => {
    if (err) {
        console.error('setApplicationEnabled failed.');
    } else {
        console.info('setApplicationEnabled successfully.');
    }
});
```
W
wusongqing 已提交
609

610 611 612
## 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 已提交
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631

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

G
Gloria 已提交
632 633 634
| Name    | Type   | Mandatory| Description                                           |
| ---------- | ------- | ---- | ----------------------------------------------- |
| bundleName | string  | Yes  | Bundle name.           |
W
wusongqing 已提交
635 636 637 638 639 640 641 642
| 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.|

643 644 645 646 647 648 649 650 651 652 653 654
**Example**

```ts
let bundleName = "com.example.myapplication";

bundleManager.setApplicationEnabled(bundleName, false).then(()=> {
    console.info('setApplicationEnabled successfully.');
}).catch(err=> {
    console.error('setApplicationEnabled failed.');
});
```

655 656 657
## 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 已提交
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676

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

677
| Name  | Type                                        | Mandatory| Description                                           |
W
wusongqing 已提交
678 679
| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.                                  |
680 681 682 683
| 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 已提交
684

685
> This API is deprecated since API version 9. You are advised to use [bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled) instead.
W
wusongqing 已提交
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704

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

705
| Name  | Type                                        | Mandatory| Description                                           |
W
wusongqing 已提交
706 707
| -------- | -------------------------------------------- | ---- | ----------------------------------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.                                  |
708
| isEnable | boolean                                      | Yes  | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|
W
wusongqing 已提交
709 710 711 712 713 714 715

**Return value**

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

716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
**Example**

```ts
let flag = bundle.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION;
let userId = 100;
let want = {
    bundleName : "com.example.myapplication",
    abilityName : "com.example.myapplication.MainAbility"
};

bundle.getAbilityInfo(want, flag, userId).then((abilityInfo) => {
    console.info('getAbilityInfo successfully. Data: ' + JSON.stringify(abilityInfo));

    bundle.setAbilityEnabled(abilityInfo, false).then(data => {
        console.info('setAbilityEnabled successfully.');
    }).catch(err => {
        console.error('setAbilityEnabled failed:' + JSON.stringify(err));
    })
}).catch(error => {
    console.error('getAbilityInfo failed. Cause: ' + JSON.stringify(error));
});
```
738 739 740
## 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 已提交
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759

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

760
| Name        | Type                                                        | Mandatory| Description                                            |
W
wusongqing 已提交
761 762
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
| permissionName | string                                                       | Yes  | Name of the permission.                                |
G
Gloria 已提交
763
| callback       | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef.md)> | Yes  | Callback used to return the permission details.|
W
wusongqing 已提交
764

765 766 767 768 769 770 771 772 773 774 775 776 777
**Example**

```ts
let permission = "ohos.permission.GET_BUNDLE_INFO";
bundleManager.getPermissionDef(permission, (err, data) => {
    if (err) {
        console.error('getPermissionDef failed:' + err.message);
    } else {
        console.info('getPermissionDef successfully:' + JSON.stringify(data));
    }
});
```

778 779 780
## 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 已提交
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799

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

800
| Name        | Type  | Mandatory| Description            |
W
wusongqing 已提交
801 802 803 804 805 806 807
| -------------- | ------ | ---- | ---------------- |
| permissionName | string | Yes  | Name of the permission.|

**Return value**

| Type                                                  | Description                                                  |
| ------------------------------------------------------ | ------------------------------------------------------ |
G
Gloria 已提交
808
| Promise<[PermissionDef](js-apis-bundle-PermissionDef.md)> | Promise used to return the permission details.|
W
wusongqing 已提交
809

810 811 812 813 814 815 816 817 818 819
**Example**

```ts
let permissionName = "ohos.permission.GET_BUNDLE_INFO";
bundle.getPermissionDef(permissionName).then((data) => {
    console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data));
}).catch(error => {
    console.error('getPermissionDef failed. Cause: ' + error.message);
});
```
W
wusongqing 已提交
820

821
## bundle.getAllApplicationInfo<sup>deprecated<sup>
W
wusongqing 已提交
822

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

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

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

W
wusongqing 已提交
829
**Required permissions**
W
wusongqing 已提交
830

W
wusongqing 已提交
831 832 833 834 835
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
836 837 838

**Parameters**

839
| Name     | Type  | Mandatory| Description                                                        |
840
| ----------- | ------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
841
| bundleFlags | number | Yes  | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
842
| 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 已提交
843 844 845

**Return value**

W
wusongqing 已提交
846 847
| Type                              | Description                             |
| -------------------------------- | ------------------------------- |
W
wusongqing 已提交
848
| Promise<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Promise used to return the application information.|
W
wusongqing 已提交
849 850 851

**Example**

852
```ts
W
wusongqing 已提交
853 854 855 856 857 858 859
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 已提交
860 861 862
})
```

863
## bundle.getAllApplicationInfo<sup>deprecated<sup>
W
wusongqing 已提交
864

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

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

869
Obtains the information about all applications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
870

W
wusongqing 已提交
871
**Required permissions**
W
wusongqing 已提交
872

W
wusongqing 已提交
873 874 875 876 877
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
878 879 880

**Parameters**

881
| Name     | Type                                                        | Mandatory| Description                                                        |
882
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
883
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
884
| 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.       |
885
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
886 887 888

**Example**

889 890
```ts
let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
W
wusongqing 已提交
891 892 893 894 895 896 897 898
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 已提交
899 900 901
```


902 903 904
## 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 已提交
905

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

908
Obtains the information about all applications of the current user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
909 910 911 912 913 914 915 916 917 918 919

**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

920
| Name     | Type                                                        | Mandatory| Description                                                        |
921
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
922
| bundleFlags | number                                                       | Yes  | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
923
| callback    | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes  | Callback used to return the application information.              |
W
wusongqing 已提交
924 925 926

**Example**

927 928
```ts
let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
W
wusongqing 已提交
929 930 931 932 933 934 935 936 937
bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
})
```

938 939 940
## 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 已提交
941

W
wusongqing 已提交
942
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo>
W
wusongqing 已提交
943 944 945 946 947 948 949 950 951

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

952
| Name       | Type    | Mandatory  | Description          |
W
wusongqing 已提交
953
| ---------- | ------ | ---- | ------------ |
954
| hapFilePath | string | Yes   | Path where the HAP file is stored. The absolute path of the application and the data directory sandbox path are supported.|
G
Gloria 已提交
955
| bundleFlags | number | Yes   | Flags used to specify information contained in the **BundleInfo** object that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
W
wusongqing 已提交
956 957

**Return value**
G
Gloria 已提交
958 959
| Type                                                | Description                                                        |
| ---------------------------------------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
960 961 962 963
| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the information about the bundles.|

**Example**

964 965
```ts
let hapFilePath = "/data/storage/el2/base/test.hap";
W
wusongqing 已提交
966 967 968 969 970 971 972 973 974
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));
})
```

975 976 977
## 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 已提交
978

W
wusongqing 已提交
979
getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void
W
wusongqing 已提交
980 981 982 983 984 985 986 987 988

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

989
| Name       | Type    | Mandatory  | Description          |
W
wusongqing 已提交
990
| ---------- | ------ | ---- | ------------ |
991
| hapFilePath | string | Yes   | Path where the HAP file is stored.. The absolute path of the application and the data directory sandbox path are supported.|
G
Gloria 已提交
992
| bundleFlags | number | Yes   | Flags used to specify information contained in the **BundleInfo** object that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflagdeprecated).|
W
wusongqing 已提交
993
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes   | Callback used to return the information about the bundles.|
W
wusongqing 已提交
994 995 996

**Example**

997 998
```ts
let hapFilePath = "/data/storage/el2/base/test.hap";
W
wusongqing 已提交
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
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));
})
```


1010 1011 1012
## 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 已提交
1013 1014 1015

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

W
wusongqing 已提交
1016
Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
1017

1018 1019
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1030 1031
| Name        | Type    | Mandatory  | Description        |
| ----------- | ------ | ---- |------------|
G
Gloria 已提交
1032
| bundleName  | string | Yes   | Bundle name.|
W
wusongqing 已提交
1033
| abilityName | string | Yes   | Ability name.|
W
wusongqing 已提交
1034 1035 1036

**Return value**

W
wusongqing 已提交
1037 1038
| Type                   | Description                   |
| --------------------- | --------------------- |
W
wusongqing 已提交
1039
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|
W
wusongqing 已提交
1040 1041 1042

**Example**

1043
```ts
W
wusongqing 已提交
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
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));
})
```

1054 1055 1056
## 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 已提交
1057

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

W
wusongqing 已提交
1060
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 已提交
1061

1062 1063
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1074 1075
| Name       | Type    | Mandatory  | Description                        |
| ----------- | ------------ | ---- |----------------------------|
G
Gloria 已提交
1076
| bundleName  | string | Yes   | Bundle name.               |
1077
| abilityName | string | Yes   | Ability name.                |
W
wusongqing 已提交
1078
| callback    | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes   | Callback used to return the ability information.|
W
wusongqing 已提交
1079 1080 1081

**Example**

1082
```ts
W
wusongqing 已提交
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
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 已提交
1093

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

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

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

W
wusongqing 已提交
1100
Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result.
W
wusongqing 已提交
1101

1102 1103
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

G
Gloria 已提交
1114 1115 1116 1117
| Name     | Type  | Mandatory| Description            |
| ----------- | ------ | ---- | ---------------- |
| bundleName  | string | Yes  | Bundle name.|
| abilityName | string | Yes  | Ability name.   |
W
wusongqing 已提交
1118 1119 1120

**Return value**

W
wusongqing 已提交
1121 1122
| Type              | Description                |
| ---------------- | ------------------ |
W
wusongqing 已提交
1123
| Promise\<string> | Promise used to return the application name.|
W
wusongqing 已提交
1124 1125 1126

**Example**

1127
```ts
W
wusongqing 已提交
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
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));
})
```

1138 1139 1140
## 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 已提交
1141 1142 1143

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

W
wusongqing 已提交
1144
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 已提交
1145

1146 1147
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

G
Gloria 已提交
1158 1159 1160 1161
| Name     | Type                  | Mandatory| Description                                          |
| ----------- | ---------------------- | ---- | ---------------------------------------------- |
| bundleName  | string                 | Yes  | Bundle name.                              |
| abilityName | string                 | Yes  | Ability name.                                 |
1162
| callback    | AsyncCallback\<string> | Yes  | Callback used to return the application name.|
W
wusongqing 已提交
1163 1164 1165

**Example**

1166
```ts
W
wusongqing 已提交
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
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 已提交
1177

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

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

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

W
wusongqing 已提交
1184
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses a promise to return the result.
W
wusongqing 已提交
1185 1186 1187 1188 1189 1190 1191

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1192 1193 1194
| Name| Type                                        | Mandatory| Description             |
| ------ | -------------------------------------------- | ---- | ----------------- |
| info   | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.|
W
wusongqing 已提交
1195 1196 1197

**Return value**

W
wusongqing 已提交
1198 1199
| Type               | Description                       |
| ----------------- | ------------------------- |
G
Gloria 已提交
1200
| Promise\<boolean> | Promise used to return the result. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1201 1202 1203

**Example**

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

1216 1217 1218
## 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 已提交
1219 1220 1221

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

W
wusongqing 已提交
1222
Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1223 1224 1225 1226 1227 1228 1229

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1230 1231 1232
| Name  | Type                                        | Mandatory| Description                   |
| -------- | -------------------------------------------- | ---- | ----------------------- |
| info     | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes  | Ability information.      |
G
Gloria 已提交
1233
| callback | AsyncCallback\<boolean>                      | Yes  | Callback used to return the result. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1234 1235 1236

**Example**

1237
```ts
W
wusongqing 已提交
1238 1239 1240 1241
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
    bundle.isAbilityEnabled(abilityInfo, (err, data) => {
W
wusongqing 已提交
1242 1243 1244 1245 1246
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
W
wusongqing 已提交
1247
    })
W
wusongqing 已提交
1248 1249 1250
})
```

1251 1252 1253
## 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 已提交
1254 1255 1256

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

W
wusongqing 已提交
1257
Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result.
W
wusongqing 已提交
1258 1259 1260 1261 1262 1263 1264

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1265 1266
| Name    | Type  | Mandatory| Description                    |
| ---------- | ------ | ---- | ------------------------ |
G
Gloria 已提交
1267
| bundleName | string | Yes  | Bundle name.|
W
wusongqing 已提交
1268 1269 1270

**Return value**

W
wusongqing 已提交
1271 1272
| Type               | Description                       |
| ----------------- | ------------------------- |
G
Gloria 已提交
1273
| Promise\<boolean> | Promise used to return the result. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1274 1275 1276

**Example**

1277
```ts
W
wusongqing 已提交
1278 1279 1280 1281 1282 1283 1284 1285 1286
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));
})
```

1287 1288 1289
## 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 已提交
1290 1291 1292

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

W
wusongqing 已提交
1293
Checks whether an application is enabled based on a given bundle name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1294 1295 1296 1297 1298 1299 1300

**System capability**

SystemCapability.BundleManager.BundleFramework

**Parameters**

1301 1302
| Name    | Type                   | Mandatory| Description                    |
| ---------- | ----------------------- | ---- | ------------------------ |
G
Gloria 已提交
1303 1304
| bundleName | string                  | Yes  | Bundle name.|
| callback   | AsyncCallback\<boolean> | Yes  | Callback used to return the result. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.|
W
wusongqing 已提交
1305 1306 1307

**Example**

1308
```ts
W
wusongqing 已提交
1309
let bundleName = "com.example.myapplication";
W
wusongqing 已提交
1310 1311 1312 1313 1314 1315 1316 1317
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 已提交
1318

1319 1320 1321
## 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 已提交
1322 1323 1324

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

G
Gloria 已提交
1325
Obtains the ability information based on given Want. This API uses a promise to return the result.
W
wusongqing 已提交
1326

1327 1328
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1329
**Required permissions**
W
wusongqing 已提交
1330

W
wusongqing 已提交
1331 1332 1333 1334 1335
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1336 1337 1338

**Parameters**

1339
| Name        | Type    | Mandatory  | Description                                   |
W
wusongqing 已提交
1340
| ----------- | ------ | ---- | ------------------------------------- |
G
Gloria 已提交
1341 1342
| want        | [Want](js-apis-application-want.md)   | Yes   | Want containing the bundle name                 |
| bundleFlags | number | Yes   | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflagdeprecated).|
W
wusongqing 已提交
1343
| 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 已提交
1344 1345 1346

**Return value**

W
wusongqing 已提交
1347 1348
| Type                          | Description                   |
| ---------------------------- | --------------------- |
W
wusongqing 已提交
1349
| Promise<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Promise used to return the ability information.|
W
wusongqing 已提交
1350 1351 1352

**Example**

1353
```ts
W
wusongqing 已提交
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
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 已提交
1365 1366 1367 1368 1369
})
```



1370 1371 1372
## 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 已提交
1373

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

G
Gloria 已提交
1376
Obtains the ability information of the specified user based on given Want. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1377

1378 1379
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1380 1381 1382
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1383 1384 1385 1386

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1387 1388 1389

**Parameters**

G
Gloria 已提交
1390 1391 1392 1393 1394 1395
| Name     | Type                                                        | Mandatory| Description                                                        |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want        | [Want](js-apis-application-want.md)                          | Yes  | Want containing the bundle name.                      |
| bundleFlags | number                                                       | Yes  | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflagdeprecated).|
| userId      | number                                                       | Yes  | User ID. 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 已提交
1396 1397 1398

**Example**

1399
```ts
W
wusongqing 已提交
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412
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 已提交
1413 1414
```

1415 1416 1417
## 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 已提交
1418

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

G
Gloria 已提交
1421
Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1422

1423 1424
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1425 1426 1427 1428
**Required permissions**

ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO

W
wusongqing 已提交
1429 1430 1431 1432
**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1433 1434
**Parameters**

G
Gloria 已提交
1435 1436 1437 1438 1439
| Name     | Type                                                        | Mandatory| Description                                                        |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want        | [Want](js-apis-application-want.md)                          | Yes  | Want containing the bundle name.                      |
| bundleFlags | number                                                       | Yes  | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflagdeprecated).|
| callback    | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes  | Callback used to return the ability information.               |
W
wusongqing 已提交
1440 1441 1442

**Example**

1443
```ts
W
wusongqing 已提交
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454
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 已提交
1455 1456 1457 1458 1459
})
```



1460 1461 1462
## 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 已提交
1463 1464 1465

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

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

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

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

**System capability**

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

**Parameters**

1478 1479
| Name    | Type  | Mandatory| Description                    |
| ---------- | ------ | ---- | ------------------------ |
G
Gloria 已提交
1480
| bundleName | string | Yes  | Bundle name.|
W
wusongqing 已提交
1481 1482

**Return value**
W
wusongqing 已提交
1483 1484
| Type            | Description                                    |
| -------------- | -------------------------------------- |
1485
| Promise\<[Want](js-apis-application-want.md)> | Promise used to return the **Want** object.|
W
wusongqing 已提交
1486 1487 1488

**Example**

1489
```ts
W
wusongqing 已提交
1490 1491 1492 1493 1494 1495 1496
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 已提交
1497 1498
```

1499 1500 1501
## 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 已提交
1502

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

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

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

W
wusongqing 已提交
1509 1510 1511 1512 1513
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1514 1515 1516

**Parameters**

1517 1518
| Name    | Type                                               | Mandatory| Description                                                    |
| ---------- | --------------------------------------------------- | ---- | -------------------------------------------------------- |
G
Gloria 已提交
1519
| bundleName | string                                              | Yes  | Bundle name.                                |
1520
| callback   | AsyncCallback\<[Want](js-apis-application-want.md)> | Yes  | Callback used to return the **Want** object.|
W
wusongqing 已提交
1521 1522 1523

**Example**

1524
```ts
W
wusongqing 已提交
1525 1526 1527 1528 1529 1530 1531 1532
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 已提交
1533 1534 1535
```


1536 1537 1538
## 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 已提交
1539 1540

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

W
wusongqing 已提交
1542
Obtains the bundle name based on a UID. This API uses a promise to return the result.
W
wusongqing 已提交
1543 1544 1545 1546

**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1547 1548 1549

**Parameters**

1550 1551 1552
| Name| Type  | Mandatory| Description         |
| ------ | ------ | ---- | ------------- |
| uid    | number | Yes  | UID based on which the bundle name is to obtain.|
W
wusongqing 已提交
1553 1554

**Return value**
W
wusongqing 已提交
1555 1556
| Type              | Description                               |
| ---------------- | --------------------------------- |
W
wusongqing 已提交
1557
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
1558 1559 1560

**Example**

1561
```ts
W
wusongqing 已提交
1562 1563 1564 1565 1566 1567 1568
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 已提交
1569 1570
```

1571 1572 1573
## 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 已提交
1574

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

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

W
wusongqing 已提交
1579 1580 1581
**System capability**

SystemCapability.BundleManager.BundleFramework
W
wusongqing 已提交
1582 1583 1584

**Parameters**

G
Gloria 已提交
1585 1586 1587
| Name  | Type                  | Mandatory| Description                                                 |
| -------- | ---------------------- | ---- | ----------------------------------------------------- |
| uid      | number                 | Yes  | UID based on which the bundle name is to obtain.                                        |
1588
| callback | AsyncCallback\<string> | Yes  | Callback used to return the bundle name.|
W
wusongqing 已提交
1589 1590 1591

**Example**

1592
```ts
W
wusongqing 已提交
1593 1594 1595 1596 1597 1598 1599 1600
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 已提交
1601 1602
```

W
wusongqing 已提交
1603

1604 1605
## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>

G
Gloria 已提交
1606
> This API is deprecated since API version 9. You are advised to use [resourceManager.getMediaContent](js-apis-resource-manager.md#getmediacontent9) instead.
W
wusongqing 已提交
1607

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

W
wusongqing 已提交
1610
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 已提交
1611

1612 1613
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1614 1615
**Required permissions**

W
wusongqing 已提交
1616
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1617 1618 1619 1620 1621

**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1622 1623
**Parameters**

G
Gloria 已提交
1624 1625 1626 1627
| Name     | Type  | Mandatory| Description                    |
| ----------- | ------ | ---- | ------------------------ |
| bundleName  | string | Yes  | Bundle name.|
| abilityName | string | Yes  | Ability name. |
W
wusongqing 已提交
1628 1629 1630 1631

**Return value**
| Type                 | Description                                                        |
| --------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1632
| Promise\<image.PixelMap> | Promise used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1633 1634 1635

**Example**

1636
```ts
W
wusongqing 已提交
1637 1638
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1639 1640 1641 1642 1643 1644 1645 1646
bundle.getAbilityIcon(bundleName, abilityName)
.then((data) => {
    console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
    console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```

1647 1648
## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>

G
Gloria 已提交
1649
> This API is deprecated since API version 9. You are advised to use [resourceManager.getMediaContent](js-apis-resource-manager.md#getmediacontent9) instead.
W
wusongqing 已提交
1650

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

W
wusongqing 已提交
1653
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 已提交
1654

1655 1656
No permission is required for obtaining the caller's own information.

W
wusongqing 已提交
1657 1658
**Required permissions**

W
wusongqing 已提交
1659
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
W
wusongqing 已提交
1660

1661

W
wusongqing 已提交
1662 1663 1664 1665
**System capability**

SystemCapability.BundleManager.BundleFramework

W
wusongqing 已提交
1666 1667
**Parameters**

1668 1669
| Name        | Type                                      | Mandatory  | Description                                             |
| ----------- | ---------------------------------------- | ---- |-------------------------------------------------|
G
Gloria 已提交
1670
| bundleName  | string                                   | Yes   | Bundle name.                               |
1671
| abilityName | string                                   | Yes   | Ability name.                                |
W
wusongqing 已提交
1672
| callback   | AsyncCallback\<image.PixelMap> | Yes  | Callback used to return the [pixel map](js-apis-image.md).|
W
wusongqing 已提交
1673 1674 1675

**Example**

1676
```ts
W
wusongqing 已提交
1677 1678
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
W
wusongqing 已提交
1679 1680 1681 1682 1683 1684 1685 1686 1687
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));
})
```

1688
## InstallErrorCode<sup>deprecated<sup>
1689
> This API is deprecated since API version 9. You are not advised using it anymore.
W
wusongqing 已提交
1690

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

1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718
| 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 已提交
1719

1720 1721 1722 1723 1724
Enumerates the bundle flags, which indicate the type of bundle information to obtain.

If an API does not match the flag, the flag is ignored. For example, using **GET_ABILITY_INFO_WITH_PERMISSION** to obtain the application information does not affect the result.

Flags can be used together. For example, you can use the combination of **GET_APPLICATION_INFO_WITH_PERMISSION** and **GET_APPLICATION_INFO_WITH_DISABLE** to obtain the result that contains both application permission information and disabled application information.
W
wusongqing 已提交
1725 1726

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

1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743
| 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>
1744
> This API is deprecated since API version 9. You are not advised using it anymore.
W
wusongqing 已提交
1745

1746
Options that contain the user ID.
W
wusongqing 已提交
1747

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

1750 1751 1752 1753 1754
| 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 已提交
1755

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

1758
Enumerates the ability types.
W
wusongqing 已提交
1759 1760

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

1762 1763 1764 1765 1766 1767 1768 1769
| 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 已提交
1770

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

W
wusongqing 已提交
1773 1774 1775
Enumerates display orientations.

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

1777 1778 1779 1780 1781 1782 1783 1784 1785
| 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 已提交
1786

1787
Enumerates the ability launch modes.
W
wusongqing 已提交
1788 1789

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

1791 1792
| Name     | Value  | Description               |
| --------- | ---- | ------------------- |
W
wusongqing 已提交
1793
| SINGLETON | 0    | The ability has only one instance.|
1794
| STANDARD  | 1    | The ability can have multiple instances.  |
W
wusongqing 已提交
1795

1796
## AbilitySubType<sup>deprecated<sup>
1797
> This API is deprecated since API version 9. You are not advised using it anymore.
W
wusongqing 已提交
1798

1799
Enumerates the ability subtypes.
W
wusongqing 已提交
1800 1801

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

1803 1804 1805
| Name       | Value  | Description                         |
| ----------- | ---- | ----------------------------- |
| UNSPECIFIED | 0    | Undefined ability subtype.          |
W
wusongqing 已提交
1806
| CA          | 1    | Ability that has a UI.|
W
wusongqing 已提交
1807

1808
## ColorMode<sup>deprecated<sup>
1809
> This API is deprecated since API version 9. You are not advised using it anymore.
W
wusongqing 已提交
1810

1811
Enumerates the color modes of applications and widgets.
W
wusongqing 已提交
1812 1813 1814

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

1815 1816
| Name      | Value  | Description    |
| ---------- | ---- | -------- |
W
wusongqing 已提交
1817 1818 1819
| AUTO_MODE  | -1   | Automatic mode.|
| DARK_MODE  | 0    | Dark mode.|
| LIGHT_MODE | 1    | Light mode.|
W
wusongqing 已提交
1820 1821


1822 1823 1824
## 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 已提交
1825

1826
Enumerates the permission grant states.
W
wusongqing 已提交
1827 1828 1829

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

1830 1831
| Name              | Value  | Description        |
| ------------------ | ---- | ------------ |
W
wusongqing 已提交
1832
| PERMISSION_DENIED  | -1   | Permission denied.|
1833
| PERMISSION_GRANTED | 0    | Permission granted.    |