diff --git a/IPCKit/BUILD.gn b/IPCKit/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..203f09a8fa9fc312996774a5e6a568beb5c2c540 --- /dev/null +++ b/IPCKit/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (C) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("ipc_capi_header") { + dest_dir = "$ndk_headers_out_dir/IPCKit" + sources = [ + "./ipc_cparcel.h", + "./ipc_cremote_object.h", + "./ipc_cskeleton.h", + "./ipc_error_code.h", + "./ipc_kit.h", + ] +} + +ohos_ndk_library("libipc_capi") { + output_name = "ipc_capi" + output_extension = "so" + ndk_description_file = "./libipc_capi.json" + system_capability = "SystemCapability.Communication.IPC.Core" + system_capability_headers = [ + "IPCKit/ipc_cparcel.h", + "IPCKit/ipc_cremote_object.h", + "IPCKit/ipc_cskeleton.h", + "IPCKit/ipc_error_code.h", + "IPCKit/ipc_kit.h", + ] +} diff --git a/IPCKit/ipc_cparcel.h b/IPCKit/ipc_cparcel.h new file mode 100644 index 0000000000000000000000000000000000000000..3e89733c61e1405eb1c06d6b1b334771fca194d8 --- /dev/null +++ b/IPCKit/ipc_cparcel.h @@ -0,0 +1,531 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_INCLUDE_IPC_CPARCEL_H +#define CAPI_INCLUDE_IPC_CPARCEL_H + +/** + * @addtogroup OHIPCParcel + * @{ + * + * @brief Defines C interfaces for IPC serialization and deserialization. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cparcel.h + * + * @brief Defines C interfaces for IPC serialization and deserialization. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @brief Defines an IPC serialized object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCParcel; + +/** +* @brief Typedef an IPC serialized object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCParcel OHIPCParcel; + +/** +* @brief Defines an IPC remote proxy object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCRemoteProxy; + +/** +* @brief Typedef an IPC remote proxy object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCRemoteProxy OHIPCRemoteProxy; + +/** +* @brief Defines an IPC remote service object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCRemoteStub; + +/** +* @brief Typedef an IPC remote service object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCRemoteStub OHIPCRemoteStub; + +/** + * @brief Allocates memory. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param len Length of the memory to allocate. + * @return Returns the address of the memory allocated if the operation is successful; returns NULL otherwise. + * @since 12 + */ +typedef void* (*OH_IPC_MemAllocator)(int32_t len); + +/** + * @brief Creates an OHIPCParcel object, which cannot exceed 204,800 bytes. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the pointer to the OHIPCParcel object created if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCParcel* OH_IPCParcel_Create(void); + +/** + * @brief Destroys an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the OHIPCParcel object to destroy. + * @since 12 + */ +void OH_IPCParcel_Destroy(OHIPCParcel *parcel); + +/** + * @brief Obtains the size of the data contained in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the data size obtained if the operation is successful.\n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetDataSize(const OHIPCParcel *parcel); + +/** + * @brief Obtains the number of bytes that can be written to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the number of bytes that can be written to the OHIPCParcel object. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetWritableBytes(const OHIPCParcel *parcel); + +/** + * @brief Obtains the number of bytes that can be read from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the number of bytes that can be read from the OHIPCParcel object. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetReadableBytes(const OHIPCParcel *parcel); + +/** + * @brief Obtains the position where data is read in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the position obtained if the operation is successful. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetReadPosition(const OHIPCParcel *parcel); + +/** + * @brief Obtains the position where data is written in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the position obtained if the operation is successful. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetWritePosition(const OHIPCParcel *parcel); + +/** + * @brief Resets the position to read data in an IPC parcel. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param newReadPos New position to read data. The value ranges from 0 to the current data size. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_RewindReadPosition(OHIPCParcel *parcel, uint32_t newReadPos); + +/** + * @brief Resets the position to write data in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param newWritePos New position to write data. The value ranges from 0 to the current data size. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_RewindWritePosition(OHIPCParcel *parcel, uint32_t newWritePos); + +/** + * @brief Writes an int8_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt8(OHIPCParcel *parcel, int8_t value); + +/** + * @brief Reads an int8_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt8(const OHIPCParcel *parcel, int8_t *value); + +/** + * @brief Writes an int16_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt16(OHIPCParcel *parcel, int16_t value); + +/** + * @brief Reads an int16_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt16(const OHIPCParcel *parcel, int16_t *value); + +/** + * @brief Writes an int32_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt32(OHIPCParcel *parcel, int32_t value); + +/** + * @brief Reads an int32_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt32(const OHIPCParcel *parcel, int32_t *value); + +/** + * @brief Writes an int64_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt64(OHIPCParcel *parcel, int64_t value); + +/** + * @brief Reads an int64_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt64(const OHIPCParcel *parcel, int64_t *value); + +/** + * @brief Writes a float value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteFloat(OHIPCParcel *parcel, float value); + +/** + * @brief Reads a float value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadFloat(const OHIPCParcel *parcel, float *value); + +/** + * @brief Writes a double value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteDouble(OHIPCParcel *parcel, double value); + +/** + * @brief Reads a double value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadDouble(const OHIPCParcel *parcel, double *value); + +/** + * @brief Writes a string including a string terminator to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param str String to write, which cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteString(OHIPCParcel *parcel, const char *str); + +/** + * @brief Reads a string from an OHIPCParcel object. You can obtain the length of the string from strlen. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the address of the string read if the operation is successful; + * returns NULL if the operation fails or invalid parameters are found. + * @since 12 + */ +const char* OH_IPCParcel_ReadString(const OHIPCParcel *parcel); + +/** + * @brief Writes data of the specified length from the memory to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param buffer Pointer to the address of the memory information to write. + * @param len Length of the data to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteBuffer(OHIPCParcel *parcel, const uint8_t *buffer, int32_t len); + +/** + * @brief Reads memory information of the specified length from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param len Length of the memory to be read. + * @return Returns the memory address read if the operation is successful; + * returns NULL if invalid parameters are found or len exceeds the readable length of parcel. + * @since 12 + */ +const uint8_t* OH_IPCParcel_ReadBuffer(const OHIPCParcel *parcel, int32_t len); + +/** + * @brief Writes an OHIPCRemoteStub object to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param stub Pointer to the OHIPCRemoteStub object to write. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteRemoteStub(OHIPCParcel *parcel, const OHIPCRemoteStub *stub); + +/** + * @brief Reads the OHIPCRemoteStub object from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the pointer to the OHIPCRemoteStub object read if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCRemoteStub* OH_IPCParcel_ReadRemoteStub(const OHIPCParcel *parcel); + +/** + * @brief Writes an OHIPCRemoteProxy object to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param proxy Pointer to the OHIPCRemoteProxy object to write. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteRemoteProxy(OHIPCParcel *parcel, const OHIPCRemoteProxy *proxy); + +/** + * @brief Reads the OHIPCRemoteProxy object from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the pointer to the OHIPCRemoteProxy object read if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCRemoteProxy* OH_IPCParcel_ReadRemoteProxy(const OHIPCParcel *parcel); + +/** + * @brief Writes a file descriptor to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param fd File descriptor to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteFileDescriptor(OHIPCParcel *parcel, int32_t fd); + +/** + * @brief Reads a file descriptor from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param fd Pointer to the file descriptor to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadFileDescriptor(const OHIPCParcel *parcel, int32_t *fd); + +/** + * @brief Appends data to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param data Pointer to the data to append. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the operation fails. + * @since 12 + */ +int OH_IPCParcel_Append(OHIPCParcel *parcel, const OHIPCParcel *data); + +/** + * @brief Writes an interface token to an OHIPCParcel object for interface identity verification. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param token Pointer to the interface token to write. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInterfaceToken(OHIPCParcel *parcel, const char *token); + +/** + * @brief Reads an interface token from an OHIPCParcel object for interface identity verification. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param token Pointer to the address of the memory for storing the interface token. + * The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. + * If an error code is returned, you still need to check whether the memory is empty and release the memory. + * Otherwise, memory leaks may occur. + * @param len Pointer to the length of the interface token read, including the terminator. It cannot be NULL. + * @param allocator Memory allocator specified by the user for allocating memory for token. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInterfaceToken(const OHIPCParcel *parcel, char **token, int32_t *len, + OH_IPC_MemAllocator allocator); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/IPCKit/ipc_cremote_object.h b/IPCKit/ipc_cremote_object.h new file mode 100644 index 0000000000000000000000000000000000000000..8155b725896bad1df2201c6b332b27ccdfbdf9e5 --- /dev/null +++ b/IPCKit/ipc_cremote_object.h @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_INCLUDE_IPC_CREMOTE_OBJECT_H +#define CAPI_INCLUDE_IPC_CREMOTE_OBJECT_H + +/** + * @addtogroup OHIPCRemoteObject + * @{ + * + * @brief Provides C interfaces for creating and destroying a remote object, transferring data, + * and observing the dead status of a remote object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cremote_object.h + * + * @brief Defines C interfaces for creating and destroying a remote object, transferring data, + * and observing the dead status of a remote object. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include + +#include "ipc_cparcel.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @brief Defines an OHIPCDeathRecipient object, which is used to receive a notification +* when the OHIPCRemoteStub object dies unexpectedly. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCDeathRecipient; + +/** +* @brief Typedef an OHIPCDeathRecipient object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCDeathRecipient OHIPCDeathRecipient; + +/** + * @brief Called to process the remote data request at the stub. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param code Custom command word for communication, in the range [0x01, 0x00ffffff]. + * @param data Pointer to the request data object. It cannot be NULL or released in the function. + * @param reply Pointer to the response data object. It cannot be NULL or released in the function. + * If this function returns an error, data cannot be written to this parameter. + * @param userData Pointer to the user data. It can be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns a custom error code in the range [1909001, 1909999] or a system error code otherwise. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INVALID_USER_ERROR_CODE} if the custom error code is out of the value range. + * @since 12 + */ +typedef int (*OH_OnRemoteRequestCallback)(uint32_t code, const OHIPCParcel *data, + OHIPCParcel *reply, void *userData); + +/** + * @brief Called when an observed object is destroyed. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param userData Pointer to the user data. It can be NULL. + * @since 12 + */ +typedef void (*OH_OnRemoteDestroyCallback)(void *userData); + +/** + * @brief Creates an OHIPCRemoteStub object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param descriptor Pointer to the descriptor of the OHIPCRemoteStub object to create. It cannot be NULL. + * @param requestCallback Callback used to process the data request. It cannot be NULL. + * @param destroyCallback Callback to be invoked when the object is destroyed. It can be NULL. + * @param userData Pointer to the user data. It can be NULL. + * @return Returns the pointer to the OHIPCRemoteStub object created if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCRemoteStub* OH_IPCRemoteStub_Create(const char *descriptor, OH_OnRemoteRequestCallback requestCallback, + OH_OnRemoteDestroyCallback destroyCallback, void *userData); + +/** + * @brief Destroys an OHIPCRemoteStub object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param stub Pointer to the OHIPCRemoteStub object to destroy. + * @since 12 + */ +void OH_IPCRemoteStub_Destroy(OHIPCRemoteStub *stub); + +/** + * @brief Destroys an OHIPCRemoteProxy object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object to destroy. + * @since 12 + */ +void OH_IPCRemoteProxy_Destroy(OHIPCRemoteProxy *proxy); + +/** + * @brief Enumerates the IPC request modes. + * + * @since 12 + */ +typedef enum { + /** Synchronous request. */ + OH_IPC_REQUEST_MODE_SYNC = 0, + /** Asynchronous request. */ + OH_IPC_REQUEST_MODE_ASYNC = 1, +} OH_IPC_RequestMode; + +/** + * @brief Defines the IPC message options. + * + * @since 12 + */ +#pragma pack(4) +typedef struct { + /** Message request mode. */ + OH_IPC_RequestMode mode; + /** Parameter reserved for RPC, which is invalid for IPC. */ + uint32_t timeout; + /** Reserved parameter, which must be NULL. */ + void* reserved; +} OH_IPC_MessageOption; +#pragma pack() + +/** + * @brief Sends an IPC message. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object. It cannot be NULL. + * @param code Custom IPC command word, in the range [0x01, 0x00ffffff]. + * @param data Pointer to the request data object. It cannot be NULL. + * @param reply Pointer to the response data object. It cannot be NULL in the case of a synchronous request, + * and can be NULL in the case of an asynchronous request. + * @param option Pointer to the message options. It can be NULL, which indicates a synchronous request. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_DEAD_REMOTE_OBJECT} if the OHIPCRemoteStub object is dead. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CODE_OUT_OF_RANGE} if the error code is out of the value range. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} or a custom error code in other cases. + * @since 12 + */ +int OH_IPCRemoteProxy_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPCParcel *data, + OHIPCParcel *reply, const OH_IPC_MessageOption *option); + +/** + * @brief Obtains the interface descriptor from the stub. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object. It cannot be NULL. + * @param descriptor Double pointer to the address of the memory for holding the interface descriptor. + * The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. + * If an error code is returned, you still need to check whether the memory is empty and release the memory. + * Otherwise, memory leaks may occur. + * @param len Pointer to the length of the data to be written to the descriptor, including the terminator. + * This parameter cannot be NULL. + * @param allocator Memory allocator specified by the user for allocating memory for descriptor. + * It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_DEAD_REMOTE_OBJECT} if the OHIPCRemoteStub object is dead. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_MEM_ALLOCATOR_ERROR} if memory allocation fails. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the data in the serialized object failed to be read. + * @since 12 + */ +int OH_IPCRemoteProxy_GetInterfaceDescriptor(OHIPCRemoteProxy *proxy, char **descriptor, int32_t *len, + OH_IPC_MemAllocator allocator); + +/** + * @brief Called when the OHIPCRemoteStub object dies unexpectedly. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param userData Pointer to the user data. It can be NULL. + * @since 12 + */ +typedef void (*OH_OnDeathRecipientCallback)(void *userData); + +/** + * @brief Called when the OHIPCDeathRecipient object is destroyed. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param userData Pointer to the user data. It can be NULL. + * @since 12 + */ +typedef void (*OH_OnDeathRecipientDestroyCallback)(void *userData); + +/** + * @brief Creates an OHIPCDeathRecipient object, which allows a notification to be received + * when the OHIPCRemoteStub object dies unexpectedly. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param deathRecipientCallback Callback to be invoked when the OHIPCRemoteStub object is dead. + * It cannot be NULL. + * @param destroyCallback Callback to be invoked when the object is destroyed. It can be NULL. + * @param userData Pointer to the user data. It can be NULL. + * @return Returns the pointer to the OHIPCDeathRecipient object created if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCDeathRecipient* OH_IPCDeathRecipient_Create(OH_OnDeathRecipientCallback deathRecipientCallback, + OH_OnDeathRecipientDestroyCallback destroyCallback, void *userData); + +/** + * @brief Destroys an OHIPCDeathRecipient object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param recipient Pointer to the OHIPCDeathRecipient object to destroy. + * @since 12 + */ +void OH_IPCDeathRecipient_Destroy(OHIPCDeathRecipient *recipient); + +/** + * @brief Subscribes to the death of an OHIPCRemoteStub object for an OHIPCRemoteProxy object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object that subscribes to the death notification. + * It cannot be NULL. + * @param recipient Pointer to the object that receives the death notification of the OHIPCRemoteStub object. + * It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCRemoteProxy_AddDeathRecipient(OHIPCRemoteProxy *proxy, OHIPCDeathRecipient *recipient); + +/** + * @brief Unsubscribes from the death of the OHIPCRemoteStub object for an OHIPCRemoteProxy object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object that unsubscribes from the death notification. + * It cannot be NULL. + * @param recipient Pointer to the object that receives the death notification of the OHIPCRemoteStub object. + * It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCRemoteProxy_RemoveDeathRecipient(OHIPCRemoteProxy *proxy, OHIPCDeathRecipient *recipient); + +/** + * @brief Checks whether the OHIPCRemoteStub object corresponding to the OHIPCRemoteProxy object is dead. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object to check. It cannot be NULL. + * @return Returns 1 if the OHIPCRemoteStub object is dead; returns 0 otherwise. + * If an invalid parameter is found, the OHIPCRemoteStub object does not exist. + * In this case, 1 is returned. + * @since 12 + */ +int OH_IPCRemoteProxy_IsRemoteDead(const OHIPCRemoteProxy *proxy); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/IPCKit/ipc_cskeleton.h b/IPCKit/ipc_cskeleton.h new file mode 100644 index 0000000000000000000000000000000000000000..bc70d2bb392cd7a955b472863366df5369067b48 --- /dev/null +++ b/IPCKit/ipc_cskeleton.h @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_INCLUDE_IPC_CSKELETON_H +#define CAPI_INCLUDE_IPC_CSKELETON_H + +/** + * @addtogroup OHIPCSkeleton + * @{ + * + * @brief Provides C interfaces for managing the token IDs, credentials, process IDs (PIDs), + * user IDs (UIDs), and thread pool in the IPC framework. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cskeleton.h + * + * @brief Defines C interfaces for managing the token IDs, credentials, PIDs, UIDs, and thread + * pool in the IPC framework. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include + +#include "ipc_cparcel.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Joints this thread to the IPC worker thread pool. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ +void OH_IPCSkeleton_JoinWorkThread(void); + +/** + * @brief Stops this thread. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ +void OH_IPCSkeleton_StopWorkThread(void); + +/** + * @brief Obtains the token ID of the caller. This function must be called in the IPC context. + * Otherwise, the local token ID is returned. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the token ID of the caller. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetCallingTokenId(void); + +/** + * @brief Obtains the token ID of the first caller. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the token ID obtained. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetFirstTokenId(void); + +/** + * @brief Obtains the local token ID. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the token ID obtained. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetSelfTokenId(void); + +/** + * @brief Obtains the process ID of the caller. This function must be called in the IPC context. + * Otherwise, the current process ID is returned. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the process ID of the caller. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetCallingPid(void); + +/** + * @brief Obtains the UID of the caller. This function must be called in the IPC context. + * Otherwise, the current UID is returned. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the UID of the caller. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetCallingUid(void); + +/** + * @brief Checks whether a local calling is being made. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns 1 if a local calling is in progress; returns 0 otherwise. + * @since 12 + */ +int OH_IPCSkeleton_IsLocalCalling(void); + +/** + * @brief Sets the maximum number of worker threads. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param maxThreadNum Maximum number of worker threads to set. The default value is 16. + * The value range is [1, 32]. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCSkeleton_SetMaxWorkThreadNum(const int maxThreadNum); + +/** + * @brief Resets the caller identity credential (including the token ID, UID, and PID) to that of this process and + * returns the caller credential information. + * The identity information is used in OH_IPCSkeleton_SetCallingIdentity. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param identity Pointer to the address of the memory for holding the caller identity information. + * The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. + * @param len Pointer to the length of the identity information. It cannot be NULL. + * @param allocator Memory allocator specified by the user for allocating memory for identity. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_MEM_ALLOCATOR_ERROR} if memory allocation fails. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCSkeleton_ResetCallingIdentity(char **identity, int32_t *len, OH_IPC_MemAllocator allocator); + +/** + * @brief Sets the caller credential information to the IPC context. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param identity Pointer to the caller identity, which cannot be NULL. + * The value is returned by OH_IPCSkeleton_ResetCallingIdentity. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCSkeleton_SetCallingIdentity(const char *identity); + +/** + * @brief Checks whether an IPC request is being handled. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns 1 if an IPC request is being handled; returns 0 otherwise. + * @since 12 + */ +int OH_IPCSkeleton_IsHandlingTransaction(void); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/IPCKit/ipc_error_code.h b/IPCKit/ipc_error_code.h new file mode 100644 index 0000000000000000000000000000000000000000..2a2134ca7eded3ad3d78395bf47997f575e17f95 --- /dev/null +++ b/IPCKit/ipc_error_code.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_INCLUDE_IPC_ERROR_CODE_H +#define CAPI_INCLUDE_IPC_ERROR_CODE_H + +/** + * @addtogroup OHIPCErrorCode + * @{ + * + * @brief Provides IPC error codes. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_error_code.h + * + * @brief Defines IPC error codes. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** +* @brief Enumerates IPC error codes. +* +* @since 12 +*/ +typedef enum { + /** @error Execution successful. */ + OH_IPC_SUCCESS = 0, + /** @error Start error code. */ + OH_IPC_ERROR_CODE_BASE = 1901000, + /** @error Invalid parameters. */ + OH_IPC_CHECK_PARAM_ERROR = OH_IPC_ERROR_CODE_BASE, + /** @error Failed to write data to the serialized object. */ + OH_IPC_PARCEL_WRITE_ERROR = OH_IPC_ERROR_CODE_BASE + 1, + /** @error Failed to read data from the serialized object. */ + OH_IPC_PARCEL_READ_ERROR = OH_IPC_ERROR_CODE_BASE + 2, + /** @error Failed to allocate memory. */ + OH_IPC_MEM_ALLOCATOR_ERROR = OH_IPC_ERROR_CODE_BASE + 3, + /** @error The command word is out of the value range [0x01,0x00ffffff]. */ + OH_IPC_CODE_OUT_OF_RANGE = OH_IPC_ERROR_CODE_BASE + 4, + /** @error The remote object is dead. */ + OH_IPC_DEAD_REMOTE_OBJECT = OH_IPC_ERROR_CODE_BASE + 5, + /** @error The custom error code is out of range [1900001, 1999999]. */ + OH_IPC_INVALID_USER_ERROR_CODE = OH_IPC_ERROR_CODE_BASE + 6, + /** @error IPC internal error. */ + OH_IPC_INNER_ERROR = OH_IPC_ERROR_CODE_BASE + 7, + /** @error Maximum error code. */ + OH_IPC_ERROR_CODE_MAX = OH_IPC_ERROR_CODE_BASE + 1000, + /** @error Minimum value for a custom error code. */ + OH_IPC_USER_ERROR_CODE_MIN = 1909000, + /** @error Maximum value for a custom error code. */ + OH_IPC_USER_ERROR_CODE_MAX = 1909999, +} OH_IPC_ErrorCode; + +/** @} */ +#endif diff --git a/IPCKit/ipc_kit.h b/IPCKit/ipc_kit.h new file mode 100644 index 0000000000000000000000000000000000000000..e30d81aac1f6247a2d94b2bc7d07825add909498 --- /dev/null +++ b/IPCKit/ipc_kit.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_INCLUDE_IPC_KIT_H +#define CAPI_INCLUDE_IPC_KIT_H + +/** + * @addtogroup IPCKit + * @{ + * + * @brief Provides an entry to the IPC header files for you to reference. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cparcel.h + * + * @brief Provides an entry to the IPC header files for you to reference. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include "ipc_error_code.h" +#include "ipc_cparcel.h" +#include "ipc_cremote_object.h" +#include "ipc_cskeleton.h" + +/** @} */ +#endif diff --git a/IPCKit/libipc_capi.json b/IPCKit/libipc_capi.json new file mode 100644 index 0000000000000000000000000000000000000000..5c1976b92615d57281d26eab7156d4ab19009f71 --- /dev/null +++ b/IPCKit/libipc_capi.json @@ -0,0 +1,226 @@ +[ + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_JoinWorkThread" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_StopWorkThread" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetCallingTokenId" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetFirstTokenId" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetSelfTokenId" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetCallingPid" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetCallingUid" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_IsLocalCalling" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_SetMaxWorkThreadNum" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_ResetCallingIdentity" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_SetCallingIdentity" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_IsHandlingTransaction" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteStub_Create" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteStub_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_SendRequest" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_GetInterfaceDescriptor" + }, + { + "first_introduced": "12", + "name": "OH_IPCDeathRecipient_Create" + }, + { + "first_introduced": "12", + "name": "OH_IPCDeathRecipient_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_AddDeathRecipient" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_RemoveDeathRecipient" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_IsRemoteDead" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_Create" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetDataSize" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetWritableBytes" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetReadableBytes" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetReadPosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetWritePosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_RewindReadPosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_RewindWritePosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt8" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt8" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt16" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt16" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt32" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt32" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt64" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt64" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteFloat" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadFloat" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteDouble" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadDouble" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteString" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadString" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteBuffer" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadBuffer" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteRemoteStub" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadRemoteStub" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteRemoteProxy" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadRemoteProxy" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteFileDescriptor" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadFileDescriptor" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_Append" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInterfaceToken" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInterfaceToken" + } +] diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 024c38820107138ac373d6bccaeac3e9c1ce87fc..46ff70046e603d3ad39f46f20e6d960b1da4905e 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -34,6 +34,7 @@ if (!is_arkui_x) { "native_node.h", "native_node_napi.h", "native_type.h", + "styled_string.h", "ui_input_event.h", ] } diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index e880238e0011ec4f2d59c2b1648313421234daab..b5f15e435f2c5b382402e1300d178d30e5db48c8 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -615,6 +615,10 @@ "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_SetMargin" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_WaterFlowSectionOption_GetSize" + }, { "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_GetItemCount" @@ -635,6 +639,10 @@ "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_GetMargin" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndex" + }, { "first_introduced": "12", "name": "OH_ArkUI_AnimateOption_Create" @@ -1058,5 +1066,97 @@ { "first_introduced": "12", "name": "OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_PushTextStyle" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_AddText" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_PopTextStyle" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_CreateTypography" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_AddPlaceholder" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetContent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetActionAreaDistance" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_GetActionAreaDistance" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnEnterActionArea" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnAction" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnExitActionArea" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnStateChange" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetStart" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetEdgeEffect" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_GetEdgeEffect" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChange" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 2e089f3e4f4450068d8e54293efeabd2cc7c6fe9..a0e90b0ca21d29e8acce313ed51dcd5b9b8936fd 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -1586,23 +1586,37 @@ typedef enum { NODE_FOREGROUND_BLUR_STYLE, /** - * @brief Defines layout rect attribute, which can be set, reset, and obtained as required through APIs. + * @brief Defines the component size and position for layout. + * This attribute can be set, reset, and obtained as required through APIs. * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n - * .value[0].i32: x position of the component. - * .value[1].i32: y position of the component. - * .value[2].i32: width of the component. - * .value[3].i32: height of the component. + * .value[0].i32: X coordinate of the component, in px. \n + * .value[1].i32: Y coordinate of the component, in px. \n + * .value[2].i32: width of the component, in px. \n + * .value[3].i32: height of the component, in px. \n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n - * .value[0].i32: x position of the component. - * .value[1].i32: y position of the component. - * .value[2].i32: width of the component. - * .value[3].i32: height of the component. + * .value[0].i32: X coordinate of the component, in px. \n + * .value[1].i32: Y coordinate of the component, in px. \n + * .value[2].i32: width of the component, in px. \n + * .value[3].i32: height of the component, in px. \n * */ NODE_LAYOUT_RECT, + /** + * @brief Whether the current component supports click-to-focus capability, + * which can be set, reset, and obtained as required through APIs. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].i32: The parameter type is 1 or 0. + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].i32: The parameter type is 1 or 0. + * + */ + NODE_FOCUS_ON_TOUCH, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -1952,6 +1966,18 @@ typedef enum { */ NODE_TEXT_SELECTED_BACKGROUND_COLOR, + /** + * @brief The text component uses a formatted string object to set text content properties, + * and supports property setting, property reset, and property acquisition interfaces. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .object indicates ArkUI_StyledString formatted string data. The parameter type is {@link ArkUI_StyledString}. \n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .object indicates ArkUI_StyledString formatted string data. The parameter type is {@link ArkUI_StyledString}. \n + */ + NODE_TEXT_CONTENT_WITH_STYLED_STRING, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -1985,6 +2011,18 @@ typedef enum { * */ NODE_SPAN_TEXT_BACKGROUND_STYLE, + /** + * @brief Defines the text baseline offset attribute + * This attribute can be set, reset, and obtained as required through APIs. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].f32: baseline offset, in fp.\n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].f32: baseline offset, in fp. \n + * + */ + NODE_SPAN_BASELINE_OFFSET, /** * @brief Defines the image source of the image span. * This attribute can be set, reset, and obtained as required through APIs. @@ -2013,6 +2051,20 @@ typedef enum { * */ NODE_IMAGE_SPAN_VERTICAL_ALIGNMENT, + /** + * @brief Defines the placeholder image source. + * This attribute can be set, reset, and obtained as required through APIs. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n + * + */ + NODE_IMAGE_SPAN_ALT, /** * @brief Defines the image source of the component. * This attribute can be set, reset, and obtained as required through APIs. @@ -2094,9 +2146,11 @@ typedef enum { * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n * */ NODE_IMAGE_ALT, @@ -4444,6 +4498,19 @@ typedef enum { */ NODE_SWIPER_SWIPE_TO_INDEX, + /** + * @brief: Set the delineation component of the ListItem, supporting property settings, property resets, and + * property acquisition interfaces. + * + * Attribute setting method parameter {@link ArkUI_AttributeItem} format: \n + * .object: Construct using the {@link ArkUI_ListitemSwipeActionOption} object. \n + * \n + * The return value of the attribute acquisition method {@link ArkUI_AttributeItem} format: \n + * .object: Construct using the {@link ArkUI_ListitemSwipeActionOption} object. \n + * + */ + NODE_LIST_ITEM_SWIPE_ACTION = MAX_NODE_SCOPE_NUM * ARKUI_NODE_LIST_ITEM, + /** * @brief Defines the header of the list item group. * This attribute can be set, reset, and obtained as required through APIs. @@ -5438,6 +5505,32 @@ typedef enum { */ NODE_SWIPER_EVENT_ON_GESTURE_SWIPE, + /** + * @brief Define the ARKUI_NODE_SWIPER to listen for Swiper page slide events. + * Instruction: \n + * 1. If the {@link ArkUI_SwiperDisplayModeType} attribute is set to \n + * ARKUI_SWIPER_DISPLAY_MODE_AUTO_LINEAR, the interface does not take effect. \n + * 2, circular scenario, set prevMargin and nextMargin attributes, \n + * so that Swiper front and back end display the same page, the interface does not take effect. \n + * 3. During page sliding, the ContentDidScrollCallback callback is \n + * triggered frame-by-frame for all pages in the window. \n + * For example, when there are two pages in the window with subscripts 0 and 1, \n + * callbacks with index values 0 and 1 are triggered twice per frame. \n + * 4, set the swipeByGroup parameter of the displayCount property to \n + * true if at least one page in the same group is in the window, \n + * A callback is triggered for all pages in the group. \n + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is + * {@link ArkUI_NodeComponentEvent}. \n + * {@link ArkUI_NodeComponentEvent} contains four parameters:\n + * ArkUI_NodeComponentEvent.data[0].i32 : indicates the index of the Swiper component, \n + * which is consistent with the index change in the onChange event. \n + * ArkUI_NodeComponentEvent.data[1].i32 : The index of a page in the window. \n + * ArkUI_NodeComponentEvent.data[2].f32 : The proportion of page movement relative to \n + * the start position of the Swiper spindle (selectedIndex corresponds to the start position of the page). \n + * ArkUI_NodeComponentEvent.data[3].f32 : The length of the page in the axis direction. \n + */ + NODE_SWIPER_EVENT_ON_CONTENT_DID_SCROLL, + /** * @brief Defines the event triggered when the ARKUI_NODE_SCROLL component scrolls. * @@ -5637,6 +5730,16 @@ typedef enum { */ NODE_REFRESH_ON_REFRESH, + /** + * @brief Defines the event that is triggered when the ARKUI_NODE_REFRESH drop-down distance changes. + * + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is + * {@link ArkUI_NodeComponentEvent}. \n + * {@link ArkUI_NodeComponentEvent} contains one parameter:\n + * ArkUI_NodeComponentEvent.data[0].f32: Pull-down distance. \n + */ + NODE_REFRESH_ON_OFFSET_CHANGE, + /** * @brief Defines the event triggered when the ARKUI_NODE_SCROLL component is about to scroll. * diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index 71a268f5efec8b46bebb91d323d7629739860823..381ea6d4280211c954d86ef6c83858becfcce258 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -98,6 +98,20 @@ typedef struct ArkUI_NativeDialog* ArkUI_NativeDialogHandle; */ typedef struct ArkUI_WaterFlowSectionOption ArkUI_WaterFlowSectionOption; +/** + * @brief Define the configuration information of the Item within the ListitemSwipeActionOption method. + * + * @since 12 + */ +typedef struct ArkUI_ListItemSwipeActionItem ArkUI_ListItemSwipeActionItem; + +/** + * @brief Define the configuration information for the ListitemSwipeActionOption method. + * + * @since 12 + */ +typedef struct ArkUI_ListItemSwipeActionOption ArkUI_ListItemSwipeActionOption; + /** * @brief Defines the ArkUI native context object. * @@ -862,6 +876,8 @@ typedef enum { ARKUI_SLIDER_STYLE_OUT_SET = 0, /** The slider is in the slider track. */ ARKUI_SLIDER_STYLE_IN_SET, + /** No slider. */ + ARKUI_SLIDER_STYLE_NONE, } ArkUI_SliderStyle; /** @@ -1770,6 +1786,34 @@ typedef enum { ARKUI_SWIPER_INDICATOR_TYPE_DIGIT, } ArkUI_SwiperIndicatorType; +/** + * @brief Define the pattern of element arrangement in the main axis direction of the Swiper component. + * + * @since 12 + */ +typedef enum { + /** In the folded state, when the ListItem slides in the opposite direction to the main axis, + * the operation item is hidden.*/ + ARKUI_LIST_ITEM_SWIPE_ACTION_STATE_COLLAPSED = 0, + /** In the folded state, when the ListItem slides in the opposite direction to the spindle, + * the operation item is displayed.*/ + ARKUI_LIST_ITEM_SWIPE_ACTION_STATE_EXPANDED, + /** Long distance state, the state of deleting a ListItem after it enters the long distance deletion area.*/ + ARKUI_LIST_ITEM_SWIPE_ACTION_STATE_ACTIONING, +} ArkUI_ListItemSwipeActionState; + +/** + * @brief Define the explicit and implicit mode of the SwipeAction method for the Listitem component. + * + * @since 12 + */ +typedef enum { + /** The ListItem can continue to be scratched after the distance exceeds the size of the scratched component.*/ + ARKUI_LIST_ITEM_SWIPE_EDGE_EFFECT_SPRING = 0, + /** The sliding distance of the ListItem cannot exceed the size of the scratched component.*/ + ARKUI_LIST_ITEM_SWIPE_EDGE_EFFECT_NONE, +} ArkUI_ListItemSwipeEdgeEffect; + /** * @brief Creates a size constraint. * @@ -1946,6 +1990,16 @@ void OH_ArkUI_WaterFlowSectionOption_Dispose(ArkUI_WaterFlowSectionOption* optio */ void OH_ArkUI_WaterFlowSectionOption_SetSize(ArkUI_WaterFlowSectionOption* option, int32_t size); +/** +* @brief Gets the FlowItem grouping configuration information array length. +* +* @param option FlowItem Indicates the packet configuration. +* @return Array size. If -1 is returned, the return fails. +* The possible cause of the failure is that the option parameter is abnormal, such as a null pointer. +* @since 12 +*/ +int32_t OH_ArkUI_WaterFlowSectionOption_GetSize(ArkUI_WaterFlowSectionOption* option); + /** * @brief Sets the number of items in a water flow section. * @@ -1967,6 +2021,18 @@ void OH_ArkUI_WaterFlowSectionOption_SetItemCount(ArkUI_WaterFlowSectionOption* */ int32_t OH_ArkUI_WaterFlowSectionOption_GetItemCount(ArkUI_WaterFlowSectionOption* option, int32_t index); +/** +* @brief The FlowItem grouping configuration information getsthe spindle size of +* the specified Item based on flowItemIndex. +* +* @param option Indicates the pointer to a water flow section configuration. +* @param index Indicates the index of the target water flow section. +* @param callback Gets the spindle size of the specified Item based on index. +* @since 12 +*/ +void OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndex(ArkUI_WaterFlowSectionOption* option, + int32_t index, float(*callback)(int32_t itemIndex)); + /** * @brief Sets the number of columns (in a vertical layout) or rows (in a horizontal layout) of a water flow. * @@ -2692,6 +2758,160 @@ float OH_ArkUI_AlignmentRuleOption_GetBiasHorizontal(ArkUI_AlignmentRuleOption* * @since 12 */ float OH_ArkUI_AlignmentRuleOption_GetBiasVertical(ArkUI_AlignmentRuleOption* option); + +/** + * @brief Create a configuration item for the ListitemSwipeActionItem interface settings. + * + * @return List Item SwipeActionItem configuration item instance. If the object returns a null pointer, + * it indicates creation failure, and the reason for the failure may be that the address space is full. + * @since 12 +*/ +ArkUI_ListItemSwipeActionItem* OH_ArkUI_ListItemSwipeActionItem_Create(); + +/** +* @brief Destroy the ListitemSwipeActionItem instance. +* +* @param option List Item SwipeActionItem instance to be destroyed. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_Dispose(ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the layout content of ListItem SwipeActionItem. +* +* @param option List Item SwipeActionItem instance. +* @param builder Layout information. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetContent(ArkUI_ListItemSwipeActionItem* item, ArkUI_NodeHandle node); + +/** +* @brief Set the threshold for long-distance sliding deletion distance of components. +* +* @param option List Item SwipeActionItem instance. +* @param distance Component long-distance sliding deletion distance threshold. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetActionAreaDistance(ArkUI_ListItemSwipeActionItem* item, float distance); + +/** +* @brief Obtain the threshold for long-distance sliding deletion distance of components. +* +* @param option List Item SwipeActionItem instance. +* @return Component long-distance sliding deletion distance threshold. If -1.0f is returned, the return fails. +* The possible cause of the failure is that the item parameter is abnormal, such as a null pointer. +* @since 12 +*/ +float OH_ArkUI_ListItemSwipeActionItem_GetActionAreaDistance(ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the event to be called when a sliding entry enters the deletion area. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnEnterActionArea(ArkUI_ListItemSwipeActionItem* item, void (*callback)()); + +/** +* @brief Set the event to be called when a component enters the long-range deletion area and deletes a ListItem. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnAction(ArkUI_ListItemSwipeActionItem* item, void (*callback)()); + +/** +* @brief Set the event to be called when a sliding entry exits the deletion area. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnExitActionArea(ArkUI_ListItemSwipeActionItem* item, void (*callback)()); + +/** +* @brief Set the event triggered when the sliding state of a list item changes. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* swipeActionState The changed state. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnStateChange(ArkUI_ListItemSwipeActionItem* item, + void (*callback)(ArkUI_ListItemSwipeActionState swipeActionState)); + +/** + * @brief Create a configuration item for the ListitemSwipeActionOption interface settings. + * + * @return List Item SwipeActionOption configuration item instance.If the object returns a null pointer, + * it indicates a creation failure, and the reason for the failure may be that the address space is full. + * @since 12 +*/ +ArkUI_ListItemSwipeActionOption* OH_ArkUI_ListItemSwipeActionOption_Create(); + +/** +* @brief Destroy the ListitemSwipeActionOption instance. +* +* @param option List Item SwipeActionOption instance to be destroyed. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_Dispose(ArkUI_ListItemSwipeActionOption* option); + +/** +* @brief Set the layout content on the left (vertical layout) or top (horizontal layout) +* of the ListItem SwipeActionItem. +* +* @param option List Item SwipeActionItem instance. +* @param builder Layout information. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetStart(ArkUI_ListItemSwipeActionOption* option, + ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the layout content on the right (vertical layout) or bottom (horizontal layout) +* of the ListItem SwipeActionItem. +* +* @param option List Item SwipeActionItem instance. +* @param builder Layout information. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetEnd(ArkUI_ListItemSwipeActionOption* option, + ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the sliding effect. +* +* @param option List Item SwipeActionItem instance. +* @param edgeEffect Sliding effect. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetEdgeEffect(ArkUI_ListItemSwipeActionOption* option, + ArkUI_ListItemSwipeEdgeEffect edgeEffect); + +/** +* @brief Get the sliding effect. +* +* @param option List Item SwipeActionItem instance. +* @return Sliding effect. The default return value is 0. If -1 is returned, the return fails. +* The possible cause of the failure is that the option parameter is abnormal, such as a null pointer. +* @since 12 +*/ +int32_t OH_ArkUI_ListItemSwipeActionOption_GetEdgeEffect(ArkUI_ListItemSwipeActionOption* option); + +/** +* @brief The event called when the sliding operation offset changes. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* offset Slide offset. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChange(ArkUI_ListItemSwipeActionOption* option, + void (*callback)(float offset)); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/styled_string.h b/arkui/ace_engine/native/styled_string.h new file mode 100644 index 0000000000000000000000000000000000000000..f67994505bbc684e13a60a4a7c4a72e17297a8d8 --- /dev/null +++ b/arkui/ace_engine/native/styled_string.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup ArkUI_NativeModule + * @{ + * + * @brief Provides ArkUI UI capabilities on the Native side, such as UI component creation and destruction, + * tree node operation, property setting, event monitoring, and so on. + * + * @since 12 + */ + +/** + * @file styled_string.h + * + * @brief Provides ArkUI with property string capabilities on the Native side. + * + * @library libace_ndk.z.so + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + +#ifndef ARKUI_NATIVE_STYLED_STRING_H +#define ARKUI_NATIVE_STYLED_STRING_H + +#include "native_drawing/drawing_text_declaration.h" +#include "native_drawing/drawing_text_typography.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines formatted string data objects supported by the text component. + * + * @since 12 + */ +typedef struct ArkUI_StyledString ArkUI_StyledString; + +/** + * @brief Creates a pointer to the ArkUI_StyledString object. + * + * @param style A pointer to OH_Drawing_TypographyStyle, obtained by {@link OH_Drawing_CreateTypographyStyle}. + * @param collection A pointer to OH_Drawing_FontCollection, obtained by {@link OH_Drawing_CreateFontCollection}. + * @return Creates a pointer to the ArkUI_StyledString object. If the object returns a null pointer, + * the creation failed, either because the address space was full, + * or because the style, collection parameter was an exception such as a null pointer. + * @since 12 + */ +ArkUI_StyledString* OH_ArkUI_StyledString_Create( + OH_Drawing_TypographyStyle* style, OH_Drawing_FontCollection* collection); + +/** + * @brief Free the memory occupied by the ArkUI_StyledString object. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @since 12 + */ +void OH_ArkUI_StyledString_Destroy(ArkUI_StyledString* handle); + +/** + * @brief Sets the new layout style to the top of the current format string style stack. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @param style A pointer to the OH_Drawing_TextStyle object. + * @since 12 + */ +void OH_ArkUI_StyledString_PushTextStyle(ArkUI_StyledString* handle, OH_Drawing_TextStyle* style); + +/** + * @brief Sets the corresponding text content based on the current format string style. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @param content A pointer to the text content. + * @since 12 + */ +void OH_ArkUI_StyledString_AddText(ArkUI_StyledString* handle, const char* content); + +/** + * @brief Removes the top style from the stack in the current format string object. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @since 12 + */ +void OH_ArkUI_StyledString_PopTextStyle(ArkUI_StyledString* handle); + +/** + * @brief Creates a pointer to an OH_Drawing_Typography object based on a format string object + * for advanced text estimation and typography. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @return A pointer to the OH_Drawing_Typography object. If the object returns a null pointer, + * the creation fails because the handle parameter is abnormal, such as a null pointer. + * @since 12 + */ +OH_Drawing_Typography* OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString* handle); + +/** + * @brief Set the placeholder. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @param placeholder A pointer to the OH_Drawing_PlaceholderSpan object. + * @since 12 + */ +void OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString* handle, OH_Drawing_PlaceholderSpan* placeholder); + +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_STYLED_STRING_H +/** @} */ diff --git a/build-tools/capi_parser/src/bin/config.py b/build-tools/capi_parser/src/bin/config.py index b988bef76774d6586bae86d82d0a69948418be33..5751fd7c88c01e84cf30a30553145a22548c0d8b 100644 --- a/build-tools/capi_parser/src/bin/config.py +++ b/build-tools/capi_parser/src/bin/config.py @@ -24,7 +24,6 @@ class ToolNameType(enum.Enum): DIFF = 'diff' CHECK = 'check' COLLECT_H = 'collect_h' - COLLECT_FILE = 'collect_file' tool_name_type_set = [ @@ -46,16 +45,15 @@ format_set = [ def run_tools(options): tool_name = options.tool_name + print(tool_name) if tool_name == ToolNameType["COLLECT"].value: parser.parser(options.parser_path) elif tool_name == ToolNameType["DIFF"].value: diff.process_dir(options.diff_path_old, options.diff_path_new) - elif tool_name == ToolNameType['CHECK'].value: - check.curr_entry(options.parser_path) + elif tool_name == ToolNameType["CHECK"].value: + check.curr_entry(options.path, options.checker, options.output) elif tool_name == ToolNameType['COLLECT_H'].value: parser.parser_direct(options.parser_path) - elif tool_name == ToolNameType['COLLECT_FILE'].value: - parser.parser_file_level(options.output_path) else: print("工具名称错误") @@ -68,19 +66,40 @@ class Config(object): { "name": "--tool-name", "abbr": "-N", - "required": True, + "required": False, "choices": tool_name_type_set, "type": str, - "default": ToolNameType["COLLECT"], - "help": "工具名称" + "default": ToolNameType["CHECK"].value, + "help": "工具名称,命令中不写-N的话,默认为check工具" }, { "name": "--parser-path", "abbr": "-P", - "required": True, + "required": False, "type": str, "help": "解析路径" }, + { + "name": "--codecheck--path", + "abbr": "--path", + "required": False, + "type": str, + "help": "codecheck解析文件路径" + }, + { + "name": "--check-command", + "abbr": "--checker", + "required": False, + "type": str, + "help": "校验命令" + }, + { + "name": "--check-output", + "abbr": "--output", + "required": False, + "type": str, + "help": "输出路径" + }, { "name": "--diff-path-old", "abbr": "-old", @@ -94,13 +113,6 @@ class Config(object): "required": False, "type": str, "help": "新文件路径" - }, - { - "name": "--output-path", - "abbr": "-O", - "required": False, - "type": str, - "help": "collect_file工具输出文件路径" } ] diff --git a/build-tools/capi_parser/src/coreImpl/check/check.py b/build-tools/capi_parser/src/coreImpl/check/check.py index 6c25fc3058a31a14f957ff80a887ee88b44611ce..d1298f989987881910d1ee66621c3f06a5b54158 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check.py +++ b/build-tools/capi_parser/src/coreImpl/check/check.py @@ -14,24 +14,28 @@ # limitations under the License. import json -import openpyxl as op +import os.path from pathlib import Path -from typedef.check.check import FileDocInfo, OutputTxt +from typedef.check.check import FileDocInfo, check_command_message, CheckErrorMessage from coreImpl.check.check_doc import process_comment, process_file_doc_info -from coreImpl.check.check_name import check_file_name, check_ndk_name +from coreImpl.check.check_name import check_file_name, check_api_name from coreImpl.parser.parser import parser_include_ast -from coreImpl.check.check_syntax import check_syntax -def process_api_json(api_info, file_doc_info, api_result_info_list): - api_result_info_list.extend(check_ndk_name(api_info)) +def process_api_json(api_info, file_doc_info, api_result_info_list, parent_kind, command_list): + for command in command_list: + # 对非文件名校验 + if 'NAME' in command and CheckErrorMessage.API_NAME_UNIVERSAL_14.name != command: + api_result_info_list.extend(check_api_name(api_info, parent_kind)) + break if 'comment' in api_info.keys(): comment = api_info['comment'] api_result_info_list.extend( - process_comment(comment, file_doc_info, api_info)) + process_comment(comment, file_doc_info, api_info)) + kind = api_info['kind'] child_node_list = get_api_info_child(api_info) for child_node in child_node_list: - process_api_json(child_node, file_doc_info, api_result_info_list) + process_api_json(child_node, file_doc_info, api_result_info_list, kind, command_list) def get_api_info_child(api_info): @@ -44,20 +48,24 @@ def get_api_info_child(api_info): return [] -def process_file_json(file_info, api_result_info_list): - api_result_info_list.extend(check_file_name(file_info['name'])) +def process_file_json(file_info, api_result_info_list, command_list): + # 校验文件名 + if CheckErrorMessage.API_NAME_UNIVERSAL_14.name in command_list: + api_result_info_list.extend(check_file_name(file_info)) apis = file_info['children'] + kind = file_info['kind'] file_doc_info = FileDocInfo() + # 校验Doc信息 api_result_info_list.extend(process_comment(file_info["comment"], file_doc_info, file_info)) for api in apis: - process_api_json(api, file_doc_info, api_result_info_list) + process_api_json(api, file_doc_info, api_result_info_list, kind, command_list) api_result_info_list.extend(process_file_doc_info(file_doc_info, file_info)) -def process_all_json(python_obj): +def process_all_json(python_obj, command_list): api_result_info_list = [] for file_info in python_obj: - process_file_json(file_info, api_result_info_list) + process_file_json(file_info, api_result_info_list, command_list) return api_result_info_list @@ -69,66 +77,38 @@ def write_in_txt(check_result, output_path): def result_to_json(check_result): - txt_resul = [] - for result in check_result: - location = f'{result.location}(line:{result.location_line}, col:{result.location_column})' - message = 'API check error of [{}]:{}'.format(result.error_type['description'], result.error_info) - txt_resul.append(OutputTxt(result.error_type['id'], result.level, result.api_since, - location, result.file_name, message)) - generate_excel(txt_resul) - return json.dumps(txt_resul, default=lambda obj: obj.__dict__, indent=4) - - -def generate_excel(result_info_list): - data = [] - for diff_info in result_info_list: - info_data = [ - diff_info.id, - diff_info.level, - diff_info.location, - diff_info.file_path, - diff_info.message - ] - data.append(info_data) - wb = op.Workbook() - ws = wb['Sheet'] - ws.append(['类型', '等级', '所在文件位置', '所在文件', '信息']) - for i in range(len(data)): - d = data[i][0], data[i][1], data[i][2], data[i][3], data[i][4] - ws.append(d) - wb.save('error.xlsx') - - -def curr_entry(md_files_path): - file_list = get_md_files(md_files_path) - check_result_list = [] - if len(file_list) > 0: - check_result_list = get_check_result_list(file_list) - write_in_txt(check_result_list, r'./Error.txt') + return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4) -def get_check_result_list(file_list): +def curr_entry(files_path, command: str, output): + file_list = get_files(files_path) + if command == 'all': + command_list = check_command_message + else: + command_list = command.split(',') + check_result_list = [] + if len(file_list) > 0: + check_result_list = get_check_result_list(file_list, command_list) + result_list = [] + if command != 'all': + for result in check_result_list: + if result.defectType in command_list: + result_list.append(result) + else: + result_list = check_result_list + write_in_txt(result_list, output) + + +def get_check_result_list(file_list, command_list): check_result_list = [] for file in file_list: - root_start = file.split('sdk_c')[0] - root_path = f'{root_start}sdk_c' - python_obj = parser_include_ast(root_path, [file]) - check_result_list.extend(process_all_json(python_obj)) - check_result_list.extend(check_syntax(file)) + python_obj = parser_include_ast(os.path.dirname(file), [file]) + check_result_list.extend(process_all_json(python_obj, command_list)) return check_result_list -def get_md_files(md_files_path): - with open(md_files_path, 'r') as file: - file_list = [] - line = file.readline() - while line: - file_path = line.splitlines()[0] - if file_path.find("sdk_c") != -1 and get_file_type(file_path) == '.h': - file_list.append(line.splitlines()[0]) - line = file.readline() - file.close() - return file_list +def get_files(files_path: str): + return files_path.split(',') def get_file_type(file_path): diff --git a/build-tools/capi_parser/src/coreImpl/check/check_doc.py b/build-tools/capi_parser/src/coreImpl/check/check_doc.py index 89a53eeadea0ee5131537b5cb288ccd299ea0a54..550392f5e575878e55e31a4629571a6dfd0676aa 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_doc.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_doc.py @@ -14,12 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################## + import json +import os import re import subprocess -import os + from clang.cindex import CursorKind -from typedef.check.check import ApiResultInfo, DocInfo, ErrorType, ErrorMessage, FileDocInfo, LogType, TAGS, ErrorLevel + +from typedef.check.check import DocInfo, FileDocInfo, TAGS, CheckErrorMessage, CheckOutPut current_file = os.path.dirname(__file__) # permission数据来源于https://gitee.com/openharmony/utils_system_resources/raw/master/systemres/main/config.json @@ -32,31 +35,11 @@ with open(os.path.abspath(os.path.join(current_file, "rules/syscap_rule.json"))) syscap_tag_rules = json.load(json_file) -def create_api_result_info_by_doc(error_type: ErrorType, error: ErrorMessage, params: list, api_info: object): - error_info = str(error.value) - for param in params: - error_info = error_info.replace('$$', str(param), 1) - api_result_info = ApiResultInfo(error_type.value, error_info, api_info['name']) - api_result_info.set_api_since(api_info['since']) - api_result_info.set_type(LogType.LOG_JSDOC.value) - api_result_info.set_level(ErrorLevel.LOW.value) - if 'location' in api_info.keys(): - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_file_name(api_info['location']['location_path']) - else: - api_result_info.set_file_name(api_info['name']) - api_result_info.set_location(api_info['name']) - return api_result_info - - def process_tag_addtogroup(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] group_name = tag_info['name'] if group_name == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_11.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -75,8 +58,7 @@ def process_tag_deprecated(tag_info, file_doc_info: FileDocInfo, api_info) -> li name = tag_info['name'] version: str = tag_info['description'] if name != "since" or not version.isdigit(): - api_result_info = create_api_result_info_by_doc( - ErrorType.UNKNOW_DEPRECATED, ErrorMessage.ERROR_INFO_VALUE_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_01.name) api_result_info_list.append(api_result_info) doc_info.deprecated = version return api_result_info_list @@ -87,8 +69,7 @@ def process_tag_file(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] file_name = tag_info['name'] if file_name == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_12.name) api_result_info_list.append(api_result_info) doc_info.file = file_name return api_result_info_list @@ -98,8 +79,10 @@ def process_tag_library(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] library: str = tag_info['name'] + tag_info['description'] if not library.endswith(('.so', '.a')) and library != "NA": - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_LIBRARY, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_13.name) + api_result_info_list.append(api_result_info) + if not library == library.lower(): + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_16.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -111,43 +94,26 @@ def process_tag_param(tag_info, file_doc_info: FileDocInfo, api_info) -> list: return api_result_info_list if 'parm' not in api_info.keys(): - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_COUNT_PARAM, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_FUNCTION_01.name) api_result_info_list.append(api_result_info) return api_result_info_list index = file_doc_info.curr_doc_info.param_index params = api_info['parm'] - if (len(params) < index + 1): + if len(params) < index + 1: return api_result_info_list param = api_info['parm'][index] if tag_info['name'] != param['name']: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_PARAM, [index + 1, index + 1], api_info) + main_buggy_code = get_main_buggy_code(api_info) + api_result_info = CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_info['location']['location_line'], CheckErrorMessage.API_DOC_FUNCTION_02.name, + CheckErrorMessage.__getitem__(CheckErrorMessage.API_DOC_FUNCTION_02.name).value + .replace('$$', tag_info['name']).replace('&&', param['name']), + main_buggy_code, api_info['location']['location_line']) api_result_info_list.append(api_result_info) return api_result_info_list -def process_tag_permission(tag_info, file_doc_info: FileDocInfo, api_info) -> list: - doc_info = file_doc_info.curr_doc_info - api_result_info_list = [] - permission: str = "" - if tag_info['description'] == "": - permission: str = tag_info['name'] - else: - permission: str = tag_info['name'] + ' ' + tag_info['description'] - permission_blank = re.sub(re.compile(r'\(|\)'), '', permission) - permission_join = re.sub(re.compile(r'( or | and )'), '$', permission_blank) - permission_list = permission_join.split('$') - error_permission_list = list(filter(lambda item: item not in permission_tag_rules, permission_list)) - if error_permission_list: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_PERMISSION, [], api_info) - api_result_info_list.append(api_result_info) - doc_info.permission = permission - return api_result_info_list - - def process_tag_return(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] return api_result_info_list @@ -158,12 +124,10 @@ def process_tag_since(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] value: str = tag_info['name'] + tag_info['description'] if value == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_03.name) api_result_info_list.append(api_result_info) elif not value.isdigit(): - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_SINCE, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_04.name) api_result_info_list.append(api_result_info) doc_info.since = tag_info['name'] return api_result_info_list @@ -174,12 +138,7 @@ def process_tag_syscap(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] syscap = tag_info['name'] + tag_info['description'] if syscap == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) - api_result_info_list.append(api_result_info) - if syscap not in syscap_tag_rules: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_SYSCAP, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_05.name) api_result_info_list.append(api_result_info) doc_info.syscap = syscap return api_result_info_list @@ -188,8 +147,7 @@ def process_tag_syscap(tag_info, file_doc_info: FileDocInfo, api_info) -> list: def process_tag_left_brace(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] if not file_doc_info.is_in_group_tag: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_USE_LEFT_BRACE, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_14.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -199,8 +157,7 @@ def process_tag_right_brace(tag_info, file_doc_info: FileDocInfo, api_info) -> l if not file_doc_info.has_group_end: file_doc_info.has_group_end = True return api_result_info_list - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_USE_RIGHT_BRACE, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_21.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -212,7 +169,6 @@ process_tag_function = { TAGS['FILE'].value: process_tag_file, TAGS['LIBRARY'].value: process_tag_library, TAGS['PARAM'].value: process_tag_param, - TAGS['PERMISSION'].value: process_tag_permission, TAGS['RETURN'].value: process_tag_return, TAGS['SINCE'].value: process_tag_since, TAGS['SYSCAP'].value: process_tag_syscap, @@ -230,8 +186,7 @@ def process_each_tags(tag_info, file_doc_info: FileDocInfo, api_info) -> list: tag: str = tag_info['tag'] if tag.lower() != tag: tag = tag.lower() - api_result_info = create_api_result_info_by_doc( - ErrorType.ERROR_TAG, ErrorMessage.USE_UPPER_TAG, [tag_info['tag'], tag], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_15.name) api_result_info_list.append(api_result_info) if tag not in process_tag_function.keys(): return [] @@ -250,17 +205,20 @@ def process_file_doc_group(file_doc_info: FileDocInfo, item, api_info) -> list: file_doc_info.group_name = item['name'] file_doc_info.is_in_group_tag = True else: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.REPEAT_FILE_TAG, [item['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_04.name) api_result_info_list.append(api_result_info) if item['tag'] == '{': if not file_doc_info.has_group_start: file_doc_info.has_group_start = True else: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_REPEAT_LEFT_BRACE, [item['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_06.name) api_result_info_list.append(api_result_info) - + elif item['tag'] == 'brief': + file_doc_info.group_brief = item['name'] + item['description'] + elif item['tag'] == 'library': + file_doc_info.group_library = item['name'] + item['description'] + elif item['tag'] == 'syscap': + file_doc_info.group_syscap = item['name'] + item['description'] return api_result_info_list @@ -274,8 +232,7 @@ def process_file_doc_file(file_doc_info: FileDocInfo, item, api_info) -> list: file_doc_info.file_name = item['name'] file_doc_info.is_in_file_tag = True else: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.REPEAT_FILE_TAG, [item['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_01.name) api_result_info_list.append(api_result_info) elif item['tag'] == 'brief': file_doc_info.file_brief = item['name'] + item['description'] @@ -286,6 +243,7 @@ def process_file_doc_file(file_doc_info: FileDocInfo, item, api_info) -> list: return api_result_info_list +# 第二步 def process_each_comment(comment_object, file_doc_info: FileDocInfo, api_info) -> list: ''' 检查单个comment对应的报错信息,不处理文件级别的校验 @@ -303,32 +261,36 @@ def process_each_comment(comment_object, file_doc_info: FileDocInfo, api_info) - api_result_info_list.extend(process_each_tags(item, file_doc_info, api_info)) # 判断param标签的数量和方法参数的数量是否对应 param_tag_count = file_doc_info.curr_doc_info.param_index + 1 + a = CursorKind.FUNCTION_DECL.name if api_info['kind'] == CursorKind.FUNCTION_DECL.name and \ 'parm' in api_info.keys() and len(api_info['parm']) != param_tag_count: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_INFO_COUNT_PARAM, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_FUNCTION_01.name) api_result_info_list.append(api_result_info) # 判断group标签的开头 - if file_doc_info.is_in_group_tag and not file_doc_info.has_group_start: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, ['group tag', 'start tag {'], api_info) - api_result_info_list.append(api_result_info) + if file_doc_info.is_in_group_tag: + if not file_doc_info.has_group_start: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_05.name) + api_result_info_list.append(api_result_info) + if file_doc_info.group_brief is None: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_02.name) + api_result_info_list.append(api_result_info) + if file_doc_info.group_library is None: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_07.name) + api_result_info_list.append(api_result_info) + if file_doc_info.group_syscap is None: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_08.name) + api_result_info_list.append(api_result_info) # 处理file标签的值 if file_doc_info.is_in_file_tag: if file_doc_info.file_brief is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, ['file tag', 'brief tag'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_17.name) api_result_info_list.append(api_result_info) if file_doc_info.file_library is None: - api_result_info = create_api_result_info_by_doc(ErrorType.WRONG_SCENE, - ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, - ['file tag', 'library tag'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_18.name) api_result_info_list.append(api_result_info) if file_doc_info.file_syscap is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, ['file tag', 'syscap tag'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_19.name) api_result_info_list.append(api_result_info) - return api_result_info_list @@ -342,8 +304,7 @@ def process_tag_missing(comment_object, file_doc_info: FileDocInfo, api_info): if item['tag'] == 'since': has_since_tag = True if not has_since_tag: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_LOST_LABEL, ['since'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_20.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -360,6 +321,7 @@ process_tag_missing_function = { } +# 第一步 def process_comment(comment: str, file_doc_info: FileDocInfo, api_info) -> list: ''' 处理comment数据,通过node调用comment-parser解析doc注释 @@ -368,14 +330,14 @@ def process_comment(comment: str, file_doc_info: FileDocInfo, api_info) -> list: if comment == "none_comment": return api_result_info_list result = subprocess.check_output( - ['node', os.path.abspath(os.path.join(current_file, "comment_parser.js")), comment]) # 解析comment + ['node', os.path.abspath(os.path.join(current_file, "comment_parser.js")), comment]) # 解析comment result_json = json.loads(result.decode('utf-8')) for index, item in enumerate(result_json): api_result_info_list.extend(process_each_comment(item, file_doc_info, api_info)) if index == len(result_json) - 1: api_result_info_list.extend(process_tag_missing(item, file_doc_info, api_info)) - file_doc_info.is_in_group_tag = False # 初始化group标签判断 - file_doc_info.is_in_file_tag = False # 初始化file标签判断 + file_doc_info.is_in_group_tag = False # 初始化group标签判断 + file_doc_info.is_in_file_tag = False # 初始化file标签判断 return api_result_info_list @@ -386,20 +348,28 @@ def process_file_doc_info(file_doc_info: FileDocInfo, file_info) -> list: api_result_info_list = [] # 处理group说明 if file_doc_info.group_name is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_LOSE_ONE, ['group doc'], file_info) + api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_09.name) api_result_info_list.append(api_result_info) else: # 判断group标签的结尾 if not file_doc_info.has_group_end: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, - ['group tag', 'end tag }'], file_info) + api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_10.name) api_result_info_list.append(api_result_info) # 处理file说明 if file_doc_info.file_name is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_LOSE_ONE, ['file doc'], file_info) + api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_03.name) api_result_info_list.append(api_result_info) return api_result_info_list + + +def set_value_to_result(api_info, command): + main_buggy_code = get_main_buggy_code(api_info) + return CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, + main_buggy_code, api_info['location']['location_line']) + + +def get_main_buggy_code(api_info): + main_buggy_code = '' if len(api_info['node_content']) == 0 else api_info['node_content']['content'] + return main_buggy_code diff --git a/build-tools/capi_parser/src/coreImpl/check/check_name.py b/build-tools/capi_parser/src/coreImpl/check/check_name.py index ca9a6a75a8191cb006b317d70b04d439ba2dfab8..78e919417da89fffe5c6def8e9b9cd2eaaa35141 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_name.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_name.py @@ -16,101 +16,132 @@ import enum import os.path import re -from typedef.check.check import ApiResultInfo, ErrorMessage, ErrorType, LogType, ErrorLevel +from typedef.check.check import (CheckOutPut, CheckErrorMessage) -def check_large_hump(api_info): - return processing_check_data('LARGE_HUMP', api_info) +typedefs = [CheckErrorMessage.API_NAME_UNIVERSAL_05.name, CheckErrorMessage.API_NAME_UNIVERSAL_03.name, + CheckErrorMessage.API_NAME_UNIVERSAL_07.name] -def check_function_name(api_info): +def check_large_hump(api_info, kind, parent_kind): api_result_info_list = [] - name = api_info['name'] - self_developed_function_result = re.match(r'^[OH|OS]+([\_]([A-Z]+[a-z0-9]*)+)*$', name) - ordinary_function_result = re.match(r'^([A-Z][a-z0-9]*)*$', name) - if self_developed_function_result or ordinary_function_result is not None: - return api_result_info_list - else: - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, - ErrorMessage[api_info['kind']].value.replace('$$', name), name) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_type(LogType.LOG_API.value) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(api_info['location']['location_path']) - api_result_info_list.append(api_result_info) - return api_result_info_list + # 结构体 + if kind == 'STRUCT_DECL': + api_result_info_list = processing_check_data('LARGE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_05.name) + # 枚举 + if kind == 'ENUM_DECL': + api_result_info_list = processing_check_data('LARGE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_03.name) + # 联合体 + if kind == 'UNION_DECL': + api_result_info_list = processing_check_data('LARGE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_07.name) + return api_result_info_list + + +def check_function_name(api_info, kind, parent_kind): + api_result_info_list = [] + function_name = api_info['name'] + # 自研函数 + if is_self_developed_function(function_name): + self_developed_function_result = re.match(r'^[OH|OS]+([\_]([A-Z]+[a-z0-9]*)+)*$', function_name) + if self_developed_function_result is None: + chck_output = set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_01.name) + api_result_info_list.append(chck_output) + # 一般函数 + if not is_self_developed_function(function_name): + ordinary_function_result = re.match(r'^([A-Z][a-z0-9]*)*$', function_name) + if ordinary_function_result is None: + chck_output = set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_10.name) + api_result_info_list.append(chck_output) + return api_result_info_list + + +def set_value_to_result(api_info, command): + return CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, + api_info['node_content']['content'], api_info['location']['location_line']) -def check_variable_name(api_info): +def is_self_developed_function(function_name): + return function_name.startswith('OH_') or function_name.startswith('OS_') or function_name.startswith('HMS_') + + +def check_variable_name(api_info, kind, parent_kind): + api_result_info_list = [] is_const = api_info['is_const'] + # 常量 if is_const: - return processing_check_data('ALL_UPPERCASE_HUMP', api_info) - else: - return processing_check_data('SMALL_HUMP', api_info) + api_result_info_list = processing_check_data('ALL_UPPERCASE_HUMP', + api_info, CheckErrorMessage.API_NAME_UNIVERSAL_02.name) + # 全局变量 + if not is_const: + api_result_info_list = processing_check_data('GLOBAL_VARIABLE', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_09.name) + return api_result_info_list -def check_small_hump(api_info): - return processing_check_data('SMALL_HUMP', api_info) +def check_small_hump(api_info, kind, parent_kind): + api_result_info_list = [] + # 函数参数 + if parent_kind == 'FUNCTION_DECL': + api_result_info_list = processing_check_data('SMALL_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_11.name) + # 结构体成员 + if parent_kind == 'STRUCT_DECL': + api_result_info_list = processing_check_data('SMALL_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_06.name) + # 联合体成员 + if parent_kind == 'UNION_DECL': + api_result_info_list = processing_check_data('SMALL_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_08.name) + return api_result_info_list -def check_macro_definition(api_info): +def check_macro_definition(api_info, kind, parent_kind): api_result_info_list = [] name = api_info['name'] + # 宏定义 + if not api_info['is_def_func']: + result = re.match(CheckName['MACRO_DEFINITION'].value, name) + if result is None: + api_result_info_list.append(set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_12.name)) + # 函数式宏 if api_info['is_def_func']: name = api_info['def_func_name'] - result = re.match(CheckName['ALL_UPPERCASE_HUMP'].value, name) - if result is None: - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, - ErrorMessage[api_info['kind']].value.replace('$$', name), name) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_type(LogType.LOG_API.value) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(api_info['location']['location_path']) - api_result_info_list.append(api_result_info) + result = re.match(CheckName['MACRO_DEFINITION'].value, name) + if result is None: + api_result_info_list.append(set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_13.name)) return api_result_info_list -def check_all_uppercase_hump(api_info): - return processing_check_data('ALL_UPPERCASE_HUMP', api_info) - - -def check_global_variable(api_info): - return processing_check_data('GLOBAL_VARIABLE', api_info) +def check_all_uppercase_hump(api_info, kind, parent_kind): + # 枚举值 + api_result_info_list = processing_check_data('ALL_UPPERCASE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_04.name) + return api_result_info_list -def check_file_name(file_path): +def check_file_name(file_info): api_result_info_list = [] - file_name = os.path.basename(file_path) + file_name = file_info['name'] result = re.match(CheckName['FILE_NAME'].value, file_name) if result is None: - error_info = ErrorMessage.TRANSLATION_UNIT.value.replace('$$', file_name) - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, error_info, '') - api_result_info.set_type(LogType.LOG_FILE.value) - api_result_info.set_file_name(file_path) - api_result_info.set_location(file_path) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info_list.append(api_result_info) + chck_output = CheckOutPut(os.path.join(file_info['gn_path'], file_info['name']), 0, + CheckErrorMessage.API_NAME_UNIVERSAL_14.name, + CheckErrorMessage.API_NAME_UNIVERSAL_14.value, file_name, 0) + api_result_info_list.append(chck_output) return api_result_info_list -def processing_check_data(function_type, api_info): +def processing_check_data(function_type, api_info, command): api_result_info_list = [] name = api_info['name'] result = re.match(CheckName[function_type].value, name) if result is None: - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, - ErrorMessage[api_info['kind']].value.replace('$$', name), name) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_type(LogType.LOG_API.value) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(api_info['location']['location_path']) - api_result_info_list.append(api_result_info) + chck_output = set_value_to_result(api_info, command) + api_result_info_list.append(chck_output) return api_result_info_list @@ -120,25 +151,35 @@ class CheckName(enum.Enum): ALL_UPPERCASE_HUMP = r'^[A-Z]+[0-9]*([\_][A-Z0-9]*)*$' GLOBAL_VARIABLE = r'^g_([a-z][A-Z0-9]*)*$' FILE_NAME = r'^[a-z]+[a-z0-9]+([\_][a-z0-9]+)*\.h$' + MACRO_DEFINITION = r'^[\_]*[A-Z]+[0-9]*([\_][A-Z0-9]*)*$' process_tag_function = { + # 函数 'FUNCTION_DECL': check_function_name, + # 结构体 'STRUCT_DECL': check_large_hump, + # 枚举 'ENUM_DECL': check_large_hump, + # 联合体 'UNION_DECL': check_large_hump, + # 变量 'VAR_DECL': check_variable_name, + # 参数 'PARM_DECL': check_small_hump, + # 结构体、联合体成员 'FIELD_DECL': check_small_hump, + # 宏定义 'MACRO_DEFINITION': check_macro_definition, + # 枚举值 'ENUM_CONSTANT_DECL': check_all_uppercase_hump, } -def check_ndk_name(api_info): +def check_api_name(api_info, parent_kind): api_result_info_list = [] kind = api_info['kind'] if kind not in process_tag_function.keys(): return api_result_info_list name_process = process_tag_function[kind] - return name_process(api_info) + return name_process(api_info, kind, parent_kind) diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index ad8ff44000f7ffb60a8f697bf0c4f33877d0fab1..1ca5cbcb4b21c2291f6b387626d57cbf919adfe4 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -128,18 +128,18 @@ def add_new_file(diff_file_path): if os.path.isdir(diff_file_path): add_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1)) + result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1), 1) for new_info in result_map.values(): - diff_info_list.extend(judgment_entrance(None, new_info)) + diff_info_list.extend(judgment_entrance(None, new_info, 1)) def del_old_file(diff_file_path): if os.path.isdir(diff_file_path): del_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0)) + result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0), 1) for old_info in result_map.values(): - diff_info_list.extend(judgment_entrance(old_info, None)) + diff_info_list.extend(judgment_entrance(old_info, None, 1)) def get_same_file_diff(target_file, old_file_list, new_file_list, old_dir, new_dir): @@ -176,9 +176,9 @@ def del_file(dir_path): if os.path.isdir(file_path): del_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0)) + result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0), 1) for old_info in result_map.values(): - diff_info_list.extend(judgment_entrance(old_info, None)) + diff_info_list.extend(judgment_entrance(old_info, None, 1)) def add_file(dir_path): @@ -190,19 +190,29 @@ def add_file(dir_path): if os.path.isdir(file_path): add_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1)) + result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1), 1) for new_info in result_map.values(): - diff_info_list.extend(judgment_entrance(None, new_info)) + diff_info_list.extend(judgment_entrance(None, new_info, 1)) -def parse_file_result(result): +def parse_file_result(result, data_type=0): + """ + Args: + result: *** + data_type(int): 数据处理类型。1-文件新增或删除;0-其他 + """ result_map = {} for root_node in result: - children_list = root_node['children'] - for children in children_list: - if children["name"] == '': - continue - result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) - del root_node['children'] + if data_type != 1: + parse_file_result_by_child(result_map, root_node) result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) return result_map + + +def parse_file_result_by_child(result_map, root_node): + children_list = root_node['children'] + for children in children_list: + if children["name"] == '': + continue + result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) + del root_node['children'] diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py index f9a94a7cee2ead5f1661873681543235f6ed81cf..dd5a1bab583924aa0bf26b2483dad9283a9b0c76 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py @@ -388,17 +388,23 @@ def process_variable_const(old, new): diff_var_or_con = [] if 'is_const' in old: if old['is_const']: # 处理常量 + process_constant_to_variable(old, new, diff_var_or_con) # 常量改变量 process_constant_name(old, new, diff_var_or_con) # 处理常量名 process_constant_type(old, new, diff_var_or_con) # 处理常量类型 process_constant_value(old, new, diff_var_or_con) # 处理常量值 else: # 处理变量 + process_variable_to_constant(old, new, diff_var_or_con) # 变量改常量 process_variable_name(old, new, diff_var_or_con) # 处理变量名 process_variable_type(old, new, diff_var_or_con) # 处理变量类型 process_variable_value(old, new, diff_var_or_con) # 处理变量值 return diff_var_or_con +def process_variable_to_constant(old, new, diff_variable_list): + if new['is_const']: + diff_info = wrap_diff_info(old, new, DiffInfo(DiffType.VARIABLE_CHANGE_TO_CONSTANT)) + diff_variable_list.append(diff_info) def process_variable_name(old, new, diff_variable_list): if old['name'] != new['name']: @@ -430,6 +436,10 @@ def process_variable_value(old, new, diff_variable_list): DiffInfo(DiffType.VARIABLE_VALUE_CHANGE)) diff_variable_list.append(diff_info) +def process_constant_to_variable(old, new, diff_constant_list): + if not new['is_const']: + diff_info = wrap_diff_info(old, new, DiffInfo(DiffType.CONSTANT_CHANGE_TO_VARIABLE)) + diff_constant_list.append(diff_info) def process_constant_name(old, new, diff_constant_list): if old['name'] != new['name']: @@ -510,15 +520,23 @@ process_data = { } -def judgment_entrance(old, new): +def judgment_entrance(old, new, data_type=0): + """ + Args: + old: *** + new: *** + data_type(int): 数据处理类型。1-文件新增或删除;0-其他 + """ diff_info_list = [] if old is None and new is None: return diff_info_list if old is None: - diff_info_list.append(wrap_diff_info(old, new, DiffInfo(DiffType.ADD_API))) + diff_type = DiffType.ADD_FILE if data_type == 1 else DiffType.ADD_API + diff_info_list.append(wrap_diff_info(old, new, DiffInfo(diff_type))) return diff_info_list if new is None: - diff_info_list.append(wrap_diff_info(old, new, DiffInfo(DiffType.REDUCE_API))) + diff_type = DiffType.REDUCE_FILE if data_type == 1 else DiffType.REDUCE_API + diff_info_list.append(wrap_diff_info(old, new, DiffInfo(diff_type))) return diff_info_list kind = new['kind'] diff_info_list.extend(process_comment_str(old, new)) diff --git a/build-tools/capi_parser/src/typedef/check/check.py b/build-tools/capi_parser/src/typedef/check/check.py index cca3ac40ccc7ba0685d3d9c8c84ecbbc837d341f..65eb13968b7e2465f0f78022f478946f64f62ac1 100644 --- a/build-tools/capi_parser/src/typedef/check/check.py +++ b/build-tools/capi_parser/src/typedef/check/check.py @@ -138,6 +138,7 @@ be reused please delete the extra tags.' ERROR_FILE_HAS_ONE_LOSE_OTHER = 'the file has the $$, but do not has the $$.' ERROR_FILE_LOSE_ONE = 'the file missing $$' ERROR_LOST_LABEL = 'JSDoc tag validity verification failed. Please confirm if the [$$] tag is missing' + FUNCTION_DECL = 'This name [$$] should use the big hump naming style or beginning with OH/OS,and \ using "_" segmentation.' STRUCT_DECL = 'This name [$$] should use the big hump naming style.' @@ -156,6 +157,122 @@ be reused please delete the extra tags.' TRANSLATION_UNIT = 'This name [$$] should be all lowercase, separated by underscores.' +class CheckErrorMessage(enum.Enum): + API_NAME_UNIVERSAL_01 = ('API check error of [naming errors]:The names of self-developed ' + 'functions in APIs must start with OH_ or OS_ or HMS_ and comply ' + 'with the large hump case format.') + API_NAME_UNIVERSAL_02 = ('API check error of [naming errors]:The names of constants in ' + 'APIs must be in uppercase and separated by underscores.') + API_NAME_UNIVERSAL_03 = ('API check error of [naming errors]:The naming of enumeration ' + 'types should follow the big hump rule.') + API_NAME_UNIVERSAL_04 = ('API check error of [naming errors]:The naming of enumeration ' + 'values should follow the all uppercase rule and separated by underscores.') + API_NAME_UNIVERSAL_05 = ('API check error of [naming errors]:The naming of struct should ' + 'follow the rules of the Great Hump.') + API_NAME_UNIVERSAL_06 = ('API check error of [naming errors]:The naming of members in the ' + 'structure should follow the small hump format.') + API_NAME_UNIVERSAL_07 = ('API check error of [naming errors]:The naming of the consortium ' + 'should follow the format of the large camel hump.') + API_NAME_UNIVERSAL_08 = ('API check error of [naming errors]:The naming of members in the ' + 'consortium should follow the small hump format.') + API_NAME_UNIVERSAL_09 = ('API check error of [naming errors]:The names of a global variable ' + 'must be prefixed with g_ in the small camel case format.') + API_NAME_UNIVERSAL_10 = ('API check error of [naming errors]:The naming of general functions ' + 'should follow the big hump format.') + API_NAME_UNIVERSAL_11 = ('API check error of [naming errors]:Function parameter names should ' + 'follow the small hump format.') + API_NAME_UNIVERSAL_12 = ('API check error of [naming errors]:Macro naming should follow all ' + 'uppercase format and separated by underscores.') + API_NAME_UNIVERSAL_13 = ('API check error of [naming errors]:Functional macro naming should ' + 'follow all uppercase format and separated by underscores.') + API_NAME_UNIVERSAL_14 = ('API check error of [naming errors]:The file name should be all ' + 'lowercase and separated by underscores.') + API_DOC_GLOBAL_01 = ('API check error of [api doc errors]:The [file] tag is repeat. Please ' + 'check the tag in file.') + API_DOC_GLOBAL_02 = ('API check error of [api doc errors]:The file has the [addtogroup] tag, ' + 'but do not has the [brief] tag.') + API_DOC_GLOBAL_03 = 'API check error of [api doc errors]:The file miss [file] tag.' + API_DOC_GLOBAL_04 = ('API check error of [api doc errors]:The [addtogroup] tag is repeat. ' + 'Please check the tag in file.') + API_DOC_GLOBAL_05 = ('API check error of [api doc errors]:The file has the [addtogroup] tag,' + 'but do not has the start tag [{].') + API_DOC_GLOBAL_06 = ('API check error of [api doc errors]:The [{] tag is not allowed to reuse ' + 'in Doc which has [addtogroup] tag.') + API_DOC_GLOBAL_07 = ('API check error of [api doc errors]:The file has the [addtogroup] tag, ' + 'but do not has the [library] tag.') + API_DOC_GLOBAL_08 = ('API check error of [api doc errors]:The file has the [addtogroup] tag, ' + 'but do not has the [syscap] tag.') + API_DOC_GLOBAL_09 = 'API check error of [api doc errors]:The file missing [addtogroup] tag.' + API_DOC_GLOBAL_10 = ('API check error of [api doc errors]:The file has the [addtogroup] tag,' + 'but do not has the end tag [}].') + API_DOC_GLOBAL_11 = ('API check error of [api doc errors]:The [addtogroup] tag value is empty,' + 'please supplement the default value.') + API_DOC_GLOBAL_12 = ('API check error of [api doc errors]:The [file] tag value is empty,please ' + 'supplement the default value.') + API_DOC_GLOBAL_13 = ('API check error of [api doc errors]:The [library] tag value must be end ' + 'with .so or .a, please check the usage method.') + API_DOC_GLOBAL_14 = ('API check error of [api doc errors]:The [{] tag is not allowed to used ' + 'in Doc which not the [addtogroup] tag,or used in the wrong place.'), + API_DOC_GLOBAL_15 = 'API check error of [api doc errors]:Non lowercase labels used in API Doc information.' + API_DOC_GLOBAL_16 = 'API check error of [api doc errors]:The name after the [library] tag should be in lowercase.' + API_DOC_GLOBAL_17 = ('API check error of [api doc errors]:The file has the [file] tag, but do ' + 'not has the [brief] tag.') + API_DOC_GLOBAL_18 = ('API check error of [api doc errors]:The file has the [file] tag, but do not ' + 'has the [library] tag.') + API_DOC_GLOBAL_19 = ('API check error of [api doc errors]:The file has the [file] tag, but do not ' + 'has the [syscap] tag.') + API_DOC_GLOBAL_20 = ('API check error of [api doc errors]:APIDoc tag validity verification failed. ' + 'Please confirm if the [since] tag is missing.') + API_DOC_GLOBAL_21 = ('API check error of [api doc errors]:The validity verification of the APIDoc tag ' + 'failed. The [}] tag is not allowed to be reused please delete the extra tags') + API_DOC_FUNCTION_01 = ('API check error of [api doc errors]:The count of the [param] tag is wrong.' + 'Please check the parameters and Doc.') + API_DOC_FUNCTION_02 = ('API check error of [api doc errors]:The value of the [$$] [param] tag is ' + 'incorrect. Please check if it matches the [&&] parameter name.') + API_DOC_UNIVERSAL_01 = ('API check error of [api doc errors]:The [deprecated] tag value is incorrect.' + 'Please check the usage method.') + API_DOC_UNIVERSAL_02 = ('API check error of [api doc errors]:The [permission] tag value is incorrect. ' + 'Please check if the permission field has been configured or update the ' + 'configuration file.') + API_DOC_UNIVERSAL_03 = ('API check error of [api doc errors]:The [since] tag value is empty.Please ' + 'supplement the default value.') + API_DOC_UNIVERSAL_04 = ('API check error of [api doc errors]:The [since] tag value is incorrect.' + 'Please check if the tag value is a numerical value or version number(number).') + API_DOC_UNIVERSAL_05 = ('API check error of [api doc errors]:The [syscap] tag value is empty.' + 'Please supplement the default value.') + API_DOC_UNIVERSAL_06 = ('API check error of [api doc errors]:The [syscap] tag value is incorrect.' + 'Please check if the syscap field is configured.') + + +check_command_message = [ + member.name for name_tool, + member in CheckErrorMessage.__members__.items() +] + + +class CheckOutPut: + analyzerName = 'apiengine' + buggyFilePath = '' + codeContextStartLine = -1 + defectLevel = 0 + defectType = '' + description = '' + language = 'c' + mainBuggyCode = '' + mainBuggyLine = -1 + + def __init__(self, buggy_file_path, code_context_start_line, defect_type, description, + main_buggy_code, main_buggy_line): + self.buggyFilePath = buggy_file_path + self.codeContextStartLine = code_context_start_line + self.defectLevel = 0 + self.defectType = defect_type + self.description = description + self.language = 'c' + self.mainBuggyCode = main_buggy_code + self.mainBuggyLine = main_buggy_line + + class OutputTxt: id = -1 level = -1 @@ -325,6 +442,9 @@ class DocInfo: class FileDocInfo: is_in_group_tag = False group_name = None + group_brief = None + group_library = None + group_syscap = None has_group_start = False has_group_end = False is_in_file_tag = False diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index 1cbd015fcc79f7cffe0953b374abeef3c011a1bb..82133f4fd23fad7fce0ff7efb37f36e22c14ba7b 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -43,6 +43,8 @@ class TAGS(enum.Enum): class DiffType(enum.Enum): DEFAULT = '' + ADD_FILE = 'add file' + REDUCE_FILE = 'delete file' ADD_API = 'add api' REDUCE_API = 'delete api' ADD_DOC = 'add doc' @@ -83,11 +85,13 @@ class DiffType(enum.Enum): VARIABLE_TYPE_CHANGE = 'change variable type' VARIABLE_VALUE_CHANGE = 'change variable value' VARIABLE_CHANGE_CONST = 'Change variable to constant' + VARIABLE_CHANGE_TO_CONSTANT = 'change variable to constant' CONSTANT_NAME_CHANGE = 'change constant name' CONSTANT_TYPE_CHANGE = 'change constant type' CONSTANT_VALUE_CHANGE = 'change constant value' CONST_CHANGE_VARIABLE = 'Change constant to variable' + CONSTANT_CHANGE_TO_VARIABLE = 'change constant to variable' TYPEDEF_NAME_TYPE_CHANGE = 'change typedef name type' diff --git a/build-tools/capi_parser/src/utils/constants.py b/build-tools/capi_parser/src/utils/constants.py index aed1044ee046f6afb37109f39bdb0c85750a5ea4..080f11331ac28a93fd2454258d7379f3f4dc20b0 100644 --- a/build-tools/capi_parser/src/utils/constants.py +++ b/build-tools/capi_parser/src/utils/constants.py @@ -19,7 +19,7 @@ import enum class StringConstant(enum.Enum): - LIB_CLG_PATH = r'/home/tools/llvm/lib/libclang.so' # 共享库 + LIB_CLG_PATH = r'C:\Program Files\LLVM\bin\libclang.dll' # 共享库 FUNK_NAME = "ohos_ndk_headers" REPLACE_WAREHOUSE = '\\interface_sdk_c\\interface_sdk_c' # 拉到本地仓路径(去掉磁盘) # 拉到本地仓的三方库绝对路径 @@ -31,8 +31,6 @@ class StringConstant(enum.Enum): SELF_INCLUDE_NEW = r'.\sysroot\self_include_files_new' SYSROOT = r'.\sysroot' RESULT_HEAD_NAME = "result_total.xlsx" - PARSER_DIRECT_EXCEL_NAME = 'parser_direct_data.xlsx' - FILE_LEVEL_API_DATA = r'.\file_api_json.json' class RegularExpressions(enum.Enum): diff --git a/filemanagement/environment/include/oh_environment.h b/filemanagement/environment/include/oh_environment.h index 5621fd7a5baa137331b19cf0a1460abe9fe401d3..d6f230ce8b7483dbc01d652af4d5274006b2cfc2 100644 --- a/filemanagement/environment/include/oh_environment.h +++ b/filemanagement/environment/include/oh_environment.h @@ -43,6 +43,10 @@ extern "C" { * @permission ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. + * {@link PERMISSION_ERROR} 201 - Permission verification failed. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_Environment_GetUserDownloadDir(char **result); @@ -53,6 +57,10 @@ FileManagement_ErrCode OH_Environment_GetUserDownloadDir(char **result); * @permission ohos.permission.READ_WRITE_DESKTOP_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. + * {@link PERMISSION_ERROR} 201 - Permission verification failed. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_Environment_GetUserDesktopDir(char **result); @@ -63,6 +71,10 @@ FileManagement_ErrCode OH_Environment_GetUserDesktopDir(char **result); * @permission ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. + * {@link PERMISSION_ERROR} 201 - Permission verification failed. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_Environment_GetUserDocumentDir(char **result); diff --git a/filemanagement/fileio/include/oh_fileio.h b/filemanagement/fileio/include/oh_fileio.h index 65970bdca0cd46c73a65b5bf25409a029929f059..1b57f82f05e74cf4d6924086bd0f4d196e01daf1 100644 --- a/filemanagement/fileio/include/oh_fileio.h +++ b/filemanagement/fileio/include/oh_fileio.h @@ -63,6 +63,9 @@ typedef enum FileIO_FileLocation { * @param uriLength Input the length of the uri. * @param location Output the result of file location. * @return Return the status code of the execution. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link E_NONET} 13900002 - No such file or directory. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_FileIO_GetFileLocation(char *uri, int uriLength, diff --git a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h index 8cf8e8802b8df08dc27ba0040f5c8a1187cf148a..1af5ad345630c9ebec5030ec8468059c5cd49eeb 100644 --- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h @@ -196,6 +196,31 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Dra OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Image*, OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY, const OH_Drawing_SamplingOptions*, const OH_Drawing_Matrix*); +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates a conical gradient given two circles. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param startPt Indicates the center of the start circle for the gradient. + * @param startRadius Indicates the radius of the start circle for this gradient. + * @param endPt Indicates the center of the start circle for the gradient. + * @param endRadius Indicates the radius of the start circle for this gradient. + * @param colors Indicates the colors to be distributed between the two points. + * @param pos Indicates the relative position of each corresponding color in the colors array. + * @param size Indicates the number of colors and pos. + * @param OH_Drawing_TileMode Indicates the tile mode. + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object, + which represents the local matrix of the created OH_Drawing_ShaderEffect object. + If matrix is nullptr, defaults to the identity matrix. + * @return Returns the pointer to the OH_Drawing_ShaderEffect object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is any of startPt, endPt, colors and pos is nullptr. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(const OH_Drawing_Point2D* startPt, + float startRadius, const OH_Drawing_Point2D* endPt, float endRadius, const uint32_t* colors, const float* pos, + uint32_t size, OH_Drawing_TileMode, const OH_Drawing_Matrix*); + /** * @brief Destroys an OH_Drawing_ShaderEffect object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index ef929bf417124033715b1f037fe22a258b593ee0..ac33798bdf50b8ce2c1fb1ea005604b8884d38f4 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -977,6 +977,21 @@ void OH_Drawing_TypographyLayout(OH_Drawing_Typography*, double /* maxWidth */); void OH_Drawing_TypographyPaint(OH_Drawing_Typography*, OH_Drawing_Canvas*, double /* potisionX */, double /* potisionY */); +/** + * @brief Paints path text on the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Typography Indicates the pointer to an OH_Drawing_Typography object. + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Path Indicates path information. + * @param double Indicates the distance along the path to add to the text's starting position. + * @param double Indicates the distance above(-) or below(+) the path to position the text. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TypographyPaintOnPath(OH_Drawing_Typography*, OH_Drawing_Canvas*, OH_Drawing_Path*, + double /* hOffset */, double /* vOffset */); + /** * @brief Gets the max width. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index def9cec8cc3437144df84fbefbbdd15d2f5f31c6..8d8a9a57e5c546dec5b409d228ad92aaa4954511 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -583,6 +583,10 @@ "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateImageShader" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ShaderEffectCreateTwoPointConicalGradient" + }, { "name": "OH_Drawing_ShaderEffectDestroy" }, { "first_introduced": "12", @@ -632,6 +636,10 @@ { "name": "OH_Drawing_DestroyTypography" }, { "name": "OH_Drawing_TypographyLayout" }, { "name": "OH_Drawing_TypographyPaint" }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyPaintOnPath" + }, { "name": "OH_Drawing_TypographyGetMaxWidth" }, { "name": "OH_Drawing_TypographyGetHeight" }, { "name": "OH_Drawing_TypographyGetLongestLine" }, diff --git a/graphic/graphic_2d/native_image/libnative_image.ndk.json b/graphic/graphic_2d/native_image/libnative_image.ndk.json index 45bb3093e470bc024fe79cce9a962fa8e6ed2d69..fbc8a27c01f860937c342084c7510c5cefa0e878 100644 --- a/graphic/graphic_2d/native_image/libnative_image.ndk.json +++ b/graphic/graphic_2d/native_image/libnative_image.ndk.json @@ -9,5 +9,6 @@ { "name": "OH_NativeImage_GetSurfaceId" }, { "name": "OH_NativeImage_SetOnFrameAvailableListener" }, { "name": "OH_NativeImage_UnsetOnFrameAvailableListener" }, - { "name": "OH_NativeImage_Destroy" } + { "name": "OH_NativeImage_Destroy" }, + { "name": "OH_NativeImage_GetTransformMatrixV2" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_image/native_image.h b/graphic/graphic_2d/native_image/native_image.h index b344a332cc9e33aa21b19bcfebc898b2363433f9..77577ff3f6d342e5cee89f6568192dff2a487b08 100644 --- a/graphic/graphic_2d/native_image/native_image.h +++ b/graphic/graphic_2d/native_image/native_image.h @@ -201,6 +201,19 @@ int32_t OH_NativeImage_UnsetOnFrameAvailableListener(OH_NativeImage* image); */ void OH_NativeImage_Destroy(OH_NativeImage** image); +/** + * @brief Obtains the transform matrix of the texture image by producer transform type.\n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeImage + * @param image Indicates the pointer to a OH_NativeImage instance. + * @param matrix Indicates the retrieved 4*4 transform matrix . + * @return 0 - Success. + * 40001000 - image is NULL. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeImage_GetTransformMatrixV2(OH_NativeImage* image, float matrix[16]); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_window/external_window.h b/graphic/graphic_2d/native_window/external_window.h index db6607b5f7f0719036c85dcc6a83c5eb309fa3cd..f851a3fee9bbd0af38687a9459e741223257a671 100644 --- a/graphic/graphic_2d/native_window/external_window.h +++ b/graphic/graphic_2d/native_window/external_window.h @@ -658,6 +658,24 @@ int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHS * @version 1.0 */ void OH_NativeWindow_SetBufferHold(OHNativeWindow *window); + +/** + * @brief Get the last flushed OHNativeWindowBuffer from an OHNativeWindow instance. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to an OHNativeWindow instance. + * @param buffer Indicates the pointer to an OHNativeWindowBuffer pointer. + * @param fenceFd Indicates the pointer to a file descriptor handle. + * @param matrix Indicates the retrieved 4*4 transform matrix. + * @return 0 - Success. + * 40001000 - window is NULL or buffer is NULL or fenceFd is NULL. + * 41207000 - buffer state is wrong. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer, + int *fenceFd, float matrix[16]); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_window/libnative_window.ndk.json b/graphic/graphic_2d/native_window/libnative_window.ndk.json index 668400ec62fe74cf45b78661410af4a7f0da5d9c..5707571dabdfb2206e27af8c288131ac6a4f1f5e 100644 --- a/graphic/graphic_2d/native_window/libnative_window.ndk.json +++ b/graphic/graphic_2d/native_window/libnative_window.ndk.json @@ -25,5 +25,6 @@ { "name": "OH_NativeWindow_CreateNativeWindowFromSurfaceId"}, { "name": "OH_NativeWindow_NativeWindowAttachBuffer" }, { "name": "OH_NativeWindow_NativeWindowDetachBuffer" }, - { "name": "OH_NativeWindow_SetBufferHold" } + { "name": "OH_NativeWindow_SetBufferHold" }, + { "name": "OH_NativeWindow_GetLastFlushedBufferV2" } ] \ No newline at end of file diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index f4b77d3cfa9e8644c4b071805cfab6d77977d7e1..c47def15b5a9291e74d9aa48a716b9466faffac0 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -238,6 +238,12 @@ typedef enum { * @since 10 */ AUDIOSTREAM_USAGE_NAVIGATION = 13, + /** + * Video call usage. + * + * @since 12 + */ + AUDIOSTREAM_USAGE_VIDEO_COMMUNICATION = 17, } OH_AudioStream_Usage; /** diff --git a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json index 2f11d92769bbffc922efe4ab232c7426da1ddcaa..89b3bac2f99e3039bcf914d804dca9960a36d786 100644 --- a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json +++ b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json @@ -58,5 +58,9 @@ { "first_introduced": "10", "name": "OH_AudioDecoder_IsValid" + }, + { + "first_introduced": "12", + "name": "OH_AudioDecoder_SetDecryptionConfig" } ] diff --git a/multimedia/av_codec/avcencinfo/BUILD.gn b/multimedia/av_codec/avcencinfo/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a1f43c09aecf7e5ce9e495673ad9e0a484ec5e49 --- /dev/null +++ b/multimedia/av_codec/avcencinfo/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_avcencinfo_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ "../native_cencinfo.h" ] +} + +ohos_ndk_library("libnative_media_avcencinfo") { + ndk_description_file = "./libnative_media_avcencinfo.ndk.json" + min_compact_version = "12" + output_name = "native_media_avcencinfo" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Spliter" + system_capability_headers = + [ "multimedia/player_framework/native_cencinfo.h" ] +} diff --git a/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json b/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..be84ad9ae96c279090b4cd56d8f141199e1d781f --- /dev/null +++ b/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json @@ -0,0 +1,30 @@ +[ + { + "first_introduced": "12", + "name": "OH_AVCencInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetAlgo" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetKeyIdAndIv" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetSubsampleInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetMode" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetAVBuffer" + } +] diff --git a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json index 2a3cb212f6ff277c6801502b05a573e86a028c25..dcddf3df46b0da2831e34e107322d476701bc311 100644 --- a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json +++ b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json @@ -34,5 +34,9 @@ { "first_introduced": "11", "name": "OH_AVDemuxer_GetMediaKeySystemInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback" } ] diff --git a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json index 5763f34a7c5eb7923cf5d623188e2c645e48de1f..1ccda013648a96dc49b6ae6e7a53bb32600237f8 100644 --- a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json +++ b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json @@ -59,6 +59,10 @@ "first_introduced": "11", "name": "OH_AVCODEC_MIMETYPE_AUDIO_G711MU" }, + { + "first_introduced": "12", + "name": "OH_AVCODEC_MIMETYPE_AUDIO_LBVC" + }, { "first_introduced": "12", "name": "OH_AVCODEC_MIMETYPE_AUDIO_APE" diff --git a/multimedia/av_codec/native_avcodec_audiodecoder.h b/multimedia/av_codec/native_avcodec_audiodecoder.h index e834aa233de12015f84951bee3363bebd4487aff..6e4d659844f4d9e2356033dba05cd305a4c3ae88 100644 --- a/multimedia/av_codec/native_avcodec_audiodecoder.h +++ b/multimedia/av_codec/native_avcodec_audiodecoder.h @@ -24,6 +24,13 @@ extern "C" { #endif +/** + * @brief MediaKeySession field. + * @since 12 + * @version 1.0 + */ +typedef struct MediaKeySession MediaKeySession; + /** * @brief Creates an audio decoder instance from the mime type, which is recommended in most cases. * @syscap SystemCapability.Multimedia.Media.AudioDecoder @@ -245,6 +252,20 @@ OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); */ OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid); +/** + * @brief Set decryption info. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param mediaKeySession A media key session instance with decryption function. + * @param secureAudio Require secure decoder or not. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AudioDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, + bool secureAudio); + #ifdef __cplusplus } #endif diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 164e593d9ac1548d44cb6cfb2cd1ef72f855b2b8..ff17fd55127b53b70ef121222e98c10931830343 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -218,6 +218,14 @@ extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB; extern const char *OH_AVCODEC_MIMETYPE_AUDIO_OPUS; extern const char *OH_AVCODEC_MIMETYPE_AUDIO_G711MU; +/** + * @brief Enumerates the MIME type of audio low bitrate voice codec. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 12 + */ +extern const char *OH_AVCODEC_MIMETYPE_AUDIO_LBVC; + /** * @brief Enumerates the MIME type of audio ape codec. * @@ -594,6 +602,16 @@ typedef enum OH_AVOutputFormat { AV_OUTPUT_FORMAT_DEFAULT = 0, AV_OUTPUT_FORMAT_MPEG_4 = 2, AV_OUTPUT_FORMAT_M4A = 6, + /** + * The muxer output amr file format. + * @since 12 + */ + AV_OUTPUT_FORMAT_AMR = 8, + /** + * The muxer output mp3 file format. + * @since 12 + */ + AV_OUTPUT_FORMAT_MP3 = 9, } OH_AVOutputFormat; /** diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 84634687e987dbfa241f494a726351ff3fa3bbdf..96717cf969da97a8cba0fa9cd51a01f6d8d09a8b 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -28,6 +28,16 @@ typedef struct OH_AVDemuxer OH_AVDemuxer; typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); +/** + * @brief Call back will be invoked when updating DRM information. + * @param demuxer Player OH_AVDemuxer. + * @param mediaKeySystemInfo DRM information. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef void (*Demuxer_MediaKeySystemInfoCallback)(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfo *mediaKeySystemInfo); + /** * @brief Creates an OH_AVDemuxer instance for getting samples from source. * Free the resources of the instance by calling OH_AVDemuxer_Destroy. @@ -140,6 +150,19 @@ OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVErrCode OH_AVDemuxer_SetMediaKeySystemInfoCallback(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfoCallback callback); +/** + * @brief Method to set player media key system info callback. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance + * @param callback object pointer. + * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback(OH_AVDemuxer *demuxer, + Demuxer_MediaKeySystemInfoCallback callback); + /** * @brief Obtains media key system info to create media key session. * @syscap SystemCapability.Multimedia.Media.Spliter diff --git a/multimedia/av_codec/native_avsource.h b/multimedia/av_codec/native_avsource.h index a211d69505c24d16544741600e1b25bb0bc90293..2aa0d8d24ef2bac184e1ffec80f2a3e798ead7e3 100644 --- a/multimedia/av_codec/native_avsource.h +++ b/multimedia/av_codec/native_avsource.h @@ -31,7 +31,9 @@ typedef struct OH_AVSource OH_AVSource; * @brief Creates an OH_AVSource instance that models the media with dataSource. * @syscap SystemCapability.Multimedia.Media.Spliter * @param dataSource An Struct for a remote media resource. - * @return Returns a pointer to an OH_AVSource instance + * @return Returns a pointer to an OH_AVSource instance if the execution is successful, otherwise returns nullptr. + * Possible failure causes: 1. dataSource is nullptr. 2. dataSource->size == 0. 3. set data source failed. + * 4. out of memory. 5. demuxer engine is nullptr. * @since 12 */ OH_AVSource *OH_AVSource_CreateWithDataSource(OH_AVDataSource *dataSource); diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..5accda339110384f9e37e4065a2bbcc42344edd6 --- /dev/null +++ b/multimedia/av_codec/native_cencinfo.h @@ -0,0 +1,242 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Multimedia_Drm + * @{ + * + * @brief This feature enables third-party applications to implement the + * media decapsulation and demultiplexing functions by themselves instead + * of using the functions provided by the system. + * + * After the DRM instance and session are created, the decryption interface + * provided by the DRM can be invoked for decryption. The decryption parameter + * structure defines the transmission format of decryption parameters. + * + * @since 12 + */ + +/** + * @file native_cencinfo.h + * + * @brief Provides a unified entry for the native module APIs. + * + * @library libnative_media_avcencinfo.so + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 12 + */ + +#ifndef NATIVE_AVCENCINFO_H +#define NATIVE_AVCENCINFO_H + +#include +#include "native_averrors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief AVBuffer Structure. + * @since 12 + * @version 1.0 + */ +typedef struct OH_AVBuffer OH_AVBuffer; +/** + * @brief AVCencInfo Structure. + * @since 12 + * @version 1.0 + */ +typedef struct OH_AVCencInfo OH_AVCencInfo; +/** + * @brief Key id size. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_ID_SIZE 16 +/** + * @brief Iv size. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_IV_SIZE 16 +/** + * @brief Max subsample num. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_MAX_SUB_SAMPLE_NUM 64 + +/** + * @brief Drm cenc algorithm type. + * @since 12 + * @version 1.0 + */ +typedef enum DrmCencAlgorithm { + /** + * Unencrypted. + */ + DRM_ALG_CENC_UNENCRYPTED = 0x0, + /** + * Aes ctr. + */ + DRM_ALG_CENC_AES_CTR = 0x1, + /** + * Aes wv. + */ + DRM_ALG_CENC_AES_WV = 0x2, + /** + * Aes cbc. + */ + DRM_ALG_CENC_AES_CBC = 0x3, + /** + * Sm4 cbc. + */ + DRM_ALG_CENC_SM4_CBC = 0x4, + /** + * Sm4 ctr. + */ + DRM_ALG_CENC_SM4_CTR = 0x5 +} DrmCencAlgorithm; + +/** + * @brief Mode of cend info like set or not. + * @since 12 + * @version 1.0 + */ +typedef enum DrmCencInfoMode { + /* key/iv/subsample set. */ + DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET = 0x0, + /* key/iv/subsample not set. */ + DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET = 0x1 +} DrmCencInfoMode; + +/** + * @brief Subsample info of media. + * @since 12 + * @version 1.0 + */ +typedef struct DrmSubsample { + /* Clear header len. */ + uint32_t clearHeaderLen; + /* Payload Len. */ + uint32_t payLoadLen; +} DrmSubsample; + +/** + * @brief Creates an OH_AVCencInfo instance for setting cencinfo. + * + * Free the resources of the instance by calling OH_AVCencInfo_Destory. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @return Returns a pointer to an OH_AVCencInfo instance + * @since 12 + * @version 1.0 + */ +OH_AVCencInfo *OH_AVCencInfo_Create(); + +/** + * @brief Destroy the OH_AVCencInfo instance and free the internal resources. + * + * The same instance can only be destroyed once. The destroyed instance + * should not be used before it is created again. It is recommended setting + * the instance pointer to NULL right after the instance is destroyed successfully. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo); + +/** + * @brief Method to set algo of cencinfo. + * + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param algo Cenc algo. + * @return Returns {@link AV_ERR_OK} if the algo is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetAlgorithm(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo); + +/** + * @brief Method to set key id and iv of cencinfo. + * + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param keyId Key id. + * @param keyIdLen Key id len. + * @param iv Iv. + * @param ivLen Iv len. + * @return Returns {@link AV_ERR_OK} if the key id and iv is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId, + uint32_t keyIdLen, uint8_t *iv, uint32_t ivLen); + +/** + * @brief Method to set subsample info of cencinfo. + * + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param encryptedBlockCount Number of encrypted blocks. + * @param skippedBlockCount Number of skip(clear) blocks. + * @param firstEncryptedOffset Offset of first encrypted payload. + * @param subsampleCount Subsample num. + * @param subsamples Subsample info + * @return Returns {@link AV_ERR_OK} if the subsample info is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptedBlockCount, + uint32_t skippedBlockCount, uint32_t firstEncryptedOffset, uint32_t subsampleCount, DrmSubsample *subsamples); + +/** + * @brief Method to set mode of cencinfo. + * + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param mode Cenc mode, indicate whether key/iv/subsample set or not. + * @return Returns {@link AV_ERR_OK} if the mode is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetMode(OH_AVCencInfo *cencInfo, enum DrmCencInfoMode mode); + +/** + * @brief Method to attach cencinfo to AVBuffer. + * + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param buffer AVBuffer to attach cencinfo. + * @return Returns {@link AV_ERR_OK} if the cencinfo is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetAVBuffer(OH_AVCencInfo *cencInfo, OH_AVBuffer *buffer); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVCENCINFO_H diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 41e94c3abad1fd20c7e37737c20a4c2a78b2f249..0e453e4d5b3fbae7c6a4ecacf67c026dfcd97746 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -111,10 +111,6 @@ "first_introduced": "11", "name": "OH_MediaKeySession_RequireSecureDecoderModule" }, - { - "first_introduced": "11", - "name": "OH_MediaKeySession_SetMediaKeySessionCallback" - }, { "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" @@ -122,5 +118,13 @@ { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySystem_SetCallback" } ] \ No newline at end of file diff --git a/multimedia/drm_framework/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h index 999aa04e1f36e8364863d01a41f88b92d5c3ee40..8394da5da077133b8a18f2f7ab5ed701c9c89528 100644 --- a/multimedia/drm_framework/native_mediakeysession.h +++ b/multimedia/drm_framework/native_mediakeysession.h @@ -86,6 +86,48 @@ typedef struct MediaKeySession_Callback { MediaKeySession_KeyChangeCallback keyChangeCallback; } MediaKeySession_Callback; +/** + * @brief Call back will be invoked when event triggers. + * @param mediaKeySessoin MediaKeySession instance. + * @param eventType Event type. + * @param info Event info gotten from media key session. + * @param infoLen Event info len. + * @param extra Extra info gotten from media key session. + * @return Drm_ErrCode. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySession_EventCallback)(MediaKeySession *mediaKeySessoin, DRM_EventType eventType, + uint8_t *info, int32_t infoLen, char *extra); + +/** + * @brief Call back will be invoked when key changes. + * @param mediaKeySessoin MediaKeySession instance. + * @param keysInfo Key info gotten from media key system. + * @param newKeysAvailable Whether new keys available. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySession_KeyChangeCallback)(MediaKeySession *mediaKeySessoin, DRM_KeysInfo *keysInfo, + bool newKeysAvailable); + +/** + * @brief MediaKeySession_Callback struct, used to listen event like key expired and key change etc.. + * @since 12 + * @version 1.0 + */ +typedef struct OH_MediaKeySession_Callback { + /** + * Normal event callback like key expired etc.. + */ + OH_MediaKeySession_EventCallback eventCallback; + /** + * Key change callback for keys change event. + */ + OH_MediaKeySession_KeyChangeCallback keyChangeCallback; +} OH_MediaKeySession_Callback; + /** * @brief Generate media key request. * @param mediaKeySession Media key session instance. @@ -208,6 +250,17 @@ Drm_ErrCode OH_MediaKeySession_RequireSecureDecoderModule(MediaKeySession *media Drm_ErrCode OH_MediaKeySession_SetMediaKeySessionCallback(MediaKeySession *mediaKeySessoin, MediaKeySession_Callback *callback); +/** + * @brief Set media key session event callback. + * @param mediaKeySession Media key session instance. + * @param callback Callback to be set to the media key session. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySession_SetCallback(MediaKeySession *mediaKeySessoin, + OH_MediaKeySession_Callback *callback); + /** * @brief Release the resource before the session gonna be unused. * @param mediaKeySession Media key session instance. diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 88f27fdf9aedd66eb6825773d6835220fb9256f1..9f84618f05a62af6514cca4b5ec712f8716068f9 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -62,6 +62,40 @@ extern "C" { typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra); +/** + * @brief Call back will be invoked when event triggers. + * @param mediaKeySystem MediaKeySystem instance. + * @param eventType Event type. + * @param info Event info gotten from media key system. + * @param infoLen Event info len. + * @param extra Extra info gotten from media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySystem_Callback)(MediaKeySystem *mediaKeySystem, DRM_EventType eventType, + uint8_t *info, int32_t infoLen, char *extra); + +/** + * @brief Set media key system event callback. + * @param mediaKeySystem Media key system instance. + * @param callback Callback to be set to the media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback); + +/** + * @brief Acquire supported media key systems' name and uuid. + * @param descs Array used to save media key systems' name and uuid. + * @param count Used to indicate count of struct DRM_MediaKeySystemDescription. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); + /** * @brief Query if media key system is supported. * @param name Used to point a Digital Right Management solution. @@ -273,15 +307,6 @@ Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySyste */ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); -/** - * @brief Acquire supported media key systems' name and uuid. - * @param descs Array used to save media key systems' name and uuid. - * @param count Used to indicate count of struct DRM_MediaKeySystemDescription. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. - * @since 12 - * @version 1.0 - */ -Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); #ifdef __cplusplus } diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index a567e46151cc279c9c49300171ce17a65036aa57..c60eac8b37abf32b0b528765f7662a2ab4a417a0 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -1258,6 +1258,15 @@ static const char *OHOS_IMAGE_PROPERTY_SCENE_POINTER = "HwMnoteScenePointer"; * @since 12 */ static const char *OHOS_IMAGE_PROPERTY_SCENE_VERSION = "HwMnoteSceneVersion"; + +/** + * @brief Gif Loop Count + * It is used in {@link OH_ImageSource_GetImageProperty}. + * If infinite loop returns 0, other values represent the number of loops + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GIF_LOOP_COUNT = "GIFLoopCount"; #ifdef __cplusplus }; #endif diff --git a/multimedia/media_foundation/native_avbuffer.h b/multimedia/media_foundation/native_avbuffer.h index 19ec2be468ca77e35aa52ca8f73ce522630f3069..088750f0578ab0ff72293cc20d7fd377bd48cb2d 100644 --- a/multimedia/media_foundation/native_avbuffer.h +++ b/multimedia/media_foundation/native_avbuffer.h @@ -33,7 +33,9 @@ typedef struct OH_NativeBuffer OH_NativeBuffer; * to by the return value * needs to be manually released by {@link OH_AVBuffer_Destroy}. * @syscap SystemCapability.Multimedia.Media.Core * @param capacity the buffer's capacity, bytes - * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr + * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr. + * Possible failure causes: 1. capacity <= 0. 2. create allocator failed. 3. create OH_AVBuffer failed. + * 4. created buffer memory is nullptr. 5. created buffer memory's addr is nullptr. 6. failed to new OH_AVBuffer. * @since 11 */ OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); @@ -42,8 +44,10 @@ OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); * @brief Clear the internal resources of the buffer and destroy the buffer instance. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr or buffer's magic error. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if input buffer is not user created. * @since 11 */ OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); @@ -54,8 +58,10 @@ OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to * {@link OH_AVCodecBufferAttr} - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, + * input buffer's buffer is nulllptr or attr is nullptr. * @since 11 */ OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr); @@ -66,8 +72,10 @@ OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to * {@link OH_AVCodecBufferAttr} - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, + * input buffer's buffer is nulllptr, attr is nullptr, the size or offset of input buffer's memory is invalid. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr); @@ -78,7 +86,8 @@ OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBuff * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful, - * otherwise returns nullptr + * otherwise returns nullptr. Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's meta is nullptr. * @since 11 */ OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); @@ -88,8 +97,10 @@ OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param format Encapsulate OH_AVFormat structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, + * input buffer's buffer is nulllptr, input format is nullptr, buffer's magic error, or input meta is nullptr. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); @@ -99,6 +110,8 @@ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *fo * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return the buffer's virtual address if the buffer is valid, otherwise nullptr + * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. * @since 11 */ uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); @@ -108,6 +121,8 @@ uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return the buffer's capacity if the buffer is valid, otherwise -1 + * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. * @since 11 */ int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); @@ -117,8 +132,9 @@ int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); * instance pointed to by the return value * needs to be manually released by {@link OH_NativeBuffer_Unreference}. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, - * otherwise returns nullptr + * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, otherwise returns nullptr + * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. 5. surfaceBuffer is nullptr. * @since 11 */ OH_NativeBuffer *OH_AVBuffer_GetNativeBuffer(OH_AVBuffer *buffer); diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index eb2ad2039021e031e55870fe3e6062f940750e2a..19d2ca4366db511acab9982c8c4203f9d3351afa 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -27,54 +27,56 @@ extern "C" { */ typedef enum OH_AVErrCode { /** - * the operation completed successfully. + * @error the operation completed successfully. */ AV_ERR_OK = 0, /** - * no memory. + * @error no memory. */ AV_ERR_NO_MEMORY = 1, /** - * opertation not be permitted. + * @error opertation not be permitted. */ AV_ERR_OPERATE_NOT_PERMIT = 2, /** - * invalid argument. + * @error invalid argument. */ AV_ERR_INVALID_VAL = 3, /** - * IO error. + * @error IO error. */ AV_ERR_IO = 4, /** - * network timeout. + * @error network timeout. */ AV_ERR_TIMEOUT = 5, /** - * unknown error. + * @error unknown error. */ AV_ERR_UNKNOWN = 6, /** - * media service died. + * @error media service died. */ AV_ERR_SERVICE_DIED = 7, /** - * the state is not support this operation. + * @error the state is not support this operation. */ AV_ERR_INVALID_STATE = 8, /** - * unsupport interface. + * @error unsupport interface. */ AV_ERR_UNSUPPORT = 9, /** - * extend err start. + * @error extend err start. */ AV_ERR_EXTEND_START = 100, - /** drm error base. + /** + * @error drm error base. * @since 12 */ AV_ERR_DRM_BASE = 200, - /** drm decypt failed. + /** + * @error drm decypt failed. * @since 12 */ AV_ERR_DRM_DECRYPT_FAILED = 201, diff --git a/multimedia/media_foundation/native_avformat.h b/multimedia/media_foundation/native_avformat.h index 4335cee3370160b09cf5cf5d9b866ed699bc82c7..12aa1a1d459c580fe3a381e9b029958f9340a787 100644 --- a/multimedia/media_foundation/native_avformat.h +++ b/multimedia/media_foundation/native_avformat.h @@ -70,7 +70,8 @@ struct OH_AVFormat *OH_AVFormat_Create(void); * @param mimeType mime type * @param sampleRate sample rate * @param channelCount channel count - * @return Returns a pointer to an OH_AVFormat instance + * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise nullptr + * Possible failure causes: 1. mimeType is nullptr. 2. new format is nullptr. * @since 10 * @version 1.0 */ @@ -84,7 +85,8 @@ struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType, * @param mimeType mime type * @param width width * @param height height - * @return Returns a pointer to an OH_AVFormat instance + * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise nullptr + * Possible failure causes: 1. mimeType is nullptr. 2. new format is nullptr. * @since 10 * @version 1.0 */ @@ -108,6 +110,7 @@ void OH_AVFormat_Destroy(struct OH_AVFormat *format); * @param to OH_AVFormat handle pointer to receive data * @param from pointer to the OH_AVFormat handle of the copied data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. * @since 9 * @version 1.0 */ @@ -120,6 +123,7 @@ bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from); * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -132,6 +136,7 @@ bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_ * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -144,6 +149,7 @@ bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64 * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -156,6 +162,7 @@ bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, floa * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -168,6 +175,8 @@ bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, dou * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. value is nullptr. * @since 9 * @version 1.0 */ @@ -181,6 +190,8 @@ bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, con * @param addr written data addr * @param size written data length * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. addr is nullptr. 5. size is zero. * @since 9 * @version 1.0 */ @@ -193,6 +204,8 @@ bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const ui * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -205,6 +218,8 @@ bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_ * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -217,6 +232,8 @@ bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64 * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -229,6 +246,8 @@ bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, floa * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -242,6 +261,8 @@ bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, dou * @param out The read string pointer, the data life cycle pointed to is updated with GetString, * and Format is destroyed. If the caller needs to hold it for a long time, it must copy the memory * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. 5. malloc out string nullptr. * @since 9 * @version 1.0 */ @@ -256,6 +277,8 @@ bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, con * if the caller needs to hold it for a long time, it must copy the memory * @param size Length of read and write data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. addr is nullptr. 5. size is nullptr. * @since 9 * @version 1.0 */ @@ -265,7 +288,8 @@ bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t * @brief Output the information contained in OH_AVFormat as a string. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance - * @return Returns a string consisting of key and data + * @return Returns a string consisting of key and data for success, nullptr for failure + * Possible failure causes: 1. input format is nullptr. 2. malloc dump info nullptr. * @since 9 * @version 1.0 */ diff --git a/multimedia/media_foundation/native_avmemory.h b/multimedia/media_foundation/native_avmemory.h index 489a4ff49c3493e94dda7ed35772c061e156a7da..e4457d8350954b10ae4ccfc1afdccf11665c87dd 100644 --- a/multimedia/media_foundation/native_avmemory.h +++ b/multimedia/media_foundation/native_avmemory.h @@ -29,7 +29,9 @@ typedef struct OH_AVMemory OH_AVMemory; * @brief Create an OH_AVMemory instance * @syscap SystemCapability.Multimedia.Media.Core * @param size the memory's size, bytes. - * @return Returns a pointer to an OH_AVMemory instance, needs to be freed by OH_AVMemory_Destroy. + * @return Returns a pointer to an OH_AVMemory instance for success, needs to be freed by OH_AVMemory_Destroy, + * otherwise returns nullptr. Possible failure causes: 1. size <= 0. 2. create OH_AVMemory failed. + * 3.failed to new OH_AVMemory. * @deprecated since 11 * @useinstead OH_AVBuffer_Create * @since 10 @@ -41,6 +43,7 @@ OH_AVMemory *OH_AVMemory_Create(int32_t size); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's virtual address if the memory is valid, otherwise nullptr. + * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. * @deprecated since 11 * @useinstead OH_AVBuffer_GetAddr * @since 9 @@ -53,6 +56,7 @@ uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's size if the memory is valid, otherwise -1. + * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. * @deprecated since 11 * @useinstead OH_AVBuffer_GetCapacity * @since 9 @@ -65,8 +69,9 @@ int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); * instance * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input mem is nullptr, mem's magic error or input mem is not user created. * @deprecated since 11 * @useinstead OH_AVBuffer_Destroy * @since 10 diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index 0939a6516453772642bb0d9e7c08cdc292cdef5c..fa63c5ae3c6e5a772738b10d3c58b9f5a6dc3fe0 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -43,6 +43,7 @@ #include "native_averrors.h" #include "avplayer_base.h" #include "native_window/external_window.h" +#include "ohaudio/native_audiostream_base.h" #ifdef __cplusplus extern "C" { @@ -65,7 +66,7 @@ typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; * @brief Call back will be invoked when updating DRM information. * @param player Player instance. * @param mediaKeySystemInfo DRM information. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @return void * @since 12 * @version 1.0 */ @@ -74,7 +75,8 @@ typedef void (*Player_MediaKeySystemInfoCallback)(OH_AVPlayer *player, DRM_Media /** * @brief Create a player * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @return Returns a pointer to an OH_AVPlayer instance + * @return Returns a pointer to an OH_AVPlayer instance for success, nullptr for failure + * Possible failure causes: 1. failed to PlayerFactory::CreatePlayer. 2. failed to new PlayerObject. * @since 11 * @version 1.0 */ @@ -85,8 +87,9 @@ OH_AVPlayer *OH_AVPlayer_Create(void); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param url Indicates the playback source. - * @return Returns {@link AV_ERR_OK} if the url is set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, url is null or player setUrlSource failed. * @since 11 * @version 1.0 */ @@ -99,8 +102,9 @@ OH_AVErrCode OH_AVPlayer_SetURLSource(OH_AVPlayer *player, const char *url); * @param fd Indicates the file descriptor of media source. * @param offset Indicates the offset of media source in file descriptor. * @param size Indicates the size of media source. - * @return Returns {@link AV_ERR_OK} if the fd source is set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player setFdSource failed. * @since 11 * @version 1.0 */ @@ -113,8 +117,9 @@ OH_AVErrCode OH_AVPlayer_SetFDSource(OH_AVPlayer *player, int32_t fd, int64_t of * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Prepare} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Prepare failed. * @since 11 * @version 1.0 */ @@ -128,8 +133,9 @@ OH_AVErrCode OH_AVPlayer_Prepare(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if the playback is started; otherwise returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Play failed. * @since 11 * @version 1.0 */ @@ -139,8 +145,9 @@ OH_AVErrCode OH_AVPlayer_Play(OH_AVPlayer *player); * @brief Pauses playback. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Pause} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Pause failed. * @since 11 * @version 1.0 */ @@ -150,8 +157,9 @@ OH_AVErrCode OH_AVPlayer_Pause(OH_AVPlayer *player); * @brief Stop playback. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Stop} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Stop failed. * @since 11 * @version 1.0 */ @@ -165,8 +173,9 @@ OH_AVErrCode OH_AVPlayer_Stop(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Reset} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Reset failed. * @since 11 * @version 1.0 */ @@ -181,8 +190,9 @@ OH_AVErrCode OH_AVPlayer_Reset(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Release} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Release failed. * @since 11 * @version 1.0 */ @@ -197,8 +207,9 @@ OH_AVErrCode OH_AVPlayer_Release(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if the playback is released; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player ReleaseSync failed. * @since 11 * @version 1.0 */ @@ -217,8 +228,9 @@ OH_AVErrCode OH_AVPlayer_ReleaseSync(OH_AVPlayer *player); * ranging from 0 to 1. each step is 0.01. * @param rightVolume Indicates the target volume of the right audio channel to set, * ranging from 0 to 1. each step is 0.01. - * @return Returns {@link AV_ERR_OK} if the volume is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetVolume failed. * @since 11 * @version 1.0 */ @@ -233,8 +245,9 @@ OH_AVErrCode OH_AVPlayer_SetVolume(OH_AVPlayer *player, float leftVolume, float * @param player Pointer to an OH_AVPlayer instance * @param mSeconds Indicates the target playback position, accurate to milliseconds. * @param mode Indicates the player seek mode. For details, see {@link AVPlayerSeekMode}. - * @return Returns {@link AV_ERR_OK} if the seek is done; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Seek failed. * @since 11 * @version 1.0 */ @@ -245,8 +258,9 @@ OH_AVErrCode OH_AVPlayer_Seek(OH_AVPlayer *player, int32_t mSeconds, AVPlayerSee * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param currentTime Indicates the playback position. - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetCurrentTime failed. * @since 11 * @version 1.0 */ @@ -257,8 +271,9 @@ OH_AVErrCode OH_AVPlayer_GetCurrentTime(OH_AVPlayer *player, int32_t *currentTim * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param videoWidth The video width - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr. * @since 11 * @version 1.0 */ @@ -269,8 +284,9 @@ OH_AVErrCode OH_AVPlayer_GetVideoWidth(OH_AVPlayer *player, int32_t *videoWidth) * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param videoHeight The video height - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr. * @since 11 * @version 1.0 */ @@ -281,8 +297,9 @@ OH_AVErrCode OH_AVPlayer_GetVideoHeight(OH_AVPlayer *player, int32_t *videoHeigh * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param speed the rate mode {@link AVPlaybackSpeed} which can set. - * @return Returns {@link AV_ERR_OK} if the playback rate is set successful; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetPlaybackSpeed failed. * @since 11 * @version 1.0 */ @@ -293,13 +310,52 @@ OH_AVErrCode OH_AVPlayer_SetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed s * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param speed the rate mode {@link AVPlaybackSpeed} which can get. - * @return Returns {@link AV_ERR_OK} if the current player playback rate is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetPlaybackSpeed failed. * @since 11 * @version 1.0 */ OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed); +/** + * @brief Set the renderer information of the player's audio renderer + * @param player Pointer to an OH_AVPlayer instance + * @param streamUsage The value {@link OH_AudioStream_Usage} used for the stream usage of the player audio render. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or streamUsage value is invalid. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetAudioRendererInfo(OH_AVPlayer *player, OH_AudioStream_Usage streamUsage); + +/** + * @brief Set the interruption mode of the player's audio stream + * @param player Pointer to an OH_AVPlayer instance + * @param interruptMode The value {@link OH_AudioInterrupt_Mode} used for the interruption mode of + * the player audio stream. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or interruptMode value is invalid. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetAudioInterruptMode(OH_AVPlayer *player, OH_AudioInterrupt_Mode interruptMode); + +/** + * @brief Set the effect mode of the player's audio stream + * @param player Pointer to an OH_AVPlayer instance + * @param effectMode The value {@link OH_AudioStream_AudioEffectMode} used for the effect mode of + * the player audio stream. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or effectMode value is invalid. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetAudioEffectMode(OH_AVPlayer *player, OH_AudioStream_AudioEffectMode effectMode); + /** * @brief set the bit rate use for hls player * @@ -313,8 +369,9 @@ OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param bitRate the bit rate, The unit is bps. - * @return Returns {@link AV_ERR_OK} if the bit rate is set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SelectBitRate failed. * @since 11 * @version 1.0 */ @@ -325,8 +382,10 @@ OH_AVErrCode OH_AVPlayer_SelectBitRate(OH_AVPlayer *player, uint32_t bitRate); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} - * @return Returns {@link AV_ERR_OK} if the surface is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, input window is nullptr, + * or player SetVideoSurface failed. * @since 11 * @version 1.0 */ @@ -337,8 +396,9 @@ OH_AVErrCode OH_AVPlayer_SetVideoSurface(OH_AVPlayer *player, OHNativeWindow *w * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param duration Indicates the total duration of media files. - * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetDuration failed. * @since 11 * @version 1.0 */ @@ -349,8 +409,9 @@ OH_AVErrCode OH_AVPlayer_GetDuration(OH_AVPlayer *player, int32_t *duration); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param state the current playback state - * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr. * @since 11 * @version 1.0 */ @@ -360,7 +421,7 @@ OH_AVErrCode OH_AVPlayer_GetState(OH_AVPlayer *player, AVPlayerState *state); * @brief Checks whether the player is playing. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns true if the playback is playing; false otherwise. + * @return Returns true if the playback is playing; Return false if not or input player is nullptr. * @since 11 * @version 1.0 */ @@ -370,7 +431,7 @@ bool OH_AVPlayer_IsPlaying(OH_AVPlayer *player); * @brief Returns the value whether single looping is enabled or not . * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns true if the playback is single looping; false otherwise. + * @return Returns true if the playback is single looping; Return false if not or input player is nullptr. * @since 11 * @version 1.0 */ @@ -381,8 +442,9 @@ bool OH_AVPlayer_IsLooping(OH_AVPlayer *player); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param loop The switch to set loop - * @return Returns {@link AV_ERR_OK} if the single looping is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetLooping failed. * @since 11 * @version 1.0 */ @@ -393,8 +455,10 @@ OH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param callback object pointer. - * @return Returns {@link AV_ERR_OK} if the playercallback is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, + * or player SetPlayerCallback failed. * @since 11 * @version 1.0 */ @@ -410,8 +474,9 @@ OH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param index Track index - * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SelectTrack failed. * @since 11 * @version 1.0 */ @@ -427,8 +492,9 @@ OH_AVErrCode OH_AVPlayer_SelectTrack(OH_AVPlayer *player, int32_t index); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param index Track index - * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player DeselectTrack failed. * @since 11 * @version 1.0 */ @@ -443,8 +509,9 @@ OH_AVErrCode OH_AVPlayer_DeselectTrack(OH_AVPlayer *player, int32_t index); * @param player Pointer to an OH_AVPlayer instance * @param trackType Media type. * @param index Track index - * @return Returns {@link AV_ERR_OK} if the track index is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetCurrentTrack failed. * @since 11 * @version 1.0 */ @@ -455,8 +522,10 @@ OH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param callback object pointer. - * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, MediaKeySystemInfoCallback is null + * player SetDrmSystemInfoCallback failed, SetDrmSystemInfoCallback failed or SetDrmSystemInfoCallback failed. * @since 12 * @version 1.0 */ @@ -468,8 +537,9 @@ OH_AVErrCode OH_AVPlayer_SetMediaKeySystemInfoCallback(OH_AVPlayer *player, * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param mediaKeySystemInfo Media key system info. - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or no memory. * @since 12 * @version 1.0 */ @@ -482,8 +552,9 @@ OH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKey * @param player Pointer to an OH_AVPlayer instance * @param mediaKeySession A media key session instance with decryption function. * @param secureVideoPath Require secure decoder or not. - * @return Returns {@link AV_ERR_OK} if set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetDecryptConfig failed. * @since 12 * @version 1.0 */ diff --git a/multimedia/player_framework/avplayer/libavplayer.ndk.json b/multimedia/player_framework/avplayer/libavplayer.ndk.json index 5c260ec089b7a9e6340f2a5075226dc48d831041..dbfa420edf150b49c60963d92591da2fcb4bb7b2 100644 --- a/multimedia/player_framework/avplayer/libavplayer.ndk.json +++ b/multimedia/player_framework/avplayer/libavplayer.ndk.json @@ -38,5 +38,17 @@ { "first_introduced": "12", "name": "OH_AVPlayer_SetDecryptionConfig" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetAudioRendererInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetAudioInterruptMode" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetAudioEffectMode" } ] \ No newline at end of file diff --git a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json index f0a7081dab36688f7c2df90665a2025c77986822..35becaca0a75cf370749c7bc79834e503776f7a0 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -86,5 +86,9 @@ { "first_introduced": "12", "name": "OH_AVScreenCapture_ExcludeContent" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_ContentFilter_AddWindowContent" } ] \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index e954386055a278052bc00d7ad70c33c31ca5a06e..07ecc8ab7c60025586a5e6e1f486b2e89b5b97f6 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -350,6 +350,19 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent( OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreenCapture *capture, struct OH_AVScreenCapture_ContentFilter *filter); +/** + * @brief Add Window content to the screen capture content filter + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance + * @param Pointer to windowIDs to be added + * @param windowCount to be added + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent( + struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount); #ifdef __cplusplus } #endif diff --git a/resourceschedule/ffrt/ffrt.ndk.json b/resourceschedule/ffrt/ffrt.ndk.json index ac87d49f85f54cb21d81a19bf277c0baf0600e3d..0c83414e04d1376626c3c10e964ed79abad22e73 100644 --- a/resourceschedule/ffrt/ffrt.ndk.json +++ b/resourceschedule/ffrt/ffrt.ndk.json @@ -51,7 +51,7 @@ { "name": "ffrt_loop_timer_stop" }, { "name": "ffrt_queue_attr_set_max_concurrency" }, { "name": "ffrt_queue_atte_get_max_concurrency" }, - { "name": "ffrt_qet_main_queue" }, + { "name": "ffrt_get_main_queue" }, { "name": "ffrt_get_current_queue" }, { "name": "ffrt_task_attr_set_queue_priority" }, { "name": "ffrt_task_attr_get_queue_priority" }, diff --git a/security/asset/inc/asset_api.h b/security/asset/inc/asset_api.h index 87b2652dce5c320815ae412987a5054cb7472222..fc14226cb2edf2830758a95cdce185ea7119a8d6 100755 --- a/security/asset/inc/asset_api.h +++ b/security/asset/inc/asset_api.h @@ -52,7 +52,25 @@ extern "C" { * * @param attributes Pointer to the attributes of the asset to add. * @param attributes Number of the attributes of the asset to add. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_PERMISSION_DENIED} 201 - The caller doesn't have the permission. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_DUPLICATED} 24000003 - The asset already exists. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_FILE_OPERATION_ERROR} 24000014 - The file operation failed. + * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); @@ -62,7 +80,20 @@ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); * * @param query Pointer to the conditions for removing the assets. * @param queryCnt Number of conditions for removing the assets. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Incorrect parameter types. + * 2. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); @@ -74,7 +105,23 @@ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); * @param queryCnt Number of conditions for updating the asset. * @param attributes Pointer to the attributes of the asset to update. * @param attributes Number of the attributes of the asset to update. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, @@ -86,7 +133,23 @@ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, * @param query Pointer to the search criteria of the asset. * @param queryCnt Number of the search criteria. * @param challenge Pointer to the challenge value to be used when OH_Asset_Query is called. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Incorrect parameter types. + * 2. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_LIMIT_EXCEEDED} 24000016 - The cache exceeds the limit. + * {@link ASSET_UNSUPPORTED} 24000017 - The capability is not supported. * @since 11 */ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob *challenge); @@ -97,7 +160,23 @@ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob * @param query Pointer to the search criteria. * @param queryCnt Number of the search criteria. * @param resultSet Pointer to the query result obtained. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Incorrect parameter types. + * 2. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_ACCESS_DENIED} 24000004 - Access to the asset is denied. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_UNSUPPORTED} 24000017 - The capability is not supported. * @since 11 */ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultSet *resultSet); @@ -108,7 +187,17 @@ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultS * @param handle Pointer to the handle of the data to process, which includes the challenge value returned by * OH_Asset_PreQuery. * @param handleCnt Number of the elements in the handle attribute set. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. * @since 11 */ int32_t OH_Asset_PostQuery(const Asset_Attr *handle, uint32_t handleCnt); diff --git a/security/asset/inc/asset_type.h b/security/asset/inc/asset_type.h index cc2bd861d53ba93ab35e987554ab0479bb3a73b5..150d76021ae67b1f4ac91b7441554f7b89712530 100755 --- a/security/asset/inc/asset_type.h +++ b/security/asset/inc/asset_type.h @@ -216,85 +216,45 @@ typedef enum { * @since 11 */ typedef enum { - /** - * The operation is successful. - */ + /** @error The operation is successful. */ ASSET_SUCCESS = 0, - /** - * The caller does not have the required permission. - */ + /** @error The caller doesn't have the permission. */ ASSET_PERMISSION_DENIED = 201, - /** - * The parameter is invalid. - */ + /** @error The parameter is invalid. */ ASSET_INVALID_ARGUMENT = 401, - /** - * The asset service is unavailable. - */ + /** @error The ASSET service is unavailable. */ ASSET_SERVICE_UNAVAILABLE = 24000001, - /** - * The asset is not found. - */ + /** @error The asset is not found. */ ASSET_NOT_FOUND = 24000002, - /** - * The asset already exists. - */ + /** @error The asset already exists. */ ASSET_DUPLICATED = 24000003, - /** - * The access to the asset is denied. - */ + /** @error Access to the asset is denied. */ ASSET_ACCESS_DENIED = 24000004, - /** - * The lock screen status does not match the access control type specified. - */ + /** @error The screen lock status does not match. */ ASSET_STATUS_MISMATCH = 24000005, - /** - * The system memory is insufficient. - */ + /** @error Insufficient memory. */ ASSET_OUT_OF_MEMORY = 24000006, - /** - * The asset is corrupted. - */ + /** @error The asset is corrupted. */ ASSET_DATA_CORRUPTED = 24000007, - /** - * The database operation failed. - */ + /** @error The database operation failed. */ ASSET_DATABASE_ERROR = 24000008, - /** - * The cryptography operation failed. - */ + /** @error The cryptography operation failed. */ ASSET_CRYPTO_ERROR = 24000009, - /** - * The inter-process communication (IPC) failed. - */ + /** @error IPC failed. */ ASSET_IPC_ERROR = 24000010, - /** - * The Bundle Manager service is abnormal. - */ + /** @error Calling the Bundle Manager service failed. */ ASSET_BMS_ERROR = 24000011, - /** - * The Account service is abnormal. - */ + /** @error Calling the OS Account service failed. */ ASSET_ACCOUNT_ERROR = 24000012, - /** - * The Access Token service is abnormal. - */ + /** @error Calling the Access Token service failed. */ ASSET_ACCESS_TOKEN_ERROR = 24000013, - /** - * The file operation failed. - */ + /** @error The file operation failed. */ ASSET_FILE_OPERATION_ERROR = 24000014, - /** - * The operation for obtaining the system time failed. - */ + /** @error Getting the system time failed. */ ASSET_GET_SYSTEM_TIME_ERROR = 24000015, - /** - * The number of cached assets exceeds the limit. - */ + /** @error The cache exceeds the limit. */ ASSET_LIMIT_EXCEEDED = 24000016, - /** - * The function is not supported. - */ + /** @error The capability is not supported. */ ASSET_UNSUPPORTED = 24000017, } Asset_ResultCode; diff --git a/security/huks/include/native_huks_type.h b/security/huks/include/native_huks_type.h index 9ed7ec5a86df7cb56f0c7029e310df3888450d5b..8b07c752546b05c47d66442062c22ebdd1100235 100644 --- a/security/huks/include/native_huks_type.h +++ b/security/huks/include/native_huks_type.h @@ -409,7 +409,7 @@ enum OH_Huks_ErrCode { /** Failed to call service. */ OH_HUKS_ERR_CODE_CALL_SERVICE_FAILED = 12000015, /** - * Device password is required but not set. + * A device password is required but not set. * * @since 11 */ diff --git a/third_party/musl/ndk_musl_include/stdio.h b/third_party/musl/ndk_musl_include/stdio.h index e71ae4f8f49fc943fdd780f496092be604411d2a..31e9ca11bbc85911bd0840808883b2d7aeee118b 100644 --- a/third_party/musl/ndk_musl_include/stdio.h +++ b/third_party/musl/ndk_musl_include/stdio.h @@ -153,6 +153,7 @@ int putchar_unlocked(int); ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict); ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict); int renameat(int, const char *, int, const char *); +int renameat2(int, const char *, int, const char *, unsigned int); char *ctermid(char *); #define L_ctermid 20 #endif @@ -198,7 +199,7 @@ typedef struct _IO_cookie_io_functions_t { cookie_seek_function_t *seek; cookie_close_function_t *close; } cookie_io_functions_t; - +FILE *fopencookie(void *, const char *, cookie_io_functions_t); #endif #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) diff --git a/third_party/musl/ndk_script/adapter/libc.ndk.json b/third_party/musl/ndk_script/adapter/libc.ndk.json index dcc601a9514899917d460789b3e261cc9e77dda1..4a86a82df107f76a5c8e4da3cf210456a4b94a51 100644 --- a/third_party/musl/ndk_script/adapter/libc.ndk.json +++ b/third_party/musl/ndk_script/adapter/libc.ndk.json @@ -433,6 +433,7 @@ { "name": "fnmatch" }, { "name": "fopen" }, { "name": "fopen64" }, + { "name": "fopencookie" }, { "name": "fork" }, { "name": "forkpty" }, { "name": "fpathconf" }, @@ -1064,6 +1065,7 @@ { "name": "remquol" }, { "name": "rename" }, { "name": "renameat" }, + { "name": "renameat2" }, { "name": "res_init" }, { "name": "res_mkquery" }, { "name": "res_query" }, diff --git a/third_party/node/README.OpenSource b/third_party/node/README.OpenSource index 19eb392ef17a700ec6d95f5b618cd6cce4cf5d36..28991b992ddac0f9064195e839a956823a9f417d 100644 --- a/third_party/node/README.OpenSource +++ b/third_party/node/README.OpenSource @@ -3,7 +3,7 @@ "Name": "node", "License": "ISC License,Public Domain,MIT License,Free Software Foundation - MIT License,Apache License V2.0,ICU License,zlib/libpng License,BSD 2-Clause License,BSD 3-Clause License", "License File": "LICENSE", - "Version Number": "18.18.2", + "Version Number": "v18.20.1", "Owner": "sunbingxin@huawei.com", "Upstream URL": "http://www.nodejs.org/", "Description": "Node.js is an open-source, cross-platform, JavaScript runtime environment. It executes JavaScript code outside of a browser." diff --git a/web/webview/interfaces/native/arkweb_scheme_handler.h b/web/webview/interfaces/native/arkweb_scheme_handler.h index 9de9b94b4fb12ef9511732e4a4e6e9c7e0021009..a95caeb8739581cb86b0b1f1901a71d6d46f2d5e 100644 --- a/web/webview/interfaces/native/arkweb_scheme_handler.h +++ b/web/webview/interfaces/native/arkweb_scheme_handler.h @@ -121,6 +121,175 @@ typedef enum ArkWeb_CustomSchemeOption { ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED = 1 << 7, } ArkWeb_CustomSchemeOption; +/* + * @brief Resource type for a request. These constants match their equivalents in + * Chromium's ResourceType and should not be renumbered. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +typedef enum ArkWeb_ResourceType { + /* + * @brief Top level page. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + MAIN_FRAME = 0, + + /* + * @brief Frame or Iframe. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SUB_FRAME = 1, + + /* + * @brief CSS stylesheet. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + STYLE_SHEET = 2, + + /* + * @brief External script. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SCRIPT = 3, + + /* + * @brief Image (jpg/gif/png/etc). + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + IMAGE = 4, + + /* + * @brief Font. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + FONT_RESOURCE = 5, + + /* + * @brief Some other subresource. This is the default type if the actual type is unknown. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SUB_RESOURCE = 6, + + /* + * @brief Object (or embed) tag for a plugin, or a resource that a plugin requested. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + OBJECT = 7, + + /* + * @brief Media resource. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + MEDIA = 8, + + /* + * @brief Main resource of a dedicated worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + WORKER = 9, + + /* + * @brief Main resource of a shared worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SHARED_WORKER = 10, + + /* + * @brief Explicitly requested prefetch. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PREFETCH = 11, + + /* + * @brief Favicon. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + FAVICON = 12, + + /* + * @brief XMLHttpRequest. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + XHR = 13, + + /* + * @brief Ping request for /sendBeacon. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PING = 14, + + /* + * @brief The main resource of a service worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SERVICE_WORKER = 15, + + /* + * @brief Report of Content Security Policy violations. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + CSP_REPORT = 16, + + /* + * @brief Resource that a plugin requested. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PLUGIN_RESOURCE = 17, + + /* + * @brief A main-frame service worker navigation preload request. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + NAVIGATION_PRELOAD_MAIN_FRAME = 19, + + /* + * @brief A sub-frame service worker navigation preload request. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + NAVIGATION_PRELOAD_SUB_FRAME = 20, +} ArkWeb_ResourceType; + /* * @brief This class is used to intercept requests for a specified scheme. * @@ -324,6 +493,27 @@ void OH_ArkWebResourceRequest_GetHttpBodyStream(const ArkWeb_ResourceRequest* re */ void OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpBodyStream); +/* + * @brief Get the resource type of request. + * @param resourceRequest The ArkWeb_ResourceRequest. + * @return The resource type of request. -1 if resourceRequest is invalid. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +int32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest); + +/* + * @brief Get the url of frame which trigger this request. + * @param resourceRequest The ArkWeb_ResourceRequest. + * @param frameUrl The url of frame which trigger this request. This function will allocate memory for the url string + * and caller must release the string by OH_ArkWeb_ReleaseString. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +void OH_ArkWebResourceRequest_GetFrameUrl(const ArkWeb_ResourceRequest* resourceRequest, char** frameUrl); + /* * @brief Set a user data to ArkWeb_HttpBodyStream. * @param httpBodyStream The ArkWeb_HttpBodyStream. diff --git a/web/webview/interfaces/native/libohweb.ndk.json b/web/webview/interfaces/native/libohweb.ndk.json index 4e226f72c15cc3872d96c4557f6d9753f7245fc6..a92438ec859e9a67ab90686dbbeb52e44fe24ba3 100644 --- a/web/webview/interfaces/native/libohweb.ndk.json +++ b/web/webview/interfaces/native/libohweb.ndk.json @@ -91,6 +91,14 @@ "first_introduced": "12", "name": "OH_ArkWebResourceRequest_DestroyHttpBodyStream" }, + { + "first_introduced": "12", + "name": "OH_ArkWebResourceRequest_GetResourceType" + }, + { + "first_introduced": "12", + "name": "OH_ArkWebResourceRequest_GetFrameUrl" + }, { "first_introduced": "12", "name": "OH_ArkWebHttpBodyStream_SetReadCallback"