1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup AbilityRuntime
18  * @{
19  *
20  * @brief Describe the functions provided by the application context.
21  *
22  * @syscap SystemCapability.Ability.AbilityRuntime.Core
23  * @since 13
24  */
25 
26 /**
27  * @file application_context.h
28  *
29  * @brief Defines the application context APIs.
30  *
31  * @library libability_runtime.so
32  * @kit AbilityKit
33  * @syscap SystemCapability.Ability.AbilityRuntime.Core
34  * @since 13
35  */
36 
37 #ifndef ABILITY_RUNTIME_APPLICATION_CONTEXT_H
38 #define ABILITY_RUNTIME_APPLICATION_CONTEXT_H
39 
40 #include <stdint.h>
41 #include <stddef.h>
42 #include "ability_runtime_common.h"
43 #include "context_constant.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**
50  * @brief Obtain the cache directory of the application.
51  *
52  * @param buffer A pointer to a buffer that receives the cache directory of the application.
53  * @param bufferSize The length of the buffer.
54  * @param writeLength The string length actually written to the buffer,
55  *                    when returning {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR}.
56  * @return The error code.
57  *         {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful.
58  *         {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the buffer or writeLength is null,
59  *         or the buffer size is less than the minimum buffer size.
60  *         {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist.
61  * @since 13
62  */
63 AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetCacheDir(
64     char* buffer, int32_t bufferSize, int32_t* writeLength);
65 
66 /**
67  * @brief Obtain the area mode of the application.
68  *
69  * @param areaMode A pointer to the area mode.
70  * @return The error code.
71  *         {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful.
72  *         {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the areaMode is null.
73  *         {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist.
74  * @since 13
75  */
76 AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetAreaMode(AbilityRuntime_AreaMode* areaMode);
77 
78 /**
79  * @brief Obtain the bundle name.
80  *
81  * @param buffer A pointer to a buffer that receives the bundle name.
82  * @param bufferSize The length of the buffer.
83  * @param writeLength The string length actually written to the buffer,
84   *                   when returning {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR}.
85  * @return The error code.
86  *         {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful.
87  *         {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the buffer or writeLength is null,
88  *         or the buffer size is less than the minimum buffer size.
89  *         {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist.
90  * @since 13
91  */
92 AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetBundleName(
93     char* buffer, int32_t bufferSize, int32_t* writeLength);
94 
95 #ifdef __cplusplus
96 } // extern "C"
97 #endif
98 
99 /** @} */
100 #endif // ABILITY_RUNTIME_APPLICATION_CONTEXT_H
101