1# @ohos.bundle.bundleManager (bundleManager) 2 3The **bundleManager** module provides APIs for querying information about bundles, applications, abilities, ExtensionAbilities, and more. 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## Modules to Import 10 11```ts 12import bundleManager from '@ohos.bundle.bundleManager'; 13``` 14 15## Enums 16 17### BundleFlag 18 19Enumerates the bundle flags, which indicate the type of bundle information to obtain. 20 21 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 22 23| Name | Value | Description | 24| ----------------------------------------- | ---------- | ------------------------------------------------------------ | 25| 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.| 26| 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.| 27| 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.| 28| 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**.| 29| 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**.| 30| 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.| 31| 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**.| 32| 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.| 33| 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.| 34| 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**.| 35 36### ExtensionAbilityType 37 38Enumerates the types of ExtensionAbilities. 39 40 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 41 42| Name| Value| Description| 43|:----------------:|:---:|-----| 44| FORM | 0 | [FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md): provides APIs for widget development.| 45| WORK_SCHEDULER | 1 | [WorkSchedulerExtensionAbility](../apis-backgroundtasks-kit/js-apis-WorkSchedulerExtensionAbility.md): enables applications to execute non-real-time tasks when the system is idle.| 46| INPUT_METHOD | 2 | [InputMethodExtensionAbility](../apis-ime-kit/js-apis-inputmethod-extension-ability.md): provides APIs for developing input method applications.| 47| SERVICE | 3 | [ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility-sys.md): enables applications to run in the background and provide services.| 48| ACCESSIBILITY | 4 | [AccessibilityExtensionAbility](../apis-accessibility-kit/js-apis-application-accessibilityExtensionAbility.md): provides accessibility for access to and operations on the UI.| 49| DATA_SHARE | 5 | [DataShareExtensionAbility](../apis-arkdata/js-apis-application-dataShareExtensionAbility-sys.md): enables applications to read and write data.| 50| FILE_SHARE | 6 | FileShareExtensionAbility: enables file sharing between applications. This ability is reserved.| 51| STATIC_SUBSCRIBER| 7 | [StaticSubscriberExtensionAbility](../apis-basic-services-kit/js-apis-application-staticSubscriberExtensionAbility-sys.md): provides APIs for processing static events, such as the startup event.| 52| WALLPAPER | 8 | WallpaperExtensionAbility: provides APIs to implement the home screen wallpaper. This ability is reserved.| 53| BACKUP | 9 | [BackupExtensionAbility](../apis-core-file-kit/js-apis-application-backupExtensionAbility.md): provides APIs to implement application data backup and restore.| 54| WINDOW | 10 | [WindowExtensionAbility](../apis-arkui/js-apis-application-windowExtensionAbility-sys.md): allows system applications to display UIs of other applications.| 55| ENTERPRISE_ADMIN | 11 | [EnterpriseAdminExtensionAbility](../apis-mdm-kit/js-apis-EnterpriseAdminExtensionAbility-sys.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.| 56| THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.| 57| PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.| 58| PRINT<sup>10+</sup> | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.| 59| SHARE<sup>10+</sup> | 16 | [ShareExtensionAbility](js-apis-app-ability-shareExtensionAbility.md): provides sharing service templates based on UIExtensionAbilities.| 60| PUSH<sup>10+</sup> | 17 | PushExtensionAbility: provides APIs for pushing scenario-specific messages. This ability is reserved.| 61| DRIVER<sup>10+</sup> | 18 | [DriverExtensionAbility](../apis-driverdevelopment-kit/js-apis-app-ability-driverExtensionAbility.md): provides APIs for the peripheral driver. This type of ability is not supported yet.| 62| ACTION<sup>10+</sup> | 19 | [ActionExtensionAbility](js-apis-app-ability-actionExtensionAbility.md): provides custom action service templates based on UIExtensionAbilities.| 63| ADS_SERVICE<sup>11+</sup> | 20 | AdsServiceExtensionAbility: provides background customized ad services for external systems. This type of ability is not supported yet.| 64| UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of ExtensionAbilities.| 65 66 67### PermissionGrantState 68 69Enumerates the permission grant states. 70 71 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 72 73| Name| Value| Description| 74|:----------------:|:---:|:---:| 75| PERMISSION_DENIED| -1 | Permission denied.| 76| PERMISSION_GRANTED | 0 | Permission granted. | 77 78### SupportWindowMode 79 80Enumerates the window modes supported by the ability. 81 82 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 83 84| Name| Value| Description| 85|:----------------:|:---:|:---:| 86| FULL_SCREEN | 0 | A window in full-screen mode is supported.| 87| SPLIT | 1 | A window in split-screen mode is supported.| 88| FLOATING | 2 | A floating window is supported. | 89 90### LaunchType 91 92Enumerates the launch types of the ability. 93 94 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 95 96| Name| Value| Description| 97|:----------------:|:---:|:---:| 98| SINGLETON | 0 | The ability can have only one instance.| 99| MULTITON | 1 | The ability can have multiple instances.| 100| SPECIFIED | 2 | The ability can have one or multiple instances, depending on the internal service of the ability.| 101 102### AbilityType 103 104Enumerates the types of abilities. 105 106 **Model restriction**: This API can be used only in the FA model. 107 108 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 109 110| Name | Value | Description | 111| :-----: | ---- | :--------------------------------------------------------: | 112| PAGE | 1 | Ability that has the UI. FA developed using the Page template to provide the capability of interacting with users. | 113| SERVICE | 2 | Ability of the background service type, without the UI. PA developed using the Service template to provide the capability of running tasks in the background. | 114| DATA | 3 | PA developed using the Data template to provide unified data access for external systems.| 115 116### DisplayOrientation 117 118Enumerates the display orientations of the ability. This attribute applies only to the ability using the Page template. 119 120 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 121 122| Name |Value|Description| 123|:----------------------------------|---|---| 124| UNSPECIFIED |0 |Unspecified. The orientation is determined by the system.| 125| LANDSCAPE |1 |Landscape.| 126| PORTRAIT |2 |Portrait.| 127| FOLLOW_RECENT |3 |The last display orientation is used.| 128| LANDSCAPE_INVERTED |4 |Reverse landscape.| 129| PORTRAIT_INVERTED |5 |Reverse portrait.| 130| AUTO_ROTATION |6 |Auto rotation.| 131| AUTO_ROTATION_LANDSCAPE |7 |Auto rotation in the horizontal direction.| 132| AUTO_ROTATION_PORTRAIT |8 |Auto rotation in the vertical direction.| 133| AUTO_ROTATION_RESTRICTED |9 |Switched-determined auto rotation.| 134| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|Switched-determined auto rotation in the horizontal direction.| 135| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|Switched-determined auto rotation in the vertical direction.| 136| LOCKED |12|Locked.| 137 138### CompatiblePolicy<sup>10+</sup> 139 140Defines the version compatibility type of the shared library. 141 142 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 143 144| Name | Value | Description | 145| ---------------------- | ---- | -------------------------------- | 146| BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.| 147 148### ModuleType 149 150Enumerates the module types. 151 152 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 153 154| Name | Value | Description | 155| ------- | ---- | -------------------- | 156| ENTRY | 1 | Main module of the application. | 157| FEATURE | 2 | Dynamic feature module of the application.| 158| SHARED | 3 | Dynamic shared library module of the application. | 159 160### BundleType 161 162Enumerates the bundle types. 163 164 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 165 166| Name | Value | Description | 167| -------------- | ---- | --------------- | 168| APP | 0 | The bundle is an application. | 169| ATOMIC_SERVICE | 1 | The bundle is an atomic service.| 170 171## APIs 172 173### bundleManager.getBundleInfoForSelf 174 175getBundleInfoForSelf(bundleFlags: [number](js-apis-bundleManager.md#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> 176 177Obtains the bundle information of this bundle based on the given bundle flags. This API uses a promise to return the result. 178 179**System capability**: SystemCapability.BundleManager.BundleFramework.Core 180 181**Parameters** 182 183| Name | Type | Mandatory| Description | 184| ----------- | ------ | ---- | --------------------- | 185| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | Yes | Type of the bundle information to obtain.| 186 187**Return value** 188 189| Type | Description | 190| ----------------------------------------------------------- | ------------------------------------- | 191| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.| 192 193**Example** 194 195```ts 196// Obtain application info with metadataArray. 197import bundleManager from '@ohos.bundle.bundleManager'; 198import { BusinessError } from '@ohos.base'; 199import hilog from '@ohos.hilog'; 200let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; 201try { 202 bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { 203 hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data)); 204 }).catch((err: BusinessError) => { 205 hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message); 206 }); 207} catch (err) { 208 let message = (err as BusinessError).message; 209 hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); 210} 211``` 212 213### bundleManager.getBundleInfoForSelf 214 215getBundleInfoForSelf(bundleFlags: [number](js-apis-bundleManager.md#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void 216 217Obtains the bundle information of this bundle based on the given bundle flags. This API uses an asynchronous callback to return the result. 218 219**System capability**: SystemCapability.BundleManager.BundleFramework.Core 220 221**Parameters** 222 223| Name | Type | Mandatory| Description | 224| ----------- | ------ | ---- | --------------------- | 225| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | Yes | Type of the bundle information to obtain.| 226| 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.| 227 228**Example** 229 230```ts 231// Obtain ability info with permissions. 232import bundleManager from '@ohos.bundle.bundleManager'; 233import { BusinessError } from '@ohos.base'; 234import hilog from '@ohos.hilog'; 235let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; 236 237try { 238 bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { 239 if (err) { 240 hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message); 241 } else { 242 hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data)); 243 } 244 }); 245} catch (err) { 246 let message = (err as BusinessError).message; 247 hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); 248} 249``` 250 251### bundleManager.getProfileByAbility 252 253getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void 254 255Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API uses an asynchronous callback to return the result. 256 257> **NOTE** 258> 259> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module. 260 261**System capability**: SystemCapability.BundleManager.BundleFramework.Core 262 263**Parameters** 264 265| Name | Type | Mandatory| Description | 266| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 267| moduleName | string | Yes | Module name. | 268| abilityName | string | Yes | Name of the UIAbility component. | 269| metadataName | string | Yes | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. | 270| callback | AsyncCallback<Array\<string>> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.| 271 272**Error codes** 273 274For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 275 276| ID| Error Message | 277| -------- | ------------------------------------------------------------ | 278| 17700002 | The specified moduleName is not existed. | 279| 17700003 | The specified abilityName is not existed. | 280| 17700024 | Failed to get the profile because there is no profile in the HAP. | 281| 17700026 | The specified bundle is disabled. | 282| 17700029 | The specified ability is disabled. | 283 284**Example** 285 286```ts 287import bundleManager from '@ohos.bundle.bundleManager'; 288import { BusinessError } from '@ohos.base'; 289import hilog from '@ohos.hilog'; 290let moduleName = 'entry'; 291let abilityName = 'EntryAbility'; 292let metadataName = 'ability_metadata'; 293 294try { 295 bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => { 296 if (err) { 297 hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); 298 } else { 299 hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data)); 300 } 301 }); 302} catch (err) { 303 let message = (err as BusinessError).message; 304 hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); 305} 306``` 307 308### bundleManager.getProfileByAbility 309 310getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\> 311 312Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API uses a promise to return the result. 313 314> **NOTE** 315> 316> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module. 317 318**System capability**: SystemCapability.BundleManager.BundleFramework.Core 319 320**Parameters** 321 322| Name | Type | Mandatory| Description | 323| ------------ | ------ | ---- | -------------------------- | 324| moduleName | string | Yes | Module name. | 325| abilityName | string | Yes | Name of the UIAbility component. | 326| metadataName | string | No | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. The default value is null.| 327 328**Return value** 329 330| Type | Description | 331| ----------------------- | ------------------------------- | 332| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.| 333 334**Error codes** 335 336For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 337 338| ID| Error Message | 339| -------- | ------------------------------------------------------------ | 340| 17700002 | The specified moduleName is not existed. | 341| 17700003 | The specified abilityName is not existed. | 342| 17700024 | Failed to get the profile because there is no profile in the HAP. | 343| 17700026 | The specified bundle is disabled. | 344| 17700029 | The specified ability is disabled. | 345 346**Example** 347 348```ts 349import bundleManager from '@ohos.bundle.bundleManager'; 350import { BusinessError } from '@ohos.base'; 351import hilog from '@ohos.hilog'; 352let moduleName = 'entry'; 353let abilityName = 'EntryAbility'; 354 355try { 356 bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => { 357 hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data)); 358 }).catch((err: BusinessError) => { 359 hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); 360 }); 361} catch (err) { 362 let message = (err as BusinessError).message; 363 hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); 364} 365``` 366 367```ts 368import bundleManager from '@ohos.bundle.bundleManager'; 369import { BusinessError } from '@ohos.base'; 370import hilog from '@ohos.hilog'; 371let moduleName = 'entry'; 372let abilityName = 'EntryAbility'; 373let metadataName = 'ability_metadata'; 374try { 375 bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { 376 hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data)); 377 }).catch((err: BusinessError) => { 378 hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); 379 }); 380} catch (err) { 381 let message = (err as BusinessError).message; 382 hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); 383} 384``` 385 386### bundleManager.getProfileByAbilitySync<sup>10+</sup> 387 388getProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?: string): Array\<string\> 389 390Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ability name, and metadata name. This API returns the result synchronously. The result value is a string array. 391 392> **NOTE** 393> 394> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module. 395 396**System capability**: SystemCapability.BundleManager.BundleFramework.Core 397 398**Parameters** 399 400| Name | Type | Mandatory| Description | 401| ------------ | ------ | ---- | -------------------------- | 402| moduleName | string | Yes | Module name. | 403| abilityName | string | Yes | Name of the UIAbility component. | 404| metadataName | string | No | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. The default value is null.| 405 406**Return value** 407 408| Type | Description | 409| ----------------------- | ------------------------------- | 410| Array\<string> | An array of JSON strings.| 411 412**Error codes** 413 414For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 415 416| ID| Error Message | 417| -------- | ------------------------------------------------------------ | 418| 17700002 | The specified moduleName is not existed. | 419| 17700003 | The specified abilityName is not existed. | 420| 17700024 | Failed to get the profile because there is no profile in the HAP. | 421| 17700026 | The specified bundle is disabled. | 422| 17700029 | The specified ability is disabled. | 423 424**Example** 425 426```ts 427import bundleManager from '@ohos.bundle.bundleManager'; 428import { BusinessError } from '@ohos.base'; 429import hilog from '@ohos.hilog'; 430let moduleName = 'entry'; 431let abilityName = 'EntryAbility'; 432 433try { 434 let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName); 435 hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); 436} catch (err) { 437 let message = (err as BusinessError).message; 438 hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message); 439} 440``` 441 442```ts 443import bundleManager from '@ohos.bundle.bundleManager'; 444import { BusinessError } from '@ohos.base'; 445import hilog from '@ohos.hilog'; 446let moduleName: string = 'entry'; 447let abilityName: string = 'EntryAbility'; 448let metadataName: string = 'ability_metadata'; 449try { 450 let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName); 451 hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); 452} catch (err) { 453 let message = (err as BusinessError).message; 454 hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message); 455} 456``` 457 458### bundleManager.getProfileByExtensionAbility 459 460getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): void 461 462Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API uses an asynchronous callback to return the result. 463 464> **NOTE** 465> 466> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module. 467 468**System capability**: SystemCapability.BundleManager.BundleFramework.Core 469 470**Parameters** 471 472| Name | Type | Mandatory| Description | 473| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ | 474| moduleName | string | Yes | Module name. | 475| extensionAbilityName | string | Yes | Name of the ExtensionAbility component. | 476| metadataName | string | Yes | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. | 477| callback | AsyncCallback<Array\<string>> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.| 478 479**Error codes** 480 481For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 482 483| ID| Error Message | 484| -------- | ------------------------------------------------------------ | 485| 17700002 | The specified moduleName is not existed. | 486| 17700003 | The specified extensionAbilityName not existed. | 487| 17700024 | Failed to get the profile because there is no profile in the HAP. | 488| 17700026 | The specified bundle is disabled. | 489 490**Example** 491 492```ts 493import bundleManager from '@ohos.bundle.bundleManager'; 494import { BusinessError } from '@ohos.base'; 495import hilog from '@ohos.hilog'; 496let moduleName = 'entry'; 497let extensionAbilityName = 'com.example.myapplication.extension'; 498let metadataName = 'ability_metadata'; 499 500try { 501 bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => { 502 if (err) { 503 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message); 504 } else { 505 hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data)); 506 } 507 }); 508} catch (err) { 509 let message = (err as BusinessError).message; 510 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message); 511} 512``` 513 514### bundleManager.getProfileByExtensionAbility 515 516getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\> 517 518Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API uses a promise to return the result. 519 520> **NOTE** 521> 522> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module. 523 524**System capability**: SystemCapability.BundleManager.BundleFramework.Core 525 526**Parameters** 527 528| Name | Type | Mandatory| Description | 529| -------------------- | ------ | ---- | ---------------------------------- | 530| moduleName | string | Yes | Module name. | 531| extensionAbilityName | string | Yes | Name of the ExtensionAbility component.| 532| metadataName | string | No | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. The default value is null. | 533 534**Return value** 535 536| Type | Description | 537| ----------------------- | ----------------------------------- | 538| Promise<Array\<string>> | Promise used to return the array of JSON strings obtained.| 539 540**Error codes** 541 542For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 543 544| ID| Error Message | 545| -------- | ------------------------------------------------------------ | 546| 17700002 | The specified moduleName is not existed. | 547| 17700003 | The specified extensionAbilityName not existed. | 548| 17700024 | Failed to get the profile because there is no profile in the HAP. | 549| 17700026 | The specified bundle is disabled. | 550 551**Example** 552 553```ts 554import bundleManager from '@ohos.bundle.bundleManager'; 555import { BusinessError } from '@ohos.base'; 556import hilog from '@ohos.hilog'; 557let moduleName = 'entry'; 558let extensionAbilityName = 'com.example.myapplication.extension'; 559let metadataName = 'ability_metadata'; 560 561try { 562 bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => { 563 hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data)); 564 }).catch((err: BusinessError) => { 565 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); 566 }); 567} catch (err) { 568 let message = (err as BusinessError).message; 569 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message); 570} 571 572try { 573 bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => { 574 hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data)); 575 }).catch((err: BusinessError) => { 576 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); 577 }); 578} catch (err) { 579 let message = (err as BusinessError).message; 580 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message); 581} 582``` 583 584### bundleManager.getProfileByExtensionAbilitySync<sup>10+</sup> 585 586getProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: string, metadataName?: string): Array\<string\> 587 588Obtains the JSON string array of the current application's configuration file in the [metadata](../../quick-start/module-configuration-file.md#metadata) based on a given module name, ExtensionAbility name, and metadata name. This API returns the result synchronously. The result value is a string array. 589 590> **NOTE** 591> 592> If the profile uses the resource reference format, the return value retains this format (for example, **$string:res_id**). You can obtain the referenced resources through related APIs of the resource management module. 593 594**System capability**: SystemCapability.BundleManager.BundleFramework.Core 595 596**Parameters** 597 598| Name | Type | Mandatory| Description | 599| -------------------- | ------ | ---- | ---------------------------------- | 600| moduleName | string | Yes | Module name. | 601| extensionAbilityName | string | Yes | Name of the ExtensionAbility component.| 602| metadataName | string | No | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. The default value is null. | 603 604**Return value** 605 606| Type | Description | 607| ----------------------- | ----------------------------------- | 608| Array\<string> | An array of JSON strings.| 609 610**Error codes** 611 612For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 613 614| ID| Error Message | 615| -------- | ------------------------------------------------------------ | 616| 17700002 | The specified moduleName is not existed. | 617| 17700003 | The specified extensionAbilityName not existed. | 618| 17700024 | Failed to get the profile because there is no profile in the HAP. | 619| 17700026 | The specified bundle is disabled. | 620 621**Example** 622 623```ts 624import bundleManager from '@ohos.bundle.bundleManager'; 625import { BusinessError } from '@ohos.base'; 626import hilog from '@ohos.hilog'; 627let moduleName = 'entry'; 628let extensionAbilityName = 'com.example.myapplication.extension'; 629let metadataName = 'ability_metadata'; 630 631try { 632 let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName); 633 hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); 634} catch (err) { 635 let message = (err as BusinessError).message; 636 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message); 637} 638 639try { 640 let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName); 641 hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); 642} catch (err) { 643 let message = (err as BusinessError).message; 644 hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message); 645} 646``` 647 648### bundleManager.getBundleInfoForSelfSync<sup>10+</sup> 649 650getBundleInfoForSelfSync(bundleFlags: number): BundleInfo 651 652Obtains the bundle information of this bundle based on the given bundle flags. This API returns the result synchronously. 653 654**System capability**: SystemCapability.BundleManager.BundleFramework.Core 655 656**Parameters** 657 658| Name | Type | Mandatory| Description | 659| ----------- | ------ | ---- | --------------------- | 660| bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | Yes | Type of the bundle information to obtain.| 661 662**Return value** 663 664| Type | Description | 665| ------------------------------------------------- | -------------------- | 666| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| 667 668**Example** 669 670```ts 671import bundleManager from '@ohos.bundle.bundleManager'; 672import { BusinessError } from '@ohos.base'; 673import hilog from '@ohos.hilog'; 674let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; 675try { 676 let data = bundleManager.getBundleInfoForSelfSync(bundleFlags); 677 hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data)); 678} catch (err) { 679 let message = (err as BusinessError).message; 680 hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message); 681} 682``` 683 684### bundleManager.verifyAbc<sup>11+</sup> 685 686verifyAbc(abcPaths: Array\<string>, deleteOriginalFiles: boolean, callback: AsyncCallback\<void>): void 687 688Verifies an .abc file. This API uses an asynchronous callback to return the result. 689 690**Required permissions**: ohos.permission.RUN_DYN_CODE 691 692**System capability**: SystemCapability.BundleManager.BundleFramework.Core 693 694**Parameters** 695 696| Name | Type | Mandatory| Description | 697| ----------- | ------ | ---- | ---------------------------- | 698| abcPaths | Array\<string> | Yes | Path of the .abc file.| 699| deleteOriginalFiles | boolean | Yes | Whether to delete the .abc file. The value **true** means to delete the file, and **false** means the opposite.| 700| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the verification is successful, **err** is **undefined**; otherwise, **err** is an error object.| 701 702**Error codes** 703 704For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 705 706| ID| Error Message | 707| -------- | ------------------------------------- | 708| 17700201 | verifyAbc failed. | 709 710**Example** 711 712```ts 713import bundleManager from '@ohos.bundle.bundleManager'; 714import { BusinessError } from '@ohos.base'; 715import hilog from '@ohos.hilog'; 716let abcPaths : Array<string> = ['/data/storage/el2/base/a.abc']; 717 718try { 719 bundleManager.verifyAbc(abcPaths, true, (err, data) => { 720 if (err) { 721 hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', err.message); 722 } else { 723 hilog.info(0x0000, 'testTag', 'verifyAbc successfully'); 724 } 725 }); 726} catch (err) { 727 let message = (err as BusinessError).message; 728 hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', message); 729} 730``` 731 732### bundleManager.verifyAbc<sup>11+</sup> 733 734verifyAbc(abcPaths: Array\<string>, deleteOriginalFiles: boolean): Promise\<void> 735 736Verifies an .abc file. This API uses a promise to return the result. 737 738**Required permissions**: ohos.permission.RUN_DYN_CODE 739 740**System capability**: SystemCapability.BundleManager.BundleFramework.Core 741 742**Parameters** 743 744| Name | Type | Mandatory| Description | 745| ----------- | ------ | ---- | ---------------------------- | 746| abcPaths | Array\<string> | Yes | Path of the .abc file.| 747| deleteOriginalFiles | boolean | Yes | Whether to delete the .abc file. The value **true** means to delete the file, and **false** means the opposite. | 748 749**Return value** 750 751| Type | Description | 752| ----------------------------------------------------------- | --------------------------- | 753| Promise\<void> | Promise that returns no value.| 754 755**Error codes** 756 757For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 758 759| ID| Error Message | 760| -------- | --------------------------------------| 761| 17700201 | verifyAbc failed. | 762 763**Example** 764 765```ts 766import bundleManager from '@ohos.bundle.bundleManager'; 767import { BusinessError } from '@ohos.base'; 768import hilog from '@ohos.hilog'; 769let abcPaths : Array<string> = ['/data/storage/el2/base/a.abc']; 770 771try { 772 bundleManager.verifyAbc(abcPaths, true).then((data) => { 773 hilog.info(0x0000, 'testTag', 'verifyAbc successfully'); 774 }).catch((err: BusinessError) => { 775 hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', err.message); 776 }); 777} catch (err) { 778 let message = (err as BusinessError).message; 779 hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', message); 780} 781``` 782 783### bundleManager.deleteAbc<sup>11+</sup> 784 785deleteAbc(abcPath: string): Promise\<void> 786 787Deletes an .abc file based on the specified file path. This API uses a promise to return the result. 788 789**Required permissions**: ohos.permission.RUN_DYN_CODE 790 791**System capability**: SystemCapability.BundleManager.BundleFramework.Core 792 793**Parameters** 794 795| Name | Type | Mandatory| Description | 796| ----------- | ------ | ---- | ---------------------------- | 797| abcPath | string | Yes | Path of the .abc file.| 798 799**Return value** 800 801| Type | Description | 802| ----------------------------------------------------------- | --------------------------- | 803| Promise\<void> | Promise that returns no value.| 804 805**Error codes** 806 807For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 808 809| ID| Error Message | 810| -------- | --------------------------------------| 811| 17700202 | deleteAbc failed. | 812 813**Example** 814 815```ts 816import bundleManager from '@ohos.bundle.bundleManager'; 817import { BusinessError } from '@ohos.base'; 818import hilog from '@ohos.hilog'; 819let abcPath : string = '/data/storage/el2/base/a.abc'; 820 821try { 822 bundleManager.deleteAbc(abcPath).then((data) => { 823 hilog.info(0x0000, 'testTag', 'deleteAbc successfully'); 824 }).catch((err: BusinessError) => { 825 hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', err.message); 826 }); 827} catch (err) { 828 let message = (err as BusinessError).message; 829 hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', message); 830} 831``` 832 833