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