1# @ohos.bundle.bundleManager (bundleManager) (System API) 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 application information, including [BundleInfo](js-apis-bundleManager-bundleInfo.md), [ApplicationInfo](js-apis-bundleManager-ApplicationInfo-sys.md), [AbilityInfo](js-apis-bundleManager-abilityInfo.md), and [ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md). 10 11> **NOTE** 12> 13> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 14> 15> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.bundle.bundleManager](js-apis-bundleManager.md). 16 17## Modules to Import 18 19```ts 20import { bundleManager } from '@kit.AbilityKit'; 21``` 22 23## BundleFlag 24 25Enumerates the bundle flags, which indicate the type of bundle information to obtain. The table below describes only flags available in system APIs. For details about flags available in public APIs, see [BundleFlag](./js-apis-bundleManager.md#bundleflag). 26 27**System capability**: SystemCapability.BundleManager.BundleFramework.Core 28 29| Name | Value | Description | 30| --------------------------------------------- | ---------- | ------------------------------------------------------------ | 31| GET_BUNDLE_INFO_ONLY_WITH_LAUNCHER_ABILITY<sup>12+</sup> | 0x00001000 | Used to obtain the bundle information of the application that has only a home screen icon. It is valid only in the [getAllBundleInfo](#bundlemanagergetallbundleinfo) API.<br>**System API**: This flag can be used only in system APIs.| 32| GET_BUNDLE_INFO_OF_ANY_USER<sup>12+</sup> | 0x00002000 | Used to obtain the bundle information of an application installed by any user. It must be used together with **GET_BUNDLE_INFO_WITH_APPLICATION**. It is valid only in the [getBundleInfo](#bundlemanagergetbundleinfo14) and [getAllBundleInfo](#bundlemanagergetallbundleinfo) APIs.<br>**System API**: This flag can be used only in system APIs.| 33| GET_BUNDLE_INFO_EXCLUDE_CLONE<sup>12+</sup> | 0x00004000 | Used to obtain the bundle information of a main application (excluding its clones). It is valid only in the [getAllBundleInfo](#bundlemanagergetallbundleinfo) API.<br>**System API**: This flag can be used only in system APIs.| 34| GET_BUNDLE_INFO_WITH_CLOUD_KIT<sup>20+</sup> | 0x00008000 | Used to obtain the bundle information of an application that has device-cloud file synchronization or device-cloud structured data synchronization enabled. It is valid only in the [getAllBundleInfo](#bundlemanagergetallbundleinfo) API.<br>**System API**: This flag can be used only in system APIs.| 35 36## ApplicationFlag 37 38Enumerates the application flags, which indicate the type of application information to obtain. 39 40**System capability**: SystemCapability.BundleManager.BundleFramework.Core 41 42**System API**: This is a system API. 43 44| Name | Value | Description | 45| ------------------------------------ | ---------- | ------------------------------------------------------------ | 46| GET_APPLICATION_INFO_DEFAULT | 0x00000000 | Used to obtain the default application information. The obtained information does not contain the permission information or metadata.| 47| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the application information with permission information. | 48| GET_APPLICATION_INFO_WITH_METADATA | 0x00000002 | Used to obtain the application information with metadata. | 49| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000004 | Used to obtain the application information of disabled bundles. | 50 51## AbilityFlag 52 53Enumerates the ability flags, which indicate the type of ability information to obtain. 54 55**System capability**: SystemCapability.BundleManager.BundleFramework.Core 56 57**System API**: This is a system API. 58 59| Name | Value | Description | 60| --------------------------------- | ---------- | ------------------------------------------------------------ | 61| GET_ABILITY_INFO_DEFAULT | 0x00000000 | Used to obtain the default ability information. The obtained information does not contain the permission, metadata, or disabled ability information.| 62| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the ability information with permission information. | 63| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ability information with application information. | 64| GET_ABILITY_INFO_WITH_METADATA | 0x00000004 | Used to obtain the ability information with metadata. | 65| GET_ABILITY_INFO_WITH_DISABLE | 0x00000008 | Used to obtain the ability information of disabled abilities. | 66| GET_ABILITY_INFO_ONLY_SYSTEM_APP | 0x00000010 | Used to obtain the ability information of system applications. | 67| GET_ABILITY_INFO_WITH_APP_LINKING<sup>12+</sup> | 0x00000040 | Used to obtain the ability information filtered by domain name verification. | 68| GET_ABILITY_INFO_WITH_SKILL<sup>12+</sup> | 0x00000080 | Used to obtain the ability information with skills. | 69 70## ExtensionAbilityFlag 71 72Enumerates the ExtensionAbility flags, which indicate the type of ExtensionAbility information to obtain. 73 74**System capability**: SystemCapability.BundleManager.BundleFramework.Core 75 76**System API**: This is a system API. 77 78| Name | Value | Description | 79| ------------------------------------------- | ---------- | ------------------------------------------------------------ | 80| GET_EXTENSION_ABILITY_INFO_DEFAULT | 0x00000000 | Used to obtain the default ExtensionAbility information. The obtained information does not contain the permission, metadata, or disabled ExtensionAbility information.| 81| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the ExtensionAbility information with permission information. | 82| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ExtensionAbility information with application information. | 83| GET_EXTENSION_ABILITY_INFO_WITH_METADATA | 0x00000004 | Used to obtain the ExtensionAbility information with metadata. | 84| GET_EXTENSION_ABILITY_INFO_WITH_SKILL<sup>12+</sup> | 0x00000010 | Used to obtain the ExtensionAbility information with skills. | 85 86## ProfileType<sup>11+</sup> 87 88Enumerates the types of profiles (also called application files). 89 90**System capability**: SystemCapability.BundleManager.BundleFramework.Core 91 92**System API**: This is a system API. 93 94| Name | Value | Description | 95| -------------- | ---- | --------------- | 96| INTENT_PROFILE | 1 | Profile of the InsightIntent framework. | 97 98## AppDistributionType<sup>12+</sup> 99 100Enumerates the application [distribution types](../../security/app-provision-structure.md). 101 102**System capability**: SystemCapability.BundleManager.BundleFramework.Core 103 104**System API**: This is a system API. 105 106| Name | Value | Description | 107| ----------------- | ---- | --------------- | 108| APP_GALLERY | 1 | Application installed from AppGallery. | 109| ENTERPRISE | 2 | Enterprise application that can be installed on personal devices. | 110| ENTERPRISE_NORMAL | 3 | Common enterprise application that can be installed on enterprise devices only through an enterprise mobile device management (MDM) application. | 111| ENTERPRISE_MDM | 4 | Enterprise MDM application that can be installed only on enterprise devices. To install a common enterprise application, you must have [administrator privileges](../apis-mdm-kit/js-apis-enterprise-adminManager-sys.md#adminmanagerenableadmin). | 112| OS_INTEGRATION | 5 | Preinstalled system application. | 113| CROWDTESTING | 6 | Application under crowdtesting, which is distributed by AppGallery to a limited number of users and come with a set expiration date. When the system detects that the validity period of the application expires, it prompts the user to update to the release version available on AppGallery. | 114| NONE | 7 | Other. | 115 116## ApplicationInfoFlag<sup>12+</sup> 117Enumerates the application information flag, which describes the status between an application and user. 118 119**System capability**: SystemCapability.BundleManager.BundleFramework.Core 120 121**System API**: This is a system API. 122 123| Name| Value| Description| 124|----------------|---|---| 125| FLAG_INSTALLED| 0x00000001 | The application is installed for the specified user.| 126| FLAG_OTHER_INSTALLED<sup>15+</sup>| 0x00000010 | The application is installed for users other than the specified user.| 127| FLAG_PREINSTALLED_APP<sup>15+</sup>| 0x00000020 | The application is a preinstalled application.| 128| FLAG_PREINSTALLED_APP_UPDATE<sup>15+</sup>| 0x00000040 | The preinstalled application is updated.| 129 130## bundleManager.getBundleInfo<sup>14+</sup> 131 132getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<BundleInfo>): void 133 134Obtains the bundle information based on the given bundle name, bundle flags, and user ID. 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**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 139 140**System capability**: SystemCapability.BundleManager.BundleFramework.Core 141 142**Parameters** 143 144| Name | Type | Mandatory| Description | 145| ----------- | ------ | ---- | ---------------------------- | 146| bundleName | string | Yes | Bundle name.| 147| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain.| 148| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 149| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| 150 151**Error codes** 152 153For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 154 155| ID| Error Message | 156| -------- | ------------------------------------- | 157| 201 | Permission denied. | 158| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 159| 17700001 | The specified bundleName is not found. | 160| 17700004 | The specified user ID is not found. | 161| 17700026 | The specified bundle is disabled. | 162 163**Example** 164 165```ts 166// Obtain the bundle information with the ability information. 167import { bundleManager } from '@kit.AbilityKit'; 168import { BusinessError } from '@kit.BasicServicesKit'; 169import { hilog } from '@kit.PerformanceAnalysisKit'; 170let bundleName = 'com.example.myapplication'; 171let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY; 172let userId = 100; 173 174try { 175 bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { 176 if (err) { 177 hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message); 178 } else { 179 hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data)); 180 } 181 }); 182} catch (err) { 183 let message = (err as BusinessError).message; 184 hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message); 185} 186``` 187 188```ts 189// Obtain the bundle information with the metadata in the application information. 190import { bundleManager } from '@kit.AbilityKit'; 191import { BusinessError } from '@kit.BasicServicesKit'; 192import { hilog } from '@kit.PerformanceAnalysisKit'; 193let bundleName = 'com.example.myapplication'; 194let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; 195let userId = 100; 196 197try { 198 bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { 199 if (err) { 200 hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message); 201 } else { 202 hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data)); 203 } 204 }); 205} catch (err) { 206 let message = (err as BusinessError).message; 207 hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message); 208} 209``` 210 211## bundleManager.getBundleInfo<sup>14+</sup> 212 213getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void 214 215Obtains the bundle information based on the given bundle name and bundle flags. This API uses an asynchronous callback to return the result. 216 217No permission is required for obtaining the caller's own information. 218 219**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 220 221**System capability**: SystemCapability.BundleManager.BundleFramework.Core 222 223**Parameters** 224 225| Name | Type | Mandatory| Description | 226| ----------- | ------ | ---- | ---------------------------- | 227| bundleName | string | Yes | Bundle name.| 228| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain.| 229| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| 230 231**Error codes** 232 233For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 234 235| ID| Error Message | 236| -------- | ------------------------------------- | 237| 201 | Permission denied. | 238| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 239| 17700001 | The specified bundleName is not found. | 240| 17700026 | The specified bundle is disabled. | 241 242**Example** 243 244```ts 245// Obtain the bundle information with the ExtensionAbility information. 246import { bundleManager } from '@kit.AbilityKit'; 247import { BusinessError } from '@kit.BasicServicesKit'; 248import { hilog } from '@kit.PerformanceAnalysisKit'; 249let bundleName = 'com.example.myapplication'; 250let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; 251 252try { 253 bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => { 254 if (err) { 255 hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', err.message); 256 } else { 257 hilog.info(0x0000, 'testTag', 'getBundleInfo successfully: %{public}s', JSON.stringify(data)); 258 } 259 }); 260} catch (err) { 261 let message = (err as BusinessError).message; 262 hilog.error(0x0000, 'testTag', 'getBundleInfo failed: %{public}s', message); 263} 264``` 265 266## bundleManager.getBundleInfo<sup>14+</sup> 267 268getBundleInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<BundleInfo> 269 270Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses a promise to return the result. 271 272No permission is required for obtaining the caller's own information. 273 274**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 275 276**System capability**: SystemCapability.BundleManager.BundleFramework.Core 277 278**Parameters** 279 280| Name | Type | Mandatory| Description | 281| ----------- | ------ | ---- | ---------------------------- | 282| bundleName | string | Yes | Bundle name.| 283| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 284| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 285 286**Return value** 287 288| Type | Description | 289| ----------------------------------------------------------- | --------------------------- | 290| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.| 291 292**Error codes** 293 294For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 295 296| ID| Error Message | 297| -------- | --------------------------------------| 298| 201 | Permission denied. | 299| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 300| 17700001 | The specified bundleName is not found. | 301| 17700004 | The specified user ID is not found. | 302| 17700026 | The specified bundle is disabled. | 303 304**Example** 305 306```ts 307// Obtain the bundle information with the application and signature information. 308import { bundleManager } from '@kit.AbilityKit'; 309import { BusinessError } from '@kit.BasicServicesKit'; 310import { hilog } from '@kit.PerformanceAnalysisKit'; 311let bundleName = 'com.example.myapplication'; 312let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; 313let userId = 100; 314 315try { 316 bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => { 317 hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); 318 }).catch((err: BusinessError) => { 319 hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message); 320 }); 321} catch (err) { 322 let message = (err as BusinessError).message; 323 hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message); 324} 325``` 326 327```ts 328import { bundleManager } from '@kit.AbilityKit'; 329import { BusinessError } from '@kit.BasicServicesKit'; 330import { hilog } from '@kit.PerformanceAnalysisKit'; 331let bundleName = 'com.example.myapplication'; 332let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 333 334try { 335 bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => { 336 hilog.info(0x0000, 'testTag', 'getBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); 337 }).catch((err: BusinessError) => { 338 hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', err.message); 339 }); 340} catch (err) { 341 let message = (err as BusinessError).message; 342 hilog.error(0x0000, 'testTag', 'getBundleInfo failed. Cause: %{public}s', message); 343} 344 345``` 346 347## bundleManager.getApplicationInfo 348 349getApplicationInfo(bundleName: string, appFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void 350 351Obtains the application information based on the given bundle name, application flags, and user ID. This API uses an asynchronous callback to return the result. 352 353No permission is required for obtaining the caller's own information. 354 355**System API**: This is a system API. 356 357**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 358 359**System capability**: SystemCapability.BundleManager.BundleFramework.Core 360 361**Parameters** 362 363| Name | Type | Mandatory| Description | 364| ---------- | ------ | ---- | ---------------------------- | 365| bundleName | string | Yes | Bundle name.| 366| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 367| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 368| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the application information obtained. Otherwise, **err** is an error object.| 369 370**Error codes** 371 372For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 373 374| ID| Error Message | 375| -------- | --------------------------------------| 376| 201 | Permission denied. | 377| 202 | Permission denied, non-system app called system api. | 378| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 379| 17700001 | The specified bundleName is not found. | 380| 17700004 | The specified user ID is not found. | 381| 17700026 | The specified bundle is disabled. | 382 383**Example** 384 385```ts 386import { bundleManager } from '@kit.AbilityKit'; 387import { BusinessError } from '@kit.BasicServicesKit'; 388import { hilog } from '@kit.PerformanceAnalysisKit'; 389let bundleName = 'com.example.myapplication'; 390let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; 391let userId = 100; 392 393try { 394 bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => { 395 if (err) { 396 hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message); 397 } else { 398 hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data)); 399 } 400 }); 401} catch (err) { 402 let message = (err as BusinessError).message; 403 hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message); 404} 405``` 406 407## bundleManager.getApplicationInfo 408 409getApplicationInfo(bundleName: string, appFlags: number, callback: AsyncCallback\<ApplicationInfo>): void 410 411Obtains the application information based on the given bundle name and application flags. This API uses an asynchronous callback to return the result. 412 413No permission is required for obtaining the caller's own information. 414 415**System API**: This is a system API. 416 417**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 418 419**System capability**: SystemCapability.BundleManager.BundleFramework.Core 420 421**Parameters** 422 423| Name | Type | Mandatory| Description | 424| ---------- | ------ | ---- | ---------------------------- | 425| bundleName | string | Yes | Bundle name.| 426| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 427| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the application information obtained. Otherwise, **err** is an error object.| 428 429**Error codes** 430 431For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 432 433| ID| Error Message | 434| -------- | --------------------------------------| 435| 201 | Permission denied. | 436| 202 | Permission denied, non-system app called system api. | 437| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 438| 17700001 | The specified bundleName is not found. | 439| 17700026 | The specified bundle is disabled. | 440 441**Example** 442 443```ts 444import { bundleManager } from '@kit.AbilityKit'; 445import { BusinessError } from '@kit.BasicServicesKit'; 446import { hilog } from '@kit.PerformanceAnalysisKit'; 447let bundleName = 'com.example.myapplication'; 448let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; 449 450try { 451 bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => { 452 if (err) { 453 hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', err.message); 454 } else { 455 hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully: %{public}s', JSON.stringify(data)); 456 } 457 }); 458} catch (err) { 459 let message = (err as BusinessError).message; 460 hilog.error(0x0000, 'testTag', 'getApplicationInfo failed: %{public}s', message); 461} 462``` 463 464## bundleManager.getApplicationInfo 465 466getApplicationInfo(bundleName: string, appFlags: number, userId?: number): Promise\<ApplicationInfo> 467 468Obtains the application information based on the given bundle name, application flags, and user ID. This API uses a promise to return the result. 469 470No permission is required for obtaining the caller's own information. 471 472**System API**: This is a system API. 473 474**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 475 476**System capability**: SystemCapability.BundleManager.BundleFramework.Core 477 478**Parameters** 479 480| Name | Type | Mandatory| Description | 481| ---------- | ------ | ---- | ---------------------------- | 482| bundleName | string | Yes | Bundle name.| 483| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 484| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0.| 485 486**Return value** 487 488| Type | Description | 489| ------------------------------------------------------------ | -------------------------------- | 490| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise used to return the application information obtained.| 491 492**Error codes** 493 494For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 495 496| ID| Error Message | 497| -------- | ------------------------------------- | 498| 201 | Permission denied. | 499| 202 | Permission denied, non-system app called system api. | 500| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 501| 17700001 | The specified bundleName is not found. | 502| 17700004 | The specified user ID is not found. | 503| 17700026 | The specified bundle is disabled. | 504 505**Example** 506 507```ts 508import { bundleManager } from '@kit.AbilityKit'; 509import { BusinessError } from '@kit.BasicServicesKit'; 510import { hilog } from '@kit.PerformanceAnalysisKit'; 511let bundleName = 'com.example.myapplication'; 512let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; 513let userId = 100; 514 515try { 516 bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => { 517 hilog.info(0x0000, 'testTag', 'getApplicationInfo successfully. Data: %{public}s', JSON.stringify(data)); 518 }).catch((err: BusinessError) => { 519 hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', err.message); 520 }); 521} catch (err) { 522 let message = (err as BusinessError).message; 523 hilog.error(0x0000, 'testTag', 'getApplicationInfo failed. Cause: %{public}s', message); 524} 525``` 526 527## bundleManager.getAllBundleInfo 528 529getAllBundleInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void 530 531Obtains all the bundle information in the system based on the given bundle flags and user ID. This API uses an asynchronous callback to return the result. 532 533**System API**: This is a system API. 534 535**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST 536 537**System capability**: SystemCapability.BundleManager.BundleFramework.Core 538 539**Parameters** 540 541| Name | Type | Mandatory| Description | 542| ----------- | ------ | ---- | -------------------------------------------------- | 543| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 544| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 545| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.| 546 547**Error codes** 548 549For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 550 551| ID| Error Message | 552| -------- | --------------------------------- | 553| 201 | Permission denied. | 554| 202 | Permission denied, non-system app called system api. | 555| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 556| 17700004 | The specified user ID is not found. | 557 558**Example** 559 560```ts 561import { bundleManager } from '@kit.AbilityKit'; 562import { BusinessError } from '@kit.BasicServicesKit'; 563import { hilog } from '@kit.PerformanceAnalysisKit'; 564let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; 565let userId = 100; 566 567try { 568 bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => { 569 if (err) { 570 hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message); 571 } else { 572 hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data)); 573 } 574 }); 575} catch (err) { 576 let message = (err as BusinessError).message; 577 hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message); 578} 579``` 580 581## bundleManager.getAllBundleInfo 582 583getAllBundleInfo(bundleFlags: number, callback: AsyncCallback<Array\<BundleInfo>>): void 584 585Obtains all the bundle information in the system based on the given bundle flags. This API uses an asynchronous callback to return the result. 586 587**System API**: This is a system API. 588 589**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST 590 591**System capability**: SystemCapability.BundleManager.BundleFramework.Core 592 593**Parameters** 594 595| Name | Type | Mandatory| Description | 596| ----------- | ------ | ---- | -------------------------------------------------- | 597| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 598| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.| 599 600**Error codes** 601 602For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 603 604| ID| Error Message | 605| -------- | ---------------------------------- | 606| 201 | Permission denied. | 607| 202 | Permission denied, non-system app called system api. | 608| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 609 610**Example** 611 612```ts 613import { bundleManager } from '@kit.AbilityKit'; 614import { BusinessError } from '@kit.BasicServicesKit'; 615import { hilog } from '@kit.PerformanceAnalysisKit'; 616let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 617 618try { 619 bundleManager.getAllBundleInfo(bundleFlags, (err, data) => { 620 if (err) { 621 hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', err.message); 622 } else { 623 hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully: %{public}s', JSON.stringify(data)); 624 } 625 }); 626} catch (err) { 627 let message = (err as BusinessError).message; 628 hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed: %{public}s', message); 629} 630``` 631 632## bundleManager.getAllBundleInfo 633 634getAllBundleInfo(bundleFlags: number, userId?: number): Promise<Array\<BundleInfo>> 635 636Obtains all the bundle information in the system based on the given bundle flags and user ID. This API uses a promise to return the result. 637 638**System API**: This is a system API. 639 640**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST 641 642**System capability**: SystemCapability.BundleManager.BundleFramework.Core 643 644**Parameters** 645 646| Name | Type | Mandatory| Description | 647| ----------- | ------ | ---- | -------------------------------------------------- | 648| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 649| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 650 651**Return value** 652 653| Type | Description | 654| ------------------------------------------------------------ | ----------------------------------- | 655| Promise<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Promise used to return the array of bundle information obtained.| 656 657**Error codes** 658 659For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 660 661| ID| Error Message | 662| -------- | ---------------------------------- | 663| 201 | Permission denied. | 664| 202 | Permission denied, non-system app called system api. | 665| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 666| 17700004 | The specified user ID is not found. | 667 668**Example** 669 670```ts 671import { bundleManager } from '@kit.AbilityKit'; 672import { BusinessError } from '@kit.BasicServicesKit'; 673import { hilog } from '@kit.PerformanceAnalysisKit'; 674let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 675 676try { 677 bundleManager.getAllBundleInfo(bundleFlags).then((data) => { 678 hilog.info(0x0000, 'testTag', 'getAllBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); 679 }).catch((err: BusinessError) => { 680 hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', err.message); 681 }); 682} catch (err) { 683 let message = (err as BusinessError).message; 684 hilog.error(0x0000, 'testTag', 'getAllBundleInfo failed. Cause: %{public}s', message); 685} 686``` 687 688## bundleManager.getAllApplicationInfo 689 690getAllApplicationInfo(appFlags: number, userId: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void 691 692Obtains all the application information in the system based on the given application flags and user ID. This API uses an asynchronous callback to return the result. 693 694**System API**: This is a system API. 695 696**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST 697 698**System capability**: SystemCapability.BundleManager.BundleFramework.Core 699 700**Parameters** 701 702| Name | Type | Mandatory| Description | 703| -------- | ------ | ---- | ----------------------------------------------------------- | 704| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 705| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 706| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.| 707 708**Error codes** 709 710For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 711 712| ID| Error Message | 713| -------- | ---------------------------------- | 714| 201 | Permission denied. | 715| 202 | Permission denied, non-system app called system api. | 716| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 717| 17700004 | The specified user ID is not found. | 718 719**Example** 720 721```ts 722import { bundleManager } from '@kit.AbilityKit'; 723import { BusinessError } from '@kit.BasicServicesKit'; 724import { hilog } from '@kit.PerformanceAnalysisKit'; 725let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; 726let userId = 100; 727 728try { 729 bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => { 730 if (err) { 731 hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message); 732 } else { 733 hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data)); 734 } 735 }); 736} catch (err) { 737 let message = (err as BusinessError).message; 738 hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message); 739} 740``` 741 742## bundleManager.getAllApplicationInfo 743 744getAllApplicationInfo(appFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>): void 745 746Obtains all the application information in the system based on the given application flags. This API uses an asynchronous callback to return the result. 747 748**System API**: This is a system API. 749 750**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST 751 752**System capability**: SystemCapability.BundleManager.BundleFramework.Core 753 754**Parameters** 755 756| Name | Type | Mandatory| Description | 757| -------- | ------ | ---- | ----------------------------------------------------------- | 758| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 759| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.| 760 761**Error codes** 762 763For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 764 765| ID| Error Message | 766| -------- | ---------------------------------- | 767| 201 | Permission denied. | 768| 202 | Permission denied, non-system app called system api. | 769| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 770 771**Example** 772 773```ts 774import { bundleManager } from '@kit.AbilityKit'; 775import { BusinessError } from '@kit.BasicServicesKit'; 776import { hilog } from '@kit.PerformanceAnalysisKit'; 777let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; 778 779try { 780 bundleManager.getAllApplicationInfo(appFlags, (err, data) => { 781 if (err) { 782 hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', err.message); 783 } else { 784 hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully: %{public}s', JSON.stringify(data)); 785 } 786 }); 787} catch (err) { 788 let message = (err as BusinessError).message; 789 hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed: %{public}s', message); 790} 791``` 792 793## bundleManager.getAllApplicationInfo 794 795getAllApplicationInfo(appFlags: number, userId?: number): Promise<Array\<ApplicationInfo>> 796 797Obtains all the application information in the system based on the given application flags and user ID. This API uses a promise to return the result. 798 799**System API**: This is a system API. 800 801**Required permissions**: ohos.permission.GET_INSTALLED_BUNDLE_LIST 802 803**System capability**: SystemCapability.BundleManager.BundleFramework.Core 804 805**Parameters** 806 807| Name | Type | Mandatory| Description | 808| -------- | ------ | ---- | ---------------------------------------------------------- | 809| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 810| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 811 812**Return value** 813 814| Type | Description | 815| ------------------------------------------------------------ | ---------------------------------------- | 816| Promise<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Promise used to return the array of application information obtained.| 817 818**Error codes** 819 820For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 821 822| ID| Error Message | 823| -------- | ---------------------------------- | 824| 201 | Permission denied. | 825| 202 | Permission denied, non-system app called system api. | 826| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 827| 17700004 | The specified user ID is not found. | 828 829**Example** 830 831```ts 832import { bundleManager } from '@kit.AbilityKit'; 833import { BusinessError } from '@kit.BasicServicesKit'; 834import { hilog } from '@kit.PerformanceAnalysisKit'; 835let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; 836 837try { 838 bundleManager.getAllApplicationInfo(appFlags).then((data) => { 839 hilog.info(0x0000, 'testTag', 'getAllApplicationInfo successfully. Data: %{public}s', JSON.stringify(data)); 840 }).catch((err: BusinessError) => { 841 hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', err.message); 842 }); 843} catch (err) { 844 let message = (err as BusinessError).message; 845 hilog.error(0x0000, 'testTag', 'getAllApplicationInfo failed. Cause: %{public}s', message); 846} 847 848``` 849 850## bundleManager.queryAbilityInfo 851 852queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void 853 854Obtains the ability information based on the given Want, ability flags, and user ID. This API uses an asynchronous callback to return the result. 855 856No permission is required for obtaining the caller's own information. 857 858**System API**: This is a system API. 859 860**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 861 862**System capability**: SystemCapability.BundleManager.BundleFramework.Core 863 864**Parameters** 865 866| Name | Type | Mandatory| Description | 867| ------------ | ------ | ---- | ------------------------------------------------------- | 868| want | Want | Yes | Want containing the bundle name to query. | 869| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain. | 870| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 871| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ability information obtained. Otherwise, **err** is an error object.| 872 873**Error codes** 874 875For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 876 877| ID| Error Message | 878| -------- | -------------------------------------- | 879| 201 | Permission denied. | 880| 202 | Permission denied, non-system app called system api. | 881| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 882| 17700001 | The specified bundleName is not found. | 883| 17700003 | The specified ability is not found. | 884| 17700004 | The specified userId is invalid. | 885| 17700026 | The specified bundle is disabled. | 886| 17700029 | The specified ability is disabled. | 887 888**Example** 889 890```ts 891import { bundleManager } from '@kit.AbilityKit'; 892import { BusinessError } from '@kit.BasicServicesKit'; 893import { hilog } from '@kit.PerformanceAnalysisKit'; 894import { Want } from '@kit.AbilityKit'; 895let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 896let userId = 100; 897let want: Want = { 898 bundleName : "com.example.myapplication", 899 abilityName : "EntryAbility" 900}; 901 902try { 903 bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => { 904 if (err) { 905 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message); 906 } else { 907 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data)); 908 } 909 }); 910} catch (err) { 911 let message = (err as BusinessError).message; 912 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message); 913} 914``` 915 916## bundleManager.queryAbilityInfo 917 918queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback<Array\<AbilityInfo>>): void 919 920Obtains the ability information based on the given Want and ability flags. This API uses an asynchronous callback to return the result. 921 922No permission is required for obtaining the caller's own information. 923 924**System API**: This is a system API. 925 926**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 927 928**System capability**: SystemCapability.BundleManager.BundleFramework.Core 929 930**Parameters** 931 932| Name | Type | Mandatory| Description | 933| ------------ | ------ | ---- | -------------------------------------------------------| 934| want | Want | Yes | Want containing the bundle name to query. | 935| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain. | 936| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ability information obtained. Otherwise, **err** is an error object.| 937 938**Error codes** 939 940For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 941 942| ID| Error Message | 943| -------- | -------------------------------------- | 944| 201 | Permission denied. | 945| 202 | Permission denied, non-system app called system api. | 946| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 947| 17700001 | The specified bundleName is not found. | 948| 17700003 | The specified ability is not found. | 949| 17700026 | The specified bundle is disabled. | 950| 17700029 | The specified ability is disabled. | 951 952**Example** 953 954```ts 955import { bundleManager } from '@kit.AbilityKit'; 956import { BusinessError } from '@kit.BasicServicesKit'; 957import { hilog } from '@kit.PerformanceAnalysisKit'; 958import { Want } from '@kit.AbilityKit'; 959let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 960let want: Want = { 961 bundleName : "com.example.myapplication", 962 abilityName : "EntryAbility" 963}; 964 965try { 966 bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => { 967 if (err) { 968 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', err.message); 969 } else { 970 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully: %{public}s', JSON.stringify(data)); 971 } 972 }); 973} catch (err) { 974 let message = (err as BusinessError).message; 975 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed: %{public}s', message); 976} 977``` 978 979## bundleManager.queryAbilityInfo 980 981queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise<Array\<AbilityInfo>> 982 983Obtains the ability information based on the given Want, ability flags, and user ID. This API uses a promise to return the result. 984 985No permission is required for obtaining the caller's own information. 986 987**System API**: This is a system API. 988 989**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 990 991**System capability**: SystemCapability.BundleManager.BundleFramework.Core 992 993**Parameters** 994 995| Name | Type | Mandatory| Description | 996| ------------ | ------ | ---- | ------------------------------------------------------- | 997| want | Want | Yes | Want containing the bundle name to query. | 998| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain.| 999| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 1000 1001**Return value** 1002 1003| Type | Description | 1004| ------------------------------------------------------------ | ------------------------------------ | 1005| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise used to return the array of ability information obtained.| 1006 1007**Error codes** 1008 1009For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1010 1011| ID| Error Message | 1012| -------- | ------------------------------------- | 1013| 201 | Permission denied. | 1014| 202 | Permission denied, non-system app called system api. | 1015| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1016| 17700001 | The specified bundleName is not found. | 1017| 17700003 | The specified ability is not found. | 1018| 17700004 | The specified userId is invalid. | 1019| 17700026 | The specified bundle is disabled. | 1020| 17700029 | The specified ability is disabled. | 1021 1022**Example** 1023 1024```ts 1025import { bundleManager } from '@kit.AbilityKit'; 1026import { BusinessError } from '@kit.BasicServicesKit'; 1027import { hilog } from '@kit.PerformanceAnalysisKit'; 1028import { Want } from '@kit.AbilityKit'; 1029let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 1030let userId = 100; 1031let want: Want = { 1032 bundleName : "com.example.myapplication", 1033 abilityName : "EntryAbility" 1034}; 1035 1036try { 1037 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => { 1038 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); 1039 }).catch((err: BusinessError) => { 1040 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 1041 }); 1042} catch (err) { 1043 let message = (err as BusinessError).message; 1044 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 1045} 1046``` 1047 1048```ts 1049import { bundleManager } from '@kit.AbilityKit'; 1050import { BusinessError } from '@kit.BasicServicesKit'; 1051import { hilog } from '@kit.PerformanceAnalysisKit'; 1052import { Want } from '@kit.AbilityKit'; 1053let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 1054let want: Want = { 1055 bundleName : "com.example.myapplication", 1056 abilityName : "EntryAbility" 1057}; 1058 1059try { 1060 bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => { 1061 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); 1062 }).catch((err: BusinessError) => { 1063 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 1064 }) 1065} catch (err) { 1066 let message = (err as BusinessError).message; 1067 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 1068} 1069``` 1070 1071## bundleManager.queryAbilityInfoSync<sup>10+</sup> 1072 1073queryAbilityInfoSync(want: Want, abilityFlags: number, userId?: number): Array\<AbilityInfo> 1074 1075Obtains the ability information based on the given want, ability flags, and user ID. This API returns the result synchronously. 1076 1077No permission is required for obtaining the caller's own information. 1078 1079**System API**: This is a system API. 1080 1081**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1082 1083**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1084 1085**Parameters** 1086 1087| Name | Type | Mandatory| Description | 1088| ------------ | ------ | ---- | ------------------------------------------------------- | 1089| want | Want | Yes | Want containing the bundle name to query. | 1090| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain.| 1091| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 1092 1093**Return value** 1094 1095| Type | Description | 1096| ------------------------------------------------------------ | ------------------------------------ | 1097| Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | An array of ability information.| 1098 1099**Error codes** 1100 1101For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1102 1103| ID| Error Message | 1104| -------- | ------------------------------------- | 1105| 201 | Permission denied. | 1106| 202 | Permission denied, non-system app called system api. | 1107| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1108| 17700001 | The specified bundleName is not found. | 1109| 17700003 | The specified ability is not found. | 1110| 17700004 | The specified userId is invalid. | 1111| 17700026 | The specified bundle is disabled. | 1112| 17700029 | The specified ability is disabled. | 1113 1114**Example** 1115 1116```ts 1117import { bundleManager } from '@kit.AbilityKit'; 1118import { BusinessError } from '@kit.BasicServicesKit'; 1119import { hilog } from '@kit.PerformanceAnalysisKit'; 1120import { Want } from '@kit.AbilityKit'; 1121let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 1122let userId = 100; 1123let want: Want = { 1124 bundleName : "com.example.myapplication", 1125 abilityName : "EntryAbility" 1126}; 1127 1128try { 1129 1130 let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags, userId); 1131 hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos)); 1132} catch (err) { 1133 let message = (err as BusinessError).message; 1134 hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message); 1135} 1136``` 1137 1138```ts 1139import { bundleManager } from '@kit.AbilityKit'; 1140import { BusinessError } from '@kit.BasicServicesKit'; 1141import { hilog } from '@kit.PerformanceAnalysisKit'; 1142import { Want } from '@kit.AbilityKit'; 1143let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 1144let want: Want = { 1145 bundleName : "com.example.myapplication", 1146 abilityName : "EntryAbility" 1147}; 1148 1149try { 1150 let infos = bundleManager.queryAbilityInfoSync(want, abilityFlags); 1151 hilog.info(0x0000, 'testTag', 'queryAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(infos)); 1152} catch (err) { 1153 let message = (err as BusinessError).message; 1154 hilog.error(0x0000, 'testTag', 'queryAbilityInfoSync failed. Cause: %{public}s', message); 1155} 1156``` 1157 1158## bundleManager.queryAbilityInfo<sup>12+</sup> 1159 1160queryAbilityInfo(wants: Array\<Want>, abilityFlags: number, userId?: number): Promise<Array\<AbilityInfo>> 1161 1162Obtains the ability information based on the given Want list, ability flags, and user ID. This API uses a promise to return the result. 1163 1164No permission is required for obtaining the caller's own information. 1165 1166**System API**: This is a system API. 1167 1168**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1169 1170**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1171 1172**Parameters** 1173 1174| Name | Type | Mandatory| Description | 1175| ------------ | ------ | ---- | ------------------------------------------------------- | 1176| want | Array\<Want> | Yes | List of want containing the bundle name to query. | 1177| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain.| 1178| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 1179 1180**Return value** 1181 1182| Type | Description | 1183| ------------------------------------------------------------ | ------------------------------------ | 1184| Promise<Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)>> | Promise used to return an array of [AbilityInfo](js-apis-bundleManager-abilityInfo.md) object.| 1185 1186**Error codes** 1187 1188For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1189 1190| ID| Error Message | 1191| -------- | ------------------------------------- | 1192| 201 | Permission denied. | 1193| 202 | Permission denied, non-system app called system api. | 1194| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1195| 17700001 | The specified bundleName is not found. | 1196| 17700003 | The specified ability is not found. | 1197| 17700004 | The specified userId is invalid. | 1198| 17700026 | The specified bundle is disabled. | 1199| 17700029 | The specified ability is disabled. | 1200 1201**Example** 1202 1203```ts 1204import { bundleManager } from '@kit.AbilityKit'; 1205import { BusinessError } from '@kit.BasicServicesKit'; 1206import { hilog } from '@kit.PerformanceAnalysisKit'; 1207import { Want } from '@kit.AbilityKit'; 1208let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 1209let userId = 100; 1210let want: Want = { 1211 bundleName : "com.example.myapplication1", 1212 abilityName : "EntryAbility" 1213}; 1214let want1: Want = { 1215 bundleName : "com.example.myapplication2", 1216 abilityName : "EntryAbility" 1217}; 1218let wants: Array<Want> = [ want, want1 ]; 1219 try { 1220 bundleManager.queryAbilityInfo(wants, abilityFlags, userId).then((data) => { 1221 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); 1222 }).catch((err: BusinessError) => { 1223 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 1224 }) 1225 } catch (err) { 1226 let message = (err as BusinessError).message; 1227 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 1228 } 1229``` 1230 1231## bundleManager.queryExtensionAbilityInfo 1232 1233queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void 1234 1235Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API uses an asynchronous callback to return the result. 1236 1237No permission is required for obtaining the caller's own information. 1238 1239**System API**: This is a system API. 1240 1241**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1242 1243**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1244 1245**Parameters** 1246 1247| Name | Type | Mandatory| Description | 1248| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 1249| want | Want | Yes | Want containing the bundle name to query. | 1250| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | Type of the ExtensionAbility. | 1251| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the ExtensionAbility information to obtain. | 1252| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 1253| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ExtensionAbility information obtained. Otherwise, **err** is an error object.| 1254 1255**Error codes** 1256 1257For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1258 1259| ID| Error Message | 1260| -------- | ------------------------------------------- | 1261| 201 | Permission denied. | 1262| 202 | Permission denied, non-system app called system api. | 1263| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1264| 17700001 | The specified bundleName is not found. | 1265| 17700003 | The specified extensionAbility is not found. | 1266| 17700004 | The specified userId is invalid. | 1267| 17700026 | The specified bundle is disabled. | 1268 1269**Example** 1270 1271```ts 1272import { bundleManager } from '@kit.AbilityKit'; 1273import { BusinessError } from '@kit.BasicServicesKit'; 1274import { hilog } from '@kit.PerformanceAnalysisKit'; 1275import { Want } from '@kit.AbilityKit'; 1276let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; 1277let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 1278let userId = 100; 1279let want: Want = { 1280 bundleName : "com.example.myapplication", 1281 abilityName : "EntryAbility" 1282}; 1283 1284try { 1285 bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => { 1286 if (err) { 1287 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message); 1288 } else { 1289 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data)); 1290 } 1291 }); 1292} catch (err) { 1293 let message = (err as BusinessError).message; 1294 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message); 1295} 1296``` 1297 1298## bundleManager.queryExtensionAbilityInfo 1299 1300queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void 1301 1302Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, and ExtensionAbility flags. This API uses an asynchronous callback to return the result. 1303 1304No permission is required for obtaining the caller's own information. 1305 1306**System API**: This is a system API. 1307 1308**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1309 1310**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1311 1312**Parameters** 1313 1314| Name | Type | Mandatory| Description | 1315| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 1316| want | Want | Yes | Want containing the bundle name to query. | 1317| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | Type of the ExtensionAbility. | 1318| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the ExtensionAbility information to obtain. | 1319| callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ExtensionAbility information obtained. Otherwise, **err** is an error object.| 1320 1321**Error codes** 1322 1323For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1324 1325| ID| Error Message | 1326| -------- | -------------------------------------------- | 1327| 201 | Permission denied. | 1328| 202 | Permission denied, non-system app called system api. | 1329| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1330| 17700001 | The specified bundleName is not found. | 1331| 17700003 | The specified extensionAbility is not found. | 1332| 17700026 | The specified bundle is disabled. | 1333 1334**Example** 1335 1336```ts 1337import { bundleManager } from '@kit.AbilityKit'; 1338import { BusinessError } from '@kit.BasicServicesKit'; 1339import { hilog } from '@kit.PerformanceAnalysisKit'; 1340import { Want } from '@kit.AbilityKit'; 1341let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; 1342let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 1343let want: Want = { 1344 bundleName : "com.example.myapplication", 1345 abilityName : "EntryAbility" 1346}; 1347 1348try { 1349 bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => { 1350 if (err) { 1351 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', err.message); 1352 } else { 1353 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully: %{public}s', JSON.stringify(data)); 1354 } 1355 }); 1356} catch (err) { 1357 let message = (err as BusinessError).message; 1358 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed: %{public}s', message); 1359} 1360``` 1361 1362## bundleManager.queryExtensionAbilityInfo 1363 1364queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId?: number): Promise<Array\<ExtensionAbilityInfo>> 1365 1366Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API uses a promise to return the result. 1367 1368No permission is required for obtaining the caller's own information. 1369 1370**System API**: This is a system API. 1371 1372**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1373 1374**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1375 1376**Parameters** 1377 1378| Name | Type | Mandatory| Description | 1379| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- | 1380| want | Want | Yes | Want containing the bundle name to query. | 1381| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | Type of the ExtensionAbility. | 1382| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the ExtensionAbility information to obtain.| 1383| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 1384 1385**Return value** 1386 1387| Type | Description | 1388| ------------------------------------------------------------ | --------------------------------------------- | 1389| Promise<Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)>> | Promise used to return the array of ExtensionAbility information obtained.| 1390 1391**Error codes** 1392 1393For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1394 1395| ID| Error Message | 1396| -------- | --------------------------------------| 1397| 201 | Permission denied. | 1398| 202 | Permission denied, non-system app called system api. | 1399| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1400| 17700001 | The specified bundleName is not found. | 1401| 17700003 | The specified extensionAbility is not found. | 1402| 17700004 | The specified userId is invalid. | 1403| 17700026 | The specified bundle is disabled. | 1404 1405**Example** 1406 1407```ts 1408import { bundleManager } from '@kit.AbilityKit'; 1409import { BusinessError } from '@kit.BasicServicesKit'; 1410import { hilog } from '@kit.PerformanceAnalysisKit'; 1411import { Want } from '@kit.AbilityKit'; 1412 1413let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; 1414let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 1415let userId = 100; 1416let want: Want = { 1417 bundleName : "com.example.myapplication", 1418 abilityName : "EntryAbility" 1419}; 1420 1421try { 1422 bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => { 1423 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); 1424 }).catch((err: BusinessError) => { 1425 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message); 1426 }); 1427} catch (err) { 1428 let message = (err as BusinessError).message; 1429 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message); 1430} 1431``` 1432 1433```ts 1434import { bundleManager } from '@kit.AbilityKit'; 1435import { BusinessError } from '@kit.BasicServicesKit'; 1436import { hilog } from '@kit.PerformanceAnalysisKit'; 1437import { Want } from '@kit.AbilityKit'; 1438let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; 1439let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 1440let want: Want = { 1441 bundleName : "com.example.myapplication", 1442 abilityName : "EntryAbility" 1443}; 1444 1445try { 1446 bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => { 1447 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfo successfully. Data: %{public}s', JSON.stringify(data)); 1448 }).catch((err: BusinessError) => { 1449 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', err.message); 1450 }) 1451} catch (err) { 1452 let message = (err as BusinessError).message; 1453 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfo failed. Cause: %{public}s', message); 1454} 1455``` 1456 1457## bundleManager.queryExtensionAbilityInfoSync<sup>10+</sup> 1458 1459queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId?: number): Array\<ExtensionAbilityInfo> 1460 1461Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API returns the result synchronously. 1462 1463No permission is required for obtaining the caller's own information. 1464 1465**System API**: This is a system API. 1466 1467**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1468 1469**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1470 1471**Parameters** 1472 1473| Name | Type | Mandatory| Description | 1474| --------------------- | --------------------------------------------- | ---- | --------------------------------------------------------- | 1475| want | Want | Yes | Want containing the bundle name to query. | 1476| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | Type of the ExtensionAbility. | 1477| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the ExtensionAbility information to obtain.| 1478| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 1479 1480**Return value** 1481 1482| Type | Description | 1483| ------------------------------------------------------------ | --------------------------------------------- | 1484| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of ExtensionAbility information.| 1485 1486**Error codes** 1487 1488For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1489 1490| ID| Error Message | 1491| -------- | --------------------------------------| 1492| 201 | Permission denied. | 1493| 202 | Permission denied, non-system app called system api. | 1494| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 1495| 17700001 | The specified bundleName is not found. | 1496| 17700003 | The specified extensionAbility is not found. | 1497| 17700004 | The specified userId is invalid. | 1498| 17700026 | The specified bundle is disabled. | 1499 1500**Example** 1501 1502```ts 1503import { bundleManager } from '@kit.AbilityKit'; 1504import { BusinessError } from '@kit.BasicServicesKit'; 1505import { hilog } from '@kit.PerformanceAnalysisKit'; 1506import { Want } from '@kit.AbilityKit'; 1507 1508let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; 1509let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 1510let userId = 100; 1511let want: Want = { 1512 bundleName : "com.example.myapplication", 1513 abilityName : "EntryAbility" 1514}; 1515 1516try { 1517 let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId); 1518 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos)); 1519} catch (err) { 1520 let message = (err as BusinessError).message; 1521 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message); 1522} 1523``` 1524 1525```ts 1526import { bundleManager } from '@kit.AbilityKit'; 1527import { BusinessError } from '@kit.BasicServicesKit'; 1528import { hilog } from '@kit.PerformanceAnalysisKit'; 1529import { Want } from '@kit.AbilityKit'; 1530let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; 1531let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 1532let want: Want = { 1533 bundleName : "com.example.myapplication", 1534 abilityName : "EntryAbility" 1535}; 1536 1537try { 1538 let extenInfos = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags); 1539 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(extenInfos)); 1540} catch (err) { 1541 let message = (err as BusinessError).message; 1542 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed. Cause: %{public}s', message); 1543} 1544``` 1545 1546## bundleManager.getBundleNameByUid<sup>14+</sup> 1547 1548getBundleNameByUid(uid: number, callback: AsyncCallback\<string>): void 1549 1550Obtains the bundle name based on the given UID. This API uses an asynchronous callback to return the result. 1551 1552**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1553 1554**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1555 1556**Parameters** 1557 1558| Name | Type | Mandatory| Description | 1559| -------- | ---------------------- | ---- | ------------------------------------------------------------ | 1560| uid | number | Yes | UID of the application. | 1561| callback | AsyncCallback\<string> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle name obtained. Otherwise, **err** is an error object.| 1562 1563**Error codes** 1564 1565For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1566 1567| ID| Error Message | 1568| -------- | --------------------- | 1569| 201 | Permission denied. | 1570| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1571| 17700021 | The uid is not found. | 1572 1573**Example** 1574 1575```ts 1576import { bundleManager } from '@kit.AbilityKit'; 1577import { BusinessError } from '@kit.BasicServicesKit'; 1578import { hilog } from '@kit.PerformanceAnalysisKit'; 1579let uid = 20010005; 1580try { 1581 bundleManager.getBundleNameByUid(uid, (err, data) => { 1582 if (err) { 1583 hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', err.message); 1584 } else { 1585 hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully: %{public}s', JSON.stringify(data)); 1586 } 1587 }); 1588} catch (err) { 1589 let message = (err as BusinessError).message; 1590 hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed: %{public}s', message); 1591} 1592``` 1593 1594## bundleManager.getBundleNameByUid<sup>14+</sup> 1595 1596getBundleNameByUid(uid: number): Promise\<string> 1597 1598Obtains the bundle name based on the given UID. This API uses a promise to return the result. 1599 1600**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1601 1602**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1603 1604**Parameters** 1605 1606| Name| Type | Mandatory| Description | 1607| ---- | ------ | ---- | ------------------ | 1608| uid | number | Yes | UID of the application.| 1609 1610**Return value** 1611 1612| Type | Description | 1613| ---------------- | --------------------------- | 1614| Promise\<string> | Promise used to return the bundle name obtained.| 1615 1616**Error codes** 1617 1618For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1619 1620| ID| Error Message | 1621| -------- | ---------------------| 1622| 201 | Permission denied. | 1623| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1624| 17700021 | The uid is not found. | 1625 1626**Example** 1627 1628```ts 1629import { bundleManager } from '@kit.AbilityKit'; 1630import { BusinessError } from '@kit.BasicServicesKit'; 1631import { hilog } from '@kit.PerformanceAnalysisKit'; 1632let uid = 20010005; 1633try { 1634 bundleManager.getBundleNameByUid(uid).then((data) => { 1635 hilog.info(0x0000, 'testTag', 'getBundleNameByUid successfully. Data: %{public}s', JSON.stringify(data)); 1636 }).catch((err: BusinessError) => { 1637 hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', err.message); 1638 }); 1639} catch (err) { 1640 let message = (err as BusinessError).message; 1641 hilog.error(0x0000, 'testTag', 'getBundleNameByUid failed. Cause: %{public}s', message); 1642} 1643``` 1644 1645## bundleManager.getBundleNameByUidSync<sup>14+</sup> 1646 1647getBundleNameByUidSync(uid: number): string 1648 1649Obtains the bundle name based on the given UID. This API returns the result synchronously. 1650 1651**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 1652 1653**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1654 1655**Parameters** 1656 1657| Name| Type | Mandatory| Description | 1658| ---- | ------ | ---- | ------------------ | 1659| uid | number | Yes | UID of the application.| 1660 1661**Return value** 1662 1663| Type | Description | 1664| ---------------- | --------------------------- | 1665| string | Bundle name obtained.| 1666 1667**Error codes** 1668 1669For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1670 1671| ID| Error Message | 1672| -------- | ---------------------| 1673| 201 | Permission denied. | 1674| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1675| 17700021 | The uid is not found. | 1676 1677**Example** 1678 1679```ts 1680import { bundleManager } from '@kit.AbilityKit'; 1681import { BusinessError } from '@kit.BasicServicesKit'; 1682import { hilog } from '@kit.PerformanceAnalysisKit'; 1683let uid = 20010005; 1684try { 1685 let data = bundleManager.getBundleNameByUidSync(uid); 1686 hilog.info(0x0000, 'testTag', 'getBundleNameByUidSync successfully. Data: %{public}s', JSON.stringify(data)); 1687} catch (err) { 1688 let message = (err as BusinessError).message; 1689 hilog.error(0x0000, 'testTag', 'getBundleNameByUidSync failed. Cause: %{public}s', message); 1690} 1691``` 1692 1693## bundleManager.getBundleArchiveInfo 1694 1695getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void 1696 1697Obtains the bundle information based on the given HAP file path and bundle flags. This API uses an asynchronous callback to return the result. 1698 1699**System API**: This is a system API. 1700 1701**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1702 1703**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1704 1705**Parameters** 1706 1707| Name | Type | Mandatory| Description | 1708| ----------- | ------ | ---- | ----------------------------------------------------------- | 1709| hapFilePath | string | Yes | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.| 1710| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 1711| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| 1712 1713**Error codes** 1714 1715For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1716 1717| ID| Error Message | 1718| -------- | --------------------------- | 1719| 201 | Permission denied. | 1720| 202 | Permission denied, non-system app called system api. | 1721| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1722| 17700022 | The hapFilePath is invalid. | 1723 1724**Example** 1725 1726```ts 1727import { bundleManager } from '@kit.AbilityKit'; 1728import { BusinessError } from '@kit.BasicServicesKit'; 1729import { hilog } from '@kit.PerformanceAnalysisKit'; 1730let hapFilePath = "/data/xxx/test.hap"; 1731let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 1732 1733try { 1734 bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { 1735 if (err) { 1736 hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message); 1737 } else { 1738 hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully: %{public}s', JSON.stringify(data)); 1739 } 1740 }); 1741} catch (err) { 1742 let message = (err as BusinessError).message; 1743 hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message); 1744} 1745``` 1746 1747## bundleManager.getBundleArchiveInfo 1748 1749getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise\<BundleInfo> 1750 1751Obtains the bundle information based on the given HAP file path and bundle flags. This API uses a promise to return the result. 1752 1753**System API**: This is a system API. 1754 1755**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1756 1757**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1758 1759**Parameters** 1760 1761| Name | Type | Mandatory| Description | 1762| ----------- | ------ | ---- | ------------------------------------------------------------ | 1763| hapFilePath | string | Yes | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.| 1764| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 1765 1766**Return value** 1767 1768| Type | Description | 1769| ----------------------------------------------------------- | --------------------------- | 1770| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.| 1771 1772**Error codes** 1773 1774For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1775 1776| ID| Error Message | 1777| -------- | -------------------------- | 1778| 201 | Permission denied. | 1779| 202 | Permission denied, non-system app called system api. | 1780| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1781| 17700022 | The hapFilePath is invalid. | 1782 1783**Example** 1784 1785```ts 1786import { bundleManager } from '@kit.AbilityKit'; 1787import { BusinessError } from '@kit.BasicServicesKit'; 1788import { hilog } from '@kit.PerformanceAnalysisKit'; 1789let hapFilePath = "/data/xxx/test.hap"; 1790let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 1791 1792try { 1793 bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => { 1794 hilog.info(0x0000, 'testTag', 'getBundleArchiveInfo successfully. Data: %{public}s', JSON.stringify(data)); 1795 }).catch((err: BusinessError) => { 1796 hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', err.message); 1797 }); 1798} catch (err) { 1799 let message = (err as BusinessError).message; 1800 hilog.error(0x0000, 'testTag', 'getBundleArchiveInfo failed. Cause: %{public}s', message); 1801} 1802``` 1803 1804## bundleManager.getBundleArchiveInfoSync<sup>10+</sup> 1805 1806getBundleArchiveInfoSync(hapFilePath: string, bundleFlags: number): BundleInfo 1807 1808Obtains the bundle information based on the given HAP file path and bundle flags. This API returns the result synchronously. 1809 1810**System API**: This is a system API. 1811 1812**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1813 1814**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1815 1816**Parameters** 1817 1818| Name | Type | Mandatory| Description | 1819| ----------- | ------ | ---- | ------------------------------------------------------------ | 1820| hapFilePath | string | Yes | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.| 1821| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 1822 1823**Return value** 1824 1825| Type | Description | 1826| ----------------------------------------------------------- | --------------------------- | 1827| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| 1828 1829**Error codes** 1830 1831For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1832 1833| ID| Error Message | 1834| -------- | -------------------------- | 1835| 201 | Permission denied. | 1836| 202 | Permission denied, non-system app called system api. | 1837| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1838| 17700022 | The hapFilePath is invalid. | 1839 1840**Example** 1841 1842```ts 1843import { bundleManager } from '@kit.AbilityKit'; 1844import { BusinessError } from '@kit.BasicServicesKit'; 1845import { hilog } from '@kit.PerformanceAnalysisKit'; 1846let hapFilePath = "/data/xxx/test.hap"; 1847let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 1848 1849try { 1850 let data = bundleManager.getBundleArchiveInfoSync(hapFilePath, bundleFlags) 1851 hilog.info(0x0000, 'testTag', 'getBundleArchiveInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 1852} catch (err) { 1853 let message = (err as BusinessError).message; 1854 hilog.error(0x0000, 'testTag', 'getBundleArchiveInfoSync failed. Cause: %{public}s', message); 1855} 1856``` 1857 1858## bundleManager.getAllBundleCacheSize<sup>15+</sup> 1859 1860getAllBundleCacheSize(): Promise\<number> 1861 1862Obtains the global cache size. This API uses a promise to return the result. 1863 1864It is not possible to obtain the cache of applications that are currently running or have been granted the "AllowAppDataNotCleared" privilege as specified in the [application configuration guide](../../../device-dev/subsystems/subsys-app-privilege-config-guide.md). 1865 1866**System API**: This is a system API. 1867 1868**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1869 1870**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1871 1872**Return value** 1873 1874| Type | Description | 1875| ---------------------------------------- | ------- | 1876| Promise\<number> | Promise used to return the size of the global cache, in bytes.| 1877 1878**Error codes** 1879 1880For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1881 1882| ID| Error Message | 1883| -------- | ---------------------------------------------------------- | 1884| 201 | Permission denied. | 1885| 202 | Permission denied, non-system app called system api. | 1886 1887**Example** 1888 1889```ts 1890import { bundleManager } from '@kit.AbilityKit'; 1891import { BusinessError } from '@kit.BasicServicesKit'; 1892import { hilog } from '@kit.PerformanceAnalysisKit'; 1893 1894try { 1895 bundleManager.getAllBundleCacheSize().then((data) => { 1896 hilog.info(0x0000, 'testTag','getAllBundleCacheSize successful. Data: ' + JSON.stringify(data)); 1897 }).catch((err: BusinessError) => { 1898 hilog.error(0x0000, 'testTag', 'getAllBundleCacheSize failed: %{public}s', err.message); 1899 }); 1900} catch (err) { 1901 let message = (err as BusinessError).message; 1902 hilog.error(0x0000, 'testTag', 'getAllBundleCacheSize failed: %{public}s', message); 1903} 1904``` 1905 1906## bundleManager.cleanAllBundleCache<sup>15+</sup> 1907 1908cleanAllBundleCache(): Promise\<void> 1909 1910Clears the global cache. This API uses a promise to return the result. 1911 1912**System API**: This is a system API. 1913 1914**Required permissions**: ohos.permission.REMOVE_CACHE_FILES 1915 1916**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1917 1918**Return value** 1919 1920| Type | Description | 1921| ---------------------------------------- | ------- | 1922| Promise\<void> | Promise that returns no value.| 1923 1924**Error codes** 1925 1926For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1927 1928| ID| Error Message | 1929| -------- | ---------------------------------------------------------- | 1930| 201 | Permission denied. | 1931| 202 | Permission denied, non-system app called system api. | 1932 1933**Example** 1934 1935```ts 1936import { bundleManager } from '@kit.AbilityKit'; 1937import { BusinessError } from '@kit.BasicServicesKit'; 1938import { hilog } from '@kit.PerformanceAnalysisKit'; 1939 1940try { 1941 bundleManager.cleanAllBundleCache().then((data) => { 1942 hilog.info(0x0000, 'testTag','cleanAllBundleCache successful.'); 1943 }).catch((err: BusinessError) => { 1944 hilog.error(0x0000, 'testTag', 'cleanAllBundleCache failed: %{public}s', err.message); 1945 }); 1946} catch (err) { 1947 let message = (err as BusinessError).message; 1948 hilog.error(0x0000, 'testTag', 'cleanAllBundleCache failed: %{public}s', message); 1949} 1950``` 1951 1952## bundleManager.cleanBundleCacheFiles 1953 1954cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void 1955 1956Clears the bundle cache based on the given bundle name. This API uses an asynchronous callback to return the result. 1957 1958No permission is required when the caller clears its own cache. 1959 1960**System API**: This is a system API. 1961 1962**Required permissions**: ohos.permission.REMOVE_CACHE_FILES 1963 1964**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1965 1966**Parameters** 1967 1968| Name | Type | Mandatory| Description | 1969| ---------- | -------------------- | ---- | ------------------------------------------------------------ | 1970| bundleName | string | Yes | Bundle name. | 1971| callback | AsyncCallback\<void> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 1972 1973**Error codes** 1974 1975For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1976 1977| ID| Error Message | 1978| -------- | ------------------------------------------------------------ | 1979| 201 | Permission denied. | 1980| 202 | Permission denied, non-system app called system api. | 1981| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1982| 17700001 | The specified bundleName is not found. | 1983| 17700030 | The specified bundle does not support clearing of cache files. | 1984 1985**Example** 1986 1987```ts 1988import { bundleManager } from '@kit.AbilityKit'; 1989import { BusinessError } from '@kit.BasicServicesKit'; 1990import { hilog } from '@kit.PerformanceAnalysisKit'; 1991let bundleName = "com.ohos.myapplication"; 1992 1993try { 1994 bundleManager.cleanBundleCacheFiles(bundleName, err => { 1995 if (err) { 1996 hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message); 1997 } else { 1998 hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.'); 1999 } 2000 }); 2001} catch (err) { 2002 let message = (err as BusinessError).message; 2003 hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message); 2004} 2005``` 2006 2007## bundleManager.cleanBundleCacheFiles 2008 2009cleanBundleCacheFiles(bundleName: string): Promise\<void> 2010 2011Clears the bundle cache based on the given bundle name. This API uses a promise to return the result. 2012 2013No permission is required when the caller clears its own cache. 2014 2015**System API**: This is a system API. 2016 2017**Required permissions**: ohos.permission.REMOVE_CACHE_FILES 2018 2019**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2020 2021**Parameters** 2022 2023| Name | Type | Mandatory| Description | 2024| ---------- | ------ | ---- | ------------------------------------------ | 2025| bundleName | string | Yes | Bundle name.| 2026 2027**Return value** 2028 2029| Type | Description | 2030| -------------- | ------------------------------------------------------------ | 2031| Promise\<void> | Promise that returns no value. If clearing the cache files fails, an error object is thrown.| 2032 2033**Error codes** 2034 2035For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2036 2037| ID| Error Message | 2038| -------- | ---------------------------------------------------------- | 2039| 201 | Permission denied. | 2040| 202 | Permission denied, non-system app called system api. | 2041| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2042| 17700001 | The specified bundleName is not found. | 2043| 17700030 | The specified bundle does not support clearing of cache files. | 2044 2045**Example** 2046 2047```ts 2048import { bundleManager } from '@kit.AbilityKit'; 2049import { BusinessError } from '@kit.BasicServicesKit'; 2050import { hilog } from '@kit.PerformanceAnalysisKit'; 2051let bundleName = "com.ohos.myapplication"; 2052 2053try { 2054 bundleManager.cleanBundleCacheFiles(bundleName).then(() => { 2055 hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.'); 2056 }).catch((err: BusinessError) => { 2057 hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message); 2058 }); 2059} catch (err) { 2060 let message = (err as BusinessError).message; 2061 hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message); 2062} 2063``` 2064 2065## bundleManager.cleanBundleCacheFiles<sup>15+</sup> 2066 2067cleanBundleCacheFiles(bundleName: string, appIndex: number): Promise\<void> 2068 2069Clears the bundle cache based on the given bundle name and application index. This API uses a promise to return the result. 2070 2071No permission is required when the caller clears its own cache. 2072 2073**System API**: This is a system API. 2074 2075**Required permissions**: ohos.permission.REMOVE_CACHE_FILES 2076 2077**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2078 2079**Parameters** 2080 2081| Name | Type | Mandatory| Description | 2082| ---------- | ------ | ---- | ------------------------------------------ | 2083| bundleName | string | Yes | Bundle name.| 2084| appIndex | number | Yes | Index of the application clone.<br>The value **0** means to clear the cache of the main application. A value greater than 0 means to clear the cache data of the application clone.| 2085 2086**Return value** 2087 2088| Type | Description | 2089| -------------- | ------------------------------------------------------------ | 2090| Promise\<void> | Promise that returns no value. If clearing the cache files fails, an error object is thrown.| 2091 2092**Error codes** 2093 2094For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2095 2096| ID| Error Message | 2097| -------- | ---------------------------------------------------------- | 2098| 201 | Permission denied. | 2099| 202 | Permission denied, non-system app called system api. | 2100| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2101| 17700001 | The specified bundleName is not found. | 2102| 17700030 | The specified bundle does not support clearing of cache files. | 2103| 17700061 | AppIndex is not in the valid range. | 2104 2105**Example** 2106 2107```ts 2108import { bundleManager } from '@kit.AbilityKit'; 2109import { BusinessError } from '@kit.BasicServicesKit'; 2110import { hilog } from '@kit.PerformanceAnalysisKit'; 2111let bundleName = "com.ohos.myapplication"; 2112let appIndex = 1; 2113 2114try { 2115 bundleManager.cleanBundleCacheFiles(bundleName, appIndex).then(() => { 2116 hilog.info(0x0000, 'testTag', 'cleanBundleCacheFiles successfully.'); 2117 }).catch((err: BusinessError) => { 2118 hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', err.message); 2119 }); 2120} catch (err) { 2121 let message = (err as BusinessError).message; 2122 hilog.error(0x0000, 'testTag', 'cleanBundleCacheFiles failed: %{public}s', message); 2123} 2124``` 2125 2126## bundleManager.setApplicationEnabled 2127 2128setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\<void>): void 2129 2130Enables or disables an application. This API uses an asynchronous callback to return the result. 2131 2132**System API**: This is a system API. 2133 2134**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2135 2136**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2137 2138**Parameters** 2139 2140| Name | Type | Mandatory| Description | 2141| ---------- | ------- | ---- | ------------------------------------- | 2142| bundleName | string | Yes | Bundle name. | 2143| isEnabled | boolean | Yes | Whether to enable the application. **true** to enable, **false** otherwise.| 2144| callback | AsyncCallback\<void> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 2145 2146**Error codes** 2147 2148For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2149 2150| ID| Error Message | 2151| -------- | -------------------------------------- | 2152| 201 | Permission denied. | 2153| 202 | Permission denied, non-system app called system api. | 2154| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2155| 17700001 | The specified bundleName is not found. | 2156 2157**Example** 2158 2159```ts 2160import { bundleManager } from '@kit.AbilityKit'; 2161import { BusinessError } from '@kit.BasicServicesKit'; 2162import { hilog } from '@kit.PerformanceAnalysisKit'; 2163let bundleName = "com.ohos.myapplication"; 2164 2165try { 2166 bundleManager.setApplicationEnabled(bundleName, false, err => { 2167 if (err) { 2168 hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message); 2169 } else { 2170 hilog.info(0x0000, 'testTag', 'setApplicationEnabled successfully.'); 2171 } 2172 }); 2173} catch (err) { 2174 let message = (err as BusinessError).message; 2175 hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message); 2176} 2177``` 2178 2179## bundleManager.setApplicationEnabled 2180 2181setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\<void> 2182 2183Enables or disables an application. This API uses a promise to return the result. 2184 2185**System API**: This is a system API. 2186 2187**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2188 2189**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2190 2191**Parameters** 2192 2193| Name | Type | Mandatory| Description | 2194| ---------- | ------- | ---- | ------------------------------------- | 2195| bundleName | string | Yes | Bundle name. | 2196| isEnabled | boolean | Yes | Whether to enable the application. **true** to enable, **false** otherwise.| 2197 2198**Return value** 2199 2200| Type | Description | 2201| -------------- | ------------------------------------ | 2202| Promise\<void> | Promise that returns no value.| 2203 2204**Error codes** 2205 2206For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2207 2208| ID| Error Message | 2209| -------- | -------------------------------------- | 2210| 201 | Permission denied. | 2211| 202 | Permission denied, non-system app called system api. | 2212| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2213| 17700001 | The specified bundleName is not found. | 2214 2215**Example** 2216 2217```ts 2218import { bundleManager } from '@kit.AbilityKit'; 2219import { BusinessError } from '@kit.BasicServicesKit'; 2220import { hilog } from '@kit.PerformanceAnalysisKit'; 2221let bundleName = "com.ohos.myapplication"; 2222 2223try { 2224 bundleManager.setApplicationEnabled(bundleName, false).then(() => { 2225 hilog.info(0x0000, "testTag", "setApplicationEnabled successfully."); 2226 }).catch((err: BusinessError) => { 2227 hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message); 2228 }); 2229} catch (err) { 2230 let message = (err as BusinessError).message; 2231 hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message); 2232} 2233``` 2234 2235## bundleManager.setApplicationEnabled<sup>12+</sup> 2236 2237setApplicationEnabled(bundleName: string, appIndex: number, isEnabled: boolean): Promise\<void> 2238 2239Enables or disables an application or an application clone. This API uses a promise to return the result. 2240 2241**System API**: This is a system API. 2242 2243**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2244 2245**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2246 2247**Parameters** 2248 2249| Name | Type | Mandatory| Description | 2250| ---------- | ------- | ---- | ------------------------------------- | 2251| bundleName | string | Yes | Bundle name. | 2252| appIndex | number | Yes | Index of the application clone.<br>The value **0** means to enable or disable the main application. A value greater than 0 means to enable or disable the application clone. | 2253| isEnabled | boolean | Yes | Whether to enable the application or application clone. **true** to enable, **false** otherwise.| 2254 2255**Return value** 2256 2257| Type | Description | 2258| -------------- | ------------------------------------ | 2259| Promise\<void> | Promise that returns no value.| 2260 2261**Error codes** 2262 2263For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2264 2265| ID| Error Message | 2266| -------- | -------------------------------------- | 2267| 201 | Permission denied. | 2268| 202 | Permission denied, non-system app called system api. | 2269| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2270| 17700001 | The specified bundleName is not found. | 2271| 17700061 | AppIndex is not in the valid range. | 2272 2273**Example** 2274 2275```ts 2276import { bundleManager } from '@kit.AbilityKit'; 2277import { BusinessError } from '@kit.BasicServicesKit'; 2278import { hilog } from '@kit.PerformanceAnalysisKit'; 2279let bundleName = "com.ohos.myapplication"; 2280 2281try { 2282 bundleManager.setApplicationEnabled(bundleName, 1, false).then(() => { 2283 hilog.info(0x0000, "testTag", "setApplicationEnabled successfully."); 2284 }).catch((err: BusinessError) => { 2285 hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', err.message); 2286 }); 2287} catch (err) { 2288 let message = (err as BusinessError).message; 2289 hilog.error(0x0000, 'testTag', 'setApplicationEnabled failed: %{public}s', message); 2290} 2291``` 2292 2293## bundleManager.setApplicationEnabledSync<sup>10+</sup> 2294 2295setApplicationEnabledSync(bundleName: string, isEnabled: boolean): void 2296 2297Enables or disables an application. This API returns the result synchronously. 2298 2299**System API**: This is a system API. 2300 2301**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2302 2303**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2304 2305**Parameters** 2306 2307| Name | Type | Mandatory| Description | 2308| ---------- | ------- | ---- | ------------------------------------- | 2309| bundleName | string | Yes | Bundle name. | 2310| isEnabled | boolean | Yes | Whether to enable the application. **true** to enable, **false** otherwise.| 2311 2312**Error codes** 2313 2314For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2315 2316| ID| Error Message | 2317| -------- | -------------------------------------- | 2318| 201 | Permission denied. | 2319| 202 | Permission denied, non-system app called system api. | 2320| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2321| 17700001 | The specified bundleName is not found. | 2322 2323**Example** 2324 2325```ts 2326import { bundleManager } from '@kit.AbilityKit'; 2327import { BusinessError } from '@kit.BasicServicesKit'; 2328import { hilog } from '@kit.PerformanceAnalysisKit'; 2329let bundleName = "com.ohos.myapplication"; 2330 2331try { 2332 bundleManager.setApplicationEnabledSync(bundleName, false); 2333 hilog.info(0x0000, 'testTag', 'setApplicationEnabledSync successfully.'); 2334} catch (err) { 2335 let message = (err as BusinessError).message; 2336 hilog.error(0x0000, 'testTag', 'setApplicationEnabledSync failed: %{public}s', message); 2337} 2338``` 2339 2340## bundleManager.setAbilityEnabled 2341 2342setAbilityEnabled(info: AbilityInfo, isEnabled: boolean, callback: AsyncCallback\<void>): void 2343 2344Enables or disables an ability. This API uses an asynchronous callback to return the result. 2345 2346**System API**: This is a system API. 2347 2348**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2349 2350**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2351 2352**Parameters** 2353 2354| Name | Type | Mandatory| Description | 2355| -------- | ----------- | ---- | ------------------------------------- | 2356| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability. | 2357| isEnabled| boolean | Yes | Whether to enable the ability. **true** to enable, **false** otherwise.| 2358| callback | AsyncCallback\<void> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 2359 2360**Error codes** 2361 2362For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2363 2364| ID| Error Message | 2365| -------- | ---------------------------------------| 2366| 201 | Permission denied. | 2367| 202 | Permission denied, non-system app called system api. | 2368| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2369| 17700001 | The specified bundleName is not found. | 2370| 17700003 | The specified abilityInfo is not found. | 2371 2372**Example** 2373 2374```ts 2375import { bundleManager } from '@kit.AbilityKit'; 2376import { BusinessError } from '@kit.BasicServicesKit'; 2377import { hilog } from '@kit.PerformanceAnalysisKit'; 2378import { Want } from '@kit.AbilityKit'; 2379let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2380let userId = 100; 2381let want: Want = { 2382 bundleName : "com.example.myapplication", 2383 abilityName : "EntryAbility" 2384}; 2385 2386try { 2387 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2388 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 2389 let info = abilitiesInfo[0]; 2390 2391 bundleManager.setAbilityEnabled(info, false, err => { 2392 if (err) { 2393 hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message); 2394 } else { 2395 hilog.info(0x0000, "testTag", "setAbilityEnabled successfully."); 2396 } 2397 }); 2398 }).catch((err: BusinessError) => { 2399 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 2400 }); 2401} catch (err) { 2402 let message = (err as BusinessError).message; 2403 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 2404} 2405``` 2406 2407## bundleManager.setAbilityEnabled 2408 2409setAbilityEnabled(info: AbilityInfo, isEnabled: boolean): Promise\<void> 2410 2411Enables or disables an ability. This API uses a promise to return the result. 2412 2413**System API**: This is a system API. 2414 2415**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2416 2417**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2418 2419**Parameters** 2420 2421| Name | Type | Mandatory| Description | 2422| -------- | ----------- | ---- | ------------------------------------- | 2423| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability. | 2424| isEnabled| boolean | Yes | Whether to enable the ability. **true** to enable, **false** otherwise.| 2425 2426**Return value** 2427 2428| Type | Description | 2429| -------------- | --------------------------------- | 2430| Promise\<void> | Promise that returns no value.| 2431 2432**Error codes** 2433 2434For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2435 2436| ID| Error Message | 2437| -------- | -------------------------------------- | 2438| 201 | Permission denied. | 2439| 202 | Permission denied, non-system app called system api. | 2440| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2441| 17700001 | The specified bundleName is not found. | 2442| 17700003 | The specified abilityInfo is not found. | 2443 2444**Example** 2445 2446```ts 2447import { bundleManager } from '@kit.AbilityKit'; 2448import { BusinessError } from '@kit.BasicServicesKit'; 2449import { hilog } from '@kit.PerformanceAnalysisKit'; 2450import { Want } from '@kit.AbilityKit'; 2451let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2452let userId = 100; 2453let want: Want = { 2454 bundleName : "com.example.myapplication", 2455 abilityName : "EntryAbility" 2456}; 2457 2458try { 2459 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2460 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 2461 let info = abilitiesInfo[0]; 2462 2463 bundleManager.setAbilityEnabled(info, false).then(() => { 2464 hilog.info(0x0000, "testTag", "setAbilityEnabled successfully."); 2465 }).catch((err: BusinessError) => { 2466 hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message); 2467 }); 2468 }).catch((err: BusinessError) => { 2469 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 2470 }); 2471} catch (err) { 2472 let message = (err as BusinessError).message; 2473 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 2474} 2475``` 2476 2477## bundleManager.setAbilityEnabled<sup>12+</sup> 2478 2479setAbilityEnabled(info: AbilityInfo, appIndex: number, isEnabled: boolean): Promise\<void> 2480 2481Enables or disables an ability of an application or an application clone. This API uses a promise to return the result. 2482 2483**System API**: This is a system API. 2484 2485**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2486 2487**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2488 2489**Parameters** 2490 2491| Name | Type | Mandatory| Description | 2492| -------- | ----------- | ---- | ------------------------------------- | 2493| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability. | 2494| appIndex | number | Yes | Index of the application clone.<br>The value **0** means to enable or disable the ability of the main application. A value greater than 0 means to enable or disable the ability of the application clone. | 2495| isEnabled| boolean | Yes | Whether to enable the ability. **true** to enable, **false** otherwise.| 2496 2497**Return value** 2498 2499| Type | Description | 2500| -------------- | --------------------------------- | 2501| Promise\<void> | Promise that returns no value.| 2502 2503**Error codes** 2504 2505For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2506 2507| ID| Error Message | 2508| -------- | -------------------------------------- | 2509| 201 | Permission denied. | 2510| 202 | Permission denied, non-system app called system api. | 2511| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2512| 17700001 | The specified bundleName is not found. | 2513| 17700003 | The specified abilityInfo is not found. | 2514| 17700061 | AppIndex is not in the valid range. | 2515 2516**Example** 2517 2518```ts 2519import { bundleManager } from '@kit.AbilityKit'; 2520import { BusinessError } from '@kit.BasicServicesKit'; 2521import { hilog } from '@kit.PerformanceAnalysisKit'; 2522import { Want } from '@kit.AbilityKit'; 2523let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2524let userId = 100; 2525let want: Want = { 2526 bundleName : "com.example.myapplication", 2527 abilityName : "EntryAbility" 2528}; 2529 2530try { 2531 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2532 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 2533 let info = abilitiesInfo[0]; 2534 2535 bundleManager.setAbilityEnabled(info, 1, false).then(() => { 2536 hilog.info(0x0000, "testTag", "setAbilityEnabled successfully."); 2537 }).catch((err: BusinessError) => { 2538 hilog.error(0x0000, 'testTag', 'setAbilityEnabled failed: %{public}s', err.message); 2539 }); 2540 }).catch((err: BusinessError) => { 2541 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 2542 }); 2543} catch (err) { 2544 let message = (err as BusinessError).message; 2545 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 2546} 2547``` 2548 2549## bundleManager.setAbilityEnabledSync<sup>10+</sup> 2550 2551setAbilityEnabledSync(info: AbilityInfo, isEnabled: boolean): void 2552 2553Enables or disables an ability. This API returns the result synchronously. 2554 2555**System API**: This is a system API. 2556 2557**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE 2558 2559**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2560 2561**Parameters** 2562 2563| Name | Type | Mandatory| Description | 2564| -------- | ----------- | ---- | ------------------------------------- | 2565| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability. | 2566| isEnabled| boolean | Yes | Whether to enable the ability. **true** to enable, **false** otherwise.| 2567 2568**Error codes** 2569 2570For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2571 2572| ID| Error Message | 2573| -------- | ---------------------------------------| 2574| 201 | Permission denied. | 2575| 202 | Permission denied, non-system app called system api. | 2576| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2577| 17700001 | The specified bundleName is not found. | 2578| 17700003 | The specified abilityInfo is not found. | 2579 2580**Example** 2581 2582```ts 2583import { bundleManager } from '@kit.AbilityKit'; 2584import { BusinessError } from '@kit.BasicServicesKit'; 2585import { hilog } from '@kit.PerformanceAnalysisKit'; 2586import { Want } from '@kit.AbilityKit'; 2587let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2588let userId = 100; 2589let want: Want = { 2590 bundleName : "com.example.myapplication", 2591 abilityName : "EntryAbility" 2592}; 2593 2594try { 2595 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2596 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 2597 let info = abilitiesInfo[0]; 2598 2599 try { 2600 bundleManager.setAbilityEnabledSync(info, false); 2601 hilog.info(0x0000, "testTag", "setAbilityEnabledSync successfully."); 2602 } catch (err) { 2603 let message = (err as BusinessError).message; 2604 hilog.error(0x0000, 'testTag', 'setAbilityEnabledSync failed: %{public}s', message); 2605 } 2606 }).catch((err: BusinessError) => { 2607 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 2608 }); 2609} catch (err) { 2610 let message = (err as BusinessError).message; 2611 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 2612} 2613``` 2614 2615## bundleManager.isApplicationEnabled 2616 2617isApplicationEnabled(bundleName: string, callback: AsyncCallback\<boolean>): void 2618 2619Checks whether an application is enabled. This API uses an asynchronous callback to return the result. 2620 2621**System API**: This is a system API. 2622 2623**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2624 2625**Parameters** 2626 2627| Name | Type | Mandatory| Description | 2628| ---------- | ------ | ---- | -------------------------- | 2629| bundleName | string | Yes | Bundle name.| 2630| callback | AsyncCallback\<boolean> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. **true** if enabled, **false** otherwise.| 2631 2632**Error codes** 2633 2634For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2635 2636| ID| Error Message | 2637| -------- | -------------------------------------- | 2638| 202 | Permission denied, non-system app called system api. | 2639| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2640| 17700001 | The specified bundleName is not found. | 2641 2642**Example** 2643 2644```ts 2645import { bundleManager } from '@kit.AbilityKit'; 2646import { BusinessError } from '@kit.BasicServicesKit'; 2647import { hilog } from '@kit.PerformanceAnalysisKit'; 2648let bundleName = 'com.example.myapplication'; 2649 2650try { 2651 bundleManager.isApplicationEnabled(bundleName, (err, data) => { 2652 if (err) { 2653 hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', err.message); 2654 } else { 2655 hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully: %{public}s', JSON.stringify(data)); 2656 } 2657 }); 2658} catch (err) { 2659 let message = (err as BusinessError).message; 2660 hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed: %{public}s', message); 2661} 2662``` 2663 2664## bundleManager.isApplicationEnabled 2665 2666isApplicationEnabled(bundleName: string): Promise\<boolean> 2667 2668Checks whether an application is enabled. This API uses a promise to return the result. 2669 2670**System API**: This is a system API. 2671 2672**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2673 2674**Parameters** 2675 2676| Name | Type | Mandatory| Description | 2677| ---------- | ------ | ---- | -------------------------- | 2678| bundleName | string | Yes | Bundle name. | 2679 2680**Return value** 2681 2682| Type | Description | 2683| ----------------- | ------------------------------------------------------------ | 2684| Promise\<boolean> | Promise used to return the result. **true** if enabled, **false** otherwise.| 2685 2686**Error codes** 2687 2688For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2689 2690| ID| Error Message | 2691| -------- | -------------------------------------- | 2692| 202 | Permission denied, non-system app called system api. | 2693| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2694| 17700001 | The specified bundleName is not found. | 2695 2696**Example** 2697 2698```ts 2699import { bundleManager } from '@kit.AbilityKit'; 2700import { BusinessError } from '@kit.BasicServicesKit'; 2701import { hilog } from '@kit.PerformanceAnalysisKit'; 2702let bundleName = 'com.example.myapplication'; 2703 2704try { 2705 bundleManager.isApplicationEnabled(bundleName).then((data) => { 2706 hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data)); 2707 }).catch((err: BusinessError) => { 2708 hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message); 2709 }); 2710} catch (err) { 2711 let message = (err as BusinessError).message; 2712 hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message); 2713} 2714``` 2715 2716## bundleManager.isApplicationEnabled<sup>12+</sup> 2717 2718isApplicationEnabled(bundleName: string, appIndex: number): Promise\<boolean> 2719 2720Checks whether an application or an application clone is enabled. This API uses a promise to return the result. 2721 2722**System API**: This is a system API. 2723 2724**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2725 2726**Parameters** 2727 2728| Name | Type | Mandatory| Description | 2729| ---------- | ------ | ---- | -------------------------- | 2730| bundleName | string | Yes | Bundle name. | 2731| appIndex | number | Yes | Index of the application clone.<br>The value **0** means to obtain the enabled status of the main application. A value greater than 0 means to obtain the enabled status of the application clone. | 2732 2733**Return value** 2734 2735| Type | Description | 2736| ----------------- | ------------------------------------------------------------ | 2737| Promise\<boolean> | Promise used to return the result. **true** if enabled, **false** otherwise.| 2738 2739**Error codes** 2740 2741For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2742 2743| ID| Error Message | 2744| -------- | -------------------------------------- | 2745| 202 | Permission denied, non-system app called system api. | 2746| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2747| 17700001 | The specified bundleName is not found. | 2748| 17700061 | AppIndex is not in the valid range. | 2749 2750**Example** 2751 2752```ts 2753import { bundleManager } from '@kit.AbilityKit'; 2754import { BusinessError } from '@kit.BasicServicesKit'; 2755import { hilog } from '@kit.PerformanceAnalysisKit'; 2756let bundleName = 'com.example.myapplication'; 2757 2758try { 2759 bundleManager.isApplicationEnabled(bundleName, 1).then((data) => { 2760 hilog.info(0x0000, 'testTag', 'isApplicationEnabled successfully. Data: %{public}s', JSON.stringify(data)); 2761 }).catch((err: BusinessError) => { 2762 hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', err.message); 2763 }); 2764} catch (err) { 2765 let message = (err as BusinessError).message; 2766 hilog.error(0x0000, 'testTag', 'isApplicationEnabled failed. Cause: %{public}s', message); 2767} 2768``` 2769 2770## bundleManager.isApplicationEnabledSync<sup>10+</sup> 2771 2772isApplicationEnabledSync(bundleName: string): boolean 2773 2774Checks whether an application is enabled. This API returns the result synchronously. 2775 2776**System API**: This is a system API. 2777 2778**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2779 2780**Parameters** 2781 2782| Name | Type | Mandatory| Description | 2783| ---------- | ------ | ---- | -------------------------- | 2784| bundleName | string | Yes | Bundle name.| 2785 2786**Return value** 2787 2788| Type | Description | 2789| ------- | ------------------------------------------------------------ | 2790| boolean | Check result for whether the application is enabled. **true** if enabled, **false** otherwise.| 2791 2792**Error codes** 2793 2794For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2795 2796| ID| Error Message | 2797| -------- | -------------------------------------- | 2798| 202 | Permission denied, non-system app called system api. | 2799| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2800| 17700001 | The specified bundleName is not found. | 2801 2802**Example** 2803 2804```ts 2805import { bundleManager } from '@kit.AbilityKit'; 2806import { BusinessError } from '@kit.BasicServicesKit'; 2807import { hilog } from '@kit.PerformanceAnalysisKit'; 2808let bundleName = 'com.example.myapplication'; 2809 2810try { 2811 let data = bundleManager.isApplicationEnabledSync(bundleName); 2812 hilog.info(0x0000, 'testTag', 'isApplicationEnabledSync successfully: %{public}s', JSON.stringify(data)); 2813} catch (err) { 2814 let message = (err as BusinessError).message; 2815 hilog.error(0x0000, 'testTag', 'isApplicationEnabledSync failed: %{public}s', message); 2816} 2817``` 2818 2819## bundleManager.isAbilityEnabled 2820 2821isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback\<boolean>): void 2822 2823Checks whether an ability is enabled. This API uses an asynchronous callback to return the result. 2824 2825**System API**: This is a system API. 2826 2827**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2828 2829**Parameters** 2830 2831| Name| Type | Mandatory| Description | 2832| ---- | ----------- | ---- | --------------------------- | 2833| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability.| 2834| callback | AsyncCallback\<boolean> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. **true** if enabled, **false** otherwise.| 2835 2836**Error codes** 2837 2838For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2839 2840| ID| Error Message | 2841| -------- | --------------------------------------- | 2842| 202 | Permission denied, non-system app called system api. | 2843| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2844| 17700001 | The specified bundleName is not found. | 2845| 17700003 | The specified abilityName is not found. | 2846 2847**Example** 2848 2849```ts 2850import { bundleManager } from '@kit.AbilityKit'; 2851import { BusinessError } from '@kit.BasicServicesKit'; 2852import { hilog } from '@kit.PerformanceAnalysisKit'; 2853import { Want } from '@kit.AbilityKit'; 2854let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2855let userId = 100; 2856let want: Want = { 2857 bundleName : "com.example.myapplication", 2858 abilityName : "EntryAbility" 2859}; 2860 2861try { 2862 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2863 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 2864 let info = abilitiesInfo[0]; 2865 2866 bundleManager.isAbilityEnabled(info, (err, data) => { 2867 if (err) { 2868 hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed: %{public}s', err.message); 2869 } else { 2870 hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully: %{public}s', JSON.stringify(data)); 2871 } 2872 }); 2873 }).catch((err: BusinessError) => { 2874 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 2875 }); 2876} catch (err) { 2877 let message = (err as BusinessError).message; 2878 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 2879} 2880``` 2881 2882## bundleManager.isAbilityEnabled 2883 2884isAbilityEnabled(info: AbilityInfo): Promise\<boolean> 2885 2886Checks whether an ability is enabled. This API uses a promise to return the result. 2887 2888**System API**: This is a system API. 2889 2890**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2891 2892**Parameters** 2893 2894| Name| Type | Mandatory| Description | 2895| ---- | ----------- | ---- | --------------------------- | 2896| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability.| 2897 2898**Return value** 2899 2900| Type | Description | 2901| ----------------- | ------------------------------------------------------------ | 2902| Promise\<boolean> | Promise used to return the result. **true** if enabled, **false** otherwise.| 2903 2904**Error codes** 2905 2906For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2907 2908| ID| Error Message | 2909| -------- | --------------------------------------- | 2910| 202 | Permission denied, non-system app called system api. | 2911| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2912| 17700001 | The specified bundleName is not found. | 2913| 17700003 | The specified abilityName is not found. | 2914 2915**Example** 2916 2917```ts 2918import { bundleManager } from '@kit.AbilityKit'; 2919import { BusinessError } from '@kit.BasicServicesKit'; 2920import { hilog } from '@kit.PerformanceAnalysisKit'; 2921import { Want } from '@kit.AbilityKit'; 2922let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2923let userId = 100; 2924let want: Want = { 2925 bundleName : "com.example.myapplication", 2926 abilityName : "EntryAbility" 2927}; 2928 2929try { 2930 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2931 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 2932 let info = abilitiesInfo[0]; 2933 2934 bundleManager.isAbilityEnabled(info).then((data) => { 2935 hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data)); 2936 }).catch((err: BusinessError) => { 2937 hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message); 2938 }); 2939 }).catch((err: BusinessError) => { 2940 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 2941 }); 2942} catch (err) { 2943 let message = (err as BusinessError).message; 2944 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 2945} 2946``` 2947 2948## bundleManager.isAbilityEnabled<sup>12+</sup> 2949 2950isAbilityEnabled(info: AbilityInfo, appIndex: number): Promise\<boolean> 2951 2952Checks whether an ability of an application or an application clone is enabled. This API uses a promise to return the result. 2953 2954**System API**: This is a system API. 2955 2956**System capability**: SystemCapability.BundleManager.BundleFramework.Core 2957 2958**Parameters** 2959 2960| Name| Type | Mandatory| Description | 2961| ---- | ----------- | ---- | --------------------------- | 2962| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability.| 2963| appIndex | number | Yes | Index of the application clone.<br>The value **0** means to obtain the enabled status of the ability of the main application. A value greater than 0 means to obtain the enabled status of the ability of the application clone. | 2964 2965**Return value** 2966 2967| Type | Description | 2968| ----------------- | ------------------------------------------------------------ | 2969| Promise\<boolean> | Promise used to return the result. **true** if enabled, **false** otherwise.| 2970 2971**Error codes** 2972 2973For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 2974 2975| ID| Error Message | 2976| -------- | --------------------------------------- | 2977| 202 | Permission denied, non-system app called system api. | 2978| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 2979| 17700001 | The specified bundleName is not found. | 2980| 17700003 | The specified abilityName is not found. | 2981| 17700061 | AppIndex is not in the valid range. | 2982 2983**Example** 2984 2985```ts 2986import { bundleManager } from '@kit.AbilityKit'; 2987import { BusinessError } from '@kit.BasicServicesKit'; 2988import { hilog } from '@kit.PerformanceAnalysisKit'; 2989import { Want } from '@kit.AbilityKit'; 2990let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 2991let userId = 100; 2992let want: Want = { 2993 bundleName : "com.example.myapplication", 2994 abilityName : "EntryAbility" 2995}; 2996 2997try { 2998 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 2999 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 3000 let info = abilitiesInfo[0]; 3001 3002 bundleManager.isAbilityEnabled(info, 1).then((data) => { 3003 hilog.info(0x0000, 'testTag', 'isAbilityEnabled successfully. Data: %{public}s', JSON.stringify(data)); 3004 }).catch((err: BusinessError) => { 3005 hilog.error(0x0000, 'testTag', 'isAbilityEnabled failed. Cause: %{public}s', err.message); 3006 }); 3007 }).catch((err: BusinessError) => { 3008 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 3009 }); 3010} catch (err) { 3011 let message = (err as BusinessError).message; 3012 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 3013} 3014``` 3015 3016## bundleManager.isAbilityEnabledSync<sup>10+</sup> 3017 3018isAbilityEnabledSync(info: AbilityInfo): boolean 3019 3020Checks whether an ability is enabled. This API returns the result synchronously. 3021 3022**System API**: This is a system API. 3023 3024**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3025 3026**Parameters** 3027 3028| Name| Type | Mandatory| Description | 3029| ---- | ----------- | ---- | --------------------------- | 3030| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability.| 3031 3032**Return value** 3033 3034| Type | Description | 3035| ------- | ------------------------------------------------------------------- | 3036| boolean | Check result for whether the ability is enabled. **true** if enabled, **false** otherwise.| 3037 3038**Error codes** 3039 3040For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3041 3042| ID| Error Message | 3043| -------- | --------------------------------------- | 3044| 202 | Permission denied, non-system app called system api. | 3045| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3046| 17700001 | The specified bundleName is not found. | 3047| 17700003 | The specified abilityName is not found. | 3048 3049**Example** 3050 3051```ts 3052import { bundleManager } from '@kit.AbilityKit'; 3053import { BusinessError } from '@kit.BasicServicesKit'; 3054import { hilog } from '@kit.PerformanceAnalysisKit'; 3055import { Want } from '@kit.AbilityKit'; 3056let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; 3057let userId = 100; 3058let want: Want = { 3059 bundleName : "com.example.myapplication", 3060 abilityName : "EntryAbility" 3061}; 3062 3063try { 3064 bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { 3065 hilog.info(0x0000, 'testTag', 'queryAbilityInfo successfully. Data: %{public}s', JSON.stringify(abilitiesInfo)); 3066 let info = abilitiesInfo[0]; 3067 3068 try { 3069 let data = bundleManager.isAbilityEnabledSync(info); 3070 hilog.info(0x0000, 'testTag', 'isAbilityEnabledSync successfully: %{public}s', JSON.stringify(data)); 3071 } catch (err) { 3072 let message = (err as BusinessError).message; 3073 hilog.error(0x0000, 'testTag', 'isAbilityEnabledSync failed: %{public}s', message); 3074 } 3075 }).catch((err: BusinessError) => { 3076 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', err.message); 3077 }); 3078} catch (err) { 3079 let message = (err as BusinessError).message; 3080 hilog.error(0x0000, 'testTag', 'queryAbilityInfo failed. Cause: %{public}s', message); 3081} 3082``` 3083 3084## bundleManager.getLaunchWantForBundle 3085 3086getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\<Want>): void 3087 3088Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API uses an asynchronous callback to return the result. 3089 3090**System API**: This is a system API. 3091 3092**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3093 3094**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3095 3096**Parameters** 3097 3098| Name | Type | Mandatory| Description | 3099| ---------- | -------------------- | ---- | ------------------------------------------------------------ | 3100| bundleName | string | Yes | Bundle name. | 3101| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 3102| callback | AsyncCallback\<Want> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the Want. Otherwise, **err** is an error object.| 3103 3104**Error codes** 3105 3106For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3107 3108| ID| Error Message | 3109| -------- | --------------------------------------| 3110| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. | 3111| 202 | Permission denied, non-system app called system api. | 3112| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3113| 17700001 | The specified bundleName is not found. | 3114| 17700004 | The specified user ID is not found. | 3115| 17700026 | The specified bundle is disabled. | 3116 3117**Example** 3118 3119```ts 3120import { bundleManager } from '@kit.AbilityKit'; 3121import { BusinessError } from '@kit.BasicServicesKit'; 3122import { hilog } from '@kit.PerformanceAnalysisKit'; 3123let bundleName = 'com.example.myapplication'; 3124let userId = 100; 3125 3126try { 3127 bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => { 3128 if (err) { 3129 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message); 3130 } else { 3131 hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data)); 3132 } 3133 }); 3134} catch (err) { 3135 let message = (err as BusinessError).message; 3136 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message); 3137} 3138``` 3139 3140## bundleManager.getLaunchWantForBundle 3141 3142getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void 3143 3144Obtains the Want used to launch the bundle based on the given bundle name. This API uses an asynchronous callback to return the result. 3145 3146**System API**: This is a system API. 3147 3148**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3149 3150**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3151 3152**Parameters** 3153 3154| Name | Type | Mandatory| Description | 3155| ---------- | -------------------- | ---- | ------------------------------------------------------------ | 3156| bundleName | string | Yes | Bundle name. | 3157| callback | AsyncCallback\<Want> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the Want. Otherwise, **err** is an error object.| 3158 3159**Error codes** 3160 3161For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3162 3163| ID| Error Message | 3164| -------- | --------------------------------------| 3165| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. | 3166| 202 | Permission denied, non-system app called system api. | 3167| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3168| 17700001 | The specified bundleName is not found. | 3169| 17700026 | The specified bundle is disabled. | 3170 3171**Example** 3172 3173```ts 3174import { bundleManager } from '@kit.AbilityKit'; 3175import { BusinessError } from '@kit.BasicServicesKit'; 3176import { hilog } from '@kit.PerformanceAnalysisKit'; 3177let bundleName = 'com.example.myapplication'; 3178 3179try { 3180 bundleManager.getLaunchWantForBundle(bundleName, (err, data) => { 3181 if (err) { 3182 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', err.message); 3183 } else { 3184 hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully: %{public}s', JSON.stringify(data)); 3185 } 3186 }); 3187} catch (err) { 3188 let message = (err as BusinessError).message; 3189 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed: %{public}s', message); 3190} 3191``` 3192 3193## bundleManager.getLaunchWantForBundle 3194 3195getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want> 3196 3197Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API uses a promise to return the result. 3198 3199**System API**: This is a system API. 3200 3201**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3202 3203**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3204 3205**Parameters** 3206 3207| Name | Type | Mandatory| Description | 3208| ---------- | ------ | ---- | ------------------------- | 3209| bundleName | string | Yes | Bundle name.| 3210| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 3211 3212**Return value** 3213 3214| Type | Description | 3215| -------------- | ------------------------- | 3216| Promise\<Want> | Promise used to return the Want object obtained.| 3217 3218**Error codes** 3219 3220For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3221 3222| ID| Error Message | 3223| -------- | --------------------------------------| 3224| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. | 3225| 202 | Permission denied, non-system app called system api. | 3226| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3227| 17700001 | The specified bundleName is not found. | 3228| 17700004 | The specified user ID is not found. | 3229| 17700026 | The specified bundle is disabled. | 3230 3231**Example** 3232 3233```ts 3234import { bundleManager } from '@kit.AbilityKit'; 3235import { BusinessError } from '@kit.BasicServicesKit'; 3236import { hilog } from '@kit.PerformanceAnalysisKit'; 3237let bundleName = 'com.example.myapplication'; 3238let userId = 100; 3239 3240try { 3241 bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => { 3242 hilog.info(0x0000, 'testTag', 'getLaunchWantForBundle successfully. Data: %{public}s', JSON.stringify(data)); 3243 }).catch((err: BusinessError) => { 3244 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', err.message); 3245 }); 3246} catch (err) { 3247 let message = (err as BusinessError).message; 3248 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundle failed. Cause: %{public}s', message); 3249} 3250``` 3251 3252 3253## bundleManager.getLaunchWantForBundleSync<sup>10+</sup> 3254 3255getLaunchWantForBundleSync(bundleName: string, userId?: number): Want 3256 3257Obtains the Want used to launch the bundle based on the given bundle name and user ID. This API returns the result synchronously. 3258 3259**System API**: This is a system API. 3260 3261**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3262 3263**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3264 3265**Parameters** 3266 3267| Name | Type | Mandatory| Description | 3268| ---------- | ------ | ---- | ------------------------- | 3269| bundleName | string | Yes | Bundle name.| 3270| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 3271 3272**Return value** 3273 3274| Type | Description | 3275| -------------- | ------------------------- | 3276| Want | Want object.| 3277 3278**Error codes** 3279 3280For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3281 3282| ID| Error Message | 3283| -------- | --------------------------------------| 3284| 201 | Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. | 3285| 202 | Permission denied, non-system app called system api. | 3286| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3287| 17700001 | The specified bundleName is not found. | 3288| 17700004 | The specified user ID is not found. | 3289| 17700026 | The specified bundle is disabled. | 3290 3291**Example** 3292 3293```ts 3294import { bundleManager } from '@kit.AbilityKit'; 3295import { BusinessError } from '@kit.BasicServicesKit'; 3296import { hilog } from '@kit.PerformanceAnalysisKit'; 3297import { Want } from '@kit.AbilityKit'; 3298let bundleName = 'com.example.myapplication'; 3299let userId = 100; 3300 3301try { 3302 let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName, userId); 3303 hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want)); 3304} catch (err) { 3305 let message = (err as BusinessError).message; 3306 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message); 3307} 3308``` 3309 3310```ts 3311import { bundleManager } from '@kit.AbilityKit'; 3312import { BusinessError } from '@kit.BasicServicesKit'; 3313import { hilog } from '@kit.PerformanceAnalysisKit'; 3314import { Want } from '@kit.AbilityKit'; 3315let bundleName = 'com.example.myapplication'; 3316let userId = 100; 3317 3318try { 3319 let want: Want = bundleManager.getLaunchWantForBundleSync(bundleName); 3320 hilog.info(0x0000, 'testTag', 'getLaunchWantForBundleSync successfully. Data: %{public}s', JSON.stringify(want)); 3321} catch (err) { 3322 let message = (err as BusinessError).message; 3323 hilog.error(0x0000, 'testTag', 'getLaunchWantForBundleSync failed. Cause: %{public}s', message); 3324} 3325``` 3326 3327## bundleManager.getPermissionDef 3328 3329getPermissionDef(permissionName: string, callback: AsyncCallback\<PermissionDef>): void 3330 3331Obtains the PermissionDef struct based on the given permission name. This API uses an asynchronous callback to return the result. 3332 3333**System API**: This is a system API. 3334 3335**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3336 3337**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3338 3339**Parameters** 3340 3341| Name | Type | Mandatory| Description | 3342| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 3343| permissionName | string | Yes | Name of the permission. | 3344| callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the PermissionDef object obtained. Otherwise, **err** is an error object.| 3345 3346**Error codes** 3347 3348For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3349 3350| ID| Error Message | 3351| -------- | ------------------------------------- | 3352| 201 | Permission denied. | 3353| 202 | Permission denied, non-system app called system api. | 3354| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3355| 17700006 | The specified permission is not found. | 3356 3357**Example** 3358 3359```ts 3360import { bundleManager } from '@kit.AbilityKit'; 3361import { BusinessError } from '@kit.BasicServicesKit'; 3362import { hilog } from '@kit.PerformanceAnalysisKit'; 3363let permission = "ohos.permission.GET_BUNDLE_INFO"; 3364try { 3365 bundleManager.getPermissionDef(permission, (err, data) => { 3366 if (err) { 3367 hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', err.message); 3368 } else { 3369 hilog.info(0x0000, 'testTag', 'getPermissionDef successfully: %{public}s', JSON.stringify(data)); 3370 } 3371 }); 3372} catch (err) { 3373 let message = (err as BusinessError).message; 3374 hilog.error(0x0000, 'testTag', 'getPermissionDef failed: %{public}s', message); 3375} 3376``` 3377 3378## bundleManager.getPermissionDef 3379 3380getPermissionDef(permissionName: string): Promise\<PermissionDef> 3381 3382Obtains the PermissionDef struct based on the given permission name. This API uses a promise to return the result. 3383 3384**System API**: This is a system API. 3385 3386**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3387 3388**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3389 3390**Parameters** 3391 3392| Name | Type | Mandatory| Description | 3393| -------------- | ------ | ---- | -------------- | 3394| permissionName | string | Yes | Name of the permission.| 3395 3396**Return value** 3397 3398| Type | Description | 3399| ------------------------------------------------------------ | ------------------------------------------ | 3400| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef-sys.md)> | Promise used to return the PermissionDef object obtained.| 3401 3402**Error codes** 3403 3404For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3405 3406| ID| Error Message | 3407| -------- | ------------------------------------- | 3408| 201 | Permission denied. | 3409| 202 | Permission denied, non-system app called system api. | 3410| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3411| 17700006 | The specified permission is not found. | 3412 3413**Example** 3414 3415```ts 3416import { bundleManager } from '@kit.AbilityKit'; 3417import { BusinessError } from '@kit.BasicServicesKit'; 3418import { hilog } from '@kit.PerformanceAnalysisKit'; 3419let permissionName = "ohos.permission.GET_BUNDLE_INFO"; 3420try { 3421 bundleManager.getPermissionDef(permissionName).then((data) => { 3422 hilog.info(0x0000, 'testTag', 'getPermissionDef successfully. Data: %{public}s', JSON.stringify(data)); 3423 }).catch((err: BusinessError) => { 3424 hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', err.message); 3425 }); 3426} catch (err) { 3427 let message = (err as BusinessError).message; 3428 hilog.error(0x0000, 'testTag', 'getPermissionDef failed. Cause: %{public}s', message); 3429} 3430``` 3431 3432## bundleManager.getPermissionDefSync<sup>10+</sup> 3433 3434getPermissionDefSync(permissionName: string): PermissionDef; 3435 3436Obtains the **PermissionDef** struct based on the given permission name. This API returns the result synchronously. 3437 3438**System API**: This is a system API. 3439 3440**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3441 3442**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3443 3444**Parameters** 3445 3446| Name | Type | Mandatory| Description | 3447| -------------- | ------ | ---- | -------------- | 3448| permissionName | string | Yes | Name of the permission.| 3449 3450**Return value** 3451 3452| Type | Description | 3453| ------------------------------------------------------------ | ------------------------------------------ | 3454|[PermissionDef](js-apis-bundleManager-permissionDef-sys.md) | PermissionDef object.| 3455 3456**Error codes** 3457 3458For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3459 3460| ID| Error Message | 3461| -------- | ------------------------------------- | 3462| 201 | Permission denied. | 3463| 202 | Permission denied, non-system app called system api. | 3464| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3465| 17700006 | The specified permission is not found. | 3466 3467**Example** 3468 3469```ts 3470import { bundleManager } from '@kit.AbilityKit'; 3471import { BusinessError } from '@kit.BasicServicesKit'; 3472import { hilog } from '@kit.PerformanceAnalysisKit'; 3473let permissionName = "ohos.permission.GET_BUNDLE_INFO"; 3474try { 3475 let PermissionDef = bundleManager.getPermissionDefSync(permissionName); 3476 hilog.info(0x0000, 'testTag', 'getPermissionDefSync successfully. Data: %{public}s', JSON.stringify(PermissionDef)); 3477} catch (err) { 3478 let message = (err as BusinessError).message; 3479 hilog.error(0x0000, 'testTag', 'getPermissionDefSync failed. Cause: %{public}s', message); 3480} 3481``` 3482 3483## bundleManager.getAbilityLabel 3484 3485getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<string>): void 3486 3487Obtains the label based on the given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. 3488 3489No permission is required for obtaining the caller's own information. 3490 3491**System API**: This is a system API. 3492 3493**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3494 3495**System capability**: SystemCapability.BundleManager.BundleFramework.Resource 3496 3497**Parameters** 3498 3499| Name | Type | Mandatory| Description | 3500| ----------- | ---------------------- | ---- | ------------------------------------------------------------ | 3501| bundleName | string | Yes | Bundle name. | 3502| moduleName | string | Yes | Module name. | 3503| abilityName | string | Yes | Name of the UIAbility component. | 3504| callback | AsyncCallback\<string> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the label. Otherwise, **err** is an error object.| 3505 3506**Error codes** 3507 3508For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3509 3510| ID| Error Message | 3511| -------- | -------------------------------------- | 3512| 201 | Permission denied. | 3513| 202 | Permission denied, non-system app called system api. | 3514| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3515| 801 | Capability not supported. | 3516| 17700001 | The specified bundleName is not found. | 3517| 17700002 | The specified moduleName is not found. | 3518| 17700003 | The specified abilityName is not found. | 3519| 17700026 | The specified bundle is disabled. | 3520| 17700029 | The specified ability is disabled. | 3521 3522**Example** 3523 3524```ts 3525import { bundleManager } from '@kit.AbilityKit'; 3526import { BusinessError } from '@kit.BasicServicesKit'; 3527import { hilog } from '@kit.PerformanceAnalysisKit'; 3528let bundleName = 'com.example.myapplication'; 3529let moduleName = 'entry'; 3530let abilityName = 'EntryAbility'; 3531 3532try { 3533 bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => { 3534 if (err) { 3535 hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', err.message); 3536 } else { 3537 hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully: %{public}s', JSON.stringify(data)); 3538 } 3539 }); 3540} catch (err) { 3541 let message = (err as BusinessError).message; 3542 hilog.error(0x0000, 'testTag', 'getAbilityLabel failed: %{public}s', message); 3543} 3544``` 3545 3546## bundleManager.getAbilityLabel 3547 3548getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\<string> 3549 3550Obtains the label based on the given bundle name, module name, and ability name. This API uses a promise to return the result. 3551 3552No permission is required for obtaining the caller's own information. 3553 3554**System API**: This is a system API. 3555 3556**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3557 3558**System capability**: SystemCapability.BundleManager.BundleFramework.Resource 3559 3560**Parameters** 3561 3562| Name | Type | Mandatory| Description | 3563| ----------- | ------ | ---- | ------------------------- | 3564| bundleName | string | Yes | Bundle name. | 3565| moduleName | string | Yes | Module name. | 3566| abilityName | string | Yes | Name of the UIAbility component.| 3567 3568**Return value** 3569 3570| Type | Description | 3571| ---------------- | ----------------------------------- | 3572| Promise\<string> | Promise used to return the label.| 3573 3574**Error codes** 3575 3576For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3577 3578| ID| Error Message | 3579| -------- | --------------------------------------- | 3580| 201 | Permission denied. | 3581| 202 | Permission denied, non-system app called system api. | 3582| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3583| 801 | Capability not supported. | 3584| 17700001 | The specified bundleName is not found. | 3585| 17700002 | The specified moduleName is not found. | 3586| 17700003 | The specified abilityName is not found. | 3587| 17700026 | The specified bundle is disabled. | 3588| 17700029 | The specified ability is disabled. | 3589 3590**Example** 3591 3592```ts 3593import { bundleManager } from '@kit.AbilityKit'; 3594import { BusinessError } from '@kit.BasicServicesKit'; 3595import { hilog } from '@kit.PerformanceAnalysisKit'; 3596let bundleName = 'com.example.myapplication'; 3597let moduleName = 'entry'; 3598let abilityName = 'EntryAbility'; 3599 3600try { 3601 bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => { 3602 hilog.info(0x0000, 'testTag', 'getAbilityLabel successfully. Data: %{public}s', JSON.stringify(data)); 3603 }).catch((err: BusinessError) => { 3604 hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', err.message); 3605 }); 3606} catch (err) { 3607 let message = (err as BusinessError).message; 3608 hilog.error(0x0000, 'testTag', 'getAbilityLabel failed. Cause: %{public}s', message); 3609} 3610``` 3611 3612## bundleManager.getAbilityLabelSync<sup>10+</sup> 3613 3614getAbilityLabelSync(bundleName: string, moduleName: string, abilityName: string): string 3615 3616Obtains the ability label based on the given bundle name, module name, and ability name. This API returns the result synchronously. 3617 3618No permission is required for obtaining the caller's own information. 3619 3620**System API**: This is a system API. 3621 3622**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3623 3624**System capability**: SystemCapability.BundleManager.BundleFramework.Resource 3625 3626**Parameters** 3627 3628| Name | Type | Mandatory| Description | 3629| ----------- | ------ | ---- | ------------------------- | 3630| bundleName | string | Yes | Bundle name. | 3631| moduleName | string | Yes | Module name. | 3632| abilityName | string | Yes | Name of the UIAbility component.| 3633 3634**Return value** 3635 3636| Type | Description | 3637| ---------------- | ----------------------------------- | 3638| string | Label of the ability.| 3639 3640**Error codes** 3641 3642For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3643 3644| ID| Error Message | 3645| -------- | --------------------------------------- | 3646| 201 | Permission denied. | 3647| 202 | Permission denied, non-system app called system api. | 3648| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3649| 801 | Capability not supported. | 3650| 17700001 | The specified bundleName is not found. | 3651| 17700002 | The specified moduleName is not found. | 3652| 17700003 | The specified abilityName is not found. | 3653| 17700026 | The specified bundle is disabled. | 3654| 17700029 | The specified ability is disabled. | 3655 3656**Example** 3657 3658```ts 3659import { bundleManager } from '@kit.AbilityKit'; 3660import { BusinessError } from '@kit.BasicServicesKit'; 3661import { hilog } from '@kit.PerformanceAnalysisKit'; 3662let bundleName = 'com.example.myapplication'; 3663let moduleName = 'entry'; 3664let abilityName = 'EntryAbility'; 3665 3666try { 3667 let abilityLabel = bundleManager.getAbilityLabelSync(bundleName, moduleName, abilityName); 3668 hilog.info(0x0000, 'testTag', 'getAbilityLabelSync successfully. Data: %{public}s', abilityLabel); 3669} catch (err) { 3670 let message = (err as BusinessError).message; 3671 hilog.error(0x0000, 'testTag', 'getAbilityLabelSync failed. Cause: %{public}s', message); 3672} 3673``` 3674 3675## bundleManager.getApplicationInfoSync 3676 3677getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : ApplicationInfo 3678 3679Obtains the application information based on the given bundle name, application flags, and user ID. This API returns the result synchronously. 3680 3681No permission is required for obtaining the caller's own information. 3682 3683**System API**: This is a system API. 3684 3685**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3686 3687**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3688 3689**Parameters** 3690 3691| Name | Type | Mandatory| Description | 3692| ----------- | ------ | ---- | ----------------------------------------------------------| 3693| bundleName | string | Yes | Bundle name. | 3694| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | 3695| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 3696 3697**Return value** 3698 3699| Type | Description | 3700| --------------- | ------------------------- | 3701| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.| 3702 3703**Error codes** 3704 3705For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3706 3707| ID| Error Message | 3708| -------- | -------------------------------------- | 3709| 201 | Permission denied. | 3710| 202 | Permission denied, non-system app called system api. | 3711| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3712| 17700001 | The specified bundleName is not found. | 3713| 17700004 | The specified user ID is not found. | 3714| 17700026 | The specified bundle is disabled. | 3715 3716**Example** 3717 3718```ts 3719import { bundleManager } from '@kit.AbilityKit'; 3720import { BusinessError } from '@kit.BasicServicesKit'; 3721import { hilog } from '@kit.PerformanceAnalysisKit'; 3722let bundleName = 'com.example.myapplication'; 3723let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; 3724let userId = 100; 3725 3726try { 3727 let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId); 3728 hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data)); 3729} catch (err) { 3730 let message = (err as BusinessError).message; 3731 hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message); 3732} 3733``` 3734 3735## bundleManager.getApplicationInfoSync 3736 3737getApplicationInfoSync(bundleName: string, applicationFlags: number) : ApplicationInfo 3738 3739Obtains the application information based on the given bundle name and application flags. This API returns the result synchronously. 3740 3741No permission is required for obtaining the caller's own information. 3742 3743**System API**: This is a system API. 3744 3745**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3746 3747**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3748 3749**Parameters** 3750 3751| Name | Type | Mandatory| Description | 3752| ---------------- | -------------------------- | ---- | ----------------------------------------------------- | 3753| bundleName | string | Yes | Bundle name. | 3754| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain.| 3755 3756**Return value** 3757 3758| Type | Description | 3759| ----------------------------------------------------------- | ------------------------- | 3760| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.| 3761 3762**Error codes** 3763 3764For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3765 3766| ID| Error Message | 3767| -------- | -------------------------------------- | 3768| 201 | Permission denied. | 3769| 202 | Permission denied, non-system app called system api. | 3770| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3771| 17700001 | The specified bundleName is not found. | 3772| 17700026 | The specified bundle is disabled. | 3773 3774**Example** 3775 3776```ts 3777import { bundleManager } from '@kit.AbilityKit'; 3778import { BusinessError } from '@kit.BasicServicesKit'; 3779import { hilog } from '@kit.PerformanceAnalysisKit'; 3780let bundleName = 'com.example.myapplication'; 3781let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; 3782 3783try { 3784 let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags); 3785 hilog.info(0x0000, 'testTag', 'getApplicationInfoSync successfully: %{public}s', JSON.stringify(data)); 3786} catch (err) { 3787 let message = (err as BusinessError).message; 3788 hilog.error(0x0000, 'testTag', 'getApplicationInfoSync failed: %{public}s', message); 3789} 3790``` 3791 3792## bundleManager.getBundleInfoSync<sup>14+</sup> 3793 3794getBundleInfoSync(bundleName: string, bundleFlags: number, userId: number): BundleInfo 3795 3796Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API returns the result synchronously. 3797 3798No permission is required for obtaining the caller's own information. 3799 3800**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3801 3802**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3803 3804**Parameters** 3805 3806| Name | Type | Mandatory| Description | 3807| ----------- | ------ | ---- | -------------------------------------------------------- | 3808| bundleName | string | Yes | Bundle name. | 3809| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain.| 3810| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 3811 3812**Return value** 3813 3814| Type | Description | 3815| ---------- | -------------------- | 3816| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| 3817 3818**Error codes** 3819 3820For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3821 3822| ID| Error Message | 3823| -------- | ------------------------------------- | 3824| 201 | Permission denied. | 3825| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3826| 17700001 | The specified bundleName is not found. | 3827| 17700004 | The specified user ID is not found. | 3828| 17700026 | The specified bundle is disabled. | 3829 3830**Example** 3831 3832```ts 3833import { bundleManager } from '@kit.AbilityKit'; 3834import { BusinessError } from '@kit.BasicServicesKit'; 3835import { hilog } from '@kit.PerformanceAnalysisKit'; 3836let bundleName = 'com.example.myapplication'; 3837let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; 3838let userId = 100; 3839 3840try { 3841 let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); 3842 hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data)); 3843} catch (err) { 3844 let message = (err as BusinessError).message; 3845 hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message); 3846} 3847``` 3848 3849## bundleManager.getBundleInfoSync<sup>14+</sup> 3850 3851getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo 3852 3853Obtains the bundle information for the caller's user based on the given bundle name and bundle flags. This API returns the result synchronously. 3854 3855No permission is required for obtaining the caller's own information. 3856 3857**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 3858 3859**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3860 3861**Parameters** 3862 3863| Name | Type | Mandatory| Description | 3864| ----------- | --------------------- | ---- | ------------------------------------------------------ | 3865| bundleName | string | Yes | Bundle name. | 3866| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain.| 3867 3868**Return value** 3869 3870| Type | Description | 3871| ------------------------------------------------- | -------------------- | 3872| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| 3873 3874**Error codes** 3875 3876For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3877 3878| ID| Error Message | 3879| -------- | -------------------------------------- | 3880| 201 | Permission denied. | 3881| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3882| 17700001 | The specified bundleName is not found. | 3883| 17700026 | The specified bundle is disabled. | 3884 3885**Example** 3886 3887```ts 3888import { bundleManager } from '@kit.AbilityKit'; 3889import { BusinessError } from '@kit.BasicServicesKit'; 3890import { hilog } from '@kit.PerformanceAnalysisKit'; 3891let bundleName = 'com.example.myapplication'; 3892let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; 3893try { 3894 let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags); 3895 hilog.info(0x0000, 'testTag', 'getBundleInfoSync successfully: %{public}s', JSON.stringify(data)); 3896} catch (err) { 3897 let message = (err as BusinessError).message; 3898 hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', message); 3899} 3900``` 3901 3902## bundleManager.getSharedBundleInfo<sup>10+</sup> 3903 3904getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void 3905 3906Obtains the shared bundle information based on the given bundle name. This API uses an asynchronous callback to return the result. 3907 3908No permission is required for obtaining the caller's own information. 3909 3910**System API**: This is a system API. 3911 3912**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3913 3914**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3915 3916**Parameters** 3917 3918| Name | Type | Mandatory| Description | 3919| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 3920| bundleName | string | Yes | Bundle name. | 3921| moduleName | string | Yes | Module name. | 3922| callback | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the shared bundle information obtained.| 3923 3924**Error codes** 3925 3926For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3927 3928| ID| Error Message | 3929| -------- | -------------------------------------- | 3930| 201 | Permission denied. | 3931| 202 | Permission denied, non-system app called system api. | 3932| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3933| 17700001 | The specified bundleName is not found. | 3934| 17700002 | The specified moduleName is not found. | 3935 3936**Example** 3937 3938```ts 3939import { bundleManager } from '@kit.AbilityKit'; 3940import { BusinessError } from '@kit.BasicServicesKit'; 3941import { hilog } from '@kit.PerformanceAnalysisKit'; 3942let bundleName = 'com.example.myapplication'; 3943let moduleName = 'library'; 3944 3945try { 3946 bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => { 3947 if (err) { 3948 hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message); 3949 } else { 3950 hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data)); 3951 } 3952 }); 3953} catch (err) { 3954 let message = (err as BusinessError).message; 3955 hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', message); 3956} 3957``` 3958 3959## bundleManager.getSharedBundleInfo<sup>10+</sup> 3960 3961getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<SharedBundleInfo\>\> 3962 3963Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result. 3964 3965No permission is required for obtaining the caller's own information. 3966 3967**System API**: This is a system API. 3968 3969**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 3970 3971**System capability**: SystemCapability.BundleManager.BundleFramework.Core 3972 3973**Parameters** 3974 3975| Name | Type | Mandatory| Description | 3976| ---------- | ------ | ---- | -------------------------- | 3977| bundleName | string | Yes | Bundle name.| 3978| moduleName | string | Yes | Module name.| 3979 3980**Return value** 3981 3982| Type | Description | 3983| ------------------------------------------------------------ | ----------------------------------- | 3984| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Promise used to return the shared bundle information obtained.| 3985 3986**Error codes** 3987 3988For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 3989 3990| ID| Error Message | 3991| -------- | -------------------------------------- | 3992| 201 | Permission denied. | 3993| 202 | Permission denied, non-system app called system api. | 3994| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 3995| 17700001 | The specified bundleName is not found. | 3996| 17700002 | The specified moduleName is not found. | 3997 3998**Example** 3999 4000```ts 4001import { bundleManager } from '@kit.AbilityKit'; 4002import { BusinessError } from '@kit.BasicServicesKit'; 4003import { hilog } from '@kit.PerformanceAnalysisKit'; 4004let bundleName = 'com.example.myapplication'; 4005let moduleName = 'library'; 4006 4007try { 4008 bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => { 4009 hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); 4010 }).catch((err: BusinessError) => { 4011 hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); 4012 }); 4013} catch (err) { 4014 let message = (err as BusinessError).message; 4015 hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', message); 4016} 4017``` 4018 4019## bundleManager.getAllSharedBundleInfo<sup>10+</sup> 4020 4021getAllSharedBundleInfo(callback: AsyncCallback\<Array\<SharedBundleInfo\>\>): void 4022 4023Obtains all the shared bundle information. This API uses an asynchronous callback to return the result. 4024 4025**System API**: This is a system API. 4026 4027**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4028 4029**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4030 4031**Parameters** 4032 4033| Name | Type | Mandatory| Description | 4034| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 4035| callback | AsyncCallback\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is all the shared bundle information obtained.| 4036 4037**Error codes** 4038 4039For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4040 4041| ID| Error Message | 4042| -------- | ------------------------------------- | 4043| 201 | Permission denied. | 4044| 202 | Permission denied, non-system app called system api. | 4045 4046**Example** 4047 4048```ts 4049import { bundleManager } from '@kit.AbilityKit'; 4050import { BusinessError } from '@kit.BasicServicesKit'; 4051import { hilog } from '@kit.PerformanceAnalysisKit'; 4052 4053try { 4054 bundleManager.getAllSharedBundleInfo((err, data) => { 4055 if (err) { 4056 hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message); 4057 } else { 4058 hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data)); 4059 } 4060 }); 4061} catch (err) { 4062 let message = (err as BusinessError).message; 4063 hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', message); 4064} 4065``` 4066 4067## bundleManager.getAllSharedBundleInfo<sup>10+</sup> 4068 4069getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\> 4070 4071Obtains all the shared bundle information. This API uses a promise to return the result. 4072 4073**System API**: This is a system API. 4074 4075**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4076 4077**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4078 4079**Return value** 4080 4081| Type | Description | 4082| ------------------------------------------------------------ | ----------------------------------- | 4083| Promise\<Array\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md)\>\> | Promise used to return an array of the shared bundle information obtained.| 4084 4085**Error codes** 4086 4087For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4088 4089| ID| Error Message | 4090| -------- | ------------------------------------- | 4091| 201 | Permission denied. | 4092| 202 | Permission denied, non-system app called system api. | 4093 4094**Example** 4095 4096```ts 4097import { bundleManager } from '@kit.AbilityKit'; 4098import { BusinessError } from '@kit.BasicServicesKit'; 4099import { hilog } from '@kit.PerformanceAnalysisKit'; 4100 4101try { 4102 bundleManager.getAllSharedBundleInfo().then((data) => { 4103 hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); 4104 }).catch((err: BusinessError) => { 4105 hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); 4106 }); 4107} catch (err) { 4108 let message = (err as BusinessError).message; 4109 hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', message); 4110} 4111``` 4112 4113## bundleManager.getAppProvisionInfo<sup>10+</sup> 4114 4115getAppProvisionInfo(bundleName: string, callback: AsyncCallback\<AppProvisionInfo\>): void 4116 4117Obtains the provision profile based on the given bundle name. This API uses an asynchronous callback to return the result. 4118 4119No permission is required for obtaining the caller's own information. 4120 4121**System API**: This is a system API. 4122 4123**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4124 4125**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4126 4127**Parameters** 4128 4129| Name | Type | Mandatory| Description | 4130| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 4131| bundleName | string | Yes | Bundle name.| 4132| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the provision profile.| 4133 4134**Error codes** 4135 4136For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4137 4138| ID| Error Message | 4139| -------- | -------------------------------------- | 4140| 201 | Permission denied. | 4141| 202 | Permission denied, non-system app called system api. | 4142| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. | 4143| 17700001 | The specified bundleName is not found. | 4144 4145**Example** 4146 4147```ts 4148import { bundleManager } from '@kit.AbilityKit'; 4149import { BusinessError } from '@kit.BasicServicesKit'; 4150import { hilog } from '@kit.PerformanceAnalysisKit'; 4151let bundleName = "com.ohos.myapplication"; 4152 4153try { 4154 bundleManager.getAppProvisionInfo(bundleName, (err, data) => { 4155 if (err) { 4156 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message); 4157 } else { 4158 hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data)); 4159 } 4160 }); 4161} catch (err) { 4162 let message = (err as BusinessError).message; 4163 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message); 4164} 4165``` 4166 4167## bundleManager.getAppProvisionInfo<sup>10+</sup> 4168 4169getAppProvisionInfo(bundleName: string, userId: number, callback: AsyncCallback\<AppProvisionInfo\>): void 4170 4171Obtains the provision profile based on the given bundle name and user ID. This API uses an asynchronous callback to return the result. 4172 4173No permission is required for obtaining the caller's own information. 4174 4175**System API**: This is a system API. 4176 4177**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4178 4179**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4180 4181**Parameters** 4182 4183| Name | Type | Mandatory| Description | 4184| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 4185| bundleName | string | Yes | Bundle name.| 4186| userId | number | Yes| User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).| 4187| callback | AsyncCallback\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the provision profile.| 4188 4189 4190**Error codes** 4191 4192For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4193 4194| ID| Error Message | 4195| -------- | -------------------------------------- | 4196| 201 | Permission denied. | 4197| 202 | Permission denied, non-system app called system api. | 4198| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. | 4199| 17700001 | The specified bundleName is not found. | 4200| 17700004 | The specified user ID is not found. | 4201 4202**Example** 4203 4204```ts 4205import { bundleManager } from '@kit.AbilityKit'; 4206import { BusinessError } from '@kit.BasicServicesKit'; 4207import { hilog } from '@kit.PerformanceAnalysisKit'; 4208let bundleName = "com.ohos.myapplication"; 4209let userId = 100; 4210 4211try { 4212 bundleManager.getAppProvisionInfo(bundleName, userId, (err, data) => { 4213 if (err) { 4214 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', err.message); 4215 } else { 4216 hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully: %{public}s', JSON.stringify(data)); 4217 } 4218 }); 4219} catch (err) { 4220 let message = (err as BusinessError).message; 4221 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed: %{public}s', message); 4222} 4223``` 4224 4225## bundleManager.getAppProvisionInfo<sup>10+</sup> 4226 4227getAppProvisionInfo(bundleName: string, userId?: number): Promise\<AppProvisionInfo\> 4228 4229Obtains the provision profile based on the given bundle name and user ID. This API uses a promise to return the result. 4230 4231No permission is required for obtaining the caller's own information. 4232 4233**System API**: This is a system API. 4234 4235**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4236 4237**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4238 4239**Parameters** 4240 4241| Name | Type | Mandatory| Description | 4242| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 4243| bundleName | string | Yes| Bundle name.| 4244| userId | number | No| User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0.| 4245 4246 4247**Return value** 4248 4249| Type | Description | 4250| ------------------------------------------------------------ | ----------------------------------- | 4251| Promise\<[AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md)\> | Promise used to return the provision profile obtained.| 4252 4253**Error codes** 4254 4255For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4256 4257| ID| Error Message | 4258| -------- | -------------------------------------- | 4259| 201 | Permission denied. | 4260| 202 | Permission denied, non-system app called system api. | 4261| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. | 4262| 17700001 | The specified bundleName is not found. | 4263| 17700004 | The specified user ID is not found. | 4264 4265**Example** 4266 4267```ts 4268import { bundleManager } from '@kit.AbilityKit'; 4269import { BusinessError } from '@kit.BasicServicesKit'; 4270import { hilog } from '@kit.PerformanceAnalysisKit'; 4271let bundleName = "com.ohos.myapplication"; 4272let userId = 100; 4273 4274try { 4275 bundleManager.getAppProvisionInfo(bundleName).then((data) => { 4276 hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data)); 4277 }).catch((err: BusinessError) => { 4278 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); 4279 }); 4280} catch (err) { 4281 let message = (err as BusinessError).message; 4282 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message); 4283} 4284 4285try { 4286 bundleManager.getAppProvisionInfo(bundleName, userId).then((data) => { 4287 hilog.info(0x0000, 'testTag', 'getAppProvisionInfo successfully. Data: %{public}s', JSON.stringify(data)); 4288 }).catch((err: BusinessError) => { 4289 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); 4290 }); 4291} catch (err) { 4292 let message = (err as BusinessError).message; 4293 hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', message); 4294} 4295``` 4296 4297## bundleManager.getAppProvisionInfoSync<sup>10+</sup> 4298 4299getAppProvisionInfoSync(bundleName: string, userId?: number): AppProvisionInfo 4300 4301Obtains the provision profile based on the given bundle name and user ID. This API returns the result synchronously. 4302 4303No permission is required for obtaining the caller's own information. 4304 4305**System API**: This is a system API. 4306 4307**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4308 4309**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4310 4311**Parameters** 4312 4313| Name | Type | Mandatory| Description | 4314| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 4315| bundleName | string | Yes| Bundle name.| 4316| userId | number | No| User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0.| 4317 4318 4319**Return value** 4320 4321| Type | Description | 4322| ------------------------------------------------------------ | ----------------------------------- | 4323| [AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md) | Provision profile.| 4324 4325**Error codes** 4326 4327For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4328 4329| ID| Error Message | 4330| -------- | -------------------------------------- | 4331| 201 | Permission denied. | 4332| 202 | Permission denied, non-system app called system api. | 4333| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. | 4334| 17700001 | The specified bundleName is not found. | 4335| 17700004 | The specified user ID is not found. | 4336 4337**Example** 4338 4339```ts 4340import { bundleManager } from '@kit.AbilityKit'; 4341import { BusinessError } from '@kit.BasicServicesKit'; 4342import { hilog } from '@kit.PerformanceAnalysisKit'; 4343let bundleName = "com.ohos.myapplication"; 4344let userId = 100; 4345 4346try { 4347 let data = bundleManager.getAppProvisionInfoSync(bundleName); 4348 hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 4349} catch (err) { 4350 let message = (err as BusinessError).message; 4351 hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message); 4352} 4353 4354try { 4355 let data = bundleManager.getAppProvisionInfoSync(bundleName, userId); 4356 hilog.info(0x0000, 'testTag', 'getAppProvisionInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 4357} catch (err) { 4358 let message = (err as BusinessError).message; 4359 hilog.error(0x0000, 'testTag', 'getAppProvisionInfoSync failed. Cause: %{public}s', message); 4360} 4361``` 4362 4363## bundleManager.getSpecifiedDistributionType<sup>10+</sup> 4364getSpecifiedDistributionType(bundleName: string): string 4365 4366Obtains the [distribution type](../../security/app-provision-structure.md) of a bundle in synchronous mode. The return value is the **specifiedDistributionType** field value in [InstallParam](./js-apis-installer-sys.md#installparam) passed when **install** is called. 4367 4368No permission is required for obtaining the caller's own information. 4369 4370**System API**: This is a system API. 4371 4372**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4373 4374**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4375 4376**Parameters** 4377 4378| Name | Type | Mandatory| Description | 4379| -------------- | ----------------------------------- | ---- | ---------------------------- | 4380| bundleName | string | Yes | Bundle name.| 4381 4382**Return value** 4383 4384| Type | Description | 4385| ------------- | -------------------------------------- | 4386| string | [Distribution type](../../security/app-provision-structure.md) of the bundle.| 4387 4388**Error codes** 4389 4390For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4391 4392| ID| Error Message | 4393| -------- | ------------------------------------------------------------ | 4394| 201 | Permission denied. | 4395| 202 | Permission denied, non-system app called system api. | 4396| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 4397| 17700001 | The specified bundleName is not found. | 4398 4399**Example** 4400```ts 4401import { bundleManager } from '@kit.AbilityKit'; 4402import { BusinessError } from '@kit.BasicServicesKit'; 4403let bundleName = "com.example.myapplication"; 4404 4405try { 4406 let type = bundleManager.getSpecifiedDistributionType(bundleName); 4407 console.info('getSpecifiedDistributionType successfully, type:' + type); 4408} catch (error) { 4409 let message = (error as BusinessError).message; 4410 console.error('getSpecifiedDistributionType failed. Cause: ' + message); 4411} 4412``` 4413 4414 4415## bundleManager.getAdditionalInfo<sup>10+</sup> 4416 4417getAdditionalInfo(bundleName: string): string 4418 4419Obtains additional information about a bundle in synchronous mode. The return value is the **additionalInfo** field value in [InstallParam](./js-apis-installer-sys.md#installparam) passed when **install** is called. 4420 4421**System API**: This is a system API. 4422 4423**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4424 4425**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4426 4427**Parameters** 4428 4429| Name | Type | Mandatory| Description | 4430| -------------- | ----------------------------------- | ---- | ---------------------------- | 4431| bundleName | string | Yes | Bundle name.| 4432 4433**Return value** 4434 4435| Type | Description | 4436| ------------- | -------------------------------------- | 4437| string | Additional information about the bundle.| 4438 4439**Error codes** 4440 4441For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4442 4443| ID| Error Message | 4444| -------- | ------------------------------------------------------------ | 4445| 201 | Permission denied. | 4446| 202 | Permission denied, non-system app called system api. | 4447| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. | 4448| 17700001 | The specified bundleName is not found. | 4449 4450**Example** 4451 4452```ts 4453import { bundleManager } from '@kit.AbilityKit'; 4454import { BusinessError } from '@kit.BasicServicesKit'; 4455let bundleName = "com.example.myapplication"; 4456 4457try { 4458 let info = bundleManager.getAdditionalInfo(bundleName); 4459 console.info('getAdditionalInfo successfully, additionInfo:' + info); 4460} catch (error) { 4461 let message = (error as BusinessError).message; 4462 console.error('getAdditionalInfo failed. Cause: ' + message); 4463} 4464``` 4465 4466## bundleManager.queryExtensionAbilityInfoSync<sup>11+</sup> 4467 4468queryExtensionAbilityInfoSync(want: Want, extensionAbilityType: string, extensionAbilityFlags: number, userId?: number): Array\<ExtensionAbilityInfo> 4469 4470Obtains the ExtensionAbility information based on the given Want, ExtensionAbility type, ExtensionAbility flags, and user ID. This API returns the result synchronously. 4471 4472No permission is required for obtaining the caller's own information. 4473 4474**System API**: This is a system API. 4475 4476**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 4477 4478**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4479 4480**Parameters** 4481 4482| Name | Type | Mandatory| Description | 4483| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- | 4484| want | Want | Yes | Want containing the bundle name to query. | 4485| extensionAbilityType | string | Yes | Type of the custom ExtensionAbility. | 4486| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Information flags to be contained in the returned ExtensionAbilityInfo object.| 4487| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0.| 4488 4489**Return value** 4490 4491| Type | Description | 4492| ------------------------------------------------------------ | -------------------------------------- | 4493| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of ExtensionAbility information obtained.| 4494 4495**Error codes** 4496 4497For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4498 4499| ID| Error Message | 4500| -------- | -------------------------------------------- | 4501| 201 | Permission denied. | 4502| 202 | Permission denied, non-system app called system api. | 4503| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. At least one parameter(action, entity, uri, type or linkFeature) is required for implicit query. | 4504| 17700001 | The specified bundleName is not found. | 4505| 17700003 | The specified extensionAbility is not found. | 4506| 17700004 | The specified userId is invalid. | 4507| 17700026 | The specified bundle is disabled. | 4508 4509**Example** 4510 4511```ts 4512// Call the API with the userId parameter specified. 4513import { bundleManager } from '@kit.AbilityKit'; 4514import { hilog } from '@kit.PerformanceAnalysisKit'; 4515import { Want } from '@kit.AbilityKit'; 4516import { BusinessError } from '@kit.BasicServicesKit'; 4517 4518let extensionAbilityType = "form"; 4519let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 4520let userId = 100; 4521let want: Want = { 4522 bundleName : "com.example.myapplication", 4523 abilityName : "EntryAbility" 4524}; 4525 4526try { 4527 let data = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags, userId) 4528 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 4529} catch (err) { 4530 let message = (err as BusinessError).message; 4531 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message); 4532} 4533``` 4534 4535```ts 4536// Call the API without passing in the userId parameter. 4537import { bundleManager } from '@kit.AbilityKit'; 4538import { hilog } from '@kit.PerformanceAnalysisKit'; 4539import { Want } from '@kit.AbilityKit'; 4540import { BusinessError } from '@kit.BasicServicesKit'; 4541 4542let extensionAbilityType = "form"; 4543let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 4544let want: Want = { 4545 bundleName : "com.example.myapplication", 4546 abilityName : "EntryAbility" 4547}; 4548 4549try { 4550 let data = bundleManager.queryExtensionAbilityInfoSync(want, extensionAbilityType, extensionFlags); 4551 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 4552} catch (err) { 4553 let message = (err as BusinessError).message; 4554 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message); 4555} 4556``` 4557 4558## bundleManager.getJsonProfile<sup>11+</sup> 4559 4560getJsonProfile(profileType: ProfileType, bundleName: string, moduleName?: string, userId?: number): string 4561 4562Obtains the JSON strings of the profile based on the given profile type, bundle name, and module name. This API returns the result synchronously. 4563 4564No permission is required for obtaining the caller's own profile. 4565 4566**System API**: This is a system API. 4567 4568**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 4569 4570**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4571 4572**Parameters** 4573 4574| Name | Type | Mandatory| Description | 4575| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- | 4576| profileType | [ProfileType](#profiletype11) | Yes | Type of the profile. | 4577| bundleName | string | Yes | Bundle name of the application. | 4578| moduleName | string | No | Module name of the application. If this parameter is not passed in, the entry module is used. | 4579| userId<sup>12+</sup> | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 4580 4581**Return value** 4582 4583| Type | Description | 4584| ------ | ------------------------ | 4585| string | JSON string of the profile.| 4586 4587**Error codes** 4588 4589For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4590 4591| ID| Error Message | 4592| -------- | -------------------------------------------- | 4593| 201 | Permission denied. | 4594| 202 | Permission denied, non-system app called system api. | 4595| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 4596| 17700001 | The specified bundleName is not found. | 4597| 17700002 | The specified moduleName is not found. | 4598| 17700004 | The specified user ID is not found. | 4599| 17700024 | Failed to get the profile because the specified profile is not found in the HAP. | 4600| 17700026 | The specified bundle is disabled. | 4601 4602**Example** 4603 4604```ts 4605import { bundleManager } from '@kit.AbilityKit'; 4606import { hilog } from '@kit.PerformanceAnalysisKit'; 4607import { BusinessError } from '@kit.BasicServicesKit'; 4608 4609let bundleName = 'com.example.myapplication'; 4610let moduleName = 'entry'; 4611let profileType = bundleManager.ProfileType.INTENT_PROFILE; 4612 4613try { 4614 let data = bundleManager.getJsonProfile(profileType, bundleName, moduleName) 4615 hilog.info(0x0000, 'testTag', 'getJsonProfile successfully. Data: %{public}s', data); 4616} catch (err) { 4617 let message = (err as BusinessError).message; 4618 hilog.error(0x0000, 'testTag', 'getJsonProfile failed: %{public}s', message); 4619} 4620``` 4621 4622## bundleManager.getRecoverableApplicationInfo<sup>11+</sup> 4623 4624getRecoverableApplicationInfo(callback: AsyncCallback\<Array\<RecoverableApplicationInfo\>\>): void 4625 4626Obtains information about all preinstalled applications that can be restored. This API uses an asynchronous callback to return the result. 4627 4628**System API**: This is a system API. 4629 4630**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4631 4632**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4633 4634**Parameters** 4635 4636| Name | Type | Mandatory| Description | 4637| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 4638| callback | AsyncCallback\<Array\<[RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md)\>\> | Yes | [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null** and **data** is the information about all preinstalled applications.| 4639 4640**Error codes** 4641 4642For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4643 4644| ID| Error Message | 4645| -------- | -------------------------------------------- | 4646| 201 | Permission denied. | 4647| 202 | Permission denied, non-system app called system api. | 4648 4649**Example** 4650 4651```ts 4652import { bundleManager } from '@kit.AbilityKit'; 4653import { BusinessError } from '@kit.BasicServicesKit'; 4654import { hilog } from '@kit.PerformanceAnalysisKit'; 4655 4656try { 4657 bundleManager.getRecoverableApplicationInfo((err, data) => { 4658 if (err) { 4659 hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', err.message); 4660 } else { 4661 hilog.info(0x0000, 'testTag', 'getRecoverableApplicationInfo successfully: %{public}s', JSON.stringify(data)); 4662 } 4663 }); 4664} catch (err) { 4665 let message = (err as BusinessError).message; 4666 hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', message); 4667} 4668``` 4669 4670## bundleManager.getRecoverableApplicationInfo<sup>11+</sup> 4671 4672getRecoverableApplicationInfo(): Promise\<Array\<RecoverableApplicationInfo\>\> 4673 4674Obtains information about all preinstalled applications that can be restored. This API uses a promise to return the result. 4675 4676**System API**: This is a system API. 4677 4678**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4679 4680**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4681 4682**Return value** 4683 4684| Type | Description | 4685| ------------------------------------------------------------ | ----------------------------------- | 4686| Promise\<Array\<[RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md)\>\> | Promise used to return the information about all recoverable applications.| 4687 4688**Error codes** 4689 4690For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4691 4692| ID| Error Message | 4693| -------- | -------------------------------------------- | 4694| 201 | Permission denied. | 4695| 202 | Permission denied, non-system app called system api. | 4696 4697**Example** 4698 4699```ts 4700import { bundleManager } from '@kit.AbilityKit'; 4701import { BusinessError } from '@kit.BasicServicesKit'; 4702import { hilog } from '@kit.PerformanceAnalysisKit'; 4703 4704try { 4705 bundleManager.getRecoverableApplicationInfo().then((data) => { 4706 hilog.info(0x0000, 'testTag', 'getRecoverableApplicationInfo successfully: %{public}s', JSON.stringify(data)); 4707 }).catch((err: BusinessError) => { 4708 hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', err.message); 4709 }); 4710} catch (err) { 4711 let message = (err as BusinessError).message; 4712 hilog.error(0x0000, 'testTag', 'getRecoverableApplicationInfo failed: %{public}s', message); 4713} 4714``` 4715 4716## bundleManager.setAdditionalInfo<sup>11+</sup> 4717 4718setAdditionalInfo(bundleName: string, additionalInfo: string): void 4719 4720Sets additional information for an application. This API can be called only by AppGallery. 4721 4722**System API**: This is a system API. 4723 4724**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4725 4726**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4727 4728**Parameters** 4729 4730| Name | Type | Mandatory| Description | 4731| --------------------- | ------------------------------- | ---- | -------------------------------------------------- | 4732| bundleName | string | Yes | Bundle name. | 4733| additionalInfo | string | Yes | Additional information to set. | 4734 4735**Error codes** 4736 4737For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4738 4739| ID| Error Message | 4740| -------- | ---------------------------------------------------------- | 4741| 201 | Permission denied. | 4742| 202 | Permission denied, non-system app called system api. | 4743| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter bundleName is empty. | 4744| 17700001 | The specified bundleName is not found. | 4745| 17700053 | The caller is not AppGallery. | 4746 4747**Example** 4748 4749```ts 4750import { bundleManager } from '@kit.AbilityKit'; 4751import { BusinessError } from '@kit.BasicServicesKit'; 4752import { hilog } from '@kit.PerformanceAnalysisKit'; 4753 4754let bundleName = "com.example.myapplication"; 4755let additionalInfo = "xxxxxxxxx,formUpdateLevel:4"; 4756 4757try { 4758 bundleManager.setAdditionalInfo(bundleName, additionalInfo); 4759 hilog.info(0x0000, 'testTag', 'setAdditionalInfo successfully.'); 4760} catch (err) { 4761 let message = (err as BusinessError).message; 4762 hilog.error(0x0000, 'testTag', 'setAdditionalInfo failed. Cause: %{public}s', message); 4763} 4764``` 4765 4766## bundleManager.getAllPreinstalledApplicationInfo<sup>12+</sup> 4767 4768getAllPreinstalledApplicationInfo(): Promise\<Array\<PreinstalledApplicationInfo\>\> 4769 4770Obtains information about all preinstalled applications. This API uses a promise to return the result. 4771 4772**System API**: This is a system API. 4773 4774**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4775 4776**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4777 4778**Return value** 4779 4780| Type | Description | 4781| ------------------------------------------------------------ | ----------------------------------- | 4782| Promise<Array\<[PreinstalledApplicationInfo](js-apis-bundleManager-ApplicationInfo-sys.md)>> | Promise used to return the array of preinstalled applications obtained.| 4783 4784**Error codes** 4785 4786For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4787 4788| ID| Error Message | 4789| -------- | ---------------------------------------------------------- | 4790| 201 | Permission denied. | 4791| 202 | Permission denied, non-system app called system api. | 4792 4793**Example** 4794 4795```ts 4796import { bundleManager } from '@kit.AbilityKit'; 4797import { BusinessError } from '@kit.BasicServicesKit'; 4798import { hilog } from '@kit.PerformanceAnalysisKit'; 4799 4800try { 4801 bundleManager.getAllPreinstalledApplicationInfo().then((data)=>{ 4802 hilog.info(0x0000, 'testTag', 'getAllPreinstalledApplicationInfo success, Data: %{public}s', JSON.stringify(data)); 4803 }).catch((err: BusinessError) => { 4804 hilog.error(0x0000, 'testTag', 'getAllPreinstalledApplicationInfo failed. Cause: %{public}s', err.message); 4805 }); 4806} catch (err) { 4807 let message = (err as BusinessError).message; 4808 hilog.error(0x0000, 'testTag', 'getAllPreinstalledApplicationInfo failed: %{public}s', message); 4809} 4810``` 4811 4812## bundleManager.queryExtensionAbilityInfoSync<sup>11+</sup> 4813 4814queryExtensionAbilityInfoSync(extensionAbilityType: string, extensionAbilityFlags: number, userId?: number): Array\<ExtensionAbilityInfo> 4815 4816Obtains the ExtensionAbility information based on the given ExtensionAbility type, ExtensionAbility flags, and user ID. 4817 4818No permission is required for obtaining the caller's own information. 4819 4820**System API**: This is a system API. 4821 4822**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 4823 4824**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4825 4826**Parameters** 4827 4828| Name | Type | Mandatory| Description | 4829| --------------------- | ------------------------------- | ---- | --------------------------------------------------------- | 4830| extensionAbilityType | string | Yes | Type of the custom ExtensionAbility. | 4831| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Information flags to be contained in the returned ExtensionAbilityInfo object.| 4832| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0.| 4833 4834**Return value** 4835 4836| Type | Description | 4837| ------------------------------------------------------------ | -------------------------------------- | 4838| Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | An array of ExtensionAbility information obtained.| 4839 4840**Error codes** 4841 4842For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4843 4844| ID| Error Message | 4845| -------- | -------------------------------------------- | 4846| 201 | Permission denied. | 4847| 202 | Permission denied, non-system app called system api. | 4848| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter extensionAbilityType is empty. | 4849| 17700003 | The specified extensionAbility is not found. | 4850| 17700004 | The specified userId is invalid. | 4851 4852**Example** 4853 4854```ts 4855// Call the API with the userId parameter specified. 4856import { bundleManager } from '@kit.AbilityKit'; 4857import { hilog } from '@kit.PerformanceAnalysisKit'; 4858import { BusinessError } from '@kit.BasicServicesKit'; 4859 4860let extensionAbilityType = "form"; 4861let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 4862let userId = 100; 4863 4864try { 4865 let data = bundleManager.queryExtensionAbilityInfoSync(extensionAbilityType, extensionFlags, userId) 4866 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 4867} catch (err) { 4868 let message = (err as BusinessError).message; 4869 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message); 4870} 4871``` 4872 4873```ts 4874// Call the API without passing in the userId parameter. 4875import { bundleManager } from '@kit.AbilityKit'; 4876import { hilog } from '@kit.PerformanceAnalysisKit'; 4877import { BusinessError } from '@kit.BasicServicesKit'; 4878 4879let extensionAbilityType = "form"; 4880let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; 4881 4882try { 4883 let data = bundleManager.queryExtensionAbilityInfoSync(extensionAbilityType, extensionFlags); 4884 hilog.info(0x0000, 'testTag', 'queryExtensionAbilityInfoSync successfully. Data: %{public}s', JSON.stringify(data)); 4885} catch (err) { 4886 let message = (err as BusinessError).message; 4887 hilog.error(0x0000, 'testTag', 'queryExtensionAbilityInfoSync failed: %{public}s', message); 4888} 4889``` 4890 4891## bundleManager.getAllBundleInfoByDeveloperId<sup>12+</sup> 4892 4893getAllBundleInfoByDeveloperId(developerId: string): Array\<BundleInfo> 4894 4895Obtains the information about all bundles of the current user based on the given developer ID. 4896 4897**System API**: This is a system API. 4898 4899**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4900 4901**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4902 4903**Parameters** 4904 4905| Name | Type | Mandatory| Description | 4906| --------------------- | ---------| ---- | --------------------- | 4907| developerId | string | Yes | Developer ID. | 4908 4909**Return value** 4910 4911| Type | Description | 4912| ------------------------------------------------------------ | -------------------------------------- | 4913| Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | An array of bundle information.| 4914 4915**Error codes** 4916 4917For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 4918 4919| ID| Error Message | 4920| -------- | -------------------------------------------- | 4921| 201 | Permission denied. | 4922| 202 | Permission denied, non-system app called system api. | 4923| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter developerId is empty. | 4924| 17700059 | The specified developerId is invalid. | 4925 4926**Example** 4927 4928```ts 4929import { bundleManager } from '@kit.AbilityKit'; 4930import { hilog } from '@kit.PerformanceAnalysisKit'; 4931import { BusinessError } from '@kit.BasicServicesKit'; 4932 4933let developerId = "123456.789"; 4934 4935try { 4936 let data = bundleManager.getAllBundleInfoByDeveloperId(developerId); 4937 hilog.info(0x0000, 'testTag', 'getAllBundleInfoByDeveloperId successfully. Data: %{public}s', JSON.stringify(data)); 4938} catch (err) { 4939 let message = (err as BusinessError).message; 4940 hilog.error(0x0000, 'testTag', 'getAllBundleInfoByDeveloperId failed: %{public}s', message); 4941} 4942``` 4943 4944## bundleManager.getDeveloperIds<sup>12+</sup> 4945 4946getDeveloperIds(appDistributionType?: number): Array\<string> 4947 4948Obtains all the developer IDs of the current user based on the given application [distribution type](#appdistributiontype12). 4949 4950**System API**: This is a system API. 4951 4952**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 4953 4954**System capability**: SystemCapability.BundleManager.BundleFramework.Core 4955 4956**Parameters** 4957 4958| Name | Type | Mandatory| Description | 4959| --------------------- | ---------| ---- | --------------------- | 4960| [appDistributionType](#appdistributiontype12) | number | No | Application distribution type. If this parameter is not specified, a list of developer IDs of all applications is returned. | 4961 4962**Return value** 4963 4964| Type | Description | 4965| ------------------------------------------------------------ | -------------------------------------- | 4966| Array\<string> | An array of strings.| 4967 4968**Error codes** 4969 4970For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4971 4972| ID| Error Message | 4973| -------- | -------------------------------------------- | 4974| 201 | Permission denied. | 4975| 202 | Permission denied, non-system app called system api. | 4976| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 4977 4978**Example** 4979 4980```ts 4981import { bundleManager } from '@kit.AbilityKit'; 4982import { hilog } from '@kit.PerformanceAnalysisKit'; 4983import { BusinessError } from '@kit.BasicServicesKit'; 4984 4985let appDistributionType = bundleManager.AppDistributionType.ENTERPRISE; 4986 4987try { 4988 let data = bundleManager.getDeveloperIds(appDistributionType); 4989 hilog.info(0x0000, 'testTag', 'getDeveloperIds successfully. Data: %{public}s', JSON.stringify(data)); 4990} catch (err) { 4991 let message = (err as BusinessError).message; 4992 hilog.error(0x0000, 'testTag', 'getDeveloperIds failed: %{public}s', message); 4993} 4994``` 4995 4996## bundleManager.switchUninstallState<sup>12+</sup> 4997 4998switchUninstallState(bundleName: string, state: boolean): void 4999 5000Switches the uninstall state of an application. This API is independent of EDM application interception control. 5001 5002**System API**: This is a system API. 5003 5004**Required permissions**: ohos.permission.CHANGE_BUNDLE_UNINSTALL_STATE 5005 5006**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5007 5008**Parameters** 5009 5010| Name | Type | Mandatory| Description | 5011| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 5012| bundleName | string | Yes | Bundle name of the application.| 5013| state | boolean | Yes | Whether the application can be uninstalled. T**true** if the application can be uninstalled, **false** otherwise.| 5014 5015**Error codes** 5016 5017For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5018 5019| ID| Error Message | 5020| -------- | -------------------------------------- | 5021| 201 | Permission denied. | 5022| 202 | Permission denied, non-system app called system api. | 5023| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5024| 17700001 | The specified bundleName is not found. | 5025| 17700060 | The specified application cannot be uninstalled. | 5026 5027**Example** 5028 5029```ts 5030import { bundleManager } from '@kit.AbilityKit'; 5031import { hilog } from '@kit.PerformanceAnalysisKit'; 5032import { BusinessError } from '@kit.BasicServicesKit'; 5033 5034try { 5035 bundleManager.switchUninstallState('com.example.myapplication', false); 5036} catch (err) { 5037 let message = (err as BusinessError).message; 5038 hilog.error(0x0000, 'testTag', 'switchUninstallState failed: %{public}s', message); 5039} 5040``` 5041 5042## bundleManager.getAllPluginInfo<sup>19+</sup> 5043 5044getAllPluginInfo(hostBundleName: string, userId?: number): Promise<Array\<PluginBundleInfo>> 5045 5046Obtains all the plugin information in the system based on the given host bundle name and user ID. This API uses a promise to return the result. 5047 5048**System API**: This is a system API. 5049 5050**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 5051 5052**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5053 5054**Parameters** 5055 5056| Name | Type | Mandatory| Description | 5057| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 5058| hostBundleName | string | Yes | Bundle name of the target application.| 5059| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0.| 5060 5061**Return value** 5062 5063| Type | Description | 5064| ------------------------------------------------------------ | -------------------------------------- | 5065| Promise<Array\<[PluginBundleInfo](js-apis-bundleManager-pluginBundleInfo-sys.md)>> | Promise used to return the array of plugin information obtained.| 5066 5067**Error codes** 5068 5069For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5070 5071| ID| Error Message | 5072| -------- | -------------------------------------- | 5073| 201 | Permission denied. | 5074| 202 | Permission denied, non-system app called system api. | 5075| 17700001 | The specified bundleName is not found. | 5076| 17700004 | The specified user ID is not found. | 5077 5078**Example** 5079 5080```ts 5081import { bundleManager } from '@kit.AbilityKit'; 5082import { BusinessError } from '@kit.BasicServicesKit'; 5083import { hilog } from '@kit.PerformanceAnalysisKit'; 5084let hostBundleName = 'com.ohos.demo'; 5085let userId = 100; 5086 5087try { 5088 bundleManager.getAllPluginInfo(hostBundleName, userId).then((data) => { 5089 hilog.info(0x0000, 'testTag', 'getAllPluginInfo successfully. Data: %{public}s', JSON.stringify(data)); 5090 }).catch((err: BusinessError) => { 5091 hilog.error(0x0000, 'testTag', 'getAllPluginInfo failed. Cause: %{public}s', err.message); 5092 }); 5093} catch (err) { 5094 let message = (err as BusinessError).message; 5095 hilog.error(0x0000, 'testTag', 'getAllPluginInfo failed. Cause: %{public}s', message); 5096} 5097``` 5098 5099```ts 5100import { bundleManager } from '@kit.AbilityKit'; 5101import { BusinessError } from '@kit.BasicServicesKit'; 5102import { hilog } from '@kit.PerformanceAnalysisKit'; 5103let hostBundleName = 'com.ohos.demo'; 5104 5105try { 5106 bundleManager.getAllPluginInfo(hostBundleName).then((data) => { 5107 hilog.info(0x0000, 'testTag', 'getAllPluginInfo successfully. Data: %{public}s', JSON.stringify(data)); 5108 }).catch((err: BusinessError) => { 5109 hilog.error(0x0000, 'testTag', 'getAllPluginInfo failed. Cause: %{public}s', err.message); 5110 }); 5111} catch (err) { 5112 let message = (err as BusinessError).message; 5113 hilog.error(0x0000, 'testTag', 'getAllPluginInfo failed. Cause: %{public}s', message); 5114} 5115``` 5116 5117## bundleManager.getExtResource<sup>12+</sup> 5118 5119getExtResource(bundleName: string): Promise\<Array\<string>>; 5120 5121Obtains the module names corresponding to the extended resources based on the given bundle name. This API uses a promise to return the result. 5122 5123**System API**: This is a system API. 5124 5125**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 5126 5127**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5128 5129**Parameters** 5130 5131| Name | Type | Mandatory| Description | 5132| ----------- | ------ | ---- | ---------------------------- | 5133| bundleName | string | Yes | Bundle name based on which the extended resources are to be queried.| 5134 5135**Return value** 5136 5137| Type | Description | 5138| ----------------------------------------------------------- | --------------------------- | 5139| Promise\<Array\<string>> | Promise used to return the API call result and the module names corresponding to the extended resources.| 5140 5141**Error codes** 5142 5143For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5144 5145| ID| Error Message | 5146| -------- | --------------------------------------| 5147| 201 | Permission denied. | 5148| 202 | Permission denied, non-system app called system api. | 5149| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5150| 17700001 | The specified bundleName is not found. | 5151| 17700303 | Failed to obtain extended resources. | 5152 5153**Example** 5154 5155```ts 5156import { bundleManager } from '@kit.AbilityKit'; 5157import { BusinessError } from '@kit.BasicServicesKit'; 5158import { hilog } from '@kit.PerformanceAnalysisKit'; 5159let bundleName : string = 'com.ohos.demo'; 5160 5161try { 5162 bundleManager.getExtResource(bundleName).then((modules : Array<string>) => { 5163 for (let i = 0; i < modules.length; i++) { 5164 hilog.info(0x0000, 'testTag', 'getExtResource item: %s', modules[i]); 5165 } 5166 }).catch((err: BusinessError) => { 5167 hilog.error(0x0000, 'testTag', 'getExtResource failed. Cause: %{public}s', err.message); 5168 }); 5169} catch (err) { 5170 let message = (err as BusinessError).message; 5171 hilog.error(0x0000, 'testTag', 'getExtResource failed. Cause: %{public}s', message); 5172} 5173``` 5174 5175## bundleManager.enableDynamicIcon<sup>12+</sup> 5176 5177enableDynamicIcon(bundleName: string, moduleName: string): Promise\<void>; 5178 5179Enables the dynamic icon based on the given bundle name and module name. This API uses a promise to return the result. 5180 5181**System API**: This is a system API. 5182 5183**Required permissions**: ohos.permission.ACCESS_DYNAMIC_ICON 5184 5185**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5186 5187**Parameters** 5188 5189| Name | Type | Mandatory| Description | 5190| ----------- | ------ | ---- | ---------------------------- | 5191| bundleName | string | Yes | Bundle name based on which the dynamic icon is to be enabled.| 5192| moduleName | string | Yes | Module name based on which the dynamic icon is to be enabled.| 5193 5194**Return value** 5195 5196| Type | Description | 5197| ----------------------------------------------------------- | --------------------------- | 5198| Promise\<void> | Promise that returns no value.| 5199 5200**Error codes** 5201 5202For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5203 5204| ID| Error Message | 5205| -------- | --------------------------------------| 5206| 201 | Permission denied. | 5207| 202 | Permission denied, non-system app called system api. | 5208| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5209| 17700001 | The specified bundleName is not found. | 5210| 17700002 | The specified moduleName is not found. | 5211| 17700304 | Failed to enable the dynamic icon. | 5212| 17700307 | Dynamic icons cannot take effect due to existing custom themes. | 5213 5214**Example** 5215 5216```ts 5217import { bundleManager } from '@kit.AbilityKit'; 5218import { BusinessError } from '@kit.BasicServicesKit'; 5219import { hilog } from '@kit.PerformanceAnalysisKit'; 5220let bundleName : string = 'com.ohos.demo'; 5221let moduleName : string = 'moduleTest'; 5222 5223try { 5224 bundleManager.enableDynamicIcon(bundleName, moduleName).then((data) => { 5225 hilog.info(0x0000, 'testTag', 'enableDynamicIcon successfully'); 5226 }).catch((err: BusinessError) => { 5227 hilog.error(0x0000, 'testTag', 'enableDynamicIcon failed. Cause: %{public}s', err.message); 5228 }); 5229} catch (err) { 5230 let message = (err as BusinessError).message; 5231 hilog.error(0x0000, 'testTag', 'enableDynamicIcon failed. Cause: %{public}s', message); 5232} 5233``` 5234 5235## bundleManager.enableDynamicIcon<sup>20+</sup> 5236 5237enableDynamicIcon(bundleName: string, moduleName: string, option?: BundleOptions): Promise\<void> 5238 5239Enables the dynamic icon based on the given bundle name, module name, and bundle options. This API uses a promise to return the result. 5240 5241To enable the dynamic icon for the current user, you must request the ohos.permission.ACCESS_DYNAMIC_ICON permission. 5242 5243To enable the dynamic icon for another user, you must request the ohos.permission.ACCESS_DYNAMIC_ICON and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS permissions. 5244 5245**System API**: This is a system API. 5246 5247**Required permissions**: ohos.permission.ACCESS_DYNAMIC_ICON or (ohos.permission.ACCESS_DYNAMIC_ICON and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS) 5248 5249 5250**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5251 5252**Parameters** 5253 5254| Name | Type | Mandatory| Description | 5255| ----------- | ------ | ---- | ---------------------------- | 5256| bundleName | string | Yes | Bundle name based on which the dynamic icon is to be enabled.| 5257| moduleName | string | Yes | Module name based on which the dynamic icon is to be enabled.| 5258| option | [BundleOptions](js-apis-bundleManager-BundleInfo-sys.md#bundleoptions) | No | User and application clone index based on which the dynamic icon is to be enabled. By default, the dynamic icon is enabled for all users and all application clones.| 5259 5260**Return value** 5261 5262| Type | Description | 5263| ----------------------------------------------------------- | --------------------------- | 5264| Promise\<void> | Promise that returns no value.| 5265 5266**Error codes** 5267 5268For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5269 5270| ID| Error Message | 5271| -------- | --------------------------------------| 5272| 201 | Permission denied. | 5273| 202 | Permission denied, non-system app called system api. | 5274| 17700001 | The specified bundleName is not found. | 5275| 17700002 | The specified moduleName is not found. | 5276| 17700004 | The specified user ID is not found. | 5277| 17700061 | AppIndex not in valid range. | 5278| 17700304 | Failed to enable the dynamic icon. | 5279| 17700307 | Dynamic icons cannot take effect due to existing custom themes. | 5280 5281**Example** 5282 5283```ts 5284import { bundleManager } from '@kit.AbilityKit'; 5285import { BusinessError } from '@kit.BasicServicesKit'; 5286import { hilog } from '@kit.PerformanceAnalysisKit'; 5287 5288let bundleName: string = 'com.ohos.demo'; 5289let moduleName: string = 'moduleTest'; 5290let option: bundleManager.BundleOptions = {'userId':100, 'appIndex':0}; 5291 5292try { 5293 bundleManager.enableDynamicIcon(bundleName, moduleName, option).then(() => { 5294 hilog.info(0x0000, 'testTag', 'enableDynamicIcon successfully'); 5295 }).catch((err: BusinessError) => { 5296 hilog.error(0x0000, 'testTag', 'enableDynamicIcon failed. Cause: %{public}s', err.message); 5297 }); 5298} catch (err) { 5299 let message = (err as BusinessError).message; 5300 hilog.error(0x0000, 'testTag', 'enableDynamicIcon failed. Cause: %{public}s', message); 5301} 5302``` 5303 5304## bundleManager.disableDynamicIcon<sup>12+</sup> 5305 5306disableDynamicIcon(bundleName: string): Promise\<void>; 5307 5308Disables the dynamic icon based on the given bundle name. This API uses a promise to return the result. 5309 5310**System API**: This is a system API. 5311 5312**Required permissions**: ohos.permission.ACCESS_DYNAMIC_ICON 5313 5314**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5315 5316**Parameters** 5317 5318| Name | Type | Mandatory| Description | 5319| ----------- | ------ | ---- | ---------------------------- | 5320| bundleName | string | Yes | Bundle name based on which the dynamic icon is to be disabled.| 5321 5322**Return value** 5323 5324| Type | Description | 5325| ----------------------------------------------------------- | --------------------------- | 5326| Promise\<void> | Promise that returns no value.| 5327 5328**Error codes** 5329 5330For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5331 5332| ID| Error Message | 5333| -------- | --------------------------------------| 5334| 201 | Permission denied. | 5335| 202 | Permission denied, non-system app called system api. | 5336| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5337| 17700001 | The specified bundleName is not found. | 5338| 17700305 | Failed to disable the dynamic icon. | 5339 5340**Example** 5341 5342```ts 5343import { bundleManager } from '@kit.AbilityKit'; 5344import { BusinessError } from '@kit.BasicServicesKit'; 5345import { hilog } from '@kit.PerformanceAnalysisKit'; 5346let bundleName : string = 'com.ohos.demo'; 5347 5348try { 5349 bundleManager.disableDynamicIcon(bundleName).then((data) => { 5350 hilog.info(0x0000, 'testTag', 'disableDynamicIcon successfully'); 5351 }).catch((err: BusinessError) => { 5352 hilog.error(0x0000, 'testTag', 'disableDynamicIcon failed. Cause: %{public}s', err.message); 5353 }); 5354} catch (err) { 5355 let message = (err as BusinessError).message; 5356 hilog.error(0x0000, 'testTag', 'disableDynamicIcon failed. Cause: %{public}s', message); 5357} 5358``` 5359 5360## bundleManager.disableDynamicIcon<sup>20+</sup> 5361 5362disableDynamicIcon(bundleName: string, option?: BundleOptions): Promise\<void> 5363 5364Disables the dynamic icon based on the given bundle name and bundle options. This API uses a promise to return the result. 5365 5366To disable the dynamic icon for the current user, you must request the ohos.permission.ACCESS_DYNAMIC_ICON permission. 5367 5368To disable the dynamic icon for another user, you must request the ohos.permission.ACCESS_DYNAMIC_ICON and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS permissions. 5369 5370**System API**: This is a system API. 5371 5372**Required permissions**: ohos.permission.ACCESS_DYNAMIC_ICON or (ohos.permission.ACCESS_DYNAMIC_ICON and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS) 5373 5374 5375**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5376 5377**Parameters** 5378 5379| Name | Type | Mandatory| Description | 5380| ----------- | ------ | ---- | ---------------------------- | 5381| bundleName | string | Yes | Bundle name based on which the dynamic icon is to be disabled.| 5382| option | [BundleOptions](js-apis-bundleManager-BundleInfo-sys.md#bundleoptions) | No | User and application clone index based on which the dynamic icon is to be disabled. By default, the dynamic icon is disabled for all users and all application clones.| 5383 5384**Return value** 5385 5386| Type | Description | 5387| ----------------------------------------------------------- | --------------------------- | 5388| Promise\<void> | Promise that returns no value.| 5389 5390**Error codes** 5391 5392For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5393 5394| ID| Error Message | 5395| -------- | --------------------------------------| 5396| 201 | Permission denied. | 5397| 202 | Permission denied, non-system app called system api. | 5398| 17700001 | The specified bundleName is not found. | 5399| 17700004 | The specified user ID is not found. | 5400| 17700061 | AppIndex not in valid range. | 5401| 17700305 | Failed to disable the dynamic icon. | 5402 5403**Example** 5404 5405```ts 5406import { bundleManager } from '@kit.AbilityKit'; 5407import { BusinessError } from '@kit.BasicServicesKit'; 5408import { hilog } from '@kit.PerformanceAnalysisKit'; 5409 5410let bundleName: string = 'com.ohos.demo'; 5411let option: bundleManager.BundleOptions = {'userId':100, 'appIndex':0}; 5412 5413try { 5414 bundleManager.disableDynamicIcon(bundleName, option).then(() => { 5415 hilog.info(0x0000, 'testTag', 'disableDynamicIcon successfully'); 5416 }).catch((err: BusinessError) => { 5417 hilog.error(0x0000, 'testTag', 'disableDynamicIcon failed. Cause: %{public}s', err.message); 5418 }); 5419} catch (err) { 5420 let message = (err as BusinessError).message; 5421 hilog.error(0x0000, 'testTag', 'disableDynamicIcon failed. Cause: %{public}s', message); 5422} 5423``` 5424 5425## bundleManager.getDynamicIcon<sup>12+</sup> 5426 5427getDynamicIcon(bundleName: string): Promise\<string>; 5428 5429Obtains the module name corresponding to the dynamic icon based on the specified bundle name. This API uses a promise to return the result. 5430 5431**System API**: This is a system API. 5432 5433**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 5434 5435**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5436 5437**Parameters** 5438 5439| Name | Type | Mandatory| Description | 5440| ----------- | ------ | ---- | ---------------------------- | 5441| bundleName | string | Yes | Bundle name based on which the extended resources are to be queried.| 5442 5443**Return value** 5444 5445| Type | Description | 5446| ----------------------------------------------------------- | --------------------------- | 5447| Promise\<string> | Promise used to return the API call result and module name corresponding to the dynamic icon.| 5448 5449**Error codes** 5450 5451For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5452 5453| ID| Error Message | 5454| -------- | --------------------------------------| 5455| 201 | Permission denied. | 5456| 202 | Permission denied, non-system app called system api. | 5457| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5458| 17700001 | The specified bundleName is not found. | 5459| 17700306 | Failed to obtain the dynamic icon. | 5460 5461**Example** 5462 5463```ts 5464import { bundleManager } from '@kit.AbilityKit'; 5465import { BusinessError } from '@kit.BasicServicesKit'; 5466import { hilog } from '@kit.PerformanceAnalysisKit'; 5467let bundleName : string = 'com.ohos.demo'; 5468 5469try { 5470 bundleManager.getDynamicIcon(bundleName).then((data) => { 5471 hilog.info(0x0000, 'testTag', 'getDynamicIcon successfully %s', JSON.stringify(data)); 5472 }).catch((err: BusinessError) => { 5473 hilog.error(0x0000, 'testTag', 'getDynamicIcon failed. Cause: %{public}s', err.message); 5474 }); 5475} catch (err) { 5476 let message = (err as BusinessError).message; 5477 hilog.error(0x0000, 'testTag', 'getDynamicIcon failed. Cause: %{public}s', message); 5478} 5479``` 5480 5481## bundleManager.getAppCloneIdentity<sup>14+</sup> 5482 5483getAppCloneIdentity(uid: number): Promise\<AppCloneIdentity>; 5484 5485Obtains the bundle name and application index of an application clone based on the given UID. This API uses a promise to return the result. 5486 5487**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 5488 5489**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5490 5491**Parameters** 5492 5493| Name | Type | Mandatory| Description | 5494| ---------- | ------ | ---- | ---------------------------| 5495| uid | number | Yes | UID of the application. | 5496 5497**Return value** 5498 5499| Type | Description | 5500| ----------------------------------------------------------- | --------------------------- | 5501| Promise\<AppCloneIdentity> | Promise used to return \<AppCloneIdentity>.| 5502 5503**Error codes** 5504 5505For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5506 5507| ID| Error Message | 5508| -------- | --------------------------------------| 5509| 201 | Permission denied. | 5510| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5511| 17700021 | The uid is not found. | 5512 5513**Example** 5514 5515```ts 5516import { bundleManager } from '@kit.AbilityKit'; 5517import { BusinessError } from '@kit.BasicServicesKit'; 5518import { hilog } from '@kit.PerformanceAnalysisKit'; 5519let uid = 20010005; 5520 5521try { 5522 bundleManager.getAppCloneIdentity(uid).then((res: bundleManager.AppCloneIdentity) => { 5523 hilog.info(0x0000, 'testTag', 'getAppCloneIdentity res = %{public}s', JSON.stringify(res)); 5524 }).catch((err: BusinessError) => { 5525 hilog.error(0x0000, 'testTag', 'getAppCloneIdentity failed. Cause: %{public}s', err.message); 5526 }); 5527} catch (err) { 5528 let message = (err as BusinessError).message; 5529 hilog.error(0x0000, 'testTag', 'getAppCloneIdentity failed. Cause: %{public}s', message); 5530} 5531``` 5532 5533## bundleManager.getAppCloneIdentityBySandboxDataDir<sup>20+</sup> 5534 5535getAppCloneIdentityBySandboxDataDir(sandboxDataDir: string): AppCloneIdentity 5536 5537Obtains the identity information of an application, including the bundle name and clone index, based on the given sandbox directory name. 5538 5539**System API**: This is a system API. 5540 5541**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5542 5543**Parameters** 5544 5545| Name | Type | Mandatory| Description | 5546| ---------- | ------ | ---- | ---------------------------| 5547| sandboxDataDir | string | Yes | Name of the [sandbox directory of the application](../../file-management/app-sandbox-directory.md).<br>**NOTE**<br>The validity of this parameter is not verified. If the input **sandboxDataDir** does not match the directory name format for application clones or atomic services, **sandboxDataDir** is returned as **AppCloneIdentity.bundleName**, and **AppCloneIdentity.appIndex** is **0**.<br> 1. Directory name format for application clones: `+clone-{appIndex}+{bundleName}`, where **appIndex** and **bundleName** are variables corresponding to the clone index and bundle name, respectively. Example: `+clone-1+com.example.myapplication`.<br> 2. Directory name format for atomic services: `+auid-{uid}+{bundleName}`, where **uid** and **bundleName** are variables corresponding to the UID and bundle name, respectively. Example: `+auid-20000000+com.example.myapplication`. | 5548 5549**Return value** 5550 5551| Type | Description | 5552| ----------------------------------------------------------- | --------------------------- | 5553| [AppCloneIdentity](js-apis-bundleManager-bundleInfo.md#appcloneidentity14) | Bundle name and clone index of the application.| 5554 5555 5556**Example** 5557 5558```ts 5559import { bundleManager } from '@kit.AbilityKit'; 5560import { BusinessError } from '@kit.BasicServicesKit'; 5561 5562// Main application. 5563let dataDir = 'com.example.myapplication'; 5564try { 5565 let res = bundleManager.getAppCloneIdentityBySandboxDataDir(dataDir); 5566 console.info('getAppCloneIdentityBySandboxDataDir successfully. res = ' + JSON.stringify(res)); 5567} catch (err) { 5568 let message = (err as BusinessError).message; 5569 console.error('getAppCloneIdentityBySandboxDataDir failed. Cause = ' + message); 5570} 5571 5572// Application clone. 5573let cloneDataDir = '+clone-1+com.example.myapplication'; 5574try { 5575 let res = bundleManager.getAppCloneIdentityBySandboxDataDir(cloneDataDir); 5576 console.info('getAppCloneIdentityBySandboxDataDir successfully. res = ' + JSON.stringify(res)); 5577} catch (err) { 5578 let message = (err as BusinessError).message; 5579 console.error('getAppCloneIdentityBySandboxDataDir failed. Cause = ' + message); 5580} 5581 5582// Atomic service. 5583let atomicDataDir = '+auid-20000000+com.example.myapplication'; 5584try { 5585 let res = bundleManager.getAppCloneIdentityBySandboxDataDir(atomicDataDir); 5586 console.info('getAppCloneIdentityBySandboxDataDir successfully. res = ' + JSON.stringify(res)); 5587} catch (err) { 5588 let message = (err as BusinessError).message; 5589 console.error('getAppCloneIdentityBySandboxDataDir failed. Cause = ' + message); 5590} 5591``` 5592 5593## bundleManager.getSandboxDataDir<sup>20+</sup> 5594 5595getSandboxDataDir(bundleName: string, appIndex: number): string 5596 5597Obtains the sandbox directory of an application based on the given bundle name and clone index. 5598 5599**System API**: This is a system API. 5600 5601**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 5602 5603**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5604 5605**Parameters** 5606 5607| Name | Type | Mandatory| Description | 5608| ---------- | ------ | ---- | ---------------------------| 5609| bundleName | string | Yes | Bundle name of the application. This API can be called only when the application or its clone is available for the current user. Otherwise, error code 17700001 is returned. | 5610| appIndex | number | Yes | Index of the application. The value ranges from 0 to 5. The value **0** indicates the main application, and the values 1 to 5 indicate the indexes of application clones. | 5611 5612**Return value** 5613 5614| Type | Description | 5615| ----------------------------------------------------------- | --------------------------- | 5616| string | Sandbox directory of the application.| 5617 5618**Error codes** 5619 5620For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5621 5622| ID| Error Message | 5623| -------- | --------------------------------------| 5624| 201 | Permission denied. | 5625| 202 | Permission denied, non-system app called system api. | 5626| 17700001 | The specified bundleName is not found. | 5627| 17700061 | The appIndex is invalid. | 5628 5629**Example** 5630 5631```ts 5632import { bundleManager } from '@kit.AbilityKit'; 5633import { BusinessError } from '@kit.BasicServicesKit'; 5634 5635let bundleName = 'com.example.myapplication'; 5636let appIndex = 1; 5637 5638try { 5639 let dataDir = bundleManager.getSandboxDataDir(bundleName, appIndex); 5640 console.info('getSandboxDataDir successfully. dataDir = ' + dataDir); 5641} catch (err) { 5642 let message = (err as BusinessError).message; 5643 console.error('getSandboxDataDir failed. Cause = ' + message); 5644} 5645``` 5646 5647## bundleManager.getAppCloneBundleInfo<sup>12+</sup> 5648 5649getAppCloneBundleInfo(bundleName: string, appIndex: number, bundleFlags: number, userId?: number): Promise\<BundleInfo>; 5650 5651Obtains the bundle information of an application or an application clone based on the given bundle name, app index, [bundleFlags](js-apis-bundleManager.md#bundleflag), and user ID. This API uses a promise to return the result. 5652 5653No permission is required for obtaining the caller's own information. 5654 5655**System API**: This is a system API. 5656 5657**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 5658 5659**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5660 5661**Parameters** 5662 5663| Name | Type | Mandatory| Description | 5664| ---------- | ------ | ---- | ---------------------------| 5665| bundleName | string | Yes | Bundle name. | 5666| appIndex | number | Yes | Index of the application clone.<br>The value **0** means to obtain the bundle information of the main application. A value greater than 0 means to obtain the bundle information of the application clone. | 5667| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 5668| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 5669 5670**Return value** 5671 5672| Type | Description | 5673| ----------------------------------------------------------- | --------------------------- | 5674| Promise\<BundleInfo> | Promise used to return the bundle information.| 5675 5676**Error codes** 5677 5678For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5679 5680| ID| Error Message | 5681| -------- | --------------------------------------| 5682| 201 | Permission denied. | 5683| 202 | Permission denied, non-system app called system api. | 5684| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5685| 17700001 | The specified bundleName is not found. | 5686| 17700004 | The specified userId is invalid. | 5687| 17700026 | The specified bundle is disabled. | 5688| 17700061 | The appIndex is invalid. | 5689 5690**Example** 5691 5692```ts 5693import { bundleManager } from '@kit.AbilityKit'; 5694import { BusinessError } from '@kit.BasicServicesKit'; 5695import { hilog } from '@kit.PerformanceAnalysisKit'; 5696let bundleName = 'com.example.myapplication'; 5697let appIndex = 1; 5698let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; 5699 5700try { 5701 bundleManager.getAppCloneBundleInfo(bundleName, appIndex, bundleFlags).then((res: bundleManager.BundleInfo) => { 5702 hilog.info(0x0000, 'testTag', 'getAppCloneBundleInfo res: BundleInfo = %{public}s', JSON.stringify(res)); 5703 }).catch((err: BusinessError) => { 5704 hilog.error(0x0000, 'testTag', 'getAppCloneBundleInfo failed. Cause: %{public}s', err.message); 5705 }); 5706} catch (err) { 5707 let message = (err as BusinessError).message; 5708 hilog.error(0x0000, 'testTag', 'getAppCloneBundleInfo failed. Cause: %{public}s', message); 5709} 5710``` 5711 5712## bundleManager.getAllAppCloneBundleInfo<sup>12+</sup> 5713 5714getAllAppCloneBundleInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<Array\<BundleInfo>>; 5715 5716Obtains all the bundle information of applications and application clones based on the given bundle name, [bundleFlags](js-apis-bundleManager.md#bundleflag), and user ID. This API uses a promise to return the result. 5717 5718No permission is required for obtaining the caller's own information. 5719 5720**System API**: This is a system API. 5721 5722**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 5723 5724**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5725 5726**Parameters** 5727 5728| Name | Type | Mandatory| Description | 5729| ---------- | ------ | ---- | ---------------------------| 5730| bundleName | string | Yes | Bundle name. | 5731| [bundleFlags](js-apis-bundleManager.md#bundleflag) | number | Yes | Type of the bundle information to obtain. | 5732| userId | number | No | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). The default value is the user ID of the caller. The value must be greater than or equal to 0. | 5733 5734**Return value** 5735 5736| Type | Description | 5737| ----------------------------------------------------------- | --------------------------- | 5738| Promise\<Array\<BundleInfo>> | Promise used to return all the bundle information.| 5739 5740**Error codes** 5741 5742For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5743 5744| ID| Error Message | 5745| -------- | --------------------------------------| 5746| 201 | Permission denied. | 5747| 202 | Permission denied, non-system app called system api. | 5748| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5749| 17700001 | The specified bundleName is not found. | 5750| 17700004 | The specified userId is invalid. | 5751| 17700026 | The specified bundle and clone apps are all disabled. | 5752 5753**Example** 5754 5755```ts 5756import { bundleManager } from '@kit.AbilityKit'; 5757import { BusinessError } from '@kit.BasicServicesKit'; 5758import { hilog } from '@kit.PerformanceAnalysisKit'; 5759let bundleName = 'com.example.myapplication'; 5760let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; 5761 5762try { 5763 bundleManager.getAllAppCloneBundleInfo(bundleName, bundleFlags).then((res: Array<bundleManager.BundleInfo>) => { 5764 let index = 0; 5765 for (let item of res) { 5766 hilog.info(0x0000, 'testTag', 'getAllAppCloneBundleInfo res: BundleInfo[%{public}d] = %{public}s', index++, JSON.stringify(item)); 5767 } 5768 }).catch((err: BusinessError) => { 5769 hilog.error(0x0000, 'testTag', 'getAllAppCloneBundleInfo failed. Cause: %{public}s', err.message); 5770 }); 5771} catch (err) { 5772 let message = (err as BusinessError).message; 5773 hilog.error(0x0000, 'testTag', 'getAllAppCloneBundleInfo failed. Cause: %{public}s', message); 5774} 5775``` 5776## bundleManager.verifyAbc<sup>11+</sup> 5777 5778verifyAbc(abcPaths: Array\<string>, deleteOriginalFiles: boolean, callback: AsyncCallback\<void>): void 5779 5780Verifies an .abc file. This API uses an asynchronous callback to return the result. 5781 5782**System API**: This is a system API. 5783 5784**Required permissions**: ohos.permission.RUN_DYN_CODE 5785 5786**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5787 5788**Parameters** 5789 5790| Name | Type | Mandatory| Description | 5791| ----------- | ------ | ---- | ---------------------------- | 5792| abcPaths | Array\<string> | Yes | Path of the .abc file.| 5793| deleteOriginalFiles | boolean | Yes | Whether to delete the .abc file. **true** to delete, **false** otherwise.| 5794| callback | AsyncCallback\<void> | Yes| [Callback](../apis-basic-services-kit/js-apis-base.md#asynccallback) used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 5795 5796**Error codes** 5797 5798For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5799 5800| ID| Error Message | 5801| -------- | ------------------------------------- | 5802| 201 | Permission denied. | 5803| 202 | Permission denied, non-system app called system api. | 5804| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5805| 17700201 | Failed to verify the abc file. | 5806 5807**Example** 5808 5809```ts 5810import { bundleManager } from '@kit.AbilityKit'; 5811import { BusinessError } from '@kit.BasicServicesKit'; 5812import { hilog } from '@kit.PerformanceAnalysisKit'; 5813 5814let abcPaths: Array<string> = ['/data/storage/el2/base/a.abc']; 5815 5816try { 5817 bundleManager.verifyAbc(abcPaths, true, (err, data) => { 5818 if (err) { 5819 hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', err.message); 5820 } else { 5821 hilog.info(0x0000, 'testTag', 'verifyAbc successfully'); 5822 } 5823 }); 5824} catch (err) { 5825 let message = (err as BusinessError).message; 5826 hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', message); 5827} 5828``` 5829 5830## bundleManager.migrateData<sup>18+</sup> 5831 5832migrateData(sourcePaths: Array<string>, destinationPath: string): Promise<void> 5833 5834Migrates files from the source path to the destination path. This API uses a promise to return the result. 5835 5836**System API**: This is a system API. 5837 5838**Required permissions**: ohos.permission.MIGRATE_DATA 5839 5840**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5841 5842**Parameters** 5843 5844| Name | Type | Mandatory| Description | 5845| ----------- | ------ | ---- | -------------------------------------------------------- | 5846| sourcePaths | Array<string> | Yes| Array of source paths. The value can be a single file path such as **/example1/test.txt** or a directory path such as **/example2/test**.| 5847| destinationPath | string | Yes| Destination path. Only one directory path is supported, for example, **/example2/test**.| 5848 5849**Return value** 5850 5851| Type | Description | 5852| ---------- | -------------------- | 5853| Promise\<void> | Promise that returns no value.| 5854 5855**Error codes** 5856 5857For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5858 5859| ID| Error Message | 5860| -------- | ------------------------------------- | 5861| 201 | Permission denied. | 5862| 202 | Permission denied, non-system app called system api. | 5863| 17700080 | The source paths are invalid. | 5864| 17700081 | The destination path is invalid. | 5865| 17700082 | User authentication failed. | 5866| 17700083 | Waiting for user authentication timeout. | 5867| 17700084 | There are inaccessible path in the source paths. | 5868| 17700085 | The destination path cannot be accessed. | 5869| 17700086 | System error occurred during copy execution. | 5870 5871**Example** 5872 5873```ts 5874import { bundleManager } from '@kit.AbilityKit'; 5875import { BusinessError } from '@kit.BasicServicesKit'; 5876 5877try { 5878 // Change the values of source1, source2, and dest to the actual file or directory paths. 5879 let source1: string = "/data/app/el2/100/base/com.example.myapplication/"; 5880 let source2: string = "/data/app/el2/101/base/com.example.myapplication/log.txt"; 5881 let dest: string = "/data/local/tmp"; 5882 let sourcePaths: Array<string> = [source1, source2]; 5883 5884 bundleManager.migrateData(sourcePaths, dest) 5885 .then(() => { 5886 console.info(`migrateData succeed`); 5887 }) 5888 .catch((err: BusinessError) => { 5889 console.error(`migrateData err : `, JSON.stringify(err)); 5890 }) 5891} catch(err) { 5892 console.error(`migrateData call err : `, JSON.stringify(err)); 5893} 5894``` 5895 5896## bundleManager.verifyAbc<sup>11+</sup> 5897 5898verifyAbc(abcPaths: Array\<string>, deleteOriginalFiles: boolean): Promise\<void> 5899 5900Verifies an .abc file. This API uses a promise to return the result. 5901 5902**System API**: This is a system API. 5903 5904**Required permissions**: ohos.permission.RUN_DYN_CODE 5905 5906**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5907 5908**Parameters** 5909 5910| Name | Type | Mandatory| Description | 5911| ----------- | ------ | ---- | ---------------------------- | 5912| abcPaths | Array\<string> | Yes | Path of the .abc file.| 5913| deleteOriginalFiles | boolean | Yes | Whether to delete the .abc file. **true** to delete, **false** otherwise. | 5914 5915**Return value** 5916 5917| Type | Description | 5918| ----------------------------------------------------------- | --------------------------- | 5919| Promise\<void> | Promise that returns no value.| 5920 5921**Error codes** 5922 5923For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5924 5925| ID| Error Message | 5926| -------- | --------------------------------------| 5927| 201 | Permission denied. | 5928| 202 | Permission denied, non-system app called system api. | 5929| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5930| 17700201 | Failed to verify the abc file. | 5931 5932**Example** 5933 5934```ts 5935import { bundleManager } from '@kit.AbilityKit'; 5936import { BusinessError } from '@kit.BasicServicesKit'; 5937import { hilog } from '@kit.PerformanceAnalysisKit'; 5938 5939let abcPaths: Array<string> = ['/data/storage/el2/base/a.abc']; 5940 5941try { 5942 bundleManager.verifyAbc(abcPaths, true).then((data) => { 5943 hilog.info(0x0000, 'testTag', 'verifyAbc successfully'); 5944 }).catch((err: BusinessError) => { 5945 hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', err.message); 5946 }); 5947} catch (err) { 5948 let message = (err as BusinessError).message; 5949 hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', message); 5950} 5951``` 5952 5953## bundleManager.deleteAbc<sup>11+</sup> 5954 5955deleteAbc(abcPath: string): Promise\<void> 5956 5957Deletes an .abc file based on the specified file path. This API uses a promise to return the result. 5958 5959**System API**: This is a system API. 5960 5961**Required permissions**: ohos.permission.RUN_DYN_CODE 5962 5963**System capability**: SystemCapability.BundleManager.BundleFramework.Core 5964 5965**Parameters** 5966 5967| Name | Type | Mandatory| Description | 5968| ----------- | ------ | ---- | ---------------------------- | 5969| abcPath | string | Yes | Path of the .abc file.| 5970 5971**Return value** 5972 5973| Type | Description | 5974| ----------------------------------------------------------- | --------------------------- | 5975| Promise\<void> | Promise that returns no value.| 5976 5977**Error codes** 5978 5979For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 5980 5981| ID| Error Message | 5982| -------- | --------------------------------------| 5983| 201 | Permission denied. | 5984| 202 | Permission denied, non-system app called system api. | 5985| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 5986| 17700202 | Failed to delete the abc file. | 5987 5988**Example** 5989 5990```ts 5991import { bundleManager } from '@kit.AbilityKit'; 5992import { BusinessError } from '@kit.BasicServicesKit'; 5993import { hilog } from '@kit.PerformanceAnalysisKit'; 5994 5995let abcPath: string = '/data/storage/el2/base/a.abc'; 5996 5997try { 5998 bundleManager.deleteAbc(abcPath).then((data) => { 5999 hilog.info(0x0000, 'testTag', 'deleteAbc successfully'); 6000 }).catch((err: BusinessError) => { 6001 hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', err.message); 6002 }); 6003} catch (err) { 6004 let message = (err as BusinessError).message; 6005 hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', message); 6006} 6007``` 6008 6009## bundleManager.getDynamicIconInfo<sup>20+</sup> 6010 6011getDynamicIconInfo(bundleName: string): Promise\<Array\<DynamicIconInfo>> 6012 6013Obtains the dynamic icon information of all users and all application clones based on the given bundle name. This API uses a promise to return the result. 6014 6015**System API**: This is a system API. 6016 6017**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 6018 6019**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6020 6021**Parameters** 6022 6023| Name | Type | Mandatory| Description | 6024| ----------- | ------ | ---- | ---------------------------- | 6025| bundleName | string | Yes | Bundle name of the application for which the dynamic icon information is to be queried.| 6026 6027**Return value** 6028 6029| Type | Description | 6030| ----------------------------------------------------------- | --------------------------- | 6031| Promise\<Array<[DynamicIconInfo](js-apis-bundleManager-BundleInfo-sys.md#dynamiciconinfo)>> | Promise used to return the dynamic icon information.| 6032 6033**Error codes** 6034 6035For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 6036 6037| ID| Error Message | 6038| -------- | --------------------------------------| 6039| 201 | Permission denied. | 6040| 202 | Permission denied, non-system app called system api. | 6041| 17700001 | The specified bundleName is not found. | 6042| 17700306 | Failed to obtain the dynamic icon. | 6043 6044**Example** 6045 6046```ts 6047import { bundleManager } from '@kit.AbilityKit'; 6048import { BusinessError } from '@kit.BasicServicesKit'; 6049import { hilog } from '@kit.PerformanceAnalysisKit'; 6050 6051let bundleName: string = 'com.ohos.demo'; 6052 6053try { 6054 bundleManager.getDynamicIconInfo(bundleName).then((data) => { 6055 hilog.info(0x0000, 'testTag', 'getDynamicIconInfo successfully %s', JSON.stringify(data)); 6056 }).catch((err: BusinessError) => { 6057 hilog.error(0x0000, 'testTag', 'getDynamicIconInfo failed. Cause: %{public}s', err.message); 6058 }); 6059} catch (err) { 6060 let message = (err as BusinessError).message; 6061 hilog.error(0x0000, 'testTag', 'getDynamicIconInfo failed. Cause: %{public}s', message); 6062} 6063``` 6064 6065## bundleManager.getAllDynamicIconInfo<sup>20+</sup> 6066 6067getAllDynamicIconInfo(userId?: number): Promise\<Array\<DynamicIconInfo>> 6068 6069Obtains the dynamic icon information of all applications and all application clones of a specified user. This API uses a promise to return the result. 6070 6071To obtain the dynamic icon information of all applications and all application clones of the current user, you must request the ohos.permission.GET_BUNDLE_INFO_PRIVILEGED permission. 6072 6073To obtain the dynamic icon information of all applications and all application clones of other users or all users, you must request the ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS permissions. 6074 6075**System API**: This is a system API. 6076 6077**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 6078 6079**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6080 6081**Parameters** 6082 6083| Name | Type | Mandatory| Description | 6084| ----------- | ------ | ---- | ---------------------------- | 6085| userId | number | No | User ID. By default, the dynamic icon information of all applications and all application clones of all users is queried.| 6086 6087**Return value** 6088 6089| Type | Description | 6090| ----------------------------------------------------------- | --------------------------- | 6091| Promise\<Array\<[DynamicIconInfo](js-apis-bundleManager-BundleInfo-sys.md#dynamiciconinfo)>> | Promise used to return the dynamic icon information.| 6092 6093**Error codes** 6094 6095For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 6096 6097| ID| Error Message | 6098| -------- | --------------------------------------| 6099| 201 | Permission denied. | 6100| 202 | Permission denied, non-system app called system api. | 6101| 17700004 | The specified user ID is not found. | 6102| 17700306 | Failed to obtain the dynamic icon. | 6103 6104**Example** 6105 6106```ts 6107import { bundleManager } from '@kit.AbilityKit'; 6108import { BusinessError } from '@kit.BasicServicesKit'; 6109import { hilog } from '@kit.PerformanceAnalysisKit'; 6110 6111let userId: number = 100; 6112 6113try { 6114 bundleManager.getAllDynamicIconInfo(userId).then((data) => { 6115 hilog.info(0x0000, 'testTag', 'getAllDynamicIconInfo successfully'); 6116 }).catch((err: BusinessError) => { 6117 hilog.error(0x0000, 'testTag', 'getAllDynamicIconInfo failed. Cause: %{public}s', err.message); 6118 }); 6119} catch (err) { 6120 let message = (err as BusinessError).message; 6121 hilog.error(0x0000, 'testTag', 'getAllDynamicIconInfo failed. Cause: %{public}s', message); 6122} 6123``` 6124 6125## PermissionDef 6126 6127type PermissionDef = _PermissionDef 6128 6129Defines the detailed information about the permissions defined in the [module.json5](../../quick-start/module-configuration-file.md) file. 6130 6131**System API**: This is a system API. 6132 6133**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6134 6135| Type | Description | 6136| ------------------------------------------------------------ | -------------- | 6137| [_PermissionDef](./js-apis-bundleManager-permissionDef-sys.md#permissiondef) |Permission details defined in the configuration file.| 6138 6139## SharedBundleInfo<sup>10+</sup> 6140 6141type SharedBundleInfo = _SharedBundleInfo 6142 6143Defines the shared bundle information. 6144 6145**System API**: This is a system API. 6146 6147**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6148 6149| Type | Description | 6150| ------------------------------------------------------------ | -------------- | 6151| [_SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo-sys.md#sharedbundleinfo) |Shared bundle information.| 6152 6153## AppProvisionInfo<sup>10+</sup> 6154 6155type AppProvisionInfo = _AppProvisionInfo.AppProvisionInfo 6156 6157Defines the information in the [HarmonyAppProvision configuration file](../../security/app-provision-structure.md). 6158 6159**System API**: This is a system API. 6160 6161**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6162 6163| Type | Description | 6164| ------------------------------------------------------------ | -------------- | 6165| [_AppProvisionInfo.AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo-sys.md#appprovisioninfo) |Information in the [HarmonyAppProvision configuration file](../../security/app-provision-structure.md).| 6166 6167 6168## Validity<sup>10+</sup> 6169 6170type Validity = _AppProvisionInfo.Validity 6171 6172Defines the validity period in the configuration file. 6173 6174**System API**: This is a system API. 6175 6176**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6177 6178| Type | Description | 6179| ------------------------------------------------------------ | -------------- | 6180| [_AppProvisionInfo.Validity](js-apis-bundleManager-AppProvisionInfo-sys.md#validity) |Validity period in the configuration file.| 6181 6182## RecoverableApplicationInfo<sup>11+</sup> 6183 6184type RecoverableApplicationInfo = _RecoverableApplicationInfo 6185 6186Defines the information about a preinstalled application that can be restored after being uninstalled. 6187 6188**System API**: This is a system API. 6189 6190**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6191 6192| Type | Description | 6193| ------------------------------------------------------------ | -------------- | 6194| [_RecoverableApplicationInfo](js-apis-bundleManager-recoverableApplicationInfo-sys.md#recoverableapplicationinfo) |Information about a preinstalled application that can be restored after being uninstalled.| 6195 6196## PreinstalledApplicationInfo<sup>12+</sup> 6197 6198type PreinstalledApplicationInfo = _PreinstalledApplicationInfo 6199 6200Defines the preinstalled application information. 6201 6202**System API**: This is a system API. 6203 6204**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6205 6206| Type | Description | 6207| ------------------------------------------------------------ | -------------- | 6208| [_PreinstalledApplicationInfo](js-apis-bundleManager-ApplicationInfo-sys.md#preinstalledapplicationinfo12) |Preinstalled application information.| 6209 6210## PluginBundleInfo<sup>19+</sup> 6211 6212type PluginBundleInfo = _PluginBundleInfo 6213 6214Defines the plugin information. 6215 6216**System API**: This is a system API. 6217 6218**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6219 6220| Type | Description | 6221| ------------------------------------------------------------ | -------------- | 6222| [_PluginBundleInfo](js-apis-bundleManager-pluginBundleInfo-sys.md#pluginbundleinfo) |Plugin information.| 6223 6224## PluginModuleInfo<sup>19+</sup> 6225 6226type PluginModuleInfo = _PluginModuleInfo 6227 6228Defines the module information of a plugin. 6229 6230**System API**: This is a system API. 6231 6232**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6233 6234| Type | Description | 6235| ------------------------------------------------------------ | -------------- | 6236| [_PluginModuleInfo](js-apis-bundleManager-pluginBundleInfo-sys.md#pluginmoduleinfo) |Module information of the plugin.| 6237 6238## DynamicIconInfo<sup>20+</sup> 6239 6240type DynamicIconInfo = _BundleInfo.DynamicIconInfo 6241 6242Describes the information about the dynamic icon of an application. 6243 6244**System API**: This is a system API. 6245 6246**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6247 6248| Type | Description | 6249| ------------------------------------------------------------ | -------------- | 6250| [_BundleInfo.DynamicIconInfo](js-apis-bundleManager-BundleInfo-sys.md#dynamiciconinfo) |Information about the dynamic icon of an application.| 6251 6252## BundleOptions<sup>20+</sup> 6253 6254type BundleOptions = _BundleInfo.BundleOptions 6255 6256Describes the bundle options used to set or query application information. 6257 6258**System API**: This is a system API. 6259 6260**System capability**: SystemCapability.BundleManager.BundleFramework.Core 6261 6262| Type | Description | 6263| ------------------------------------------------------------ | -------------- | 6264| [_BundleInfo.BundleOptions](js-apis-bundleManager-BundleInfo-sys.md#bundleoptions) |Bundle options used to set or query application information.| 6265