# BundleManager - [Overview](#section931510718165623) - [Summary](#section1517998658165623) - [Files](#files) - [Data Structures](#nested-classes) - [Typedefs](#typedef-members) - [Enumerations](#enum-members) - [Functions](#func-members) - [Details](#section165948216165623) - [Typedef](#section160203913165623) - [BundleStateCallback](#gad7ea6d0bf78db2d59e6d339c31819885) - [InstallerCallback](#ga00f021e76d728d2d44e1a28887ccc3af) - [Enumeration Type](#section76133345165623) - [AbilityType](#ga44b675d687acff3d739404c1227b4259) - [AppexecfwkErrors](#gac318d4f4dc0125e2367ea8c539770ed1) - [InstallLocation](#ga4907fd26df42a0abdfd6ade10ac44efb) - [LaunchMode](#ga605d46d860e356a74db6842e66522854) - [Function](#section1955086544165623) - [ClearAbilityInfo\(\)](#ga7377545918725f75645b59b1b7a319fa) - [ClearBundleInfo\(\)](#ga78829b21273aefd65844eba4549162ca) - [ClearBundleStatusCallback\(\)](#gae5e0593438f073199bf6d69e47a84975) - [ClearElement\(\)](#ga3abe15ac14571de84ca72c98f4009724) - [ClearModuleInfo\(\)](#ga6c2242cc10f135d129b95444faacb345) - [GetBundleInfo\(\)](#ga5e81134e037911654e34cc8a7ba01a2f) - [GetBundleInfos\(\)](#ga2469dafbc61ba8e98b69041c13044cad) - [GetBundleInfosByMetaData\(\)](#ga711965038390aef4fa0a6b6a98f6998b) - [GetBundleNameForUid\(\)](#ga4afdc08ba78506fce95a066e137ac46d) - [Install\(\)](#gaf1f1521a64cc98f076b0082df6c0abdd) - [QueryAbilityInfo\(\)](#ga4360375d15224d89632f59ee110b74c9) - [QueryKeepAliveBundleInfos\(\)](#ga0c1cb00194993ecba7337fdf0a203314) - [RegisterCallback\(\)](#ga5c49620ca8b752cd6f43fabc5d5c7416) - [SetElementAbilityName\(\)](#ga93a575cc428cb96526ae02b3997f1f3b) - [SetElementBundleName\(\)](#ga60692e66a3a204a2f16f70c5cd452c1d) - [SetElementDeviceID\(\)](#ga90e16f159ee8e7f1a9385feebb3dbc0c) - [Uninstall\(\)](#gaa117e44378315a61b4e71fd252b2e496) - [UnregisterCallback\(\)](#ga095eee592eff6ce71a2a67a1a0e3e344) ## **Overview** **Description:** Provides structures and functions for managing application bundles and obtaining application information. You can use functions provided by this module to install, update, or uninstall an application, obtain [AbilityInfo](AbilityInfo.md) and [BundleInfo](BundleInfo.md) about an application, and obtain the bundle name of an application based on the application's user ID \(UID\). **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Files

File Name

Description

ability_info.h

Declares structures and functions for managing ability information.

appexecfwk_errors.h

Declares error codes returned by bundle management functions.

bundle_info.h

Declares structures and functions for managing application bundle information.

bundle_manager.h

Declares functions used for managing application bundles and obtaining bundle information.

bundle_status_callback.h

Declares the callback invoked upon state changes of an application and the structure defining the callback information.

element_name.h

Declares the structure that defines the required information for querying AbilityInfo, including the device ID, bundle name, and class name, and functions for setting such information.

module_info.h

Declares structures and functions for managing HAP package information.

## Data Structures

Data Structure Name

Description

AbilityInfo

Defines the ability information.

BundleInfo

Defines the bundle information.

BundleStatusCallback

Defines the application state callback information.

ElementName

Defines the ability information.

InstallParam

Defines parameters used for application installation, update, or uninstallation.

MetaData

Defines the metadata information in a ModuleInfo object.

ModuleInfo

Defines the HAP information.

## Typedefs

Typedef Name

Description

InstallerCallback) (const uint8_t resultCode, const void *resultMessage)

typedef void(*

Called when an application is installed, updated, or uninstalled.

BundleStateCallback) (const uint8_t installType, const uint8_t resultCode, const void *resultMessage, const char *bundleName, void *data)

