1# @ohos.bundle (Bundle) 2<!--Kit: Ability Kit--> 3<!--Subsystem: BundleManager--> 4<!--Owner: @wanghang904--> 5<!--Designer: @hanfeng6--> 6<!--Tester: @kongjing2--> 7<!--Adviser: @Brilliantry_Rui--> 8 9The 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. 10 11> **NOTE** 12> 13> 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. 14> 15> The APIs of this module are deprecated since API version 9. You are advised to use [@ohos.bundle.bundleManager](js-apis-bundleManager.md) instead. 16 17## Modules to Import 18 19```ts 20import bundle from '@ohos.bundle'; 21``` 22 23## Required Permissions 24 25| Permission | APL | Description | 26|--------------------------------------------|--------------|---------------| 27| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about a specified bundle.| 28| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all bundles. | 29 30For details about the APL, see [Basic Concepts in the Permission Mechanism](../../security/AccessToken/app-permission-mgmt-overview.md#basic-concepts-in-the-permission-mechanism). 31 32## bundle.getApplicationInfo<sup>deprecated<sup> 33 34This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager-sys.md#bundlemanagergetapplicationinfo-2) instead.<!--DelEnd--> 35 36getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo> 37 38Obtains the application information based on a given bundle name. This API uses a promise to return the result. 39 40No permission is required for obtaining the caller's own information. 41 42**Required permissions** 43 44ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 45 46**System capability** 47 48SystemCapability.BundleManager.BundleFramework 49 50**Parameters** 51 52| Name | Type | Mandatory| Description | 53| ----------- | ------ | ---- | ------------------------------------------------------------ | 54| bundleName | string | Yes | Bundle name. | 55| 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).| 56| 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. | 57 58**Return value** 59 60| Type | Description | 61| ------------------------- | ------------------ | 62| Promise\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Promise used to return the application information.| 63 64**Example** 65 66```ts 67import bundle from '@ohos.bundle'; 68import { BusinessError } from '@ohos.base'; 69 70let bundleName: string = "com.example.myapplication"; 71let bundleFlags: number = 0; 72let userId: number = 100; 73 74bundle.getApplicationInfo(bundleName, bundleFlags, userId) 75 .then((data) => { 76 console.info('Operation successful. Data: ' + JSON.stringify(data)); 77 }).catch((error: BusinessError) => { 78 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 79 }) 80``` 81 82## bundle.getApplicationInfo<sup>deprecated<sup> 83 84This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager-sys.md#bundlemanagergetapplicationinfo) instead.<!--DelEnd--> 85 86getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void 87 88Obtains the application information of the specified user based on a given bundle name. This API uses an asynchronous callback to return the result. 89 90No permission is required for obtaining the caller's own information. 91 92**Required permissions** 93 94ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 95 96**System capability** 97 98SystemCapability.BundleManager.BundleFramework 99 100**Parameters** 101 102| Name | Type | Mandatory| Description | 103| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 104| bundleName | string | Yes | Bundle name. | 105| 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).| 106| userId | number | Yes | User ID. The value must be greater than or equal to 0. | 107| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | 108 109**Example** 110 111```ts 112import bundle from '@ohos.bundle'; 113 114let bundleName: string = "com.example.myapplication"; 115let bundleFlags: number = 0; 116let userId: number = 100; 117 118bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { 119 if (err) { 120 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 121 return; 122 } 123 console.info('Operation successful. Data:' + JSON.stringify(data)); 124}) 125``` 126 127## bundle.getApplicationInfo<sup>deprecated<sup> 128 129This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager-sys.md#bundlemanagergetapplicationinfo-1) instead.<!--DelEnd--> 130 131 132getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void 133 134Obtains the application information based on a given bundle name. This API uses an asynchronous callback to return the result. 135 136No permission is required for obtaining the caller's own information. 137 138**Required permissions** 139 140ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 141 142**System capability** 143 144SystemCapability.BundleManager.BundleFramework 145 146**Parameters** 147 148| Name | Type | Mandatory| Description | 149| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 150| bundleName | string | Yes | Bundle name. | 151| 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).| 152| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | 153 154**Example** 155 156```ts 157import bundle from '@ohos.bundle'; 158 159let bundleName: string = "com.example.myapplication"; 160let bundleFlags: number = 0; 161 162bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { 163 if (err) { 164 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 165 return; 166 } 167 console.info('Operation successful. Data:' + JSON.stringify(data)); 168}) 169``` 170 171 172## bundle.getAllBundleInfo<sup>deprecated<sup> 173 174This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager-sys.md#bundlemanagergetallbundleinfo-2) instead.<!--DelEnd--> 175 176getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\<Array\<BundleInfo\>\> 177 178Obtains the information of all bundles of the specified user. This API uses a promise to return the result. 179 180**Required permissions** 181 182ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 183 184**System capability** 185 186SystemCapability.BundleManager.BundleFramework 187 188**Parameters** 189 190| Name | Type | Mandatory| Description | 191| ---------- | ---------- | ---- | ------------------------------------------------------------ | 192| 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).| 193| 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. | 194 195**Return value** 196 197| Type | Description | 198| --------------------------- | -------------------------- | 199| Promise<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Promise used to return the information of all bundles.| 200 201**Example** 202 203```ts 204import bundle from '@ohos.bundle'; 205import { BusinessError } from '@ohos.base'; 206 207let bundleFlag: number = 0; 208let userId: number = 100; 209 210bundle.getAllBundleInfo(bundleFlag, userId) 211 .then((data) => { 212 console.info('Operation successful. Data: ' + JSON.stringify(data)); 213 }).catch((error: BusinessError) => { 214 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 215 }) 216``` 217 218## bundle.getAllBundleInfo<sup>deprecated<sup> 219 220This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager-sys.md#bundlemanagergetallbundleinfo-1) instead.<!--DelEnd--> 221 222 223getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\<Array\<BundleInfo\>\>): void 224 225Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result. 226 227**Required permissions** 228 229ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 230 231**System capability** 232 233SystemCapability.BundleManager.BundleFramework 234 235**Parameters** 236 237| Name | Type | Mandatory| Description | 238| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 239| 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).| 240| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes | Callback used to return the information of all bundles. | 241 242**Example** 243 244```ts 245import bundle from '@ohos.bundle'; 246 247let bundleFlag: number = 0; 248 249bundle.getAllBundleInfo(bundleFlag, (err, data) => { 250 if (err) { 251 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 252 return; 253 } 254 console.info('Operation successful. Data:' + JSON.stringify(data)); 255}) 256``` 257 258## bundle.getAllBundleInfo<sup>deprecated<sup> 259 260This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager-sys.md#bundlemanagergetallbundleinfo) instead.<!--DelEnd--> 261 262 263getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\<Array\<BundleInfo\>\>): void 264 265Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result. 266 267**Required permissions** 268 269ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 270 271**System capability** 272 273SystemCapability.BundleManager.BundleFramework 274 275**Parameters** 276 277| Name | Type | Mandatory | Description | 278|------------|-------------------------------------------------------------------|-----|---------------------------------------------------------------------| 279| 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).| 280| 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. | 281| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | Yes | Callback used to return the information of all bundles. | 282 283**Example** 284 285```ts 286import bundle from '@ohos.bundle'; 287 288let bundleFlag: number = 0; 289let userId: number = 100; 290 291bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { 292 if (err) { 293 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 294 return; 295 } 296 console.info('Operation successful. Data:' + JSON.stringify(data)); 297}) 298``` 299 300## bundle.getBundleInfo<sup>deprecated<sup> 301 302This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo14-2) instead. 303 304 305getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo> 306 307Obtains the bundle information based on a given bundle name. This API uses a promise to return the result. 308 309No permission is required for obtaining the caller's own information. 310 311**Required permissions** 312 313ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 314 315**System capability** 316 317SystemCapability.BundleManager.BundleFramework 318 319**Parameters** 320 321| Name | Type | Mandatory | Description | 322| ----------- | ------------- | ---- |---------------------------------------------------------------------| 323| bundleName | string | Yes | Bundle name. | 324| 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).| 325| options | [BundleOptions](#bundleoptionsdeprecated) | No | Options that contain the user ID. | 326 327**Return value** 328 329| Type | Description | 330| -------------------- | ---------------------------- | 331| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the bundle information.| 332 333**Example** 334 335```ts 336import bundle from '@ohos.bundle'; 337import { BusinessError } from '@ohos.base'; 338 339let bundleName: string = "com.example.myapplication"; 340let bundleFlags: number = 1; 341let options: bundle.BundleOptions = { 342 "userId": 100 343}; 344 345bundle.getBundleInfo(bundleName, bundleFlags, options) 346 .then((data) => { 347 console.info('Operation successful. Data: ' + JSON.stringify(data)); 348 }).catch((error: BusinessError) => { 349 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 350 }) 351``` 352 353## bundle.getBundleInfo<sup>deprecated<sup> 354 355This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo14-1) instead. 356 357getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void 358 359Obtains the bundle information based on a given bundle name. This API uses an asynchronous callback to return the result. 360 361No permission is required for obtaining the caller's own information. 362 363**Required permissions** 364 365ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 366 367**System capability** 368 369SystemCapability.BundleManager.BundleFramework 370 371**Parameters** 372 373| Name | Type | Mandatory| Description | 374| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 375| bundleName | string | Yes | Bundle name. | 376| 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).| 377| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | 378 379**Example** 380 381```ts 382import bundle from '@ohos.bundle'; 383 384let bundleName: string = "com.example.myapplication"; 385let bundleFlags: number = 1; 386 387bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { 388 if (err) { 389 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 390 return; 391 } 392 console.info('Operation successful. Data:' + JSON.stringify(data)); 393}) 394``` 395 396## bundle.getBundleInfo<sup>deprecated<sup> 397 398This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo14) instead. 399 400getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void 401 402Obtains the bundle information based on a given bundle name and bundle options. This API uses an asynchronous callback to return the result. 403 404No permission is required for obtaining the caller's own information. 405 406**Required permissions** 407 408ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 409 410**System capability** 411 412SystemCapability.BundleManager.BundleFramework 413 414**Parameters** 415 416| Name | Type | Mandatory| Description | 417| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 418| bundleName | string | Yes | Bundle name. | 419| 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).| 420| options | [BundleOptions](#bundleoptionsdeprecated) | Yes | Includes **userId**. | 421| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | 422 423**Example** 424 425```ts 426import bundle from '@ohos.bundle'; 427 428let bundleName: string = "com.example.myapplication"; 429let bundleFlags: number = 1; 430let options: bundle.BundleOptions = { 431 "userId": 100 432}; 433 434bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { 435 if (err) { 436 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 437 return; 438 } 439 console.info('Operation successful. Data:' + JSON.stringify(data)); 440}) 441``` 442 443## bundle.getAllApplicationInfo<sup>deprecated<sup> 444 445This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager-sys.md#bundlemanagergetallapplicationinfo-2) instead.<!--DelEnd--> 446 447getAllApplicationInfo(bundleFlags: number, userId?: number): Promise\<Array\<ApplicationInfo\>\> 448 449Obtains the information about all applications of the specified user. This API uses a promise to return the result. 450 451**Required permissions** 452 453ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 454 455**System capability** 456 457SystemCapability.BundleManager.BundleFramework 458 459**Parameters** 460 461| Name | Type | Mandatory| Description | 462| ----------- | ------ | ---- | ------------------------------------------------------------ | 463| 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).| 464| 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. | 465 466**Return value** 467 468| Type | Description | 469| -------------------------------- | ------------------------------- | 470| Promise<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Promise used to return the application information.| 471 472**Example** 473 474```ts 475import bundle from '@ohos.bundle'; 476import { BusinessError } from '@ohos.base'; 477 478let bundleFlags: number = 8; 479let userId: number = 100; 480 481bundle.getAllApplicationInfo(bundleFlags, userId) 482 .then((data) => { 483 console.info('Operation successful. Data: ' + JSON.stringify(data)); 484 }).catch((error: BusinessError) => { 485 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 486 }) 487``` 488 489## bundle.getAllApplicationInfo<sup>deprecated<sup> 490 491This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager-sys.md#bundlemanagergetallapplicationinfo) instead.<!--DelEnd--> 492 493getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<ApplicationInfo\>\>): void 494 495Obtains the information about all applications. This API uses an asynchronous callback to return the result. 496 497**Required permissions** 498 499ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 500 501**System capability** 502 503SystemCapability.BundleManager.BundleFramework 504 505**Parameters** 506 507| Name | Type | Mandatory| Description | 508| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 509| 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).| 510| 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. | 511| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes | Callback used to return the application information. | 512 513**Example** 514 515```ts 516import bundle from '@ohos.bundle'; 517 518let bundleFlags: number = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION; 519let userId: number = 100; 520 521bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { 522 if (err) { 523 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 524 return; 525 } 526 console.info('Operation successful. Data:' + JSON.stringify(data)); 527}) 528``` 529 530 531## bundle.getAllApplicationInfo<sup>deprecated<sup> 532 533This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager-sys.md#bundlemanagergetallapplicationinfo-1) instead.<!--DelEnd--> 534 535getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback\<Array\<ApplicationInfo\>\>): void 536 537Obtains the information about all applications of the current user. This API uses an asynchronous callback to return the result. 538 539**Required permissions** 540 541ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 542 543**System capability** 544 545SystemCapability.BundleManager.BundleFramework 546 547**Parameters** 548 549| Name | Type | Mandatory| Description | 550| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 551| 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).| 552| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)>> | Yes | Callback used to return the application information. | 553 554**Example** 555 556```ts 557import bundle from '@ohos.bundle'; 558 559let bundleFlags: number = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION; 560 561bundle.getAllApplicationInfo(bundleFlags, (err, data) => { 562 if (err) { 563 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 564 return; 565 } 566 console.info('Operation successful. Data:' + JSON.stringify(data)); 567}) 568``` 569 570## bundle.getBundleArchiveInfo<sup>deprecated<sup> 571 572This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getBundleArchiveInfo](js-apis-bundleManager-sys.md#bundlemanagergetbundlearchiveinfo-1) instead.<!--DelEnd--> 573 574getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\<BundleInfo> 575 576Obtains information about the bundles contained in a HAP file. This API uses a promise to return the result. 577 578**System capability** 579 580SystemCapability.BundleManager.BundleFramework 581 582**Parameters** 583 584| Name | Type | Mandatory | Description | 585| ---------- | ------ | ---- | ------------ | 586| hapFilePath | string | Yes | Path where the HAP file is stored. The absolute path of the application and the data directory sandbox path are supported.| 587| 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).| 588 589**Return value** 590| Type | Description | 591| ---------------------------------------------------- | ------------------------------------------------------------ | 592| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the information about the bundles.| 593 594**Example** 595 596```ts 597import bundle from '@ohos.bundle'; 598import { BusinessError } from '@ohos.base'; 599 600let hapFilePath: string = "/data/storage/el2/base/test.hap"; 601let bundleFlags: number = 0; 602 603bundle.getBundleArchiveInfo(hapFilePath, bundleFlags) 604 .then((data) => { 605 console.info('Operation successful. Data: ' + JSON.stringify(data)); 606 }).catch((error: BusinessError) => { 607 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 608 }) 609``` 610 611## bundle.getBundleArchiveInfo<sup>deprecated<sup> 612 613This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getBundleArchiveInfo](js-apis-bundleManager-sys.md#bundlemanagergetbundlearchiveinfo) instead.<!--DelEnd--> 614 615getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>) : void 616 617Obtains information about the bundles contained in a HAP file. This API uses an asynchronous callback to return the result. 618 619**System capability** 620 621SystemCapability.BundleManager.BundleFramework 622 623**Parameters** 624 625| Name | Type | Mandatory | Description | 626| ---------- | ------ | ---- | ------------ | 627| hapFilePath | string | Yes | Path where the HAP file is stored. The absolute path of the application and the data directory sandbox path are supported.| 628| 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).| 629| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the information about the bundles.| 630 631**Example** 632 633```ts 634import bundle from '@ohos.bundle'; 635 636let hapFilePath: string = "/data/storage/el2/base/test.hap"; 637let bundleFlags: number = 0; 638 639bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { 640 if (err) { 641 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 642 return; 643 } 644 console.info('Operation successful. Data:' + JSON.stringify(data)); 645}) 646``` 647 648## bundle.getAbilityInfo<sup>deprecated<sup> 649 650This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager-sys.md#bundlemanagerqueryabilityinfo-2) instead.<!--DelEnd--> 651 652getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo> 653 654Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result. 655 656No permission is required for obtaining the caller's own information. 657 658**Required permissions** 659 660ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 661 662**System capability** 663 664SystemCapability.BundleManager.BundleFramework 665 666**Parameters** 667 668| Name | Type | Mandatory | Description | 669| ----------- | ------ | ---- |------------| 670| bundleName | string | Yes | Bundle name.| 671| abilityName | string | Yes | Ability name.| 672 673**Return value** 674 675| Type | Description | 676| --------------------- | --------------------- | 677| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.| 678 679**Example** 680 681```ts 682import bundle from '@ohos.bundle'; 683import { BusinessError } from '@ohos.base'; 684 685let bundleName: string = "com.example.myapplication"; 686let abilityName: string = "EntryAbility"; 687 688bundle.getAbilityInfo(bundleName, abilityName) 689 .then((data) => { 690 console.info('Operation successful. Data: ' + JSON.stringify(data)); 691 }).catch((error: BusinessError) => { 692 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 693 }) 694``` 695 696## bundle.getAbilityInfo<sup>deprecated<sup> 697 698This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager-sys.md#bundlemanagerqueryabilityinfo) instead.<!--DelEnd--> 699 700getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void 701 702Obtains the ability information based on a given bundle name and ability name. This API uses an asynchronous callback to return the result. 703 704No permission is required for obtaining the caller's own information. 705 706**Required permissions** 707 708ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 709 710**System capability** 711 712SystemCapability.BundleManager.BundleFramework 713 714**Parameters** 715 716| Name | Type | Mandatory | Description | 717| ----------- | ------------ | ---- |----------------------------| 718| bundleName | string | Yes | Bundle name. | 719| abilityName | string | Yes | Ability name. | 720| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | Callback used to return the ability information.| 721 722**Example** 723 724```ts 725import bundle from '@ohos.bundle'; 726 727let bundleName: string = "com.example.myapplication"; 728let abilityName: string = "EntryAbility"; 729 730bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { 731 if (err) { 732 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 733 return; 734 } 735 console.info('Operation successful. Data:' + JSON.stringify(data)); 736}) 737``` 738 739## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup> 740 741This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAbilityLabel](js-apis-bundleManager-sys.md#bundlemanagergetabilitylabel-1) instead.<!--DelEnd--> 742 743getAbilityLabel(bundleName: string, abilityName: string): Promise\<string> 744 745Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result. 746 747No permission is required for obtaining the caller's own information. 748 749**Required permissions** 750 751ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 752 753**System capability** 754 755SystemCapability.BundleManager.BundleFramework 756 757**Parameters** 758 759| Name | Type | Mandatory| Description | 760| ----------- | ------ | ---- | ---------------- | 761| bundleName | string | Yes | Bundle name.| 762| abilityName | string | Yes | Ability name. | 763 764**Return value** 765 766| Type | Description | 767| ---------------- | ------------------ | 768| Promise\<string> | Promise used to return the application name.| 769 770**Example** 771 772```ts 773import bundle from '@ohos.bundle'; 774import { BusinessError } from '@ohos.base'; 775 776let bundleName: string = "com.example.myapplication"; 777let abilityName: string = "EntryAbility"; 778 779bundle.getAbilityLabel(bundleName, abilityName) 780 .then((data) => { 781 console.info('Operation successful. Data: ' + JSON.stringify(data)); 782 }).catch((error: BusinessError) => { 783 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 784 }) 785``` 786 787## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup> 788 789This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getAbilityLabel](js-apis-bundleManager-sys.md#bundlemanagergetabilitylabel) instead.<!--DelEnd--> 790 791getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void 792 793Obtains the application name based on a given bundle name and ability name. This API uses an asynchronous callback to return the result. 794 795No permission is required for obtaining the caller's own information. 796 797**Required permissions** 798 799ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 800 801**System capability** 802 803SystemCapability.BundleManager.BundleFramework 804 805**Parameters** 806 807| Name | Type | Mandatory| Description | 808| ----------- | ---------------------- | ---- | ---------------------------------------------- | 809| bundleName | string | Yes | Bundle name. | 810| abilityName | string | Yes | Ability name. | 811| callback | AsyncCallback\<string> | Yes | Callback used to return the application name.| 812 813**Example** 814 815```ts 816import bundle from '@ohos.bundle'; 817 818let bundleName: string = "com.example.myapplication"; 819let abilityName: string = "EntryAbility"; 820 821bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { 822 if (err) { 823 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 824 return; 825 } 826 console.info('Operation successful. Data:' + JSON.stringify(data)); 827}) 828``` 829 830## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup> 831 832This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.isAbilityEnabled](js-apis-bundleManager-sys.md#bundlemanagerisabilityenabled-1) instead.<!--DelEnd--> 833 834isAbilityEnabled(info: AbilityInfo): Promise\<boolean> 835 836Checks whether the ability that matches a given AbilityInfo object is enabled. This API uses a promise to return the result. 837 838**System capability** 839 840SystemCapability.BundleManager.BundleFramework 841 842**Parameters** 843 844| Name| Type | Mandatory| Description | 845| ------ | -------------------------------------------- | ---- | ----------------- | 846| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information.| 847 848**Return value** 849 850| Type | Description | 851| ----------------- | ------------------------- | 852| Promise\<boolean> | Promise used to return the result. **true** if enabled, **false** otherwise.| 853 854**Example** 855 856```ts 857import bundle from '@ohos.bundle'; 858import { BusinessError } from '@ohos.base'; 859 860let bundleName: string = "com.example.myapplication"; 861let abilityName: string = "EntryAbility"; 862 863bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo) => { 864 bundle.isAbilityEnabled(abilityInfo).then((data) => { 865 console.info('Operation successful. Data: ' + JSON.stringify(data)); 866 }).catch((error: BusinessError) => { 867 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 868 }) 869}) 870``` 871 872## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup> 873 874This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.isAbilityEnabled](js-apis-bundleManager-sys.md#bundlemanagerisabilityenabled) instead.<!--DelEnd--> 875 876isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void 877 878Checks whether the ability that matches a given AbilityInfo object is enabled. This API uses an asynchronous callback to return the result. 879 880**System capability** 881 882SystemCapability.BundleManager.BundleFramework 883 884**Parameters** 885 886| Name | Type | Mandatory| Description | 887| -------- | -------------------------------------------- | ---- | ----------------------- | 888| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | 889| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. **true** if enabled, **false** otherwise.| 890 891**Example** 892 893```ts 894import bundle from '@ohos.bundle'; 895 896let bundleName: string = "com.example.myapplication"; 897let abilityName: string = "EntryAbility"; 898 899bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo) => { 900 bundle.isAbilityEnabled(abilityInfo, (err, data) => { 901 if (err) { 902 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 903 return; 904 } 905 console.info('Operation successful. Data:' + JSON.stringify(data)); 906 }) 907}) 908``` 909 910## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup> 911 912This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.isApplicationEnabled](js-apis-bundleManager-sys.md#bundlemanagerisapplicationenabled-1) instead.<!--DelEnd--> 913 914isApplicationEnabled(bundleName: string): Promise\<boolean> 915 916Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result. 917 918**System capability** 919 920SystemCapability.BundleManager.BundleFramework 921 922**Parameters** 923 924| Name | Type | Mandatory| Description | 925| ---------- | ------ | ---- | ------------------------ | 926| bundleName | string | Yes | Bundle name.| 927 928**Return value** 929 930| Type | Description | 931| ----------------- | ------------------------- | 932| Promise\<boolean> | Promise used to return the result. **true** if enabled, **false** otherwise.| 933 934**Example** 935 936```ts 937import bundle from '@ohos.bundle'; 938import { BusinessError } from '@ohos.base'; 939 940let bundleName: string = "com.example.myapplication"; 941 942bundle.isApplicationEnabled(bundleName) 943 .then((data) => { 944 console.info('Operation successful. Data: ' + JSON.stringify(data)); 945 }).catch((error: BusinessError) => { 946 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 947 }) 948``` 949 950## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup> 951 952This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use[bundleManager.isApplicationEnabled](js-apis-bundleManager-sys.md#bundlemanagerisapplicationenabled) instead.<!--DelEnd--> 953 954isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void 955 956Checks whether an application is enabled based on a given bundle name. This API uses an asynchronous callback to return the result. 957 958**System capability** 959 960SystemCapability.BundleManager.BundleFramework 961 962**Parameters** 963 964| Name | Type | Mandatory| Description | 965| ---------- | ----------------------- | ---- | ------------------------ | 966| bundleName | string | Yes | Bundle name.| 967| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. **true** if enabled, **false** otherwise.| 968 969**Example** 970 971```ts 972import bundle from '@ohos.bundle'; 973 974let bundleName: string = "com.example.myapplication"; 975 976bundle.isApplicationEnabled(bundleName, (err, data) => { 977 if (err) { 978 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 979 return; 980 } 981 console.info('Operation successful. Data:' + JSON.stringify(data)); 982}) 983``` 984 985## bundle.queryAbilityByWant<sup>deprecated<sup> 986 987This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager-sys.md#bundlemanagerqueryabilityinfo12) instead.<!--DelEnd--> 988 989queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise\<Array\<AbilityInfo\>\> 990 991Obtains the ability information based on given Want. This API uses a promise to return the result. 992 993No permission is required for obtaining the caller's own information. 994 995**Required permissions** 996 997ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 998 999**System capability** 1000 1001SystemCapability.BundleManager.BundleFramework 1002 1003**Parameters** 1004 1005| Name | Type | Mandatory | Description | 1006| ----------- | ------ | ---- | ------------------------------------- | 1007| want | [Want](js-apis-application-want.md) | Yes | Want containing the bundle name. | 1008| bundleFlags | number | Yes | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflagdeprecated).| 1009| 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. | 1010 1011**Return value** 1012 1013| Type | Description | 1014| ---------------------------- | --------------------- | 1015| Promise<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Promise used to return the ability information.| 1016 1017**Example** 1018 1019```ts 1020import bundle from '@ohos.bundle'; 1021import { BusinessError } from '@ohos.base'; 1022import Want from '@ohos.app.ability.Want'; 1023 1024let bundleFlags: number = 0; 1025let userId: number = 100; 1026let want: Want = { 1027 bundleName: "com.example.myapplication", 1028 abilityName: "EntryAbility" 1029}; 1030 1031bundle.queryAbilityByWant(want, bundleFlags, userId) 1032 .then((data) => { 1033 console.info('Operation successful. Data: ' + JSON.stringify(data)); 1034 }).catch((error: BusinessError) => { 1035 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 1036 }) 1037``` 1038 1039 1040 1041## bundle.queryAbilityByWant<sup>deprecated<sup> 1042 1043> This API is deprecated since API version 9. 1044 1045queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<AbilityInfo\>\>): void 1046 1047Obtains the ability information of the specified user based on given Want. This API uses an asynchronous callback to return the result. 1048 1049No permission is required for obtaining the caller's own information. 1050 1051**Required permissions** 1052 1053ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1054 1055**System capability** 1056 1057SystemCapability.BundleManager.BundleFramework 1058 1059**Parameters** 1060 1061| Name | Type | Mandatory| Description | 1062| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 1063| want | [Want](js-apis-application-want.md) | Yes | Want containing the bundle name. | 1064| bundleFlags | number | Yes | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflagdeprecated).| 1065| userId | number | Yes | User ID. The value must be greater than or equal to 0. | 1066| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes | Callback used to return the ability information. | 1067 1068**Example** 1069 1070```ts 1071import bundle from '@ohos.bundle'; 1072import Want from '@ohos.app.ability.Want'; 1073 1074let bundleFlags: number = 0; 1075let userId: number = 100; 1076let want: Want = { 1077 bundleName: "com.example.myapplication", 1078 abilityName: "EntryAbility" 1079}; 1080 1081bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { 1082 if (err) { 1083 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 1084 return; 1085 } 1086 console.info('Operation successful. Data:' + JSON.stringify(data)); 1087}) 1088``` 1089 1090## bundle.queryAbilityByWant<sup>deprecated<sup> 1091 1092> This API is deprecated since API version 9. 1093 1094queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback\<Array\<AbilityInfo\>\>): void 1095 1096Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result. 1097 1098No permission is required for obtaining the caller's own information. 1099 1100**Required permissions** 1101 1102ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1103 1104**System capability** 1105 1106SystemCapability.BundleManager.BundleFramework 1107 1108**Parameters** 1109 1110| Name | Type | Mandatory| Description | 1111| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 1112| want | [Want](js-apis-application-want.md) | Yes | Want containing the bundle name. | 1113| bundleFlags | number | Yes | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflagdeprecated).| 1114| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | Yes | Callback used to return the ability information. | 1115 1116**Example** 1117 1118```ts 1119import bundle from '@ohos.bundle'; 1120import Want from '@ohos.app.ability.Want'; 1121 1122let bundleFlags: number = 0; 1123let want: Want = { 1124 bundleName: "com.example.myapplication", 1125 abilityName: "EntryAbility" 1126}; 1127 1128bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { 1129 if (err) { 1130 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 1131 return; 1132 } 1133 console.info('Operation successful. Data:' + JSON.stringify(data)); 1134}) 1135``` 1136 1137 1138 1139## bundle.getLaunchWantForBundle<sup>deprecated<sup> 1140 1141This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getLaunchWantForBundle](js-apis-bundleManager-sys.md#bundlemanagergetlaunchwantforbundle-2) instead.<!--DelEnd--> 1142 1143getLaunchWantForBundle(bundleName: string): Promise\<Want> 1144 1145Obtains the Want object that launches the specified application. This API uses a promise to return the result. 1146 1147**Required permissions** 1148 1149ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1150 1151**System capability** 1152 1153SystemCapability.BundleManager.BundleFramework 1154 1155**Parameters** 1156 1157| Name | Type | Mandatory| Description | 1158| ---------- | ------ | ---- | ------------------------ | 1159| bundleName | string | Yes | Bundle name.| 1160 1161**Return value** 1162| Type | Description | 1163| -------------- | -------------------------------------- | 1164| Promise\<[Want](js-apis-application-want.md)> | Promise used to return the Want object.| 1165 1166**Example** 1167 1168```ts 1169import bundle from '@ohos.bundle'; 1170import { BusinessError } from '@ohos.base'; 1171 1172let bundleName: string = "com.example.myapplication"; 1173 1174bundle.getLaunchWantForBundle(bundleName) 1175 .then((data) => { 1176 console.info('Operation successful. Data: ' + JSON.stringify(data)); 1177 }).catch((error: BusinessError) => { 1178 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 1179 }) 1180``` 1181 1182## bundle.getLaunchWantForBundle<sup>deprecated<sup> 1183 1184This API is deprecated since API version 9. The substitute API is open only to system applications. <!--Del-->You are advised to use [bundleManager.getLaunchWantForBundle](js-apis-bundleManager-sys.md#bundlemanagergetlaunchwantforbundle-1) instead.<!--DelEnd--> 1185 1186getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void 1187 1188Obtains the Want object that launches the specified application. This API uses an asynchronous callback to return the result. 1189 1190**Required permissions** 1191 1192ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1193 1194**System capability** 1195 1196SystemCapability.BundleManager.BundleFramework 1197 1198**Parameters** 1199 1200| Name | Type | Mandatory| Description | 1201| ---------- | --------------------------------------------------- | ---- | -------------------------------------------------------- | 1202| bundleName | string | Yes | Bundle name. | 1203| callback | AsyncCallback\<[Want](js-apis-application-want.md)> | Yes | Callback used to return the Want object.| 1204 1205**Example** 1206 1207```ts 1208import bundle from '@ohos.bundle'; 1209 1210let bundleName: string = "com.example.myapplication"; 1211 1212bundle.getLaunchWantForBundle(bundleName, (err, data) => { 1213 if (err) { 1214 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 1215 return; 1216 } 1217 console.info('Operation successful. Data:' + JSON.stringify(data)); 1218}) 1219``` 1220 1221 1222## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup> 1223 1224This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid14-1) instead. 1225 1226getNameForUid(uid: number): Promise\<string> 1227 1228Obtains the bundle name based on a UID. This API uses a promise to return the result. 1229 1230**System capability** 1231 1232SystemCapability.BundleManager.BundleFramework 1233 1234**Parameters** 1235 1236| Name| Type | Mandatory| Description | 1237| ------ | ------ | ---- | ------------- | 1238| uid | number | Yes | UID based on which the bundle name is to obtain.| 1239 1240**Return value** 1241| Type | Description | 1242| ---------------- | --------------------------------- | 1243| Promise\<string> | Promise used to return the bundle name.| 1244 1245**Example** 1246 1247```ts 1248import bundle from '@ohos.bundle'; 1249import { BusinessError } from '@ohos.base'; 1250 1251let uid: number = 20010005; 1252 1253bundle.getNameForUid(uid) 1254 .then((data) => { 1255 console.info('Operation successful. Data: ' + JSON.stringify(data)); 1256 }).catch((error: BusinessError) => { 1257 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 1258 }) 1259``` 1260 1261## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup> 1262 1263This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid14) instead. 1264 1265getNameForUid(uid: number, callback: AsyncCallback\<string>) : void 1266 1267Obtains the bundle name based on a UID. This API uses an asynchronous callback to return the result. 1268 1269**System capability** 1270 1271SystemCapability.BundleManager.BundleFramework 1272 1273**Parameters** 1274 1275| Name | Type | Mandatory| Description | 1276| -------- | ---------------------- | ---- | ----------------------------------------------------- | 1277| uid | number | Yes | UID based on which the bundle name is to obtain. | 1278| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.| 1279 1280**Example** 1281 1282```ts 1283import bundle from '@ohos.bundle'; 1284 1285let uid: number = 20010005; 1286 1287bundle.getNameForUid(uid, (err, data) => { 1288 if (err) { 1289 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 1290 return; 1291 } 1292 console.info('Operation successful. Data:' + JSON.stringify(data)); 1293}) 1294``` 1295 1296 1297## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup> 1298 1299> This API is deprecated since API version 9. You are advised to use [resourceManager.getMediaContent](../apis-localization-kit/js-apis-resource-manager.md#getmediacontent9) instead. 1300 1301getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap> 1302 1303Obtains the [PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) of the icon corresponding to a given bundle name and ability name. This API uses a promise to return the result. 1304 1305No permission is required for obtaining the caller's own information. 1306 1307**Required permissions** 1308 1309ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1310 1311**System capability** 1312 1313SystemCapability.BundleManager.BundleFramework 1314 1315**Parameters** 1316 1317| Name | Type | Mandatory| Description | 1318| ----------- | ------ | ---- | ------------------------ | 1319| bundleName | string | Yes | Bundle name.| 1320| abilityName | string | Yes | Ability name. | 1321 1322**Return value** 1323| Type | Description | 1324| --------------------- | ------------------------------------------------------------ | 1325| Promise\<image.PixelMap> | Promise used to return the [PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md).| 1326 1327**Example** 1328 1329```ts 1330import bundle from '@ohos.bundle'; 1331import { BusinessError } from '@ohos.base'; 1332 1333let bundleName: string = "com.example.myapplication"; 1334let abilityName: string = "EntryAbility"; 1335 1336bundle.getAbilityIcon(bundleName, abilityName) 1337 .then((data) => { 1338 console.info('Operation successful. Data: ' + JSON.stringify(data)); 1339 }).catch((error: BusinessError) => { 1340 console.error('Operation failed. Cause: ' + JSON.stringify(error)); 1341 }) 1342``` 1343 1344## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup> 1345 1346> This API is deprecated since API version 9. You are advised to use [resourceManager.getMediaContent](../apis-localization-kit/js-apis-resource-manager.md#getmediacontent9) instead. 1347 1348getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void 1349 1350Obtains the [PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) of the icon corresponding to a given bundle name and ability name. This API uses an asynchronous callback to return the result. 1351 1352No permission is required for obtaining the caller's own information. 1353 1354**Required permissions** 1355 1356ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1357 1358 1359**System capability** 1360 1361SystemCapability.BundleManager.BundleFramework 1362 1363**Parameters** 1364 1365| Name | Type | Mandatory | Description | 1366| ----------- | ---------------------------------------- | ---- |-------------------------------------------------| 1367| bundleName | string | Yes | Bundle name. | 1368| abilityName | string | Yes | Ability name. | 1369| callback | AsyncCallback\<image.PixelMap> | Yes | Callback used to return the [PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md).| 1370 1371**Example** 1372 1373```ts 1374import bundle from '@ohos.bundle'; 1375 1376let bundleName: string = "com.example.myapplication"; 1377let abilityName: string = "EntryAbility"; 1378 1379bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { 1380 if (err) { 1381 console.error('Operation failed. Cause: ' + JSON.stringify(err)); 1382 return; 1383 } 1384 console.info('Operation successful. Data:' + JSON.stringify(data)); 1385}) 1386``` 1387 1388## InstallErrorCode<sup>deprecated<sup> 1389This API is deprecated since API version 9. You are advised to use [errorcode-bundle](errorcode-bundle.md) instead. 1390 1391 **System capability**: SystemCapability.BundleManager.BundleFramework 1392 1393| Name | Value | Description | 1394| ---------------------------------------------------- | ---- | ------------------------------------------------ | 1395| SUCCESS | 0 | Installation succeeded. | 1396| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed is not found.) | 1397| STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. | 1398| STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. | 1399| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) | 1400| STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. | 1401| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatibility. (A downgrade occurs or the signature information is incorrect.)| 1402| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled is not found.) | 1403| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) | 1404| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) | 1405| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)| 1406| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | Installation failed. (Download timed out.) | 1407| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | Installation failed. (Download failed.) | 1408| STATUS_RECOVER_FAILURE_INVALID<sup>8+</sup> | 0x0D | Failed to restore the pre-installed application. | 1409| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability not found. | 1410| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS service error. | 1411| STATUS_FAILED_NO_SPACE_LEFT<sup>8+</sup> | 0x42 | Insufficient device space. | 1412| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED<sup>8+</sup> | 0x43 | Application authorization failed. | 1413| STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x44 | No installation permission. | 1414| STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x45 | No uninstallation permission. | 1415 1416## BundleFlag<sup>deprecated<sup> 1417 1418> This API is deprecated since API version 9. You are advised to use [bundleManager.BundleFlag](js-apis-bundleManager.md#bundleflag) instead. 1419 1420Enumerates the bundle flags, which indicate the type of bundle information to obtain. 1421 1422If 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. 1423 1424Flags 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. 1425 1426 **System capability**: SystemCapability.BundleManager.BundleFramework 1427 1428| Name | Value | Description | 1429| ----------------------------------------------- | ---------- | ------------------------------- | 1430| GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information. | 1431| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information. | 1432| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information. | 1433| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information. | 1434| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information. | 1435| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions. | 1436| GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | Obtains the ability metadata information. | 1437| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information. | 1438| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information of system applications.| 1439| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities. | 1440| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications. | 1441| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. | 1442 1443## BundleOptions<sup>deprecated<sup> 1444> This API is deprecated since API version 9. You are not advised using it anymore. 1445 1446Options that contain the user ID. 1447 1448 **System capability**: SystemCapability.BundleManager.BundleFramework 1449 1450| Name | Type | Read-Only| Optional| Description | 1451| ------ | ------ | ---- | ---- | ----------------------------------------------------- | 1452| userId | number | No | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| 1453 1454## AbilityType<sup>deprecated<sup> 1455 1456> This API is deprecated since API version 9. You are advised to use [bundleManager.AbilityType](js-apis-bundleManager.md#abilitytype) instead. 1457 1458Enumerates the ability types. 1459 1460 **System capability**: SystemCapability.BundleManager.BundleFramework 1461 1462| Name| Value| Description | 1463| ------- | ---- | --------------------------- | 1464| UNKNOWN | None | Unknown ability type. | 1465| PAGE | None | FA developed using the Page template to provide the capability of interacting with users. | 1466| SERVICE | None | PA developed using the Service template to provide the capability of running tasks in the background. | 1467| DATA | None | PA developed using the Data template to provide unified data access for external systems.| 1468 1469## DisplayOrientation<sup>deprecated<sup> 1470 1471> This API is deprecated since API version 9. You are advised to use [bundleManager.DisplayOrientation](js-apis-bundleManager.md#displayorientation) instead. 1472 1473Enumerates display orientations. 1474 1475 **System capability**: SystemCapability.BundleManager.BundleFramework 1476 1477| Name | Value | Description | 1478| ------------- | ---- | ------------------------ | 1479| UNSPECIFIED | None | Unspecified display orientation. | 1480| LANDSCAPE | None | Landscape orientation. | 1481| PORTRAIT | None | Portrait orientation. | 1482| FOLLOW_RECENT | None | Orientation same as that of the nearest ability in the stack.| 1483## LaunchMode<sup>deprecated<sup> 1484 1485> This API is deprecated since API version 9. You are advised to use [bundleManager.LaunchType](js-apis-bundleManager.md#launchtype) instead. 1486 1487Enumerates the ability launch modes. 1488 1489 **System capability**: SystemCapability.BundleManager.BundleFramework 1490 1491| Name | Value | Description | 1492| --------- | ---- | ------------------- | 1493| SINGLETON | 0 | The ability has only one instance.| 1494| STANDARD | 1 | The ability can have multiple instances. | 1495 1496## AbilitySubType<sup>deprecated<sup> 1497> This API is deprecated since API version 9. You are not advised using it anymore. 1498 1499Enumerates the ability subtypes. 1500 1501 **System capability**: SystemCapability.BundleManager.BundleFramework 1502 1503| Name | Value | Description | 1504| ----------- | ---- | ----------------------------- | 1505| UNSPECIFIED | 0 | Undefined ability subtype. | 1506| CA | 1 | Ability that has a UI.| 1507 1508## ColorMode<sup>deprecated<sup> 1509> This API is deprecated since API version 9. You are not advised using it anymore. 1510 1511Enumerates the color modes of applications and widgets. 1512 1513 **System capability**: SystemCapability.BundleManager.BundleFramework 1514 1515| Name | Value | Description | 1516| ---------- | ---- | -------- | 1517| AUTO_MODE | -1 | Auto mode.| 1518| DARK_MODE | 0 | Dark mode.| 1519| LIGHT_MODE | 1 | Light mode.| 1520 1521 1522## GrantStatus<sup>deprecated<sup> 1523 1524> This API is deprecated since API version 9. You are advised to use [bundleManager.PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate) instead. 1525 1526Enumerates the permission grant states. 1527 1528 **System capability**: SystemCapability.BundleManager.BundleFramework 1529 1530| Name | Value | Description | 1531| ------------------ | ---- | ------------ | 1532| PERMISSION_DENIED | -1 | Permission denied.| 1533| PERMISSION_GRANTED | 0 | Permission granted. | 1534