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