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