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