/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup AbilityRuntime * @{ * * @brief Describe the functions provided by the application context. * * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 13 */ /** * @file application_context.h * * @brief Defines the application context APIs. * * @library libability_runtime.so * @kit AbilityKit * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 13 */ #ifndef ABILITY_RUNTIME_APPLICATION_CONTEXT_H #define ABILITY_RUNTIME_APPLICATION_CONTEXT_H #include #include #include "ability_runtime_common.h" #include "context_constant.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Obtain the cache directory of the application. * * @param buffer A pointer to a buffer that receives the cache directory of the application. * @param bufferSize The length of the buffer. * @param writeLength The string length actually written to the buffer, * when returning {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR}. * @return The error code. * {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful. * {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the buffer or writeLength is null, * or the buffer size is less than the minimum buffer size. * {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist. * @since 13 */ AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetCacheDir( char* buffer, int32_t bufferSize, int32_t* writeLength); /** * @brief Obtain the area mode of the application. * * @param areaMode A pointer to the area mode. * @return The error code. * {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful. * {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the areaMode is null. * {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist. * @since 13 */ AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetAreaMode(AbilityRuntime_AreaMode* areaMode); /** * @brief Obtain the bundle name. * * @param buffer A pointer to a buffer that receives the bundle name. * @param bufferSize The length of the buffer. * @param writeLength The string length actually written to the buffer, * when returning {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR}. * @return The error code. * {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful. * {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the buffer or writeLength is null, * or the buffer size is less than the minimum buffer size. * {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist. * @since 13 */ AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetBundleName( char* buffer, int32_t bufferSize, int32_t* writeLength); #ifdef __cplusplus } // extern "C" #endif /** @} */ #endif // ABILITY_RUNTIME_APPLICATION_CONTEXT_H