1e41f4b71Sopenharmony_ci# AbilityRuntime 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe AbilityRuntime module provides capabilities related to the ability framework. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**Since**: 13 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Summary 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci### Files 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| Name| Description| 19e41f4b71Sopenharmony_ci| -------- | -------- | 20e41f4b71Sopenharmony_ci| [ability_runtime_common.h](ability__runtime__common_8h.md) | Declares the error codes of the ability framework.<br>**File to include**: <AbilityKit/ability_runtime/ability_runtime_common.h><br>**Library**: libability_runtime.so| 21e41f4b71Sopenharmony_ci| [application_context.h](application__context_8h.md) | Declares the context capability at the application level.<br>**File to include**: <AbilityKit/ability_runtime/application_context.h><br>**Library**: libability_runtime.so| 22e41f4b71Sopenharmony_ci| [context_constant.h](context__constant_8h.md) | Declares context-related enums.<br>**File to include**: <AbilityKit/ability_runtime/context_constant.h><br>**Library**: libability_runtime.so| 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci### Enums 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci| Name | Description | 27e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ---------------------- | 28e41f4b71Sopenharmony_ci| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) {<br> ABILITY_RUNTIME_ERROR_CODE_NO_ERROR = 0,<br> ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID = 401,<br> ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST = 16000011,<br>} | Enumerates the error codes used by the ability framework.| 29e41f4b71Sopenharmony_ci| [AbilityRuntime_AreaMode](#abilityruntime_areamode) {<br> ABILITY_RUNTIME_AREA_MODE_EL1 = 0,<br> ABILITY_RUNTIME_AREA_MODE_EL2 = 1,<br> ABILITY_RUNTIME_AREA_MODE_EL3 = 2,<br> ABILITY_RUNTIME_AREA_MODE_EL4 = 3,<br> ABILITY_RUNTIME_AREA_MODE_EL5 = 4<br>} | Enumerates the data encryption levels. | 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci### Functions 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Name| Description| 34e41f4b71Sopenharmony_ci| -------- | -------- | 35e41f4b71Sopenharmony_ci| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetCacheDir](#oh_abilityruntime_applicationcontextgetcachedir)(char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the application-level cache directory.| 36e41f4b71Sopenharmony_ci| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetAreaMode](#oh_abilityruntime_applicationcontextgetareamode)([AbilityRuntime_AreaMode](#abilityruntime_areamode)* areaMode) | Obtains the application-level data encryption level.| 37e41f4b71Sopenharmony_ci| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetBundleName](#oh_abilityruntime_applicationcontextgetbundlename)(char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the bundle name of the application.| 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci## Enum Description 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci### AbilityRuntime_ErrorCode 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci``` 44e41f4b71Sopenharmony_cienum AbilityRuntime_ErrorCode 45e41f4b71Sopenharmony_ci``` 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci**Description** 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ciEnumerates the error codes used by the ability framework. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci**Since**: 13 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci| Value | Description | 54e41f4b71Sopenharmony_ci| --------------------------------------------- | -------------- | 55e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_ERROR_CODE_NO_ERROR | Operation successful. | 56e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID ARAM | Invalid parameter. | 57e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST | The context does not exist.| 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci### AbilityRuntime_AreaMode 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci``` 62e41f4b71Sopenharmony_cienum AbilityRuntime_AreaMode 63e41f4b71Sopenharmony_ci``` 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**Description** 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ciEnumerates the data encryption levels. 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci**Since**: 13 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci| Value | Description | 72e41f4b71Sopenharmony_ci| ----------------------------- | ------------------------------------------------------------ | 73e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_AREA_MODE_EL1 | For private files, such as alarms and wallpapers, the application can place them in a directory with the device-level encryption (EL1) to ensure that they can be accessed before the user enters the password.| 74e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_AREA_MODE_EL2 | For sensitive files, such as personal privacy data, the application can place them in a directory with the user-level encryption (EL2).| 75e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_AREA_MODE_EL3 | For step recording, file download, or music playback that needs to read, write, and create files when the screen is locked, the application can place these files in EL3.| 76e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_AREA_MODE_EL4 | For files that are related to user security information and do not need to be read, written, or created when the screen is locked, the application can place them in EL4.| 77e41f4b71Sopenharmony_ci| ABILITY_RUNTIME_AREA_MODE_EL5 | By default, sensitive user privacy files cannot be read or written on the lock screen. If such files need to be read or written on the lock screen, you can call [Access](js-apis-screenLockFileManager.md#screenlockfilemanageracquireaccess) to apply for reading or writing files before the screen is locked or create new files that can be read and written after the screen is locked. It is more appropriate to place these files in EL5.| 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci## Function Description 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci### OH_AbilityRuntime_ApplicationContextGetCacheDir 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci``` 85e41f4b71Sopenharmony_ciAbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetCacheDir(char* buffer, int32_t bufferSize, int32_t* writeLength) 86e41f4b71Sopenharmony_ci``` 87e41f4b71Sopenharmony_ci**Description** 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciObtains the application-level cache directory. 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci**Since**: 13 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci**Parameters** 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci| Name| Description| 96e41f4b71Sopenharmony_ci| -------- | -------- | 97e41f4b71Sopenharmony_ci| buffer | Pointer to the buffer. The cache directory string is written to this area.| 98e41f4b71Sopenharmony_ci| bufferSize | Buffer size.| 99e41f4b71Sopenharmony_ci| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci**Returns** 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process] (c-apis-ability-childprocess.md) created by the application. 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci### OH_AbilityRuntime_ApplicationContextGetAreaMode 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci``` 112e41f4b71Sopenharmony_ciAbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetAreaMode(AbilityRuntime_AreaMode* areaMode) 113e41f4b71Sopenharmony_ci``` 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci**Description** 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ciObtains the application-level data encryption level. 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci**Since**: 13 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci**Parameters** 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci| Name | Description | 124e41f4b71Sopenharmony_ci| -------- | ------------------------ | 125e41f4b71Sopenharmony_ci| areaMode | Pointer to the data encryption level.| 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci**Returns** 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if **areaMode** is a null pointer. 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process] (c-apis-ability-childprocess.md) created by the application. 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci### OH_AbilityRuntime_ApplicationContextGetBundleName 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci``` 138e41f4b71Sopenharmony_ciAbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetBundleName(char* buffer, int32_t bufferSize, int32_t* writeLength) 139e41f4b71Sopenharmony_ci``` 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**Description** 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ciObtains the bundle name of the application. 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci**Since**: 13 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**Parameters** 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci| Name | Description | 150e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------ | 151e41f4b71Sopenharmony_ci| buffer | Pointer to the buffer. The bundle name string is written to this area. | 152e41f4b71Sopenharmony_ci| bufferSize | Buffer size. | 153e41f4b71Sopenharmony_ci| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci**Returns** 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ciReturns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process] (c-apis-ability-childprocess.md) created by the application. 162