!1023 资源管理CAPI规范整改

Merge pull request !1023 from 高超/rawfile_new
This commit is contained in:
openharmony_ci 2024-07-27 09:49:47 +00:00 committed by Gitee
commit fc434beb69
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 228 additions and 4 deletions

View File

@ -38,7 +38,9 @@
#ifndef GLOBAL_RAW_FILE_H
#define GLOBAL_RAW_FILE_H
#include <string>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@ -197,9 +199,24 @@ long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile);
* @return Returns true: open the raw file descriptor successfully, false: the raw file is not allowed to access.
* @since 8
* @version 1.0
* @deprecated since 12
* @useinstead OH_ResourceManager_GetRawFileDescriptorData
*/
bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor);
/**
* @brief Obtains the file descriptor of a raw file based on the long offset and file length.
*
* The obtains raw file descriptor is used to read the raw file.
*
* @param rawFile Indicates the pointer to {@link RawFile}.
* @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP.
* @return Returns true: obtains the raw file descriptor successfully, false: the raw file is not allowed to access.
* @since 12
* @version 1.0
*/
bool OH_ResourceManager_GetRawFileDescriptorData(const RawFile *rawFile, RawFileDescriptor *descriptor);
/**
* @brief Closes the file descriptor of a raw file.
*
@ -209,9 +226,23 @@ bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDesc
* @return Returns true: closes the raw file descriptor successfully, false: closes the raw file descriptor failed.
* @since 8
* @version 1.0
* @deprecated since 12
* @useinstead OH_ResourceManager_ReleaseRawFileDescriptorData
*/
bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor);
/**
* @brief Release the file descriptor of a raw file.
*
* The opened raw file descriptor must be released after used to avoid the file descriptor leak.
*
* @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP.
* @return Returns true: release the raw file descriptor successfully, false: release the raw file descriptor failed.
* @since 12
* @version 1.0
*/
bool OH_ResourceManager_ReleaseRawFileDescriptorData(const RawFileDescriptor *descriptor);
/**
* @brief Reads a raw file.
*

View File

@ -65,6 +65,29 @@ extern "C" {
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64(const NativeResourceManager *mgr, uint32_t resId,
char **resultValue, uint64_t *resultLen, uint32_t density = 0);
/**
* @brief Obtains the Base64 code of the image resource.
*
* Obtains the Base64 code of the image resource corresponding to the specified resource ID.
*
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resId Indicates the resource ID.
* @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
* to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
* @param resultValue the result write to resultValue.
* @param resultLen the media length write to resultLen.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
* 1.Incorrect parameter types; 2.Parameter verification failed.
{@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
{@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
{@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64Data(const NativeResourceManager *mgr, uint32_t resId,
char **resultValue, uint64_t *resultLen, uint32_t density);
/**
* @brief Obtains the Base64 code of the image resource.
*
@ -88,6 +111,29 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64(const NativeResource
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName(const NativeResourceManager *mgr,
const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density = 0);
/**
* @brief Obtains the Base64 code of the image resource.
*
* Obtains the Base64 code of the image resource corresponding to the specified resource name.
*
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resName Indicates the resource name.
* @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
* to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
* @param resultValue the result write to resultValue.
* @param resultLen the media length write to resultLen.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
* 1.Incorrect parameter types; 2.Parameter verification failed.
{@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
{@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
{@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64DataByName(const NativeResourceManager *mgr,
const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density);
/**
* @brief Obtains the content of the image resource.
*
@ -111,6 +157,29 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName(const NativeRe
ResourceManager_ErrorCode OH_ResourceManager_GetMedia(const NativeResourceManager *mgr, uint32_t resId,
uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0);
/**
* @brief Obtains the content of the image resource.
*
* Obtains the content of the specified screen density media file corresponding to a specified resource ID.
*
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resId Indicates the resource ID.
* @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
* to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
* @param resultValue the result write to resultValue.
* @param resultLen the media length write to resultLen.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
* 1.Incorrect parameter types; 2.Parameter verification failed.
{@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
{@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
{@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetMediaData(const NativeResourceManager *mgr, uint32_t resId,
uint8_t **resultValue, uint64_t *resultLen, uint32_t density);
/**
* @brief Obtains the content of the image resource.
*
@ -134,6 +203,29 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMedia(const NativeResourceManage
ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName(const NativeResourceManager *mgr, const char *resName,
uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0);
/**
* @brief Obtains the content of the image resource.
*
* Obtains the content of the specified screen density media file corresponding to a specified resource name.
*
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resName Indicates the resource name.
* @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
* to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
* @param resultValue the result write to resultValue.
* @param resultLen the media length write to resultLen.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
* 1.Incorrect parameter types; 2.Parameter verification failed.
{@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
{@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
{@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetMediaDataByName(const NativeResourceManager *mgr, const char *resName,
uint8_t **resultValue, uint64_t *resultLen, uint32_t density);
/**
* @brief Obtains the DrawableDescriptor of the media file.
*
@ -156,6 +248,29 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName(const NativeResource
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor(const NativeResourceManager *mgr,
uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0);
/**
* @brief Obtains the DrawableDescriptor of the media file.
*
* Obtains the DrawableDescriptor of the media file corresponding to a specified resource ID.
*
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resId Indicates the resource ID.
* @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
* to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
* @param type The optional parameter means the media type, 0 means the normal media, 1 means the the theme style media.
* If this attribute is not required, set this parameter to 0.
* @param drawableDescriptor the result write to drawableDescriptor.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
* 1.Incorrect parameter types; 2.Parameter verification failed.
{@link ERROR_CODE_RES_ID_NOT_FOUND} 9001001 - Invalid resource ID.
{@link ERROR_CODE_RES_NOT_FOUND_BY_ID} 9001002 - No matching resource is found based on the resource ID.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorData(const NativeResourceManager *mgr,
uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type);
/**
* @brief Obtains the DrawableDescriptor of the media file.
*
@ -178,6 +293,28 @@ ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor(const NativeR
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName(const NativeResourceManager *mgr,
const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0);
/**
* @brief Obtains the DrawableDescriptor of the media file.
*
* Obtains the DrawableDescriptor of the media file corresponding to a specified resource name.
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resName Indicates the resource name.
* @param density The optional parameter ScreenDensity{@link ScreenDensity}, A value of 0 means
* to use the density of current system dpi. If this attribute is not required, set this parameter to 0.
* @param type The optional parameter means the media type, 0 means the normal media, 1 means the the theme style media,
* 2 means the theme dynamic media. If this attribute is not required, set this parameter to 0.
* @param drawableDescriptor the result write to drawableDescriptor.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid. Possible causes:
* 1.Incorrect parameter types; 2.Parameter verification failed.
{@link ERROR_CODE_RES_NAME_NOT_FOUND} 9001003 - Invalid resource name.
{@link ERROR_CODE_RES_NOT_FOUND_BY_NAME} 9001004 - No matching resource is found based on the resource name.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorDataByName(const NativeResourceManager *mgr,
const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type);
/**
* @brief Obtains the symbol resource.
*
@ -238,6 +375,26 @@ ResourceManager_ErrorCode OH_ResourceManager_GetSymbolByName(const NativeResourc
ResourceManager_ErrorCode OH_ResourceManager_GetLocales(const NativeResourceManager *mgr, char ***resultValue,
uint32_t *resultLen, bool includeSystem = false);
/**
* @brief Obtains locales list.
*
* You need to call the OH_ResourceManager_ReleaseStringArray() method to release the memory of localinfo.
*
* @param mgr Indicates the pointer to {@link NativeResourceManager}
* {@link OH_ResourceManager_InitNativeResourceManager}.
* @param resultValue the result write to resultValue.
* @param resultLen the locales length write to resultLen.
* @param includeSystem the parameter controls whether to include system resources.
* If this attribute is not required, set this parameter to false.
* @return {@link SUCCESS} 0 - Success.
* {@link ERROR_CODE_INVALID_INPUT_PARAMETER} 401 - The input parameter invalid.
Possible causes: Incorrect parameter types.
* {@link ERROR_CODE_OUT_OF_MEMORY} 9001100 - Out of memory.
* @since 12
*/
ResourceManager_ErrorCode OH_ResourceManager_GetLocalesData(const NativeResourceManager *mgr, char ***resultValue,
uint32_t *resultLen, bool includeSystem);
/**
* @brief Obtains the device configuration.
*

View File

@ -149,7 +149,7 @@ typedef struct ResourceManager_Configuration {
/** Indicates the screen direction of the current device. */
ResourceManager_Direction direction;
/** Indicates the current system language, for example, zh-Hans-CN. */
char* locale = nullptr;
char* locale;
/** Indicates the device type. */
ResourceManager_DeviceType deviceType;
/** Indicates the screen density. */
@ -157,9 +157,9 @@ typedef struct ResourceManager_Configuration {
/** Indicates the color mode. */
ResourceManager_ColorMode colorMode;
/** Indicates the mcc. */
uint32_t mcc = 0;
uint32_t mcc;
/** Indicates the mnc. */
uint32_t mnc = 0;
uint32_t mnc;
/** Reserved attributes. */
uint32_t reserved[20];
} ResourceManager_Configuration;

View File

@ -22,5 +22,33 @@
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetDrawableDescriptorByName"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetMediaBase64Data"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetMediaBase64DataByName"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetMediaData"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetMediaDataByName"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetDrawableDescriptorData"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetDrawableDescriptorDataByName"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetLocalesData"
}
]

View File

@ -162,5 +162,13 @@
{
"first_introduced": "12",
"name": "OH_ResourceManager_RemoveResource"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_GetRawFileDescriptorData"
},
{
"first_introduced": "12",
"name": "OH_ResourceManager_ReleaseRawFileDescriptorData"
}
]