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 resourcemanager
18 * @{
19 *
20 * @brief Provides the c interface to obtain resources, and relies on librawfile.z.so when used.
21 *
22 * @since 12
23 */
24
25/**
26 * @file ohresmgr.h
27 *
28 * @brief Provides the implementation of the interface.
29 * @syscap SystemCapability.Global.ResourceManager
30 * @library libohresmgr.so
31 * @kit LocalizationKit
32 * @since 12
33 */
34#ifndef GLOBAL_OH_RESMGR_H
35#define GLOBAL_OH_RESMGR_H
36
37#include "resmgr_common.h"
38#include "../rawfile/raw_file_manager.h"
39#include "../arkui/drawable_descriptor.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/**
46 * @brief Obtains the Base64 code of the image resource.
47 *
48 * Obtains the Base64 code of the image resource corresponding to the specified resource ID.
49 *
50 * @param mgr Indicates the pointer to {@link NativeResourceManager}
51 * {@link OH_ResourceManager_InitNativeResourceManager}.
52 * @param resId Indicates the resource ID.
53 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
54 * to use the density of current system dpi.
55 * @param resultValue the result write to resultValue.
56 * @param resultLen the media length write to resultLen.
57 * @return {@link SUCCESS} 0 - Success.
58 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
59 *         1.Incorrect parameter types; 2.Parameter verification failed.
60           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
61           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
62           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
63 * @since 12
64 */
65ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64(const NativeResourceManager *mgr, uint32_t resId,
66    char **resultValue, uint64_t *resultLen, uint32_t density = 0);
67
68/**
69 * @brief Obtains the Base64 code of the image resource.
70 *
71 * Obtains the Base64 code of the image resource corresponding to the specified resource ID.
72 *
73 * @param mgr Indicates the pointer to {@link NativeResourceManager}
74 * {@link OH_ResourceManager_InitNativeResourceManager}.
75 * @param resId Indicates the resource ID.
76 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
77 * to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
78 * @param resultValue the result write to resultValue.
79 * @param resultLen the media length write to resultLen.
80 * @return {@link SUCCESS} 0 - Success.
81 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
82 *         1.Incorrect parameter types; 2.Parameter verification failed.
83           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
84           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
85           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
86 * @since 12
87 */
88ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64Data(const NativeResourceManager *mgr, uint32_t resId,
89    char **resultValue, uint64_t *resultLen, uint32_t density);
90
91/**
92 * @brief Obtains the Base64 code of the image resource.
93 *
94 * Obtains the Base64 code of the image resource corresponding to the specified resource name.
95 *
96 * @param mgr Indicates the pointer to {@link NativeResourceManager}
97 * {@link OH_ResourceManager_InitNativeResourceManager}.
98 * @param resName Indicates the resource name.
99 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
100 * to use the density of current system dpi.
101 * @param resultValue the result write to resultValue.
102 * @param resultLen the media length write to resultLen.
103 * @return {@link SUCCESS} 0 - Success.
104 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
105 *         1.Incorrect parameter types; 2.Parameter verification failed.
106           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
107           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
108           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
109 * @since 12
110 */
111ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName(const NativeResourceManager *mgr,
112    const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density = 0);
113
114/**
115 * @brief Obtains the Base64 code of the image resource.
116 *
117 * Obtains the Base64 code of the image resource corresponding to the specified resource name.
118 *
119 * @param mgr Indicates the pointer to {@link NativeResourceManager}
120 * {@link OH_ResourceManager_InitNativeResourceManager}.
121 * @param resName Indicates the resource name.
122 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
123 * to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
124 * @param resultValue the result write to resultValue.
125 * @param resultLen the media length write to resultLen.
126 * @return {@link SUCCESS} 0 - Success.
127 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
128 *         1.Incorrect parameter types; 2.Parameter verification failed.
129           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
130           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
131           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
132 * @since 12
133 */
134ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64DataByName(const NativeResourceManager *mgr,
135    const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density);
136
137/**
138 * @brief Obtains the content of the image resource.
139 *
140 * Obtains the content of the specified screen density media file corresponding to a specified resource ID.
141 *
142 * @param mgr Indicates the pointer to {@link NativeResourceManager}
143 * {@link OH_ResourceManager_InitNativeResourceManager}.
144 * @param resId Indicates the resource ID.
145 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
146 * to use the density of current system dpi.
147 * @param resultValue the result write to resultValue.
148 * @param resultLen the media length write to resultLen.
149 * @return {@link SUCCESS} 0 - Success.
150 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
151 *         1.Incorrect parameter types; 2.Parameter verification failed.
152           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
153           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
154           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
155 * @since 12
156 */
157ResourceManager_ErrorCode OH_ResourceManager_GetMedia(const NativeResourceManager *mgr, uint32_t resId,
158    uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0);
159
160/**
161 * @brief Obtains the content of the image resource.
162 *
163 * Obtains the content of the specified screen density media file corresponding to a specified resource ID.
164 *
165 * @param mgr Indicates the pointer to {@link NativeResourceManager}
166 * {@link OH_ResourceManager_InitNativeResourceManager}.
167 * @param resId Indicates the resource ID.
168 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
169 * to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
170 * @param resultValue the result write to resultValue.
171 * @param resultLen the media length write to resultLen.
172 * @return {@link SUCCESS} 0 - Success.
173 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
174 *         1.Incorrect parameter types; 2.Parameter verification failed.
175           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
176           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
177           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
178 * @since 12
179 */
180ResourceManager_ErrorCode OH_ResourceManager_GetMediaData(const NativeResourceManager *mgr, uint32_t resId,
181    uint8_t **resultValue, uint64_t *resultLen, uint32_t density);
182
183/**
184 * @brief Obtains the content of the image resource.
185 *
186 * Obtains the content of the specified screen density media file corresponding to a specified resource name.
187 *
188 * @param mgr Indicates the pointer to {@link NativeResourceManager}
189 * {@link OH_ResourceManager_InitNativeResourceManager}.
190 * @param resName Indicates the resource name.
191 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
192 * to use the density of current system dpi.
193 * @param resultValue the result write to resultValue.
194 * @param resultLen the media length write to resultLen.
195 * @return {@link SUCCESS} 0 - Success.
196 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
197 *         1.Incorrect parameter types; 2.Parameter verification failed.
198           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
199           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
200           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
201 * @since 12
202 */
203ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName(const NativeResourceManager *mgr, const char *resName,
204    uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0);
205
206/**
207 * @brief Obtains the content of the image resource.
208 *
209 * Obtains the content of the specified screen density media file corresponding to a specified resource name.
210 *
211 * @param mgr Indicates the pointer to {@link NativeResourceManager}
212 * {@link OH_ResourceManager_InitNativeResourceManager}.
213 * @param resName Indicates the resource name.
214 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
215 * to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
216 * @param resultValue the result write to resultValue.
217 * @param resultLen the media length write to resultLen.
218 * @return {@link SUCCESS} 0 - Success.
219 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
220 *         1.Incorrect parameter types; 2.Parameter verification failed.
221           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
222           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
223           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
224 * @since 12
225 */
226ResourceManager_ErrorCode OH_ResourceManager_GetMediaDataByName(const NativeResourceManager *mgr, const char *resName,
227    uint8_t **resultValue, uint64_t *resultLen, uint32_t density);
228
229/**
230 * @brief Obtains the DrawableDescriptor of the media file.
231 *
232 * Obtains the DrawableDescriptor of the media file corresponding to a specified resource ID.
233 *
234 * @param mgr Indicates the pointer to {@link NativeResourceManager}
235 * {@link OH_ResourceManager_InitNativeResourceManager}.
236 * @param resId Indicates the resource ID.
237 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
238 * to use the density of current system dpi.
239 * @param type The optional parameter means the media type, 0 means the normal media, 1 means the the theme style media.
240 * @param drawableDescriptor the result write to drawableDescriptor.
241 * @return {@link SUCCESS} 0 - Success.
242 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
243 *         1.Incorrect parameter types; 2.Parameter verification failed.
244           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
245           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
246 * @since 12
247 */
248ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor(const NativeResourceManager *mgr,
249    uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0);
250
251/**
252 * @brief Obtains the DrawableDescriptor of the media file.
253 *
254 * Obtains the DrawableDescriptor of the media file corresponding to a specified resource ID.
255 *
256 * @param mgr Indicates the pointer to {@link NativeResourceManager}
257 * {@link OH_ResourceManager_InitNativeResourceManager}.
258 * @param resId Indicates the resource ID.
259 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
260 * to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
261 * @param type The optional parameter means the media type, 0 means the normal media, 1 means the the theme style media.
262 * If this attribute is not required, set this parameter to 0.
263 * @param drawableDescriptor the result write to drawableDescriptor.
264 * @return {@link SUCCESS} 0 - Success.
265 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
266 *         1.Incorrect parameter types; 2.Parameter verification failed.
267           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
268           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
269 * @since 12
270 */
271ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorData(const NativeResourceManager *mgr,
272    uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type);
273
274/**
275 * @brief Obtains the DrawableDescriptor of the media file.
276 *
277 * Obtains the DrawableDescriptor of the media file corresponding to a specified resource name.
278 * @param mgr Indicates the pointer to {@link NativeResourceManager}
279 * {@link OH_ResourceManager_InitNativeResourceManager}.
280 * @param resName Indicates the resource name.
281 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
282 * to use the density of current system dpi.
283 * @param type The optional parameter means the media type, 0 means the normal media, 1 means the the theme style media,
284 * 2 means the theme dynamic media.
285 * @param drawableDescriptor the result write to drawableDescriptor.
286 * @return {@link SUCCESS} 0 - Success.
287 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
288 *         1.Incorrect parameter types; 2.Parameter verification failed.
289           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
290           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
291 * @since 12
292 */
293ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName(const NativeResourceManager *mgr,
294    const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0);
295
296/**
297 * @brief Obtains the DrawableDescriptor of the media file.
298 *
299 * Obtains the DrawableDescriptor of the media file corresponding to a specified resource name.
300 * @param mgr Indicates the pointer to {@link NativeResourceManager}
301 * {@link OH_ResourceManager_InitNativeResourceManager}.
302 * @param resName Indicates the resource name.
303 * @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
304 * to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
305 * @param type The optional parameter means the media type, 0 means the normal media, 1 means the the theme style media,
306 * 2 means the theme dynamic media. If this attribute is not required, set this parameter to 0.
307 * @param drawableDescriptor the result write to drawableDescriptor.
308 * @return {@link SUCCESS} 0 - Success.
309 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
310 *         1.Incorrect parameter types; 2.Parameter verification failed.
311           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
312           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
313 * @since 12
314 */
315ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorDataByName(const NativeResourceManager *mgr,
316    const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type);
317
318/**
319 * @brief Obtains the symbol resource.
320 *
321 * Obtains the symbol resource corresponding to the specified resource ID.
322 *
323 * @param mgr Indicates the pointer to {@link NativeResourceManager}
324 *        {@link OH_ResourceManager_InitNativeResourceManager}.
325 * @param resId Indicates the resource ID.
326 * @param resultValue the result write to resultValue.
327 * @return {@link SUCCESS} 0 - Success.
328 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
329           Possible causes: Incorrect parameter types.
330           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
331           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
332           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
333 * @since 12
334 */
335ResourceManager_ErrorCode OH_ResourceManager_GetSymbol(const NativeResourceManager *mgr, uint32_t resId,
336    uint32_t *resultValue);
337
338/**
339 * @brief Obtains the symbol resource.
340 *
341 * Obtains the symbol resource corresponding to the specified resource name.
342 *
343 * @param mgr Indicates the pointer to {@link NativeResourceManager}
344 *        {@link OH_ResourceManager_InitNativeResourceManager}.
345 * @param resName Indicates the resource name.
346 * @param resultValue the result write to resultValue.
347 * @return {@link SUCCESS} 0 - Success.
348 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
349           Possible causes: Incorrect parameter types.
350           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
351           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
352           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
353 * @since 12
354 */
355ResourceManager_ErrorCode OH_ResourceManager_GetSymbolByName(const NativeResourceManager *mgr, const char *resName,
356    uint32_t *resultValue);
357
358/**
359 * @brief Obtains locales list.
360 *
361 * You need to call the OH_ResourceManager_ReleaseStringArray() method to release the memory of localinfo.
362 *
363 * @param mgr Indicates the pointer to {@link NativeResourceManager}
364 *        {@link OH_ResourceManager_InitNativeResourceManager}.
365 * @param resultValue the result write to resultValue.
366 * @param resultLen the locales length write to resultLen.
367 * @param includeSystem the parameter controls whether to include system resources,
368 * the default value is false, it has no effect when only system resources query the locales list.
369 * @return {@link SUCCESS} 0 - Success.
370 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
371           Possible causes: Incorrect parameter types.
372 *         {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
373 * @since 12
374 */
375ResourceManager_ErrorCode OH_ResourceManager_GetLocales(const NativeResourceManager *mgr, char ***resultValue,
376    uint32_t *resultLen, bool includeSystem = false);
377
378/**
379 * @brief Obtains locales list.
380 *
381 * You need to call the OH_ResourceManager_ReleaseStringArray() method to release the memory of localinfo.
382 *
383 * @param mgr Indicates the pointer to {@link NativeResourceManager}
384 *        {@link OH_ResourceManager_InitNativeResourceManager}.
385 * @param resultValue the result write to resultValue.
386 * @param resultLen the locales length write to resultLen.
387 * @param includeSystem the parameter controls whether to include system resources.
388 * If this attribute is not required, set this parameter to false.
389 * @return {@link SUCCESS} 0 - Success.
390 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
391           Possible causes: Incorrect parameter types.
392 *         {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
393 * @since 12
394 */
395ResourceManager_ErrorCode OH_ResourceManager_GetLocalesData(const NativeResourceManager *mgr, char ***resultValue,
396    uint32_t *resultLen, bool includeSystem);
397
398/**
399 * @brief Obtains the device configuration.
400 *
401 * You need to call the OH_ResourceManager_ReleaseConfiguration() method to release the memory.
402 * If you use malloc to create a ResourceManager_Configuration object, you also need to call free to release it.
403 *
404 * @param mgr Indicates the pointer to {@link NativeResourceManager}
405 *        {@link OH_ResourceManager_InitNativeResourceManager}.
406 * @param configuration the result write to ResourceManager_Configuration.
407 * @return {@link SUCCESS} 0 - Success.
408 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
409           Possible causes: Incorrect parameter types.
410           {@link ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED} 9001009 - If failed to access the system resource.
411           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
412 * @since 12
413 */
414ResourceManager_ErrorCode OH_ResourceManager_GetConfiguration(const NativeResourceManager *mgr,
415    ResourceManager_Configuration *configuration);
416
417/**
418 * @brief Release the device configuration.
419 * @param configuration the object need to release.
420 * @return {@link SUCCESS} 0 - Success.
421           {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
422           Possible causes: Incorrect parameter types.
423 * @since 12
424 */
425ResourceManager_ErrorCode OH_ResourceManager_ReleaseConfiguration(ResourceManager_Configuration *configuration);
426
427/**
428 * @brief Obtains the character string.
429 *
430 * Obtains the character string corresponding to a specified resource ID.
431 * Obtain normal resource by calling OH_ResourceManager_GetString(mgr, resId, resultValue),
432   obtain a formatted resource with replacements for %d, %s, %f,
433   call OH_ResourceManager_GetString(mgr, resId, resultValue, 10, "format", 10.10).
434 * You need to call free() to release the memory for the string.
435 *
436 * @param mgr Indicates the pointer to {@link NativeResourceManager}
437 *        {@link OH_ResourceManager_InitNativeResourceManager}.
438 * @param resId Indicates the resource ID.
439 * @param resultValue the result write to resultValue.
440 * @param { const char* | int | float } args - Indicates the formatting string resource parameters.
441 * @return {@link SUCCESS} 0 - Success.
442 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
443           Possible causes: Incorrect parameter types.
444           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
445           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
446           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
447           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
448 * @since 12
449 */
450ResourceManager_ErrorCode OH_ResourceManager_GetString(const NativeResourceManager *mgr, uint32_t resId,
451    char **resultValue, ...);
452
453/**
454 * @brief Obtains the character string.
455 *
456 * Obtains the character string corresponding to a specified resource name.
457 * Obtain normal resource by calling OH_ResourceManager_GetString(mgr, resName, resultValue),
458   obtain a formatted resource with replacements for %d, %s, %f,
459   call OH_ResourceManager_GetString(mgr, resName, resultValue, 10, "format", 10.10).
460 * You need to call free() to release the memory for the string.
461 *
462 * @param mgr Indicates the pointer to {@link NativeResourceManager}
463 *        {@link OH_ResourceManager_InitNativeResourceManager}.
464 * @param resName Indicates the resource name.
465 * @param resultValue the result write to resultValue.
466 * @param { const char* | int | float } args - Indicates the formatting string resource parameters.
467 * @return {@link SUCCESS} 0 - Success.
468 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
469           Possible causes: Incorrect parameter types.
470           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
471           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
472           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
473           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
474 * @since 12
475 */
476ResourceManager_ErrorCode OH_ResourceManager_GetStringByName(const NativeResourceManager *mgr, const char *resName,
477    char **resultValue, ...);
478
479/**
480 * @brief Obtains the array of character strings.
481 *
482 * Obtains the array of character strings corresponding to a specified resource ID.
483 * You need to call the OH_ResourceManager_ReleaseStringArray() method to release the memory of string array.
484 *
485 * @param mgr Indicates the pointer to {@link NativeResourceManager}
486 *        {@link OH_ResourceManager_InitNativeResourceManager}.
487 * @param resId Indicates the resource ID.
488 * @param resultValue the result write to resultValue.
489 * @param resultLen the StringArray length write to resultLen.
490 * @return {@link SUCCESS} 0 - Success.
491 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
492           Possible causes: Incorrect parameter types.
493           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
494           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
495           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
496           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
497 * @since 12
498 */
499ResourceManager_ErrorCode OH_ResourceManager_GetStringArray(const NativeResourceManager *mgr, uint32_t resId,
500    char ***resultValue, uint32_t *resultLen);
501
502/**
503 * @brief Obtains the array of character strings.
504 *
505 * Obtains the array of character strings corresponding to a specified resource name.
506 * You need to call the OH_ResourceManager_ReleaseStringArray() method to release the memory of string array.
507 *
508 * @param mgr Indicates the pointer to {@link NativeResourceManager}
509 *        {@link OH_ResourceManager_InitNativeResourceManager}.
510 * @param resName Indicates the resource name.
511 * @param resultValue the result write to resultValue.
512 * @param resultLen the StringArray length write to resultLen.
513 * @return {@link SUCCESS} 0 - Success.
514 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
515           Possible causes: Incorrect parameter types.
516           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
517           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
518           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
519           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
520 * @since 12
521 */
522ResourceManager_ErrorCode OH_ResourceManager_GetStringArrayByName(const NativeResourceManager *mgr,
523    const char *resName, char ***resultValue, uint32_t *resultLen);
524
525/**
526 * @brief Release the array of character strings.
527 * @param resValue the array of character strings corresponding to the specified resource name.
528 * @param len the length of array.
529 * @return {@link SUCCESS} 0 - Success.
530           {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
531           Possible causes: Incorrect parameter types.
532 * @since 12
533 */
534ResourceManager_ErrorCode OH_ResourceManager_ReleaseStringArray(char ***resValue, uint32_t len);
535
536/**
537 * @brief Obtains the singular-plural character string represented.
538 *
539 * Obtains the singular-plural character string represented by the ID string corresponding to the specified number.
540 * You need to call free() to release the memory for the string.
541 *
542 * @param mgr Indicates the pointer to {@link NativeResourceManager}
543 *        {@link OH_ResourceManager_InitNativeResourceManager}.
544 * @param resId Indicates the resource ID.
545 * @param num - Indicates the number.
546 * @param resultValue the result write to resultValue.
547 * @return {@link SUCCESS} 0 - Success.
548 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
549           Possible causes: Incorrect parameter types.
550           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
551           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
552           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
553           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
554 * @since 12
555 */
556ResourceManager_ErrorCode OH_ResourceManager_GetPluralString(const NativeResourceManager *mgr, uint32_t resId,
557    uint32_t num, char **resultValue);
558
559/**
560 * @brief Obtains the singular-plural character string represented.
561 *
562 * Obtains the singular-plural character string represented by the Name string corresponding to the specified number.
563 * You need to call free() to release the memory for the string.
564 *
565 * @param mgr Indicates the pointer to {@link NativeResourceManager}
566 *        {@link OH_ResourceManager_InitNativeResourceManager}.
567 * @param resName Indicates the resource name.
568 * @param num - Indicates the number.
569 * @param resultValue the result write to resultValue.
570 * @return {@link SUCCESS} 0 - Success.
571 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
572           Possible causes: Incorrect parameter types.
573           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
574           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
575           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
576           {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
577 * @since 12
578 */
579ResourceManager_ErrorCode OH_ResourceManager_GetPluralStringByName(const NativeResourceManager *mgr,
580    const char *resName, uint32_t num, char **resultValue);
581
582/**
583 * @brief Obtains the color resource.
584 *
585 * Obtains the color resource corresponding to the specified resource ID.
586 *
587 * @param mgr Indicates the pointer to {@link NativeResourceManager}
588 *        {@link OH_ResourceManager_InitNativeResourceManager}.
589 * @param resId Indicates the resource ID.
590 * @param resultValue the result write to resultValue.
591 * @return {@link SUCCESS} 0 - Success.
592 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
593           Possible causes: Incorrect parameter types.
594           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
595           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
596           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
597 * @since 12
598 */
599ResourceManager_ErrorCode OH_ResourceManager_GetColor(const NativeResourceManager *mgr, uint32_t resId,
600    uint32_t *resultValue);
601
602/**
603 * @brief Obtains the color resource.
604 *
605 * Obtains the color resource corresponding to the specified resource name.
606 *
607 * @param mgr Indicates the pointer to {@link NativeResourceManager}
608 *        {@link OH_ResourceManager_InitNativeResourceManager}.
609 * @param resName Indicates the resource name.
610 * @param resultValue the result write to resultValue.
611 * @return {@link SUCCESS} 0 - Success.
612 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
613           Possible causes: Incorrect parameter types.
614           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
615           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
616           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
617 * @since 12
618 */
619ResourceManager_ErrorCode OH_ResourceManager_GetColorByName(const NativeResourceManager *mgr, const char *resName,
620    uint32_t *resultValue);
621
622/**
623 * @brief Obtains the Int resource.
624 *
625 * Obtains the Int resource corresponding to the specified resource ID.
626 *
627 * @param mgr Indicates the pointer to {@link NativeResourceManager}
628 *        {@link OH_ResourceManager_InitNativeResourceManager}.
629 * @param resId Indicates the resource ID.
630 * @param resultValue the result write to resultValue.
631 * @return {@link SUCCESS} 0 - Success.
632 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
633           Possible causes: Incorrect parameter types.
634           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
635           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
636           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
637 * @since 12
638 */
639ResourceManager_ErrorCode OH_ResourceManager_GetInt(const NativeResourceManager *mgr, uint32_t resId,
640    int *resultValue);
641
642/**
643 * @brief Obtains the Int resource.
644 *
645 * Obtains the Int resource corresponding to the specified resource name.
646 *
647 * @param mgr Indicates the pointer to {@link NativeResourceManager}
648 *        {@link OH_ResourceManager_InitNativeResourceManager}.
649 * @param resName Indicates the resource name.
650 * @param resultValue the result write to resultValue.
651 * @return {@link SUCCESS} 0 - Success.
652 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
653           Possible causes: Incorrect parameter types.
654           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
655           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
656           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
657 * @since 12
658 */
659ResourceManager_ErrorCode OH_ResourceManager_GetIntByName(const NativeResourceManager *mgr, const char *resName,
660    int *resultValue);
661
662/**
663 * @brief Obtains the Float resource.
664 *
665 * Obtains the Int resource corresponding to the specified resource ID.
666 *
667 * @param mgr Indicates the pointer to {@link NativeResourceManager}
668 *        {@link OH_ResourceManager_InitNativeResourceManager}.
669 * @param resId Indicates the resource ID.
670 * @param resultValue the result write to resultValue.
671 * @return {@link SUCCESS} 0 - Success.
672 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
673           Possible causes: Incorrect parameter types.
674           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
675           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
676           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
677 * @since 12
678 */
679ResourceManager_ErrorCode OH_ResourceManager_GetFloat(const NativeResourceManager *mgr, uint32_t resId,
680    float *resultValue);
681
682/**
683 * @brief Obtains the Float resource.
684 *
685 * Obtains the Float resource corresponding to the specified resource name.
686 *
687 * @param mgr Indicates the pointer to {@link NativeResourceManager}
688 *        {@link OH_ResourceManager_InitNativeResourceManager}.
689 * @param resName Indicates the resource name.
690 * @param resultValue the result write to resultValue.
691 * @return {@link SUCCESS} 0 - Success.
692 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
693           Possible causes: Incorrect parameter types.
694           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
695           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
696           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
697 * @since 12
698 */
699ResourceManager_ErrorCode OH_ResourceManager_GetFloatByName(const NativeResourceManager *mgr, const char *resName,
700    float *resultValue);
701
702/**
703 * @brief Obtains the boolean result.
704 *
705 * Obtains the boolean result with a specified resource ID.
706 *
707 * @param mgr Indicates the pointer to {@link NativeResourceManager}
708 *        {@link OH_ResourceManager_InitNativeResourceManager}.
709 * @param resId Indicates the resource ID.
710 * @param resultValue the result write to resultValue.
711 * @return {@link SUCCESS} 0 - Success.
712 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
713           Possible causes: Incorrect parameter types.
714           {@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
715           {@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
716           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
717 * @since 12
718 */
719ResourceManager_ErrorCode OH_ResourceManager_GetBool(const NativeResourceManager *mgr, uint32_t resId,
720    bool *resultValue);
721
722/**
723 * @brief Obtains the boolean result.
724 *
725 * Obtains the boolean result with a specified resource name.
726 *
727 * @param mgr Indicates the pointer to {@link NativeResourceManager}
728 *        {@link OH_ResourceManager_InitNativeResourceManager}.
729 * @param resName Indicates the resource name.
730 * @param resultValue the result write to resultValue.
731 * @return {@link SUCCESS} 0 - Success.
732 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
733           Possible causes: Incorrect parameter types.
734           {@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
735           {@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
736           {@link ERROR_CODE_RES_REF_TOO_MUCH} 9001006 - The resource is referenced cyclically.
737 * @since 12
738 */
739ResourceManager_ErrorCode OH_ResourceManager_GetBoolByName(const NativeResourceManager *mgr, const char *resName,
740    bool *resultValue);
741
742/**
743 * @brief Add overlay resources during application runtime.
744 * @param mgr Indicates the pointer to {@link NativeResourceManager}
745 *        {@link OH_ResourceManager_InitNativeResourceManager}.
746 * @param path Indicates the application overlay path.
747 * @return {@link SUCCESS} 0 - Success.
748 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
749           Possible causes: Incorrect parameter types.
750           {@link ERROR_CODE_OVERLAY_RES_PATH_INVALID} 9001010 - Invalid overlay path.
751 * @since 12
752 */
753ResourceManager_ErrorCode OH_ResourceManager_AddResource(const NativeResourceManager *mgr, const char *path);
754
755/**
756 * @brief Remove overlay resources during application runtime.
757 * @param mgr Indicates the pointer to {@link NativeResourceManager}
758 *        {@link OH_ResourceManager_InitNativeResourceManager}.
759 * @param path Indicates the application overlay path.
760 * @return {@link SUCCESS} 0 - Success.
761 *         {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
762           Possible causes: Incorrect parameter types.
763           {@link ERROR_CODE_OVERLAY_RES_PATH_INVALID} 9001010 - Invalid overlay path.
764 * @since 12
765 */
766ResourceManager_ErrorCode OH_ResourceManager_RemoveResource(const NativeResourceManager *mgr, const char *path);
767#ifdef __cplusplus
768};
769#endif
770
771/** @} */
772#endif // GLOBAL_OH_RESMGR_H