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