From b1c82e0d2d5d27ebff32252c1d4a8a7c41b85016 Mon Sep 17 00:00:00 2001 From: wangyang2022 Date: Sat, 17 May 2025 08:15:44 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EC-API=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=B9=B6=E8=A1=8C=E5=8C=96=E7=9B=B8=E5=85=B3?= =?UTF-8?q?API=20Signed-off-by:=20wangyang2022=20?= =?UTF-8?q?=20Change-Id:=20I74325c4000ea950162059274c812a3f20b461039?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arkui/ace_engine/native/libace.ndk.json | 12 +++++++ arkui/ace_engine/native/native_interface.h | 6 ++++ arkui/ace_engine/native/native_node.h | 40 ++++++++++++++++++++++ arkui/ace_engine/native/native_type.h | 5 +++ 4 files changed, 63 insertions(+) diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 2e3768c59..d320274f4 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -3503,6 +3503,18 @@ "first_introduced": "20", "name": "OH_ArkUI_SetForceDarkConfig" }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PostAsyncUITask" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PostUITask" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PostUITaskAndWait" + }, { "first_introduced": "20", "name": "OH_ArkUI_NativeModule_GetNodeHandleFromAniValue" diff --git a/arkui/ace_engine/native/native_interface.h b/arkui/ace_engine/native/native_interface.h index 64cae7e06..4c3405779 100644 --- a/arkui/ace_engine/native/native_interface.h +++ b/arkui/ace_engine/native/native_interface.h @@ -57,6 +57,12 @@ typedef enum { ARKUI_NATIVE_GESTURE, /** API related to animations. For details, see the struct definition in .*/ ARKUI_NATIVE_ANIMATE, + /** + * API related to supported multi thread UI components. + * For details, see the struct definition in . + * @since 20 + */ + ARKUI_MULTI_THREAD_NATIVE_NODE, } ArkUI_NativeAPIVariantKind; /** diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 92151c968..c6abaae62 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -9888,6 +9888,46 @@ int32_t OH_ArkUI_NodeUtils_GetNodeUniqueId(ArkUI_NodeHandle node, int32_t* uniqu int32_t OH_ArkUI_SetForceDarkConfig(ArkUI_ContextHandle uiContext, bool forceDark, ArkUI_NodeType nodeType, uint32_t (*colorInvertFunc)(uint32_t color)); +/** + * @brief Post UI task to background threads. + * + * @param context UIContext pointer of the page where the UI task located. + * @param asyncUITaskData Parameter of asyncUITask and onFinish. + * @param asyncUITask Function executed by a background thread. + * @param onFinish Function executed by UI thread after async UI task is executed. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if context or asyncUITask is nullptr. + * @since 20 + */ +int32_t OH_ArkUI_PostAsyncUITask(ArkUI_ContextHandle context, void* asyncUITaskData, + void (*asyncUITask)(void* asyncUITaskData), void (*onFinish)(void* asyncUITaskData)); + +/** + * @brief Post UI task to UI thread. + * + * @param context UIContext pointer of the page where the UI task located. + * @param taskData Parameter of task. + * @param task Function executed by UI thread. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if context or task is nullptr. + * @since 20 + */ +int32_t OH_ArkUI_PostUITask(ArkUI_ContextHandle context, void* taskData, void (*task)(void* taskData)); + +/** + * @brief Post UI task to UI thread and wait until UI task finished. + * + * @param context UIContext pointer of the page where the UI task located. + * @param taskData Parameter of task. + * @param task Function executed by UI thread. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if context or task is nullptr. + * @since 20 + */ +int32_t OH_ArkUI_PostUITaskAndWait(ArkUI_ContextHandle context, void* taskData, void (*task)(void* taskData)); #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index 5552ea45b..2d3d669a6 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -2260,6 +2260,11 @@ typedef enum { * @since 15 */ ARKUI_ERROR_CODE_NODE_NOT_ON_MAIN_TREE = 106203, + /** + * @error The node is running on invalid thread. + * @since 20 + */ + ARKUI_ERROR_CODE_NODE_ON_INVALID_THREAD = 106204, /** * @error Force dark config is invalid. * @since 20 -- Gitee