BundleManager
You can use functions provided by this module to install, update, or uninstall an application, obtain AbilityInfo and 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
Data Structures
Typedefs
Called when an application is installed, updated, or uninstalled. |
Enumerations
Functions
ClearAbilityInfo ( abilityInfo) |
Clears an AbilityInfo object. |
(BundleInfo bundleInfo) |
|
RegisterCallback (BundleStatusCallback BundleStatusCallback) |
Registers a callback to monitor the installation, update, and uninstallation state changes of an application. |
Unregisters a callback previously registered for monitoring the installation, update, and uninstallation state changes of an application. |
|
Install (const char hapPath, const InstallParam installParam, installerCallback) |
|
Uninstall (const char bundleName, const InstallParam installParam, installerCallback) |
|
QueryAbilityInfo (const want, AbilityInfo abilityInfo) |
Queries the of an ability based on the information carried in the Want structure. |
(const char bundleName, int32_t flags, BundleInfo bundleInfo) |
Obtains the of an application based on the specified bundle name. |
GetBundleInfos (const int flags, **bundleInfos, int32_t len) |
Obtains the BundleInfo of all bundles in the system. |
(BundleInfo bundleInfos, int32_t len) |
|
GetBundleInfosByMetaData (const char metaDataKey, bundleInfos, int32_t len) |
Obtains the BundleInfo of application bundles based on the specified . |
GetBundleNameForUid (int32_t uid, char **bundleName) |
Obtains the bundle name of an application based on the specified UID. |
(ElementName element) |
|
SetElementDeviceID ( element, const char deviceId) |
Sets the device ID used to query AbilityInfo. |
(ElementName element, const char bundleName) |
|
SetElementAbilityName ( element, const char abilityName) |
Sets the class name of the ability used to query AbilityInfo. |
(ModuleInfo *moduleInfo) |
Details
Typedef Documentation
InstallerCallback
Description:
Called when an application is installed, updated, or uninstalled.
This function can be registered through and Uninstall to receive the installation, update, and uninstallation result.
Parameters:
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. |
AbilityType
Description:
Enumerates types of templates used by an ability.
UNKNOWN | |
PAGE | |
SERVICE |
AppexecfwkErrors
Description:
Enumerates error codes provided by the Bundle Manager .
ERR_OK | |
ERR_APPEXECFWK_QUERY_PARAMETER_ERROR | Incorrect parameter for querying or BundleInfo. |
ERR_APPEXECFWK_QUERY_NO_INFOS | No or BundleInfo is found. |
ERR_APPEXECFWK_QUERY_INFOS_INIT_ERROR | An error occurred when initializing or AbilityInfo during information query. |
ERR_APPEXECFWK_OBJECT_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_CODE_DIR_ERROR | Failed to install the application due to a file path creation error. |
ERR_APPEXECFWK_INSTALL_FAILED_REMOVE_CODE_DIR_ERROR | Failed to install the application due to a file path deletion 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_REMOVE_DATA_DIR_ERROR | Failed to install the application due to an error occurred when removing the data path. |
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_CHOWN_DATA_DIR_ERROR | Failed to install the application due to an error occurred when changing ownership of the data directory. |
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 | |
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 | Failed to parse the name field of the application’s HAP package. The HAP information is encapsulated in a object. |
ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_MODULENAME | |
ERR_APPEXECFWK_INSTALL_FAILED_PARSE_MODULE_DESCRIPTION_ERROR | |
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 | |
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 | |
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 | |
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 | 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 | |
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 | |
ERR_APPEXECFWK_INSTALL_FAILED_EXTRACT_HAP_ERROR | |
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 | |
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 | 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 | |
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 | Failed to obtain the bundle names of all applications in the system. |
ERR_APPEXECFWK_CALLBACK_NULL_CORRESPONDING_CALLBACK | |
ERR_APPEXECFWK_CALLBACK_GET_INSTALLTYPE_FAILED | Failed to obtain the installation type (installation or uninstallation). |
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 | An error occurred when calling the invoke function of the Bundle Manager Service. |
ERR_APPEXECFWK_PERMISSION_DENIED | The server that invokes the Bundle Manager does not have required permission. |
LaunchMode
enum [LaunchMode]($api-api-SmartVision-Devices-BundleManager.md#ga605d46d860e356a74db6842e66522854)
Description:
Enumerates startup modes of an ability.
Function Documentation
ClearAbilityInfo()
void ClearAbilityInfo ([AbilityInfo]($api-api-SmartVision-Devices-AbilityInfo.md) * abilityInfo)
Description:
Clears an AbilityInfo object.
This function clears and releases the memory occupied by the fields of the pointer type included in the specified object.
Parameters:
abilityInfo | Indicates the pointer to the object to clear. |
ClearBundleInfo()
void ClearBundleInfo ([BundleInfo]($api-api-SmartVision-Devices-BundleInfo.md) * bundleInfo)
Description:
Clears a object.
This function clears and releases the memory occupied by the fields of the pointer type included in the specified BundleInfo object.
Parameters:
bundleInfo | Indicates the pointer to the object to clear. |
ClearElement()
void ClearElement ([ElementName]($api-api-SmartVision-Devices-ElementName.md) * element)
Description:
Clears the internal data of a specified .
After AbilityInfo is queried, clear the internal data of an if it is no longer required.
Parameters:
element | Indicates the pointer to the to clear. |
ClearModuleInfo()
Description:
Clears a object.
This function clears and releases the memory occupied by the fields of the pointer type included in the specified ModuleInfo object.
Parameters:
moduleInfo | Indicates the pointer to the ModuleInfo object to clear. |
GetBundleInfo()
Description:
Obtains the BundleInfo of an application based on the specified bundle name.
Parameters:
bundleName | Indicates the pointer to the name of the application bundle to query. |
flags | Specifies whether the obtained BundleInfo object can contain . The value 1 indicates that it can contain AbilityInfo, and 0 indicates that it cannot. |
bundleInfo | Indicates the pointer to the obtained object. |
Attention:
Before querying a BundleInfo object, you should first call memset on the constructed object so that each field in it can be properly initialized for carrying the obtained information.
Returns:
Returns ERR_OK if this function is successfully called; returns another error code defined in otherwise.
uint8_t GetBundleInfos (const int flags, [BundleInfo]($api-api-SmartVision-Devices-BundleInfo.md) ** bundleInfos, int32_t * len )
Description:
Obtains the BundleInfo of all bundles in the system.
Parameters:
flags | Specifies whether each of the obtained BundleInfo objects can contain . The value 1 indicates that it can contain AbilityInfo, and 0 indicates that it cannot. |
bundleInfos | Indicates the double pointer to the obtained objects. |
len | Indicates the pointer to the number of BundleInfo objects obtained. |
Returns:
Returns if this function is successfully called; returns another error code defined in AppexecfwkErrors otherwise.
GetBundleInfosByMetaData()
uint8_t GetBundleInfosByMetaData (const char * metaDataKey, [BundleInfo]($api-api-SmartVision-Devices-BundleInfo.md) ** bundleInfos, int32_t * len )
Description:
Obtains the BundleInfo of application bundles based on the specified .
Parameters:
metaDataKey | Indicates the pointer to the metadata name in the . |
bundleInfos | Indicates the double pointer to the obtained BundleInfo objects. |
len | Indicates the pointer to the number of objects obtained. |
Returns:
Returns ERR_OK if this function is successfully called; returns another error code defined in otherwise.
GetBundleNameForUid()
uint8_t GetBundleNameForUid (int32_t uid, char ** bundleName )
Description:
Obtains the bundle name of an application based on the specified UID.
Parameters:
Returns:
Returns ERR_OK if this function is successfully called; returns another error code defined in otherwise.
Install()
bool Install (const char * hapPath, const InstallParam * installParam, [InstallerCallback]($api-api-SmartVision-Devices-BundleManager.md#ga00f021e76d728d2d44e1a28887ccc3af) installerCallback )
Description:
Installs or updates an application.
Parameters:
hapPath | Indicates the pointer to the path for storing the OpenHarmony Ability Package (HAP) of the application to install or update. |
bundleCallback | 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]($api-api-SmartVision-Devices-Want.md) * want, [AbilityInfo]($api-api-SmartVision-Devices-AbilityInfo.md) * abilityInfo )
Description:
Queries the of an ability based on the information carried in the Want structure.
Parameters:
want | Indicates the pointer to the Want structure used for querying the specified ability. |
abilityInfo | Indicates the pointer to the obtained object. |
Attention:
Before querying an AbilityInfo object, you should first call memset on the constructed object so that each field in it can be properly initialized for carrying the obtained information.
Returns:
Returns ERR_OK if this function is successfully called; returns another error code defined in otherwise.
QueryKeepAliveBundleInfos()
Description:
Obtains the of all keep-alive applications in the system.
Parameters:
bundleInfos | Indicates the double pointer to the obtained objects. |
len | Indicates the pointer to the number of BundleInfo objects obtained. |
Returns:
Returns if this function is successfully called; returns another error code defined in AppexecfwkErrors otherwise.
RegisterCallback()
Description:
Registers a callback to monitor the installation, update, and uninstallation state changes of an application.
Parameters:
Returns:
Returns if this function is successfully called; returns another error code defined in AppexecfwkErrors otherwise.
SetElementAbilityName()
bool SetElementAbilityName ([ElementName]($api-api-SmartVision-Devices-ElementName.md) * element, const char * abilityName )
Description:
Sets the class name of the ability used to query AbilityInfo.
Parameters:
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]($api-api-SmartVision-Devices-ElementName.md) * element, const char * bundleName )
Description:
Sets the bundle name used to query AbilityInfo.
Parameters:
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]($api-api-SmartVision-Devices-ElementName.md) * element, const char * deviceId )
Description:
Sets the device ID used to query AbilityInfo.
Parameters:
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.
bool Uninstall (const char * bundleName, const InstallParam * installParam, [InstallerCallback]($api-api-SmartVision-Devices-BundleManager.md#ga00f021e76d728d2d44e1a28887ccc3af) installerCallback )
Description:
Uninstalls an application.
Parameters:
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 state changes of an application.
Parameters:
Returns ERR_OK if this function is successfully called; returns another error code defined in otherwise.