# @ohos.bundle.bundleManager (bundleManager) The **bundleManager** module provides APIs for querying information about bundles, applications, abilities, ExtensionAbilities, and more. > **NOTE** > > 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. ## Modules to Import ```ts import bundleManager from '@ohos.bundle.bundleManager'; ``` ## Enums ### BundleFlag Enumerates the bundle flags, which indicate the type of bundle information to obtain. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name | Value | Description | | ----------------------------------------- | ---------- | ------------------------------------------------------------ | | 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.| | 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.| | 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.| | 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**.| | 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**.| | 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.| | 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**.| | 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.| | 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.| | GET_BUNDLE_INFO_WITH_MENU11+ | 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**.| ### ExtensionAbilityType Enumerates the types of ExtensionAbilities. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name| Value| Description| |:----------------:|:---:|-----| | FORM | 0 | [FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md): provides APIs for widget development.| | WORK_SCHEDULER | 1 | [WorkSchedulerExtensionAbility](../apis-backgroundtasks-kit/js-apis-WorkSchedulerExtensionAbility.md): enables applications to execute non-real-time tasks when the system is idle.| | INPUT_METHOD | 2 | [InputMethodExtensionAbility](../apis-ime-kit/js-apis-inputmethod-extension-ability.md): provides APIs for developing input method applications.| | SERVICE | 3 | [ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility-sys.md): enables applications to run in the background and provide services.| | ACCESSIBILITY | 4 | [AccessibilityExtensionAbility](../apis-accessibility-kit/js-apis-application-accessibilityExtensionAbility.md): provides accessibility for access to and operations on the UI.| | DATA_SHARE | 5 | [DataShareExtensionAbility](../apis-arkdata/js-apis-application-dataShareExtensionAbility-sys.md): enables applications to read and write data.| | FILE_SHARE | 6 | FileShareExtensionAbility: enables file sharing between applications. This ability is reserved.| | 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.| | WALLPAPER | 8 | WallpaperExtensionAbility: provides APIs to implement the home screen wallpaper. This ability is reserved.| | BACKUP | 9 | [BackupExtensionAbility](../apis-core-file-kit/js-apis-application-backupExtensionAbility.md): provides APIs to implement application data backup and restore.| | WINDOW | 10 | [WindowExtensionAbility](../apis-arkui/js-apis-application-windowExtensionAbility-sys.md): allows system applications to display UIs of other applications.| | 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.| | THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.| | 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.| | PRINT10+ | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.| | SHARE10+ | 16 | [ShareExtensionAbility](js-apis-app-ability-shareExtensionAbility.md): provides sharing service templates based on UIExtensionAbilities.| | PUSH10+ | 17 | PushExtensionAbility: provides APIs for pushing scenario-specific messages. This ability is reserved.| | DRIVER10+ | 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.| | ACTION10+ | 19 | [ActionExtensionAbility](js-apis-app-ability-actionExtensionAbility.md): provides custom action service templates based on UIExtensionAbilities.| | ADS_SERVICE11+ | 20 | AdsServiceExtensionAbility: provides background customized ad services for external systems. This type of ability is not supported yet.| | UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of ExtensionAbilities.| ### PermissionGrantState Enumerates the permission grant states. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name| Value| Description| |:----------------:|:---:|:---:| | PERMISSION_DENIED| -1 | Permission denied.| | PERMISSION_GRANTED | 0 | Permission granted. | ### SupportWindowMode Enumerates the window modes supported by the ability. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name| Value| Description| |:----------------:|:---:|:---:| | FULL_SCREEN | 0 | A window in full-screen mode is supported.| | SPLIT | 1 | A window in split-screen mode is supported.| | FLOATING | 2 | A floating window is supported. | ### LaunchType Enumerates the launch types of the ability. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name| Value| Description| |:----------------:|:---:|:---:| | SINGLETON | 0 | The ability can have only one instance.| | MULTITON | 1 | The ability can have multiple instances.| | SPECIFIED | 2 | The ability can have one or multiple instances, depending on the internal service of the ability.| ### AbilityType Enumerates the types of abilities. **Model restriction**: This API can be used only in the FA model. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name | Value | Description | | :-----: | ---- | :--------------------------------------------------------: | | PAGE | 1 | Ability that has the UI. FA developed using the Page template to provide the capability of interacting with users. | | 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. | | DATA | 3 | PA developed using the Data template to provide unified data access for external systems.| ### DisplayOrientation Enumerates the display orientations of the ability. This attribute applies only to the ability using the Page template. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name |Value|Description| |:----------------------------------|---|---| | UNSPECIFIED |0 |Unspecified. The orientation is determined by the system.| | LANDSCAPE |1 |Landscape.| | PORTRAIT |2 |Portrait.| | FOLLOW_RECENT |3 |The last display orientation is used.| | LANDSCAPE_INVERTED |4 |Reverse landscape.| | PORTRAIT_INVERTED |5 |Reverse portrait.| | AUTO_ROTATION |6 |Auto rotation.| | AUTO_ROTATION_LANDSCAPE |7 |Auto rotation in the horizontal direction.| | AUTO_ROTATION_PORTRAIT |8 |Auto rotation in the vertical direction.| | AUTO_ROTATION_RESTRICTED |9 |Switched-determined auto rotation.| | AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|Switched-determined auto rotation in the horizontal direction.| | AUTO_ROTATION_PORTRAIT_RESTRICTED |11|Switched-determined auto rotation in the vertical direction.| | LOCKED |12|Locked.| ### CompatiblePolicy10+ Defines the version compatibility type of the shared library. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name | Value | Description | | ---------------------- | ---- | -------------------------------- | | BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.| ### ModuleType Enumerates the module types. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name | Value | Description | | ------- | ---- | -------------------- | | ENTRY | 1 | Main module of the application. | | FEATURE | 2 | Dynamic feature module of the application.| | SHARED | 3 | Dynamic shared library module of the application. | ### BundleType Enumerates the bundle types. **System capability**: SystemCapability.BundleManager.BundleFramework.Core | Name | Value | Description | | -------------- | ---- | --------------- | | APP | 0 | The bundle is an application. | | ATOMIC_SERVICE | 1 | The bundle is an atomic service.| ## APIs ### bundleManager.getBundleInfoForSelf getBundleInfoForSelf(bundleFlags: [number](js-apis-bundleManager.md#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> Obtains the bundle information of this bundle based on the given bundle flags. This API uses a promise to return the result. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | --------------------- | | bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | Yes | Type of the bundle information to obtain.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------- | | Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.| **Example** ```ts // Obtain application info with metadataArray. import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; try { bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data)); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); } ``` ### bundleManager.getBundleInfoForSelf getBundleInfoForSelf(bundleFlags: [number](js-apis-bundleManager.md#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void Obtains the bundle information of this bundle based on the given bundle flags. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | --------------------- | | bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | Yes | Type of the bundle information to obtain.| | 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.| **Example** ```ts // Obtain ability info with permissions. import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; try { bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { if (err) { hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', err.message); } else { hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully: %{public}s', JSON.stringify(data)); } }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); } ``` ### bundleManager.getProfileByAbility getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\\>): void Obtains 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. > **NOTE** > > 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. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | | moduleName | string | Yes | Module name. | | abilityName | string | Yes | Name of the UIAbility component. | | metadataName | string | Yes | Metadata name of the UIAbility component, that is, **name** of the **metadata** tag under **abilities** in the **module.json5** file. | | callback | AsyncCallback> | 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.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | | 17700003 | The specified abilityName is not existed. | | 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | | 17700029 | The specified ability is disabled. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let abilityName = 'EntryAbility'; let metadataName = 'ability_metadata'; try { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => { if (err) { hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); } else { hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully: %{public}s', JSON.stringify(data)); } }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); } ``` ### bundleManager.getProfileByAbility getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\\> Obtains 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. > **NOTE** > > 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. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ------------ | ------ | ---- | -------------------------- | | moduleName | string | Yes | Module name. | | abilityName | string | Yes | Name of the UIAbility component. | | 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.| **Return value** | Type | Description | | ----------------------- | ------------------------------- | | Promise> | Promise used to return the array of JSON strings obtained.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | | 17700003 | The specified abilityName is not existed. | | 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | | 17700029 | The specified ability is disabled. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let abilityName = 'EntryAbility'; try { bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => { hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data)); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); } ``` ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let abilityName = 'EntryAbility'; let metadataName = 'ability_metadata'; try { bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data)); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); } ``` ### bundleManager.getProfileByAbilitySync10+ getProfileByAbilitySync(moduleName: string, abilityName: string, metadataName?: string): Array\ Obtains 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. > **NOTE** > > 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. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ------------ | ------ | ---- | -------------------------- | | moduleName | string | Yes | Module name. | | abilityName | string | Yes | Name of the UIAbility component. | | 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.| **Return value** | Type | Description | | ----------------------- | ------------------------------- | | Array\ | An array of JSON strings.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | | 17700003 | The specified abilityName is not existed. | | 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | | 17700029 | The specified ability is disabled. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let abilityName = 'EntryAbility'; try { let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName); hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message); } ``` ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName: string = 'entry'; let abilityName: string = 'EntryAbility'; let metadataName: string = 'ability_metadata'; try { let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName); hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message); } ``` ### bundleManager.getProfileByExtensionAbility getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\\>): void Obtains 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. > **NOTE** > > 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. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ | | moduleName | string | Yes | Module name. | | extensionAbilityName | string | Yes | Name of the ExtensionAbility component. | | metadataName | string | Yes | Metadata name of the ExtensionAbility component, that is, **name** of the **metadata** tag under **extensionAbilities** in the **module.json5** file. | | callback | AsyncCallback> | 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.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | | 17700003 | The specified extensionAbilityName not existed. | | 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let extensionAbilityName = 'com.example.myapplication.extension'; let metadataName = 'ability_metadata'; try { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => { if (err) { hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', err.message); } else { hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully: %{public}s', JSON.stringify(data)); } }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed: %{public}s', message); } ``` ### bundleManager.getProfileByExtensionAbility getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\\> Obtains 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. > **NOTE** > > 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. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ------ | ---- | ---------------------------------- | | moduleName | string | Yes | Module name. | | extensionAbilityName | string | Yes | Name of the ExtensionAbility component.| | 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. | **Return value** | Type | Description | | ----------------------- | ----------------------------------- | | Promise> | Promise used to return the array of JSON strings obtained.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | | 17700003 | The specified extensionAbilityName not existed. | | 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let extensionAbilityName = 'com.example.myapplication.extension'; let metadataName = 'ability_metadata'; try { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => { hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data)); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message); } try { bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => { hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbility successfully. Data: %{public}s', JSON.stringify(data)); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbility failed. Cause: %{public}s', message); } ``` ### bundleManager.getProfileByExtensionAbilitySync10+ getProfileByExtensionAbilitySync(moduleName: string, extensionAbilityName: string, metadataName?: string): Array\ Obtains 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. > **NOTE** > > 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. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ------ | ---- | ---------------------------------- | | moduleName | string | Yes | Module name. | | extensionAbilityName | string | Yes | Name of the ExtensionAbility component.| | 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. | **Return value** | Type | Description | | ----------------------- | ----------------------------------- | | Array\ | An array of JSON strings.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | | 17700003 | The specified extensionAbilityName not existed. | | 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let moduleName = 'entry'; let extensionAbilityName = 'com.example.myapplication.extension'; let metadataName = 'ability_metadata'; try { let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message); } try { let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName); hilog.info(0x0000, 'testTag', 'getProfileByExtensionAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message); } ``` ### bundleManager.getBundleInfoForSelfSync10+ getBundleInfoForSelfSync(bundleFlags: number): BundleInfo Obtains the bundle information of this bundle based on the given bundle flags. This API returns the result synchronously. **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | --------------------- | | bundleFlags | [number](js-apis-bundleManager.md#bundleflag) | Yes | Type of the bundle information to obtain.| **Return value** | Type | Description | | ------------------------------------------------- | -------------------- | | [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; try { let data = bundleManager.getBundleInfoForSelfSync(bundleFlags); hilog.info(0x0000, 'testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data)); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message); } ``` ### bundleManager.verifyAbc11+ verifyAbc(abcPaths: Array\, deleteOriginalFiles: boolean, callback: AsyncCallback\): void Verifies an .abc file. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.RUN_DYN_CODE **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ---------------------------- | | abcPaths | Array\ | Yes | Path of the .abc file.| | deleteOriginalFiles | boolean | Yes | Whether to delete the .abc file. The value **true** means to delete the file, and **false** means the opposite.| | callback | AsyncCallback\ | Yes| Callback used to return the result. If the verification is successful, **err** is **undefined**; otherwise, **err** is an error object.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | ------------------------------------- | | 17700201 | verifyAbc failed. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let abcPaths : Array = ['/data/storage/el2/base/a.abc']; try { bundleManager.verifyAbc(abcPaths, true, (err, data) => { if (err) { hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', err.message); } else { hilog.info(0x0000, 'testTag', 'verifyAbc successfully'); } }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'verifyAbc failed: %{public}s', message); } ``` ### bundleManager.verifyAbc11+ verifyAbc(abcPaths: Array\, deleteOriginalFiles: boolean): Promise\ Verifies an .abc file. This API uses a promise to return the result. **Required permissions**: ohos.permission.RUN_DYN_CODE **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ---------------------------- | | abcPaths | Array\ | Yes | Path of the .abc file.| | deleteOriginalFiles | boolean | Yes | Whether to delete the .abc file. The value **true** means to delete the file, and **false** means the opposite. | **Return value** | Type | Description | | ----------------------------------------------------------- | --------------------------- | | Promise\ | Promise that returns no value.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | --------------------------------------| | 17700201 | verifyAbc failed. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let abcPaths : Array = ['/data/storage/el2/base/a.abc']; try { bundleManager.verifyAbc(abcPaths, true).then((data) => { hilog.info(0x0000, 'testTag', 'verifyAbc successfully'); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'verifyAbc failed. Cause: %{public}s', message); } ``` ### bundleManager.deleteAbc11+ deleteAbc(abcPath: string): Promise\ Deletes an .abc file based on the specified file path. This API uses a promise to return the result. **Required permissions**: ohos.permission.RUN_DYN_CODE **System capability**: SystemCapability.BundleManager.BundleFramework.Core **Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ---------------------------- | | abcPath | string | Yes | Path of the .abc file.| **Return value** | Type | Description | | ----------------------------------------------------------- | --------------------------- | | Promise\ | Promise that returns no value.| **Error codes** For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). | ID| Error Message | | -------- | --------------------------------------| | 17700202 | deleteAbc failed. | **Example** ```ts import bundleManager from '@ohos.bundle.bundleManager'; import { BusinessError } from '@ohos.base'; import hilog from '@ohos.hilog'; let abcPath : string = '/data/storage/el2/base/a.abc'; try { bundleManager.deleteAbc(abcPath).then((data) => { hilog.info(0x0000, 'testTag', 'deleteAbc successfully'); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'deleteAbc failed. Cause: %{public}s', message); } ```