typedef void(*

Called when the installation, update, or uninstallation state of an application changes.

## Enumerations

Enumeration Name

Description

AbilityType { UNKNOWN = 0, PAGE, SERVICE }

Enumerates types of templates used by an ability.

LaunchMode { SINGLETON = 0, STANDARD }

Enumerates startup modes of an ability.

AppexecfwkErrors { ERR_OK = 0, ERR_APPEXECFWK_QUERY_PARAMETER_ERROR, ERR_APPEXECFWK_QUERY_NO_INFOS, ERR_APPEXECFWK_QUERY_INFOS_INIT_ERROR, ERR_APPEXECFWK_OBJECT_NULL, ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR = 10, ERR_APPEXECFWK_INSTALL_FAILED_PARAM_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_FILE_PATH_INVALID, ERR_APPEXECFWK_INSTALL_FAILED_FILE_NOT_EXISTS, ERR_APPEXECFWK_INSTALL_FAILED_INVALID_FILE_NAME, ERR_APPEXECFWK_INSTALL_FAILED_BAD_FILE, ERR_APPEXECFWK_INSTALL_FAILED_CREATE_FILE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_CREATE_PERMISSIONS_DIR_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_RENAME_DIR_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_RENAME_FILE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_CREATE_DATA_DIR_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_RECORD_INFO_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_UID_AND_GID_BACKUP_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_VERSION_DOWNGRADE, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_BUNDLE_NUMBER, ERR_APPEXECFWK_INSTALL_FAILED_STORE_PERMISSIONS_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID, ERR_APPEXECFWK_INSTALL_FAILED_INCOMPATIBLE_SIGNATURE, ERR_APPEXECFWK_INSTALL_FAILED_INVALID_PROVISIONINFO, ERR_APPEXECFWK_INSTALL_FAILED_OPERATE_SIGNED_FILE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_APP_SIGNATURE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_SIGNATURE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_SIGNATURE_ERROR , ERR_APPEXECFWK_SET_DEBUG_MODE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_ERROR = 40, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_BUNDLENAME_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_BUNDLENAME, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_VENDOR_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_VERSIONCODE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_VERSIONNAME_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PERMISSIONS_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_API_VERSION_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DEVICE_CONFIG_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_KEEPALIVE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_MODULENAME_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_MODULENAME, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_MODULE_DESCRIPTION_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DEVICETYPE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_MODULENAME_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_MODULETYPE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_DELIVERY_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_METADATA_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITIES_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_NAME_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_TYPE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_ICONPATH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_LABEL_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_DESCRIPTION_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_LAUNCHTYPE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_VISIBLE_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_BUNDLENAME_LENGTH, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_LABEL_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_VERSIONNAME_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_METADATA_NAME_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_METADATA_VALUE_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_VENDOR_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_MODULENAME_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_ABILITYNAME_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_ABILITY_DESCRIPTION_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_ABILITY_LABEL_LENGTH_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_EXTRACTOR_NOT_INIT, ERR_APPEXECFWK_INSTALL_FAILED_EXTRACT_HAP_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_JS_DIR_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_RESOURCE_INDEX_NOT_EXISTS, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_LABEL_RES_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ICON_RES_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DESCRIPTION_RES_ERROR, ERR_APPEXECFWK_INSTALL_FAILED_SEND_REQUEST_ERROR, ERR_APPEXECFWK_UNINSTALL_FAILED_INTERNAL_ERROR = 90, ERR_APPEXECFWK_UNINSTALL_FAILED_PARAM_ERROR, ERR_APPEXECFWK_UNINSTALL_FAILED_BUNDLE_NOT_EXISTS, ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_DIRS_ERROR, ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_RECORD_INFO_ERROR, ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_PERMISSIONS_ERROR, ERR_APPEXECFWK_UNINSTALL_FAILED_BUNDLE_NOT_UNINSTALLABLE, ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_UID_INFO_ERROR, ERR_APPEXECFWK_UNINSTALL_FAILED_SEND_REQUEST_ERROR, ERR_APPEXECFWK_DUMP_ERROR = 100, ERR_APPEXECFWK_COMMAND_ERROR, ERR_APPEXECFWK_CALLBACK_REGISTER_FAILED, ERR_APPEXECFWK_CALLBACK_UNREGISTER_FAILED, ERR_APPEXECFWK_CALLBACK_GENERATE_LOCAL_SERVICEID_FAILED, ERR_APPEXECFWK_CALLBACK_SERVICEID_TRANSMITTED_FAILED, ERR_APPEXECFWK_CALLBACK_NEVER_REGISTERED, ERR_APPEXECFWK_CALLBACK_OBTAIN_ALL_BUNDLE_FAILED, ERR_APPEXECFWK_CALLBACK_NULL_CORRESPONDING_CALLBACK, ERR_APPEXECFWK_CALLBACK_GET_INSTALLTYPE_FAILED, ERR_APPEXECFWK_CALLBACK_GET_ERROR_INSTALLTYPE, ERR_APPEXECFWK_SERIALIZATION_FAILED, ERR_APPEXECFWK_DESERIALIZATION_FAILED, ERR_APPEXECFWK_SYSTEM_INTERNAL_ERROR, ERR_APPEXECFWK_NO_BUNDLENAME_FOR_UID, ERR_APPEXECFWK_IPCIO_UNAVAILABLED, ERR_APPEXECFWK_INVOKE_ERROR, ERR_APPEXECFWK_PERMISSION_DENIED }

Enumerates error codes provided by the Bundle Manager Service.

InstallLocation { INSTALL_LOCATION_INTERNAL_ONLY = 1, INSTALL_LOCATION_PREFER_EXTERNAL = 2 }

 
## Functions

Function

Description

ClearAbilityInfo (AbilityInfo *abilityInfo)

void

Clears an AbilityInfo object.

ClearBundleInfo (BundleInfo *bundleInfo)

void

Clears a BundleInfo object.

RegisterCallback (BundleStatusCallback *BundleStatusCallback)

int32_t

Registers a callback to monitor the installation, update, and uninstallation state changes of an application.

UnregisterCallback ()

int32_t

Unregisters a callback previously registered for monitoring the installation, update, and uninstallation stat changes of an application.

Install (const char *hapPath, const InstallParam *installParam, InstallerCallback installerCallback)

bool

Installs or updates an application.

Uninstall (const char *bundleName, const InstallParam *installParam, InstallerCallback installerCallback)

bool

Uninstalls an application.

QueryAbilityInfo (const Want *want, AbilityInfo *abilityInfo)

uint8_t

Queries the AbilityInfo of an ability based on the information carried in the Want structure.

GetBundleInfo (const char *bundleName, int32_t flags, BundleInfo *bundleInfo)

uint8_t

Obtains the BundleInfo of an application based on the specified bundle name.

GetBundleInfos (const int flags, BundleInfo **bundleInfos, int32_t *len)

uint8_t

Obtains the BundleInfo of all bundles in the system.

QueryKeepAliveBundleInfos (BundleInfo **bundleInfos, int32_t *len)

uint8_t

Obtains the BundleInfo of all keep-alive applications in the system.

GetBundleInfosByMetaData (const char *metaDataKey, BundleInfo **bundleInfos, int32_t *len)

uint8_t

Obtains the BundleInfo of application bundles based on the specified MetaData.

GetBundleNameForUid (int32_t uid, char **bundleName)

uint8_t

Obtains the bundle name of an application based on the specified UID.

ClearBundleStatusCallback (BundleStatusCallback *bundleStatusCallback)

void

Clears and releases the memory occupied by the BundleStatusCallback structure.

ClearElement (ElementName *element)

void

Clears the internal data of a specified ElementName.

SetElementDeviceID (ElementName *element, const char *deviceId)

bool

Sets the device ID used to query AbilityInfo.

SetElementBundleName (ElementName *element, const char *bundleName)

bool

Sets the bundle name used to query AbilityInfo.

SetElementAbilityName (ElementName *element, const char *abilityName)

bool

Sets the class name of the ability used to query AbilityInfo.

ClearModuleInfo (ModuleInfo *moduleInfo)

void

Clears a ModuleInfo object.

## **Details** ## **Typedef ** ## BundleStateCallback ``` typedef void(* BundleStateCallback) (const uint8_t installType, const uint8_t resultCode, const void *resultMessage, const char *bundleName, void *data) ``` **Description:** Called when the installation, update, or uninstallation state of an application changes. This callback is used to listen for state change results of applications in the system. **Parameters:**

Name

Description

installType Indicates the installation, update, or uninstallation state. The value 0 indicates that the application is being installed or updated, and 1 indicates that the application is being uninstalled.
resultCode Indicates the status code returned for the application installation, update, or uninstallation result. For details, see AppexecfwkErrors.
resultMessage Indicates the pointer to the result message returned with the status code.
bundleName Indicates the pointer to the name of the bundle whose state has changed.
data Indicates the pointer to the data that will be used by the callback upon a state change. The data is passed through BundleStatusCallback during callback registration.
## InstallerCallback ``` typedef void(* InstallerCallback) (const uint8_t resultCode, const void *resultMessage) ``` **Description:** Called when an application is installed, updated, or uninstalled. This function can be registered through [Install](BundleManager.md#gaf1f1521a64cc98f076b0082df6c0abdd) and [Uninstall](BundleManager.md#gaa117e44378315a61b4e71fd252b2e496) to receive the installation, update, and uninstallation result. **Parameters:**

Name

Description

resultCode Indicates the status code returned for the application installation, update, or uninstallation result. For details, see AppexecfwkErrors.
resultMessage Indicates the result message returned with the status code.
## **Enumeration Type ** ## AbilityType ``` enum [AbilityType](BundleManager.md#ga44b675d687acff3d739404c1227b4259) ``` **Description:** Enumerates types of templates used by an ability.

Enumerator

Description

UNKNOWN

Unknown

PAGE

Page

SERVICE

Service

## AppexecfwkErrors ``` enum [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) ``` **Description:** Enumerates error codes provided by the Bundle Manager [Service](Service.md).

Enumerator

Description

ERR_OK

The function is successfully called.

ERR_APPEXECFWK_QUERY_PARAMETER_ERROR

Incorrect parameter for querying AbilityInfo or BundleInfo.

ERR_APPEXECFWK_QUERY_NO_INFOS

No AbilityInfo or BundleInfo is found.

ERR_APPEXECFWK_QUERY_INFOS_INIT_ERROR

An error occurred when initializing BundleInfo or AbilityInfo during information query.

ERR_APPEXECFWK_OBJECT_NULL

The object or pointer is null.

ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR

Failed to install the application due to an internal logic error.

ERR_APPEXECFWK_INSTALL_FAILED_PARAM_ERROR

Failed to install the application due to incorrect parameters.

ERR_APPEXECFWK_INSTALL_FAILED_FILE_PATH_INVALID

Failed to install the application because the installation file path is invalid.

ERR_APPEXECFWK_INSTALL_FAILED_FILE_NOT_EXISTS

Failed to install the application because the installation file does not exist.

ERR_APPEXECFWK_INSTALL_FAILED_INVALID_FILE_NAME

Failed to install the application because the installation file name is invalid.

ERR_APPEXECFWK_INSTALL_FAILED_BAD_FILE

Failed to install the application due to incorrect file content.

ERR_APPEXECFWK_INSTALL_FAILED_CREATE_FILE_ERROR

Failed to install the application due to a file creation error.

ERR_APPEXECFWK_INSTALL_FAILED_CREATE_PERMISSIONS_DIR_ERROR

Failed to install the application because an error occurred when creating the permission file directory.

ERR_APPEXECFWK_INSTALL_FAILED_RENAME_DIR_ERROR

Failed to install the application due to a path renaming error.

ERR_APPEXECFWK_INSTALL_FAILED_RENAME_FILE_ERROR

Failed to install the application due to a file renaming error.

ERR_APPEXECFWK_INSTALL_FAILED_CREATE_DATA_DIR_ERROR

Failed to install the application due to an error occurred when creating the data path.

ERR_APPEXECFWK_INSTALL_FAILED_RECORD_INFO_ERROR

Failed to install the application due to an error occurred when recording installation information.

ERR_APPEXECFWK_INSTALL_FAILED_UID_AND_GID_BACKUP_ERROR

Failed to install the application due to an error occurred when backing up the UID and GID.

ERR_APPEXECFWK_INSTALL_FAILED_VERSION_DOWNGRADE

Failed to install the application because an application of a later version has been installed.

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_BUNDLE_NUMBER

Failed to install the application because the number of installed applications exceeds the maximum (30). This error code is available only to basic watches.

ERR_APPEXECFWK_INSTALL_FAILED_STORE_PERMISSIONS_ERROR

Failed to install the application due to an error occurred when storing permission information.

ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID

Failed to install the application due to invalid file data. This error code is available only to basic watches.

ERR_APPEXECFWK_INSTALL_FAILED_INCOMPATIBLE_SIGNATURE

Failed to install the application due to unmatched signature used for version update.

ERR_APPEXECFWK_INSTALL_FAILED_INVALID_PROVISIONINFO

Failed to install the application due to unmatched provisioning information during signature verification.

ERR_APPEXECFWK_INSTALL_FAILED_OPERATE_SIGNED_FILE_ERROR

Failed to install the application due to an error occurred when processing the signature file.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_APP_SIGNATURE_ERROR

Failed to install the application due to an error occurred when parsing the application signature.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_SIGNATURE_ERROR

Failed to install the application due to an error occurred when parsing the file signature.

ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_SIGNATURE_ERROR

Failed to install the application due to an internal error during signature verification.

ERR_APPEXECFWK_SET_DEBUG_MODE_ERROR

Failed to install the application due to an error occurred when setting the signature verification mode.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_ERROR

Failed to parse the file.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_BUNDLENAME_ERROR

Failed to parse the bundle name.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_BUNDLENAME

Invalid bundle name.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_VENDOR_ERROR

Failed to parse the vendor information.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_VERSIONCODE_ERROR

Failed to parse the version code.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_VERSIONNAME_ERROR

Failed to parse the version name.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PERMISSIONS_ERROR

Failed to parse the installation permission information.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_API_VERSION_ERROR

Failed to parse the API version.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DEVICE_CONFIG_ERROR

Failed to parse the device configuration.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_KEEPALIVE_ERROR

Failed to parse the isKeepAlive field of the application.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_MODULENAME_ERROR

Failed to parse the name field of the application's HAP package. The HAP information is encapsulated in a ModuleInfo object.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_MODULENAME

Invalid HAP name.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_MODULE_DESCRIPTION_ERROR

Failed to parse the HAP description information.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DEVICETYPE_ERROR

Failed to parse the deviceType field of the application's HAP package.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_ERROR

Failed to parse the HAP information.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_MODULENAME_ERROR

Failed to parse the moduleName field of the application's HAP package.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_MODULETYPE_ERROR

Invalid HAP type.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DISTRO_DELIVERY_ERROR

Failed to parse the isDeliveryInstall field of the application's HAP package.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_METADATA_ERROR

Failed to parse the MetaData information.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITIES_ERROR

Failed to parse the AbilityInfo.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_NAME_ERROR

Failed to parse the class name of the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_TYPE_ERROR

Failed to parse the template used by the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_ICONPATH_ERROR

Failed to parse the icon path of the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_LABEL_ERROR

Failed to parse the label of the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_DESCRIPTION_ERROR

Failed to parse the description of the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_LAUNCHTYPE_ERROR

Failed to parse the startup mode of the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ABILITY_VISIBLE_ERROR

Failed to parse the isVisible field of the ability.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_BUNDLENAME_LENGTH

Invalid length of the bundle name.

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_LABEL_LENGTH_ERROR

The parsed application label exceeds the maximum length (255 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_VERSIONNAME_LENGTH_ERROR

The parsed application version name exceeds the maximum length (127 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_METADATA_NAME_LENGTH_ERROR

The parsed application metadata name exceeds the maximum length (255 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_METADATA_VALUE_LENGTH_ERROR

The parsed application metadata value exceeds the maximum length (255 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_VENDOR_LENGTH_ERROR

The parsed application vendor name exceeds the maximum length (255 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_MODULENAME_LENGTH_ERROR

The parsed HAP name exceeds the maximum length (31 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_ABILITYNAME_LENGTH_ERROR

The parsed ability class name exceeds the maximum length (127 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_ABILITY_DESCRIPTION_LENGTH_ERROR

The parsed ability description exceeds the maximum length (255 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_ABILITY_LABEL_LENGTH_ERROR

The parsed ability label exceeds the maximum length (255 bytes).

ERR_APPEXECFWK_INSTALL_FAILED_EXTRACTOR_NOT_INIT

Failed to initialize the extractor.

ERR_APPEXECFWK_INSTALL_FAILED_EXTRACT_HAP_ERROR

Failed to extract information from the HAP package.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_JS_DIR_ERROR

Failed to parse the JavaScript path. This error code is available only to basic watches.

ERR_APPEXECFWK_INSTALL_FAILED_RESOURCE_INDEX_NOT_EXISTS

The resource index does not exist.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_LABEL_RES_ERROR

Failed to parse the label resource.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_ICON_RES_ERROR

Failed to parse the icon resource.

ERR_APPEXECFWK_INSTALL_FAILED_PARSE_DESCRIPTION_RES_ERROR

Failed to parse the description resource.

ERR_APPEXECFWK_INSTALL_FAILED_SEND_REQUEST_ERROR

Failed to install the application due to a request sending error.

ERR_APPEXECFWK_UNINSTALL_FAILED_INTERNAL_ERROR

Failed to uninstall the application due to an internal error.

ERR_APPEXECFWK_UNINSTALL_FAILED_PARAM_ERROR

Failed to uninstall the application due to incorrect input parameters.

ERR_APPEXECFWK_UNINSTALL_FAILED_BUNDLE_NOT_EXISTS

Failed to uninstall the application because it does not exist.

ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_DIRS_ERROR

Failed to uninstall the application due to an error occurred when deleting the path.

ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_RECORD_INFO_ERROR

Failed to uninstall the application due to an error occurred when deleting the installation record.

ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_PERMISSIONS_ERROR

Failed to uninstall the application due to an error occurred when deleting the permission information.

ERR_APPEXECFWK_UNINSTALL_FAILED_BUNDLE_NOT_UNINSTALLABLE

Failed to uninstall the application because the application cannot be uninstalled.

ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_UID_INFO_ERROR

Failed to uninstall the application due to an error occurred when deleting the UID information.

ERR_APPEXECFWK_UNINSTALL_FAILED_SEND_REQUEST_ERROR

Failed to uninstall the application due to a request sending error.

ERR_APPEXECFWK_DUMP_ERROR

Incorrect dump information.

ERR_APPEXECFWK_COMMAND_ERROR

Incorrect command.

ERR_APPEXECFWK_CALLBACK_REGISTER_FAILED

Failed to register the callback.

ERR_APPEXECFWK_CALLBACK_UNREGISTER_FAILED

Failed to unregister the callback.

ERR_APPEXECFWK_CALLBACK_GENERATE_LOCAL_SERVICEID_FAILED

Failed to generate a service ID for the current process.

ERR_APPEXECFWK_CALLBACK_SERVICEID_TRANSMITTED_FAILED

Failed to transmit the service ID of the current process.

ERR_APPEXECFWK_CALLBACK_NEVER_REGISTERED

The callback is never registered.

ERR_APPEXECFWK_CALLBACK_OBTAIN_ALL_BUNDLE_FAILED

Failed to obtain the bundle names of all applications in the system.

ERR_APPEXECFWK_CALLBACK_NULL_CORRESPONDING_CALLBACK

The required callback is unavailable.

ERR_APPEXECFWK_CALLBACK_GET_INSTALLTYPE_FAILED

Failed to obtain the installation type (installation or uninstallation).

ERR_APPEXECFWK_CALLBACK_GET_ERROR_INSTALLTYPE

Incorrect installation type.

ERR_APPEXECFWK_SERIALIZATION_FAILED

Serialization failed.

ERR_APPEXECFWK_DESERIALIZATION_FAILED

Deserialization failed.

ERR_APPEXECFWK_SYSTEM_INTERNAL_ERROR

Internal system error.

ERR_APPEXECFWK_NO_BUNDLENAME_FOR_UID

No bundle name associated with the UID is found.

ERR_APPEXECFWK_IPCIO_UNAVAILABLED

The IpcIo structure is unavailable.

ERR_APPEXECFWK_INVOKE_ERROR

An error occurred when calling the invoke function of the Bundle Manager Service.

ERR_APPEXECFWK_PERMISSION_DENIED

The server that invokes the Bundle Manager Service does not have required permission.

## InstallLocation ``` enum [InstallLocation](BundleManager.md#ga4907fd26df42a0abdfd6ade10ac44efb) ```

Enumerator

Description

INSTALL_LOCATION_INTERNAL_ONLY

The installation or update path is storage/app when installLocation is set to 1.

INSTALL_LOCATION_PREFER_EXTERNAL

The installation or update path is sdcard/app when installLocation is set to 2.

## LaunchMode ``` enum [LaunchMode](BundleManager.md#ga605d46d860e356a74db6842e66522854) ``` **Description:** Enumerates startup modes of an ability.

Enumerator

Description

SINGLETON

Singleton mode, allowing only one instance

STANDARD

Standard mode, allowing multiple instances

## **Function ** ## ClearAbilityInfo\(\) ``` void ClearAbilityInfo ([AbilityInfo](AbilityInfo.md) * abilityInfo) ``` **Description:** Clears an [AbilityInfo](AbilityInfo.md) object. This function clears and releases the memory occupied by the fields of the pointer type included in the specified [AbilityInfo](AbilityInfo.md) object. **Parameters:**

Name

Description

abilityInfo Indicates the pointer to the AbilityInfo object to clear.
## ClearBundleInfo\(\) ``` void ClearBundleInfo ([BundleInfo](BundleInfo.md) * bundleInfo) ``` **Description:** Clears a [BundleInfo](BundleInfo.md) object. This function clears and releases the memory occupied by the fields of the pointer type included in the specified [BundleInfo](BundleInfo.md) object. **Parameters:**

Name

Description

bundleInfo Indicates the pointer to the BundleInfo object to clear.
## ClearBundleStatusCallback\(\) ``` void ClearBundleStatusCallback ([BundleStatusCallback](BundleStatusCallback.md) * bundleStatusCallback) ``` **Description:** Clears and releases the memory occupied by the [BundleStatusCallback](BundleStatusCallback.md) structure. **Parameters:**

Name

Description

bundleStatusCallback Indicates the pointer to the BundleStatusCallback structure to clear.
## ClearElement\(\) ``` void ClearElement ([ElementName](ElementName.md) * element) ``` **Description:** Clears the internal data of a specified **[ElementName](ElementName.md)**. After [AbilityInfo](AbilityInfo.md) is queried, clear the internal data of an **[ElementName](ElementName.md)** if it is no longer required. **Parameters:**

Name

Description

element Indicates the pointer to the ElementName to clear.
## ClearModuleInfo\(\) ``` void ClearModuleInfo ([ModuleInfo](ModuleInfo.md) * moduleInfo) ``` **Description:** Clears a [ModuleInfo](ModuleInfo.md) object. This function clears and releases the memory occupied by the fields of the pointer type included in the specified [ModuleInfo](ModuleInfo.md) object. **Parameters:**

Name

Description

moduleInfo Indicates the pointer to the ModuleInfo object to clear.
## GetBundleInfo\(\) ``` uint8_t GetBundleInfo (const char * bundleName, int32_t flags, [BundleInfo](BundleInfo.md) * bundleInfo ) ``` **Description:** Obtains the [BundleInfo](BundleInfo.md) of an application based on the specified bundle name. **Parameters:**

Name

Description

bundleName Indicates the pointer to the name of the application bundle to query.
flags Specifies whether the obtained BundleInfo object can contain AbilityInfo. The value 1 indicates that it can contain AbilityInfo, and 0 indicates that it cannot.
bundleInfo Indicates the pointer to the obtained BundleInfo object.
**Attention:** Before querying a [BundleInfo](BundleInfo.md) object, you should first call **memset** on the constructed [BundleInfo](BundleInfo.md) object so that each field in it can be properly initialized for carrying the obtained information. **Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## GetBundleInfos\(\) ``` uint8_t GetBundleInfos (const int flags, [BundleInfo](BundleInfo.md) ** bundleInfos, int32_t * len ) ``` **Description:** Obtains the [BundleInfo](BundleInfo.md) of all bundles in the system. **Parameters:**

Name

Description

flags Specifies whether each of the obtained BundleInfo objects can contain AbilityInfo. The value 1 indicates that it can contain AbilityInfo, and 0 indicates that it cannot.
bundleInfos Indicates the double pointer to the obtained BundleInfo objects.
len Indicates the pointer to the number of BundleInfo objects obtained.
**Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## GetBundleInfosByMetaData\(\) ``` uint8_t GetBundleInfosByMetaData (const char * metaDataKey, [BundleInfo](BundleInfo.md) ** bundleInfos, int32_t * len ) ``` **Description:** Obtains the [BundleInfo](BundleInfo.md) of application bundles based on the specified [MetaData](MetaData.md). **Parameters:**

Name

Description

metaDataKey Indicates the pointer to the metadata name in the MetaData.
bundleInfos Indicates the double pointer to the obtained BundleInfo objects.
len Indicates the pointer to the number of BundleInfo objects obtained.
**Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## GetBundleNameForUid\(\) ``` uint8_t GetBundleNameForUid (int32_t uid, char ** bundleName ) ``` **Description:** Obtains the bundle name of an application based on the specified UID. **Parameters:**

Name

Description

uid Indicates the UID of the application to query.
bundleName Indicates the double pointer to the bundle name of the application.
**Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## Install\(\) ``` bool Install (const char * hapPath, const [InstallParam](InstallParam.md) * installParam, [InstallerCallback](BundleManager.md#ga00f021e76d728d2d44e1a28887ccc3af) installerCallback ) ``` **Description:** Installs or updates an application. **Parameters:**

Name

Description

hapPath Indicates the pointer to the path for storing the OpenHarmony Ability Package (HAP) of the application to install or update.
installParam Indicates the pointer to the parameters used for application installation or update.
installerCallback Indicates the callback to be invoked for notifying the installation or update result.
**Returns:** Returns **true** if this function is successfully called; returns **false** otherwise. ## QueryAbilityInfo\(\) ``` uint8_t QueryAbilityInfo (const [Want](Want.md) * want, [AbilityInfo](AbilityInfo.md) * abilityInfo ) ``` **Description:** Queries the [AbilityInfo](AbilityInfo.md) of an ability based on the information carried in the [Want](Want.md) structure. **Parameters:**

Name

Description

want Indicates the pointer to the Want structure used for querying the specified ability.
abilityInfo Indicates the pointer to the obtained AbilityInfo object.
**Attention:** Before querying an [AbilityInfo](AbilityInfo.md) object, you should first call **memset** on the constructed [AbilityInfo](AbilityInfo.md) object so that each field in it can be properly initialized for carrying the obtained information. **Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## QueryKeepAliveBundleInfos\(\) ``` uint8_t QueryKeepAliveBundleInfos ([BundleInfo](BundleInfo.md) ** bundleInfos, int32_t * len ) ``` **Description:** Obtains the [BundleInfo](BundleInfo.md) of all keep-alive applications in the system. **Parameters:**

Name

Description

bundleInfos Indicates the double pointer to the obtained BundleInfo objects.
len Indicates the pointer to the number of BundleInfo objects obtained.
**Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## RegisterCallback\(\) ``` int32_t RegisterCallback ([BundleStatusCallback](BundleStatusCallback.md) * BundleStatusCallback) ``` **Description:** Registers a callback to monitor the installation, update, and uninstallation state changes of an application. **Parameters:**

Name

Description

BundleStatusCallback Indicates the pointer to the callback to be invoked when the installation, update, or uninstallation state of the monitored application changes.
**Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise. ## SetElementAbilityName\(\) ``` bool SetElementAbilityName ([ElementName](ElementName.md) * element, const char * abilityName ) ``` **Description:** Sets the class name of the ability used to query [AbilityInfo](AbilityInfo.md). **Parameters:**

Name

Description

element Indicates the pointer to the ElementName to set.
abilityName Indicates the pointer to the class name to set.
**Returns:** Returns **true** if the setting is successful; returns **false** otherwise. ## SetElementBundleName\(\) ``` bool SetElementBundleName ([ElementName](ElementName.md) * element, const char * bundleName ) ``` **Description:** Sets the bundle name used to query [AbilityInfo](AbilityInfo.md). **Parameters:**

Name

Description

element Indicates the pointer to the ElementName to set.
bundleName Indicates the pointer to the bundle name to set.
**Returns:** Returns **true** if the setting is successful; returns **false** otherwise. ## SetElementDeviceID\(\) ``` bool SetElementDeviceID ([ElementName](ElementName.md) * element, const char * deviceId ) ``` **Description:** Sets the device ID used to query [AbilityInfo](AbilityInfo.md). **Parameters:**

Name

Description

element Indicates the pointer to the ElementName to set.
deviceId Indicates the pointer to the device ID to set.
**Returns:** Returns **true** if the setting is successful; returns **false** otherwise. ## Uninstall\(\) ``` bool Uninstall (const char * bundleName, const [InstallParam](InstallParam.md) * installParam, [InstallerCallback](BundleManager.md#ga00f021e76d728d2d44e1a28887ccc3af) installerCallback ) ``` **Description:** Uninstalls an application. **Parameters:**

Name

Description

bundleName Indicates the pointer to the bundle name of the application to uninstall.
installParam Indicates the pointer to the parameters used for application uninstallation.
installerCallback Indicates the callback to be invoked for notifying the uninstallation result.
**Returns:** Returns **true** if this function is successfully called; returns **false** otherwise. ## UnregisterCallback\(\) ``` int32_t UnregisterCallback () ``` **Description:** Unregisters a callback previously registered for monitoring the installation, update, and uninstallation stat changes of an application. **Returns:** Returns [ERR\_OK](BundleManager.md#ggac318d4f4dc0125e2367ea8c539770ed1aa26c163b80b1f6786ca81dadc14b00fb) if this function is successfully called; returns another error code defined in [AppexecfwkErrors](BundleManager.md#gac318d4f4dc0125e2367ea8c539770ed1) otherwise.