diff --git a/arkui/ace_engine/native/drag_and_drop.h b/arkui/ace_engine/native/drag_and_drop.h index c8dc147263247f5ea57e28e1d466c75494e08361..2f68d95b0f7affd5a6d626e7bd425d6513752183 100644 --- a/arkui/ace_engine/native/drag_and_drop.h +++ b/arkui/ace_engine/native/drag_and_drop.h @@ -80,22 +80,22 @@ typedef enum { */ typedef enum { /** Unknown. */ - ARKUI_PREVIEW_DRAG_STATUS_UNKNOWN = -1, + ARKUI_PRE_DRAG_STATUS_UNKNOWN = -1, /** A drag gesture is being detected. */ - ARKUI_PREVIEW_DRAG_STATUS_ACTION_DETECTING, + ARKUI_PRE_DRAG_STATUS_ACTION_DETECTING, /** The component is ready to be dragged. */ - ARKUI_PREVIEW_DRAG_STATUS_READY_TO_TRIGGER_DRAG, + ARKUI_PRE_DRAG_STATUS_READY_TO_TRIGGER_DRAG, /** A lift animation is started. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_STARTED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_STARTED, /** A lift animation is finished. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_FINISHED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_FINISHED, /** A drop animation is started. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_STARTED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_STARTED, /** A drop animation is finished. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_FINISHED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_FINISHED, /** A drop animation is terminated. */ - ARKUI_PREVIEW_DRAG_STATUS_CANCELED_BEFORE_DRAG, -} ArkUI_PreviewDragStatus; + ARKUI_PRE_DRAG_STATUS_CANCELED_BEFORE_DRAG, +} ArkUI_PreDragStatus; /** * @brief Defines an enum for drag preview scale modes. @@ -192,7 +192,7 @@ ArkUI_DragEvent* OH_ArkUI_NodeEvent_GetDragEvent(ArkUI_NodeEvent* nodeEvent); * @return Returns the interaction state prior to the drop and drop operation. * @since 12 */ -ArkUI_PreviewDragStatus OH_ArkUI_NodeEvent_GetPreviewDragStatus(ArkUI_NodeEvent* nodeEvent); +ArkUI_PreDragStatus OH_ArkUI_NodeEvent_GetPreDragStatus(ArkUI_NodeEvent* nodeEvent); /** * @brief Sets whether to disable the default drop animation. diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 250a1c13d40a618dadb08cfd7cf34f8066cc1f83..774365f3bc51c01e71b1a4120f857864f4e42fc7 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -247,6 +247,70 @@ "first_introduced": "12", "name": "OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetResponseRecognizersFromInterruptInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SetGestureRecognizerEnabled" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureRecognizerEnabled" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureRecognizerState" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureEventTargetInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEventTargetInfo_IsScrollBegin" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEventTargetInfo_IsScrollEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetPanGestureDirectionMask" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_IsBuiltInGesture" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureTag" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureBindNodeId" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_IsGestureRecognizerValid" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetUserData" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify" + }, { "first_introduced": "12", "name": "OH_NativeXComponent_SetNeedSoftKeyboard" @@ -1765,7 +1829,7 @@ }, { "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_GetPreviewDragStatus" + "name": "OH_ArkUI_NodeEvent_GetPreDragStatus" }, { "first_introduced": "12", @@ -1982,5 +2046,93 @@ { "first_introduced": "12", "name": "OH_ArkUI_DialogDismissEvent_GetDismissReason" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_GetFontSize" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_SetWidth" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_SetHeight" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetXOffset" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetLineTop" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetLineBottom" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetBaseline" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_RegisterSystemColorModeChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_UnregisterSystemColorModeChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_RegisterSystemFontStyleChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_UnregisterSystemFontStyleChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SystemFontStyleEvent_GetFontSize" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SystemFontStyleEvent_GetFontWeight" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_gesture.h b/arkui/ace_engine/native/native_gesture.h index 35dac3924d75d777b705ff8a71685073e42edfd6..a3df8440136cbdddba3c8e5f8c01df46c9294a11 100644 --- a/arkui/ace_engine/native/native_gesture.h +++ b/arkui/ace_engine/native/native_gesture.h @@ -223,6 +223,65 @@ typedef enum { GESTURE_INTERRUPT_RESULT_REJECT, } ArkUI_GestureInterruptResult; +/** + * @brief Enumerates the gesture recognizer states. + * + * @since 12 + */ +typedef enum { + /** Ready. */ + ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0, + + /** Detecting. */ + ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1, + + /** Pending. */ + ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2, + + /** Blocked. */ + ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3, + + /** Successful. */ + ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4, + + /** Failed. */ + ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5, +} ArkUI_GestureRecognizerState; + +/** + * @brief Defines the gesture recognizer handle. + * + * @since 12 + */ +typedef ArkUI_GestureRecognizer* ArkUI_GestureRecognizerHandle; + +/** + * @brief Defines the gesture recognizer handle array. + * + * @since 12 + */ +typedef ArkUI_GestureRecognizerHandle* ArkUI_GestureRecognizerHandleArray; + +/** + * @brief Defines a GestureEventTargetInfo object that provides information about a gesture event target. + * + * @since 12 + */ +typedef struct ArkUI_GestureEventTargetInfo ArkUI_GestureEventTargetInfo; + +/** + * @brief Defines a parallel internal gesture event. + * + * @since 12 + */ +typedef struct ArkUI_ParallelInnerGestureEvent ArkUI_ParallelInnerGestureEvent; + +/** + * @brief Defines a callback function for notifying gesture recognizer destruction. + * @since 12 + */ +typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData); + /** * @brief Checks whether a gesture is a built-in gesture of the component. * @@ -408,6 +467,191 @@ float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event); * @since 12 */ ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event); + +/** +* @brief Obtains information about a gesture response chain. +* +* @param event Indicates the pointer to the gesture interruption information. +* @param responseChain Indicates the pointer to an array of gesture recognizers on the response chain. +* @param count Indicates the pointer to the number of gesture recognizers on the response chain. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event, + ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count); + +/** +* @brief Sets the enabled state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param enabled Indicates the enabled state. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled); + +/** +* @brief Obtains the enabled state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture recognizer is enabled. +* Returns false if the gesture recognizer is disabled. +* @since 12 +*/ +bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains the state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param state Indicates the pointer to the state of the gesture recognizer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state); + +/** +* @brief Obtains the information about a gesture event target. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param info Indicates the information about a gesture event target. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info); + +/** +* @brief Obtains whether this scroll container is scrolled to the top. +* +* @param info Indicates the information about a gesture event target. +* @param ret Indicates whether the scroll container is scrolled to the top. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. +* @since 12 +*/ +int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret); + +/** +* @brief Obtains whether this scroll container is scrolled to the bottom. +* +* @param info Indicates the information about a gesture event target. +* @param ret Indicates whether the scroll container is scrolled to the bottom. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. +* @since 12 +*/ +int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret); + +/** +* @brief Obtains the direction of a pan gesture. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param directionMask Indicates the pan direction. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer, + ArkUI_GestureDirectionMask* directionMask); + +/** +* @brief Obtains whether a gesture is a built-in gesture. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture is a built-in gesture; returns false otherwise. +* @since 12 +*/ +bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains the tag of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param buffer Indicates the buffer. +* @param bufferSize Indicates the buffer size. +* @param result Indicates the length of the string to be written to the buffer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result); + +/** +* @brief Obtains the ID of the component linked to a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param nodeId Indicates the component ID. +* @param size Indicates the buffer size. +* @param result Indicates the length of the string to be written to the buffer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size, + int32_t* result); + +/** +* @brief Obtains whether a gesture recognizer is valid. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture recognizer is valid. +* Returns false if the gesture recognizer is invalid. +* @since 12 +*/ +bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains custom data in the parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @return Returns the pointer to custom data. +* @since 12 +*/ +void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event); + +/** +* @brief Obtains the current gesture recognizer in a parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @return Returns the pointer to the current gesture recognizer. +* @since 12 +*/ +ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer( + ArkUI_ParallelInnerGestureEvent* event); + +/** +* @brief Obtains the conflicting gesture recognizers in a parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @param array Indicates the pointer to the array of conflicting gesture recognizers. +* @param size Indicates the size of the array of conflicting gesture recognizers. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event, + ArkUI_GestureRecognizerHandleArray* array, int32_t* size); + +/** +* @brief Sets a callback function for notifying gesture recognizer destruction. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param callback Indicates the callback function for notifying gesture recognizer destruction. +* @param userData Indicates the custom data. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +*/ +int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer, + ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData); + /** * @brief Defines the gesture APIs. * @@ -625,6 +869,21 @@ typedef struct { * @return Returns the gesture type. */ ArkUI_GestureRecognizerType (*getGestureType)(ArkUI_GestureRecognizer* recognizer); + + /** + * @brief Sets the callback function for a parallel internal gesture event. + * + * @param node Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set. + * @param userData Indicates the custom data. + * @param parallelInnerGesture Indicates the parallel internal gesture event. event returns the data of the + * parallel internal gesture event; parallelInnerGesture returns the pointer to the gesture recognizer + * that requires parallel recognition. + * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. + */ + int32_t (*setInnerGestureParallelTo)( + ArkUI_NodeHandle node, void* userData, ArkUI_GestureRecognizer* (*parallelInnerGesture)( + ArkUI_ParallelInnerGestureEvent* event)); } ArkUI_NativeGestureAPI_1; #ifdef __cplusplus diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 1412a47cfb2a2994f5ec96280b8a77d1c811e5d2..8442784be9ac2186400c6cadc15c8694c3db2ad7 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -122,6 +122,8 @@ typedef enum { ARKUI_NODE_GRID, /** Grid item. */ ARKUI_NODE_GRID_ITEM, + /** Custom span. */ + ARKUI_NODE_CUSTOM_SPAN, } ArkUI_NodeType; /** @@ -494,15 +496,16 @@ typedef enum { */ NODE_VISIBILITY, /** - * @brief Defines the clip attribute, which can be set, reset, and obtained as required through APIs. + * @brief Defines the clipping and masking attribute, 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: whether to clip the component based on the parent container bounds. - * The value 0 means to clip the component, and 1 means the opposite. \n + * The value 1 means to clip the component, and 0 means the opposite. \n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .value[0].i32: whether to clip the component based on the parent container bounds. - * The value 0 means to clip the component, and 1 means the opposite. \n + * The value 1 means to clip the component, and 0 means the opposite. \n * */ NODE_CLIP, @@ -1027,10 +1030,10 @@ typedef enum { * .string: command for drawing the path.\n * 5. Progress:\n * .value[0].i32: mask type. The parameter type is {@link ArkUI_MaskType}. - * The value is ARKUI_MASK_TYPE_PROSGRESS for the progress shape.\n + * The value is ARKUI_MASK_TYPE_PROGRESS for the progress shape.\n * .value[1].f32: current value of the progress indicator.\n * .value[2].f32: maximum value of the progress indicator.\n - * .value[3].u32: color of the progress indicator.\n + * .value[3].u32: color of the progress indicator, in 0xARGB format.\n * \n * Format of the return value {@link ArkUI_AttributeItem}, which supports five types of shapes:\n * 1. Rectangle:\n @@ -2172,6 +2175,18 @@ typedef enum { */ NODE_TEXT_CONTENT_WITH_STYLED_STRING, + /** + * @brief Sets whether to center text vertically in the text component. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].i32: whether to center text vertically. The default value is false. \n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].i32: whether to center text vertically. \n + * + */ + NODE_TEXT_HALF_LEADING = 1029, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -5537,7 +5552,7 @@ typedef enum { * 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].i32: corresponds to {@link ArkUI_PreViewDragStatus}. \n + * ArkUI_NodeComponentEvent.data[0].i32: corresponds to {@link ArkUI_PreDragStatus}. \n */ NODE_ON_PRE_DRAG = 14, /** @@ -7406,6 +7421,48 @@ ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* e */ ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event); +/** +* @brief Obtains the measurement information of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param info Indicates the measurement information to be obtained. +* @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 a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMeasureInfo* info); + +/** +* @brief Sets the measurement metrics of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param metrics Indicates the measurement metrics to set. +* @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 a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMetrics* metrics); + +/** +* @brief Obtains the drawing information of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param info Indicates the drawing information to obtain. +* @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 a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanDrawInfo* info); + /** * @brief Defines the node content event type. * @@ -7620,6 +7677,73 @@ int32_t OH_ArkUI_List_CloseAllSwipeActions(ArkUI_NodeHandle node, void* userData */ ArkUI_ContextHandle OH_ArkUI_GetContextByNode(ArkUI_NodeHandle node); +/** +* @brief The event called when the system color mode changes. +* Only one system color change callback can be registered for the same component. +* +* @param node Indicates the target node. +* @param userData Indicates the custom data to be saved. +* @param onColorModeChange Callback Events. +* @return Error code. +* {@link ARKUI_ERROR_CODE_NO_ERROR} Success. +* {@link ARKUI_ERROR_CODE_PARAM_INVALID} Function parameter exception. +* {@link ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED} The component does not support this event. +* @since 12 +*/ +int32_t OH_ArkUI_RegisterSystemColorModeChangeEvent(ArkUI_NodeHandle node, + void* userData, void (*onColorModeChange)(ArkUI_SystemColorMode colorMode, void* userData)); + +/** +* @brief Unregister the event callback when the system color mode changes. +* +* @param node Indicates the target node. +* @since 12 +*/ +void OH_ArkUI_UnregisterSystemColorModeChangeEvent(ArkUI_NodeHandle node); + +/** +* @brief The event called when the system font style changes. +* Only one system font change callback can be registered for the same component. +* +* @param node Indicates the target node. +* @param userData Indicates the custom data to be saved. +* @param onFontStyleChange Callback Events. +* @return Error code. +* {@link ARKUI_ERROR_CODE_NO_ERROR} Success. +* {@link ARKUI_ERROR_CODE_PARAM_INVALID} Function parameter exception. +* {@link ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED} The component does not support this event. +* @since 12 +*/ +int32_t OH_ArkUI_RegisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node, + void* userData, void (*onFontStyleChange)(ArkUI_SystemFontStyleEvent* event, void* userData)); + +/** +* @brief Unregister the event callback when the system font style changes. +* +* @param node Indicates the target node. +* @since 12 +*/ +void OH_ArkUI_UnregisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node); + +/** + * @brief Retrieve the font size value for system font change events. + * + * @param event Indicates a pointer to the current system font change event. + * @return Updated system font size. -1 indicates a retrieval error. + * @since 12 + */ +int32_t OH_ArkUI_SystemFontStyleEvent_GetFontSize(const ArkUI_SystemFontStyleEvent* event); + +/** + * @brief Retrieve the font thickness values for system font change events. + * + * @param event Indicates a pointer to the current system font change event. + * @return Updated system font thickness, return value type {@link ArkUI_fontWeight}, + * default value:ARKUI_FONT_WEIGHT_W100。 + * @since 12 + */ +int32_t OH_ArkUI_SystemFontStyleEvent_GetFontWeight(const ArkUI_SystemFontStyleEvent* event); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index f238b1d6ff91dc6be0bd1c0ec1e84c483909387f..6bf306990cf1e0567055392efa5de5741619e1b2 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -983,6 +983,18 @@ typedef enum { ARKUI_COLOR_MODE_DARK, } ArkUI_ColorMode; +/** + * @brief Enumerates the system color modes. + * + * @since 12 + */ +typedef enum { + /** Light color mode. */ + ARKUI_SYSTEM_COLOR_MODE_LIGHT = 0, + /** Dark color mode. */ + ARKUI_SYSTEM_COLOR_MODE_DARK, +} ArkUI_SystemColorMode; + /** * @brief Enumerates the blur styles. * @@ -1895,6 +1907,10 @@ typedef enum { ARKUI_ERROR_CODE_GET_INFO_FAILED = 106201, /** The buffer size is not large enough. */ ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR = 106202, + /** The component is not a scroll container. */ + ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER = 180001, + /** The buffer is not large enough. */ + ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH = 180002, } ArkUI_ErrorCode; /** @@ -2063,6 +2079,27 @@ typedef struct { float perspective; } ArkUI_RotationOptions; +/** + * @brief Defines a struct for the measurement information of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanMeasureInfo ArkUI_CustomSpanMeasureInfo; + +/** + * @brief Defines a struct for the measurement metrics of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanMetrics ArkUI_CustomSpanMetrics; + +/** + * @brief Defines a struct for the drawing information of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanDrawInfo ArkUI_CustomSpanDrawInfo; + /** * @brief Defines the state of the NavDestination component. * @@ -2137,6 +2174,13 @@ typedef enum { ARKUI_SAFE_AREA_EDGE_END = 1 << 3, } ArkUI_SafeAreaEdge; +/** + * @brief Defines parameter used by the system font style callback event. + * + * @since 12 + */ +typedef struct ArkUI_SystemFontStyleEvent ArkUI_SystemFontStyleEvent; + /** * @brief Creates a size constraint. * @@ -3410,6 +3454,133 @@ int32_t OH_ArkUI_ListChildrenMainSizeOption_UpdateSize(ArkUI_ListChildrenMainSiz */ float OH_ArkUI_ListChildrenMainSizeOption_GetMainSize(ArkUI_ListChildrenMainSize* option, int32_t index); +/** + * @brief Creates measurement information for this custom span. + * + * @return Returns a CustomSpanMeasureInfo instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanMeasureInfo* OH_ArkUI_CustomSpanMeasureInfo_Create(); + +/** + * @brief Disposes of measurement information of this custom span. + * + * @param info The CustomSpanMeasureInfo instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo* info); + +/** + * @brief Obtains the font size of a custom span. + * + * @param info Indicates the pointer to the measurement information of a custom span. + * @return Returns the font size. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo* info); + +/** + * @brief Creates measurement metrics for this custom span. + * + * @return Returns a CustomSpanMetrics instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanMetrics* OH_ArkUI_CustomSpanMetrics_Create(); + +/** + * @brief Disposes of measurement metrics of this custom span. + * + * @param info The CustomSpanMetrics instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics* metrics); + +/** + * @brief Sets the width for a custom span. + * + * @param metrics Indicates the pointer to a CustomSpanMetrics instance. + * @param width Indicates the width, in px. The width should be greater than 0. + * @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 a parameter error occurs. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +int32_t OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics* metrics, float width); + +/** + * @brief Sets the height for a custom span. + * + * @param metrics Indicates the pointer to a CustomSpanMetrics instance. + * @param width Indicates the height, in px. The width should be greater than 0. + * @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 a parameter error occurs. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +int32_t OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics* metrics, float height); + +/** + * @brief Creates drawing information for this custom span. + * + * @return Returns a CustomSpanDrawInfo instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanDrawInfo* OH_ArkUI_CustomSpanDrawInfo_Create(); + +/** + * @brief Disposes of drawing information for this custom span. + * + * @param info The CustomSpanDrawInfo instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the x-axis offset of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the x-axis offset. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the top margin of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the top margin. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the bottom margin of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the bottom margin. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the baseline offset of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the baseline offset. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetBaseline(ArkUI_CustomSpanDrawInfo* info); + /** * @brief Create a image frame from the image path. * @param src Indicates the image path. diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff.py b/build-tools/capi_parser/src/coreImpl/diff/diff.py index 43f15d2cacb0b87ad2fe5b1d080b505f6adbd6df..375f7ab94be6ce616070cfe0d276a9b5125dadab 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from coreImpl.parser.parser import parser_include_ast +from coreImpl.parser.parser import diff_parser_include_ast from coreImpl.diff.diff_file import start_diff_file @@ -42,5 +42,5 @@ def process_file_diff(old_file, new_file): def get_parser_data(file_path): root_start = file_path.split('sdk_c')[0] root_path = f'{root_start}sdk_c' - parser_data = parser_include_ast(root_path, [file_path]) + parser_data = diff_parser_include_ast(root_path, [file_path]) return parser_data 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 0635db772b2671ede5285629946c7da01df24d34..2c4c0fb169ed2c0b71bed6886c5fd36873073477 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -19,14 +19,15 @@ import os import stat from collections import OrderedDict import openpyxl as op -from coreImpl.parser.parser import parser_include_ast +from coreImpl.parser.parser import diff_parser_include_ast from coreImpl.diff.diff_processor_node import judgment_entrance, change_data_total -from typedef.diff.diff import OutputJson, ApiChangeData +from typedef.diff.diff import OutputJson, ApiChangeData, IgnoreFileDirectory from bin.write_md import write_md_entrance global_old_dir = '' global_new_dir = '' diff_info_list = [] +syntax_file_list = [] def get_modification_type_dict(): @@ -67,13 +68,15 @@ def get_api_change_obj(api_data): change_data_obj.set_kit_name(element.kit_name) change_data_obj.set_sub_system(element.sub_system) change_data_obj.set_is_api_change(element.is_api_change) - change_data_obj.set_class_name(element.class_name) + change_data_obj.set_current_api_type(element.current_api_type) change_data_obj.set_diff_type(element.operation_diff_type) change_data_obj.set_change_type(element.api_modification_type) change_data_obj.set_old_all_text(element.old_api_full_text) change_data_obj.set_new_all_text(element.new_api_full_text) change_data_obj.set_compatible_total(element.is_compatible) change_data_obj.set_is_system_api(element.is_system_api) + change_data_obj.set_open_close_api(element.open_close_api) + change_data_obj.set_is_third_party_api(element.is_third_party_api) key = 1 else: old_all_text = '{}#&#{}'.format(change_data_obj.old_all_text, element.old_api_full_text) @@ -120,7 +123,7 @@ def collect_node_api_change(api_change_info_list): api_change_info.kit_name, api_change_info.sub_system, api_change_info.is_api_change, - api_change_info.class_name, + api_change_info.current_api_type, api_change_info.diff_type, api_change_info.change_type, api_change_info.compatible, @@ -129,18 +132,42 @@ def collect_node_api_change(api_change_info_list): api_change_info.new_all_text, api_change_info.compatible_total, api_change_info.unique_id, - api_change_info.is_system_api + api_change_info.is_system_api, + api_change_info.open_close_api, + api_change_info.is_third_party_api ] change_data.append(info_data) return change_data +def syntax_file_excel(output_path): + data = [] + if syntax_file_list: + for syntax_dict in syntax_file_list: + info_data = [ + syntax_dict.get('current_file'), + syntax_dict.get('error_message') + ] + data.append(info_data) + + wb = op.Workbook() + ws = wb['Sheet'] + ws.title = '语法错误文件信息' + ws.append(['当前文件', '错误信息']) + for element in data: + d = element[0], element[1] + ws.append(d) + output_path_xlsx = os.path.abspath(os.path.join(output_path, r'syntax_file_error.xlsx')) + wb.save(output_path_xlsx) + + def start_diff_file(old_dir, new_dir, output_path): result_info_list = global_assignment(old_dir, new_dir) total = change_data_total collect_api_change_data = collect_api_change(total) generate_excel(result_info_list, collect_api_change_data, output_path) + syntax_file_excel(output_path) write_md_entrance(result_info_list, output_path) result_json = result_to_json(result_info_list) diff_result_path = r'./diff_result.txt' @@ -179,11 +206,11 @@ def generate_excel(result_info_list, api_change_data, output_path): ws_of_change = wb.create_sheet('api变更次数统计') ws_of_change.append(['api名称', 'kit名称', '归属子系统', '是否是api', 'api类型', '操作标记', '变更类型', '兼容性', '变更次数', '差异项-旧版本', '差异项-新版本', '兼容性列表', '接口全路径', - '是否为系统API']) + '是否为系统API', '开源/闭源API', '是否是三方库api']) for element in change_data_list: change_data = element[0], element[1], element[2], element[3], element[4], element[5],\ element[6], element[7], element[8], element[9], element[10], element[11],\ - element[12], element[13] + element[12], element[13], element[14], element[15] ws_of_change.append(change_data) output_path_xlsx = os.path.abspath(os.path.join(output_path, 'diff.xlsx')) wb.save(output_path_xlsx) @@ -224,6 +251,14 @@ def get_file_ext(file_name): return os.path.splitext(file_name)[1] +def filter_ignore_file(file_path): + ignore_dict = IgnoreFileDirectory.ignore_file_dict + for key in ignore_dict.keys(): + if key in file_path: + return False + return True + + def diff_list(old_file_list, new_file_list, old_dir, new_dir): all_list = set(old_file_list + new_file_list) if len(all_list) == 0: @@ -246,8 +281,8 @@ def diff_list(old_file_list, new_file_list, old_dir, new_dir): 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)) + elif filter_ignore_file(diff_file_path): + result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [diff_file_path], flag=1)) for new_info in result_map.values(): diff_info_list.extend(judgment_entrance(None, new_info)) @@ -255,8 +290,8 @@ def add_new_file(diff_file_path): 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)) + elif filter_ignore_file(diff_file_path): + result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [diff_file_path], flag=0)) for old_info in result_map.values(): diff_info_list.extend(judgment_entrance(old_info, None)) @@ -278,12 +313,14 @@ def get_same_file_diff(target_file, old_file_list, new_file_list, old_dir, new_d def get_file_result_diff(old_target_file, new_target_file): - old_file_result_map = parse_file_result(parser_include_ast(global_old_dir, [old_target_file], flag=0)) - new_file_result_map = parse_file_result(parser_include_ast(global_new_dir, [new_target_file], flag=1)) - merged_dict = OrderedDict(list(old_file_result_map.items()) + list(new_file_result_map.items())) - all_key_list = merged_dict.keys() - for key in all_key_list: - diff_info_list.extend(judgment_entrance(old_file_result_map.get(key), new_file_result_map.get(key))) + if filter_ignore_file(old_target_file): + old_file_result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [old_target_file], flag=0)) + new_file_result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [new_target_file], flag=1)) + if old_file_result_map and new_file_result_map: + merged_dict = OrderedDict(list(old_file_result_map.items()) + list(new_file_result_map.items())) + all_key_list = merged_dict.keys() + for key in all_key_list: + diff_info_list.extend(judgment_entrance(old_file_result_map.get(key), new_file_result_map.get(key))) def del_file(dir_path): @@ -294,8 +331,8 @@ def del_file(dir_path): file_path = os.path.join(dir_path, i) 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)) + if get_file_ext(i) == '.h' and filter_ignore_file(file_path): + result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [file_path], flag=0)) for old_info in result_map.values(): diff_info_list.extend(judgment_entrance(old_info, None)) @@ -308,8 +345,8 @@ def add_file(dir_path): file_path = os.path.join(dir_path, i) 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)) + if get_file_ext(i) == '.h' and filter_ignore_file(file_path): + result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [file_path], flag=1)) for new_info in result_map.values(): diff_info_list.extend(judgment_entrance(None, new_info)) @@ -322,16 +359,36 @@ def parse_file_result(result, data_type=0): """ result_map = {} for root_node in result: + if root_node['syntax_error'] != 'NA': + error_file_path = os.path.abspath(os.path.join(root_node['gn_path'], root_node['name'])) + error_message_dict = { + 'current_file': error_file_path, + 'error_message': root_node['syntax_error'] + } + syntax_file_list.append(error_message_dict) + result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) 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 process_empty_name(data_info: dict, result_map): + data_current_file = os.path.split(data_info['location']['location_path'])[1] + if data_info['kind'] == 'ENUM_DECL' and 'members' in data_info and data_current_file in data_info['type']: + for element in data_info['members']: + result_map.setdefault(f'{data_current_file}-{element["name"]}', element) + elif data_info['kind'] == 'ENUM_DECL' and 'members' in data_info and (data_current_file not in data_info['type']): + result_map.setdefault(f'{data_current_file}-{data_info["type"]}', data_info) + elif (data_info['kind'] == 'STRUCT_DECL' or data_info['kind'] == 'UNION_DECL') and \ + (data_current_file not in data_info['type']): + result_map.setdefault(f'{data_current_file}-{data_info["type"]}', data_info) + + def parse_file_result_by_child(result_map, root_node): children_list = root_node['children'] for children in children_list: if children["name"] == '': + process_empty_name(children, result_map) 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 a0deb5b436a09cf167b02143a8dd66277d237017..c4c1b6a3a217036472d4d7b0f4e6c52cc9325157 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 @@ -749,6 +749,27 @@ def process_typedef_child(old_child, new_child, diff_typedef_list): diff_typedef_list.extend(special_data) +def process_anonymous_enum_member(old_info, new_info): + result_obj_list = [] + if old_info and new_info: + if old_info['name'] != new_info['name']: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_NAME_CHANGE, old_info['name'], new_info['name']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + if old_info['value'] != new_info['value']: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_VALUE_CHANGE, old_info['value'], new_info['value']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + else: + if old_info: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_REDUCE, old_info['node_content']['content'], 'NA') + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + + elif new_info: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_ADD, 'NA', new_info['node_content']['content']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + + return result_obj_list + + process_data = { Scene.FUNCTION_DECL.value: process_function, Scene.MACRO_DEFINITION.value: process_define, @@ -756,14 +777,38 @@ process_data = { Scene.UNION_DECL.value: process_union, Scene.ENUM_DECL.value: process_enum, Scene.VAR_DECL.value: process_variable_const, - Scene.TYPEDEF_DECL.value: process_typedef + Scene.TYPEDEF_DECL.value: process_typedef, + Scene.ENUM_CONSTANT_DECL.value: process_anonymous_enum_member, } +def get_ch_api_kind(dict_key): + if dict_key == Scene.ENUM_CONSTANT_DECL.value: + key = 'ENUM_DECL' + else: + key = dict_key + api_kind_dict = { + 'FUNCTION_DECL': '函数类型', + 'MACRO_DEFINITION': '宏定义类型', + 'STRUCT_DECL': '结构体类型', + 'UNION_DECL': '联合体类型', + 'ENUM_DECL': '枚举类型', + 'VAR_DECL': '常/变量类型', + 'TYPEDEF_DECL': '重命名类型', + 'TRANSLATION_UNIT': 'NA' + } + return api_kind_dict.get(key) + + def collect_change_data_total(data: dict, diff_info_list): for element in diff_info_list: element.set_api_node_name(data['name']) + if (data['kind'] == Scene.STRUCT_DECL.value or data['kind'] == Scene.UNION_DECL.value) and (not data['name']): + element.set_api_node_name(data['type']) element.set_current_api_unique_id(data['unique_id']) + element.set_open_close_api(data['open_close_api']) + element.set_is_third_party_api(data['is_third_party_api']) + element.set_current_api_type(get_ch_api_kind(data['kind'])) change_data_total.append(diff_info_list) @@ -780,17 +825,18 @@ def process_add_node(add_infor, key_extern, struct_union_enum): return diff_info_list if 'is_extern' in add_infor and add_infor['is_extern']: key_extern = True - diff_type = DiffType.ADD_API - old_api_content = 'NA' - if add_infor['kind'] in struct_union_enum: - new_api_content = add_infor['type'] + if add_infor['kind'] == Scene.ENUM_CONSTANT_DECL.value: + result_obj_list = process_anonymous_enum_member(old_infor, add_infor) + diff_info_list.extend(result_obj_list) else: - new_api_content = add_infor['node_content']['content'] - diff_info_list.append(wrap_diff_info(old_infor, add_infor, DiffInfo(diff_type, - old_api_content, new_api_content))) - if diff_type == DiffType.ADD_API: - set_is_api_change_result(diff_info_list, key_extern) - collect_change_data_total(add_infor, diff_info_list) + if add_infor['kind'] in struct_union_enum: + new_api_content = add_infor['type'] + else: + new_api_content = add_infor['node_content']['content'] + diff_info_list.append(wrap_diff_info(old_infor, add_infor, DiffInfo(DiffType.ADD_API, + 'NA', new_api_content))) + set_is_api_change_result(diff_info_list, key_extern) + collect_change_data_total(add_infor, diff_info_list) return diff_info_list @@ -802,14 +848,16 @@ def process_reduce_node(reduce_infor, key_extern, struct_union_enum): return diff_info_list if 'is_extern' in reduce_infor and reduce_infor['is_extern']: key_extern = True - diff_type = DiffType.REDUCE_API - new_api_content = 'NA' - if reduce_infor['kind'] in struct_union_enum: - old_api_content = reduce_infor['type'] + if reduce_infor['kind'] == Scene.ENUM_CONSTANT_DECL.value: + result_obj_list = process_anonymous_enum_member(reduce_infor, new_infor) + diff_info_list.extend(result_obj_list) else: - old_api_content = reduce_infor['node_content']['content'] - diff_info_list.append(wrap_diff_info(reduce_infor, new_infor, DiffInfo(diff_type, - old_api_content, new_api_content))) + if reduce_infor['kind'] in struct_union_enum: + old_api_content = reduce_infor['type'] + else: + old_api_content = reduce_infor['node_content']['content'] + diff_info_list.append(wrap_diff_info(reduce_infor, new_infor, DiffInfo(DiffType.REDUCE_API, + old_api_content, 'NA'))) set_is_api_change_result(diff_info_list, key_extern) collect_change_data_total(reduce_infor, diff_info_list) diff --git a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py index 158d76bb828c789afb30e1a8d74fa2a1382b1a69..e109bfe95bdfd5aa02a9b379d9d05a90ca3a5245 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py +++ b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py @@ -85,8 +85,6 @@ def get_result_api(file_data, result_api): if 'children' in file_data: for item1 in file_data["children"]: # 抛开根节点 if (item1["kind"] == 'FUNCTION_DECL' or item1["kind"] == 'VAR_DECL') and item1["is_extern"]: - differ_infor = difference_api(item1) - item1['differ_infor'] = differ_infor item = filter_func(item1) result_api.append(item) @@ -151,7 +149,8 @@ def collated_api_data(api_data: list): api.get('location_path'), api.get('sub_system'), api.get('unique_id'), - api.get('differ_infor') + api.get('open_close_api'), + api.get('is_third_party_api') ] collated_data_total.append(collated_data) return collated_data_total @@ -161,7 +160,7 @@ def generate_excel(array, name, generate_json_unique, original_json_unique): first_line_infor = ['模块名', '类名', '方法名', '函数', '类型', '起始版本', '废弃版本', 'syscap', '错误码', '是否为系统API', '模型限制', '权限', '是否支持跨平台', '是否支持卡片应用', '是否支持高阶API', - '装饰器', 'kit', '文件路径', '子系统', '接口全路径', '开源/闭源/三方库API'] + '装饰器', 'kit', '文件路径', '子系统', '接口全路径', '开源/闭源API', '是否是三方库API'] workbook = openpyxl.Workbook() work_sheet1 = workbook.active work_sheet1.title = '对比结果' @@ -184,7 +183,7 @@ def write_information_to_worksheet(work_sheet, information_data): write_data = data[0], data[1], data[2], data[3], data[4], \ data[5], data[6], data[7], data[8], data[9], \ data[10], data[11], data[12], data[13], data[14], \ - data[15], data[16], data[17], data[18], data[19], data[20] + data[15], data[16], data[17], data[18], data[19], data[20], data[21] work_sheet.append(write_data) diff --git a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py index a067d98afeea9306f53ebf43223e9c9579411467..446ddfc8de86f5f943202a09946df3dc8000a873 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py @@ -25,7 +25,7 @@ from clang.cindex import CursorKind from clang.cindex import TypeKind from utils.constants import StringConstant from utils.constants import RegularExpressions -from typedef.parser.parser import NodeKind +from typedef.parser.parser import NodeKind, DifferApiInfor, DifferApiRegular line_dist = {} @@ -149,13 +149,26 @@ def processing_def(cursor, data): # 处理宏定义 print('mar_define error, its content is none') if text: text = text.strip() # 删除两边的字符(默认是删除左右空格) - data['text'] = text + data['text'] = text data["type"] = "def_no_type" +def difference_api(api_data: dict): + api_name = api_data['name'] + closed_pattern = DifferApiRegular.CLOSED_SOURCE_API_REGULAR.value + open_pattern = DifferApiRegular.OPEN_SOURCE_API_REGULAR.value + if re.search(closed_pattern, api_name, flags=re.IGNORECASE): + api_data['open_close_api'] = DifferApiInfor.CLOSED_SOURCE_API.value + elif re.search(open_pattern, api_name, flags=re.IGNORECASE): + api_data['open_close_api'] = DifferApiInfor.OPEN_SOURCE_API.value + else: + api_data['is_third_party_api'] = True + + def processing_func(cursor, data): # 处理函数 data["return_type"] = cursor.result_type.spelling # 增加返回类型键值对 judgment_extern(cursor, data) + difference_api(data) def processing_type(cursor, data): # 没有类型的节点处理 @@ -197,6 +210,12 @@ special_node_process = { } +def process_members_class_name(data: dict, parent_cursor): + file_name = os.path.split(data['location']['location_path'])[1] + if (not data['name']) and (file_name not in parent_cursor.type.spelling): + data['class_name'] = '{}-{}'.format(file_name, parent_cursor.type.spelling) + + def get_api_unique_id(cursor, loc, data): unique_id = '' if cursor.kind == CursorKind.MACRO_DEFINITION: @@ -213,7 +232,7 @@ def get_api_unique_id(cursor, loc, data): parent_name_str = '' elif parent_of_cursor.kind.name in struct_union_enum: parent_name_str = parent_of_cursor.type.spelling - data['class_name'] = parent_of_cursor.spelling + process_members_class_name(data, parent_of_cursor) else: parent_name_str = parent_of_cursor.spelling except ValueError: @@ -227,6 +246,20 @@ def get_api_unique_id(cursor, loc, data): return unique_id +def get_node_class_name(data): + struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, + NodeKind.ENUM_DECL.value] + current_file_name = os.path.split(data["location"]["location_path"])[1] + if data.get('kind') in struct_union_enum and 'class_name' in data: + class_name = '{}-{}'.format(current_file_name, data["name"]) + if (not data["name"]) and (current_file_name not in data["type"]): + class_name = '{}-{}'.format(current_file_name, data["type"]) + else: + class_name = current_file_name + + return class_name + + def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊处理的节点 if key == 0: location_path = cursor.spelling @@ -244,9 +277,12 @@ def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊 relative_path = os.path.relpath(location_path, gn_path) # 获取头文件相对路 loc["location_path"] = relative_path data["location"] = loc + data["class_name"] = get_node_class_name(data) data["unique_id"] = get_api_unique_id(cursor, loc, data) if key == 0: data["unique_id"] = data["name"] + syntax_error_message = diagnostic_callback(cursor.translation_unit.diagnostics, gn_path) + data["syntax_error"] = syntax_error_message if kind_name in special_node_process.keys(): node_process = special_node_process[kind_name] node_process(cursor, data) # 调用对应节点处理函数 @@ -302,11 +338,36 @@ def get_default_node_data(cursor, gn_path): "form": 'NA', "atomic_service": 'NA', "decorator": 'NA', - "unique_id": '' + "unique_id": '', + "syntax_error": 'NA', + "open_close_api": 'NA', + "is_third_party_api": False } return data +def diagnostic_callback(diagnostic, dir_path): + # 获取诊断信息的详细内容 + syntax_error_message = 'NA' + key = 0 + for dig in diagnostic: + file_path = f"{dig.location.file}" + try: + file_path = os.path.relpath(os.path.normpath(file_path), dir_path) + except ValueError: + pass + line = dig.location.line + message = dig.spelling + # 输出诊断信息 + error_message = f"{file_path}:{line}\n错误信息:{message}" + if 0 == key: + syntax_error_message = error_message + key = 1 + else: + syntax_error_message = '{}\n{}'.format(syntax_error_message, error_message) + return syntax_error_message + + def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): data = get_default_node_data(cursor, gn_path) get_comment(cursor, data) @@ -323,10 +384,6 @@ def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): data["kind"] = cursor.kind.name if cursor.kind.name == CursorKind.MACRO_DEFINITION.name: define_comment(cursor, current_file, data) - struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, - NodeKind.ENUM_DECL.value] - if data.get('kind') in struct_union_enum and 'class_name' in data: - data['class_name'] = data.get('name') get_syscap_value(data) get_since_value(data) get_kit_value(data) @@ -564,6 +621,7 @@ def api_entrance(share_lib, include_path, gn_path, link_path): # 统计入口 # options赋值为如下,代表宏定义解析数据也要 args = ['-I{}'.format(path) for path in link_path] args.append('-std=c99') + args.append('--target=aarch64-linux-musl') options = clang.cindex.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD data_total = [] # 列表对象-用于统计 diff --git a/build-tools/capi_parser/src/coreImpl/parser/parser.py b/build-tools/capi_parser/src/coreImpl/parser/parser.py index 5ab20372e1dafd9f410fa0fbfd89c0bf1208ffb5..1adac3f2ecd1379a1c0809afd72484445e0bbae5 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parser.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parser.py @@ -267,10 +267,8 @@ def find_include(link_include_path): def copy_self_include(link_include_path, self_include_file): for dir_path, dir_name, file_name_list in os.walk(self_include_file): - for element in dir_name: - dir_path_name = os.path.abspath(os.path.join(dir_path, element)) - if 'sysroot_myself' not in dir_path and dir_path_name not in link_include_path: - link_include_path.append(dir_path_name) + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path and dir_path not in link_include_path: + link_include_path.append(dir_path) def delete_typedef_child(child): @@ -294,19 +292,11 @@ def parser(directory_path): # 目录路径 return data_total -def parser_include_ast(dire_file_path, include_path: list, flag=-1): # 对于单独的.h解析接口 +def parser_include_ast(dire_file_path, include_path: list): # 对于单独的.h解析接口 correct_include_path = [] link_include_path = [dire_file_path] - # 针对check - if -1 == flag: - copy_std_lib(link_include_path, dire_file_path) - link_include(dire_file_path, StringConstant.FUNK_NAME.value, link_include_path) - # 针对diff - else: - copy_std_lib(link_include_path) - find_include(link_include_path) - if len(link_include_path) <= 2: - copy_self_include(link_include_path, dire_file_path) + copy_std_lib(link_include_path, dire_file_path) + copy_self_include(link_include_path, dire_file_path) for item in include_path: split_path = os.path.splitext(item) if split_path[1] == '.h': # 判断.h结尾 @@ -322,13 +312,25 @@ def parser_include_ast(dire_file_path, include_path: list, flag=-1): # return data +def diff_parser_include_ast(dire_file_path, include_path: list, flag=-1): # 对于单独的.h解析接口 + link_include_path = [dire_file_path] + copy_self_include(link_include_path, dire_file_path) + data = parse_include.get_include_file(include_path, link_include_path, dire_file_path) + + for item in data: + if 'children' in item: + for child in item['children']: + delete_typedef_child(child) + + return data + + def get_dir_file_path(dir_path): file_path_list = [] link_include_path = [] # 装链接头文件路径 for dir_path, dir_names, filenames in os.walk(dir_path): - for dir_name in dir_names: - if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path: - link_include_path.append(os.path.join(dir_path, dir_name)) + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path and dir_path not in link_include_path: + link_include_path.append(dir_path) for file in filenames: if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path and file.endswith('.h'): file_path_list.append(os.path.join(dir_path, file)) diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index 897c320ba71011f093e2668d18c51f3106accf7e..d9a7b4b3db1052683c80f587685ad2b2070307ba 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -116,6 +116,7 @@ class Scene(enum.Enum): VAR_DECL = 'VAR_DECL' TYPEDEF_DECL = 'TYPEDEF_DECL' TRANSLATION_UNIT = 'TRANSLATION_UNIT' + ENUM_CONSTANT_DECL = 'ENUM_CONSTANT_DECL' class TAGS(enum.Enum): @@ -229,6 +230,7 @@ compatible_list = [ DiffType.ADD_API, DiffType.ADD_DOC, DiffType.ADD_DOC_TAG, + DiffType.ENUM_MEMBER_ADD, DiffType.FUNCTION_PARAM_NAME_CHANGE, DiffType.DOC_TAG_ADDTOGROUP_NA_TO_HAVE, DiffType.DOC_TAG_ADDTOGROUP_HAVE_TO_NA, @@ -386,6 +388,9 @@ class DiffInfo: operation_diff_type: str = '' old_differ_content: str = '' new_differ_content: str = '' + open_close_api: str = '' + is_third_party_api = False + current_api_type: str = '' def __init__(self, diff_type: DiffType, old_differ_content, new_differ_content): self.diff_type = diff_type @@ -540,6 +545,24 @@ class DiffInfo: def get_new_differ_content(self): return self.new_differ_content + def set_open_close_api(self, open_close_api): + self.open_close_api = open_close_api + + def get_open_close_api(self): + return self.open_close_api + + def set_is_third_party_api(self, is_third_party_api): + self.is_third_party_api = is_third_party_api + + def get_is_third_party_api(self): + return self.is_third_party_api + + def set_current_api_type(self, current_api_type): + self.current_api_type = current_api_type + + def get_current_api_type(self): + return self.current_api_type + class OutputJson: api_name: str = '' @@ -595,6 +618,10 @@ class ApiChangeData: compatible_total = False unique_id: str = '' is_system_api = False + open_close_api: str = '' + is_third_party_api = False + api_type: str = '' + current_api_type: str = '' def set_api_name(self, api_name): self.api_name = api_name @@ -679,3 +706,41 @@ class ApiChangeData: def get_is_system_api(self): return self.is_system_api + + def set_open_close_api(self, open_close_api): + self.open_close_api = open_close_api + + def get_open_close_api(self): + return self.open_close_api + + def set_is_third_party_api(self, is_third_party_api): + self.is_third_party_api = is_third_party_api + + def get_is_third_party_api(self): + return self.is_third_party_api + + def set_api_type(self, api_type): + self.api_type = api_type + + def get_api_type(self): + return self.api_type + + def set_current_api_type(self, current_api_type): + self.current_api_type = current_api_type + + def get_current_api_type(self): + return self.current_api_type + + +class IgnoreFileDirectory: + ignore_file_dict = { + 'arm-linux-ohos': '', + 'aarch64-linux-ohos': '', + 'x86_64-linux-ohos': '', + 'i686-linux-ohos': '', + 'tee': '', + 'linux': '' + } + + def get_ignore_file_dict(self): + return self.ignore_file_dict diff --git a/build-tools/capi_parser/src/utils/constants.py b/build-tools/capi_parser/src/utils/constants.py index 9c67d962b8669b9dda3a6868012349fb0d908c90..579737ce9a20acb19c77009a8558a2cc7aff7e5b 100644 --- a/build-tools/capi_parser/src/utils/constants.py +++ b/build-tools/capi_parser/src/utils/constants.py @@ -24,15 +24,15 @@ class StringConstant(enum.Enum): REPLACE_WAREHOUSE = '\\interface_sdk_c\\interface_sdk_c' # 拉到本地仓路径(去掉磁盘) # 拉到本地仓的三方库绝对路径 INCLUDE_LIB = r'.\third_party\musl\ndk_musl_include' - STD_INCLUDE = r'.\sysroot_myself\std_include_files' - CREATE_LIB_PATH = r'.\sysroot_myself\$is_headers_out_dir' - SELF_INCLUDE = r'.\sysroot_myself\self_include_files' - SELF_INCLUDE_OLD = r'.\sysroot_myself\self_include_files_old' - SELF_INCLUDE_NEW = r'.\sysroot_myself\self_include_files_new' - SYSROOT = r'.\sysroot_myself' + STD_INCLUDE = r'./sysroot_myself/std_include_files' + CREATE_LIB_PATH = r'./sysroot_myself/$is_headers_out_dir' + SELF_INCLUDE = r'./sysroot_myself/self_include_files' + SELF_INCLUDE_OLD = r'./sysroot_myself/self_include_files_old' + SELF_INCLUDE_NEW = r'./sysroot_myself/self_include_files_new' + SYSROOT = r'./sysroot_myself' RESULT_HEAD_NAME = "result_total.xlsx" PARSER_DIRECT_EXCEL_NAME = 'parser_direct_data.xlsx' - FILE_LEVEL_API_DATA = r'.\api_kit_c.json' + FILE_LEVEL_API_DATA = r'./api_kit_c.json' class RegularExpressions(enum.Enum): diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index b702a1d7a12bbc2fa3df403e0d1a21ee278e874d..196fab5242b37ac6412a7b28f14a277c3e549da6 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -2,5 +2,6 @@ { "name": "OH_NativeVSync_Create" }, { "name": "OH_NativeVSync_Destroy" }, { "name": "OH_NativeVSync_RequestFrame" }, + { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, { "name": "OH_NativeVSync_GetPeriod" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 069d17689616c2a336e82da0ae3bb8c27af778c0..85627485c895b2d38cc06214efaf57a8fba60bda 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -65,7 +65,6 @@ OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length); * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param window Indicates the pointer to a NativeVsync instance. - * @return Returns int32_t, return value == 0, success, otherwise, failed. * @since 9 * @version 1.0 */ @@ -73,17 +72,37 @@ void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync); /** * @brief Request next vsync with callback. + * If you call this interface multiple times in one frame, it will only call the last callback. * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param nativeVsync Indicates the pointer to a NativeVsync. * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. * @param data Indicates data whick will be used in callback. - * @return Returns int32_t, return value == 0, success, otherwise, failed. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. * @since 9 * @version 1.0 */ int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); +/** + * @brief Request next vsync with callback. + * If this function is called multiple times in one vsync period, all these callbacks and dataset will be called. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. + * @param data Indicates data whick will be used in callback. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. + * @since 12 + * @version 1.0 + */ +int OH_NativeVSync_RequestFrameWithMultiCallback( + OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); + /** * @brief Get vsync period. * diff --git a/graphic/graphic_2d/native_window/graphic_error_code.h b/graphic/graphic_2d/native_window/graphic_error_code.h index cba61e5e8dbac4efa1b5f7f21a279592ed4be15c..8a24196811340761fbf7d29b8287b435d0a52f3b 100644 --- a/graphic/graphic_2d/native_window/graphic_error_code.h +++ b/graphic/graphic_2d/native_window/graphic_error_code.h @@ -80,6 +80,8 @@ typedef enum OHNativeErrorCode { NATIVE_ERROR_UNSUPPORTED = 50102000, /** @error unknown error, please check log */ NATIVE_ERROR_UNKNOWN = 50002000, + /** @error ipc send failed */ + NATIVE_ERROR_BINDER_ERROR = 50401000, /** @error the egl environment is abnormal */ NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, /** @error egl interface invocation failed */ diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 4c683158024c649dc21404fbbd054aacf9a7ccd7..8ae03c4bb792d71f2707e9a3615c86b4a6dd3691 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -279,6 +279,7 @@ OH_AVErrCode OH_AudioCodec_IsValid(OH_AVCodec *codec, bool *isValid); * {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is nullptr or invalid, * the mediaKeySession is nullptr or invalid. * {@link AV_ERR_INVALID_STATE} 8 - If the codec service is invalid. + * {@link AV_ERR_NO_MEMORY}, failed to request memory. * @since 12 * @version 1.0 */ diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index c5e35031cfa4005ba8484a54ad2014aec1e8fb86..cdaeeed5529c5e8ba9e60ece0735468ee59ed099 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1198,6 +1198,9 @@ typedef enum OH_TemporalGopReferenceMode { ADJACENT_REFERENCE = 0, /** Refer to latest long-term reference frame. */ JUMP_REFERENCE = 1, + /** Uniformly scaled reference structure, which has even distribution of video frames after drop the highest + * enhance layer. The temporal group of pictures must be power of 2. */ + UNIFORMLY_SCALED_REFERENCE = 2, } OH_TemporalGopReferenceMode; #ifdef __cplusplus diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index c52df2c28f136c9543db3e4985336834473d8eb6..012329d4f1297d7a8f46cf8a65f2b4f413c95b6e 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -343,6 +343,8 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_DRM_DECRYPT_FAILED}, the drm-protected video buffer is decrypted failed, + * it is recommended to check the logs. * @since 11 */ OH_AVErrCode OH_VideoDecoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index); @@ -442,6 +444,7 @@ OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); * @return {@link AV_ERR_OK} 0 - Success * {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the codec service or the media key session * service is in wrong status. + * {@link AV_ERR_NO_MEMORY}, instance has already released or no memory. * {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is nullptr or invalid, * the mediaKeySession is nullptr or invalid. * @since 11 diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 7b2117ebceeeb3cf9ebab50c1a54fb4db73d18d3..7db7dec7e6e97a928b859ce2148f049dc8f9cbbf 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -210,6 +210,7 @@ OH_AVErrCode OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback(OH_AVDemuxer *dem * @param mediaKeySystemInfo Indicates the media key system info which ram space allocated by callee and * released by caller. * @return {@link AV_ERR_OK} 0 - Success + * {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the demuxer engine is not inited or init failed. * {@link AV_ERR_INVALID_VAL} 3 - If the demuxer instance is nullptr or invalid * or the mediaKeySystemInfo is nullptr. * @since 11 diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 0e453e4d5b3fbae7c6a4ecacf67c026dfcd97746..7e0949b810692dc6176a491497d44613a723de68 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -115,13 +115,17 @@ "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" }, + { + "first_introduced": "11", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" }, { "first_introduced": "12", - "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + "name": "OH_MediaKeySession_SetCallback" }, { "first_introduced": "12", diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 2a818346bb2e251fbfaabe5afc2ce9385c2906d3..966948a6459bf197d2a47e41e1c4f4a030ea7c75 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -135,8 +135,6 @@ bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, * @brief Creates a media key system instance from the name. * @param name Secifies which drm system will be created by name. * @param mediaKeySystem Media key system instance. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully, - * return DRM_ERR_MAX_SYSTEM_NUM_REACHED when max num media key system reached. * @return {@link DRM_ERR_OK} 0 - Success.  *         {@link DRM_ERR_INVALID_VAL} 24700503 - Probably caused by: * 1. the name is nullptr or the length of name is zero. @@ -155,6 +153,7 @@ Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKey * @param value Configuration vaule string to be set. * @return {@link DRM_ERR_OK} 0 - Success.  *         {@link DRM_ERR_INVALID_VAL} 24700503 - The parameter passed in is a null pointer or invalid. + *         {@link DRM_ERR_UNKNOWN} 24700506 - Internal error occurred, it is recommended to check the logs. * @since 11 * @version 1.0 */ @@ -358,7 +357,6 @@ Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySyste */ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); - #ifdef __cplusplus } #endif diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h index 5f8be7c783e9671e7fd411d5ab276e6d0bd05a63..bf16c2ef5b1054d5f7a29ad9ac9451214db0aa26 100644 --- a/multimedia/image_framework/include/image/pixelmap_native.h +++ b/multimedia/image_framework/include/image/pixelmap_native.h @@ -114,30 +114,6 @@ typedef enum { PIXEL_FORMAT_NV12 = 9, } PIXEL_FORMAT; -/** - * @brief Defines the anti-aliasing level. - * - * @since 12 - */ -typedef enum { - /** - * Nearest-neighbor interpolation algorithm - */ - OH_PixelmapNative_AntiAliasing_NONE = 0, - /** - * Bilinear interpolation algorithm - */ - OH_PixelmapNative_AntiAliasing_LOW = 1, - /** - * Bilinear interpolation algorithm with mipmap linear filtering - */ - OH_PixelmapNative_AntiAliasing_MEDIUM = 2, - /** - * Cubic interpolation algorithm - */ - OH_PixelmapNative_AntiAliasing_HIGH = 3, -} OH_PixelmapNative_AntiAliasingLevel; - /** * @brief Enumerates the HDR metadata types that need to be stored in Pixelmap. * @@ -423,32 +399,6 @@ Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_I Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t srcpixelFormat); -/** - * @brief Get rowStride for InitializationOptions struct. - * - * @param options The InitializationOptions pointer will be operated. - * @param rowStride the rowStride of image buffer. - * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. - * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if rowStride is null. - * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe options is released. - * @since 12 - */ -Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride(OH_Pixelmap_InitializationOptions *options, - int32_t *rowStride); - -/** - * @brief Set rowStride number for InitializationOptions struct. - * - * @param options The InitializationOptions pointer will be operated. - * @param rowStride the rowStride of image buffer. - * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. - * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if rowStride does not match width. - * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe options is released. - * @since 12 - */ -Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride(OH_Pixelmap_InitializationOptions *options, - int32_t rowStride); - /** * @brief Get alphaType number for InitializationOtions struct. * @@ -673,24 +623,6 @@ Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rat */ Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY); -/** - * @brief Scales this image based on the input width and height with anti-aliasing. - * - * @param pixelmap The Pixelmap pointer will be operated. - * @param scaleX Scaling ratio of the width. - * @param scaleY Scaling ratio of the height. - * @param level The anti-aliasing algorithm to be used. - * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. - * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, x and y are incorrect. - * returns {@link Image_ErrorCode} IMAGE_TOO_LARGE - if image is too large. - * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if device has no memory. - * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe source pixelmap is released. - * @see OH_PixelmapNative - * @since 12 - */ -Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, - OH_PixelmapNative_AntiAliasingLevel level); - /** * @brief Translates this image based on the input coordinates. * diff --git a/multimedia/image_framework/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index b05dc9ca782afa1d6ffa898d34dabdd9c8ef52d1..26d28e3bd479de89efd6d987f292306986fad8e4 100644 --- a/multimedia/image_framework/include/image_pixel_map_mdk.h +++ b/multimedia/image_framework/include/image_pixel_map_mdk.h @@ -118,31 +118,6 @@ enum { OHOS_PIXEL_MAP_EDITABLE = 1, }; -/** - * @brief Enumerates the anti-aliasing level. - * - * @since 12 - * @version 1.0 - */ -typedef enum { - /** - * Nearest-neighbor interpolation. - */ - OH_PixelMap_AntiAliasing_NONE = 0, - /** - * Bilinear interpolation, without mipmap linear filtering. - */ - OH_PixelMap_AntiAliasing_LOW = 1, - /** - * Bilinear interpolation, with mipmap linear filtering. - */ - OH_PixelMap_AntiAliasing_MEDIUM = 2, - /** - * Cubic interpolation. - */ - OH_PixelMap_AntiAliasing_HIGH = 3, -} OH_PixelMap_AntiAliasingLevel; - /** * @brief Defines the options used for creating a pixel map. * @@ -208,31 +183,6 @@ struct OhosPixelMapCreateOps { int32_t OH_PixelMap_CreatePixelMap(napi_env env, OhosPixelMapCreateOps info, void* buf, size_t len, napi_value* res); -/** - * @brief Creates a PixelMap object with stride, whose memory is default as DMA. - * - * @param env Indicates the NAPI environment pointer. - * @param info Indicates the options for setting the PixelMap object. - * @param buf Indicates the pointer to the buffer of the image. - * @param len Indicates the image size. - * @param rowStride Indicates the stride of the image buffer. - * @param res Indicates the pointer to the PixelMap object at the application layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if info, len and rowStride do not match. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * @see OH_PixelMap_CreatePixelMapWithStride - * @since 12 - * @version 1.0 - */ -int32_t OH_PixelMap_CreatePixelMapWithStride(napi_env env, OhosPixelMapCreateOps info, - void* buf, size_t len, int32_t rowStride, napi_value* res); - /** * @brief Creates a PixelMap object that contains only alpha channel information. * @@ -438,30 +388,6 @@ int32_t OH_PixelMap_SetOpacity(const NativePixelMap* native, float opacity); */ int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); - -/** - * @brief Scales a PixelMap object with anti-aliasing. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param x Indicates the scaling ratio of the width. - * @param y Indicates the scaling ratio of the height. - * @param level Indicates the anti-aliasing algorithm to be used. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter, x and y are incorrect. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * @see Scale - * @since 12 - * @version 1.0 - */ -int32_t OH_PixelMap_ScaleWithAntiAliasing(const NativePixelMap* native, float x, float y, - OH_PixelMap_AntiAliasingLevel level); - /** * @brief Translates a PixelMap object. * diff --git a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json index 0476d801e395562946bdfb0513ba7e65515f6bc2..64800fe826282f2c62c68ee354f432af18ea4fed 100644 --- a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json +++ b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json @@ -12,10 +12,6 @@ { "name": "OH_PixelMap_CreatePixelMap" }, - { - "first_introduced": "12", - "name": "OH_PixelMap_CreatePixelMapWithStride" - }, { "name": "OH_PixelMap_CreateAlphaPixelMap" }, @@ -46,10 +42,6 @@ { "name": "OH_PixelMap_Scale" }, - { - "first_introduced": "12", - "name": "OH_PixelMap_ScaleWithAntiAliasing" - }, { "name": "OH_PixelMap_Translate" }, diff --git a/multimedia/image_framework/libohimage.ndk.json b/multimedia/image_framework/libohimage.ndk.json index a9eefa5fbf460cbf00e0f714a491f9e2b330cc41..da613fb2ac170e64b6ec444011d7a8133d3da97b 100644 --- a/multimedia/image_framework/libohimage.ndk.json +++ b/multimedia/image_framework/libohimage.ndk.json @@ -23,6 +23,10 @@ "first_introduced": "12", "name": "OH_ImageNative_GetPixelStride" }, + { + "first_introduced": "12", + "name": "OH_ImageNative_GetTimestamp" + }, { "first_introduced": "12", "name": "OH_ImageNative_Release" diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json index f06f6b1866994fabc7112dc3877870b99a9d044d..b2439b1761ee6f2b9f2ef0847a72c9cb48220ab0 100644 --- a/multimedia/image_framework/libpixelmap.ndk.json +++ b/multimedia/image_framework/libpixelmap.ndk.json @@ -43,14 +43,6 @@ "first_introduced": "12", "name": "OH_PixelmapInitializationOptions_SetAlphaType" }, - { - "first_introduced": "12", - "name": "OH_PixelmapInitializationOptions_GetRowStride" - }, - { - "first_introduced": "12", - "name": "OH_PixelmapInitializationOptions_SetRowStride" - }, { "first_introduced": "12", "name": "OH_PixelmapInitializationOptions_Release" @@ -115,10 +107,6 @@ "first_introduced": "12", "name": "OH_PixelmapNative_Scale" }, - { - "first_introduced": "12", - "name": "OH_PixelmapNative_ScaleWithAntiAliasing" - }, { "first_introduced": "12", "name": "OH_PixelmapNative_Translate" diff --git a/multimodalinput/kits/c/BUILD.gn b/multimodalinput/kits/c/BUILD.gn index 60f919ab132fe57ba9c3cdaf305e7f899264baff..1d53eb37c3208cc6c0570224f2ca4199d33616fd 100644 --- a/multimodalinput/kits/c/BUILD.gn +++ b/multimodalinput/kits/c/BUILD.gn @@ -18,6 +18,7 @@ import("//foundation/multimodalinput/input/multimodalinput_mini.gni") ohos_ndk_headers("ohinput_header") { dest_dir = "$ndk_headers_out_dir/multimodalinput" sources = [ + "./input/oh_axis_type.h", "./input/oh_input_manager.h", "./input/oh_key_code.h", ] @@ -29,6 +30,7 @@ ohos_ndk_library("libohinput_ndk") { ndk_description_file = "./ohinput.ndk.json" system_capability = "SystemCapability.MultimodalInput.Input.Core" system_capability_headers = [ + "multimodalinput/oh_axis_type.h", "multimodalinput/oh_input_manager.h", "multimodalinput/oh_key_code.h", ] diff --git a/multimodalinput/kits/c/input/oh_axis_type.h b/multimodalinput/kits/c/input/oh_axis_type.h new file mode 100644 index 0000000000000000000000000000000000000000..7d5fd8cc45645c340e67f9b59554b245b9b2380c --- /dev/null +++ b/multimodalinput/kits/c/input/oh_axis_type.h @@ -0,0 +1,165 @@ +/* + * 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 input + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 12 + */ + +/** + * @file oh_axis_type.h + * + * @brief Defines the axis event-specific structure and enumerations. + * @kit InputKit + * @syscap SystemCapability.MultimodalInput.Input.Core + * @library liboh_input.so + * @since 12 + */ + +#ifndef OH_AXIS_TYPE_H +#define OH_AXIS_TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates axis types. + * + * @since 12 + */ +typedef enum InputEvent_AxisType { + /** + * Indicates an unknown axis type. It is generally used as the initial value. + * + * @since 12 + */ + AXIS_TYPE_UNKNOWN, + + /** + * Indicates the vertical scroll axis. When you scroll the mouse wheel or make certain gestures on the touchpad, + * the status of the vertical scroll axis changes. + * + * @since 12 + */ + AXIS_TYPE_SCROLL_VERTICAL, + + /** + * Indicates the horizontal scroll axis. + * When you scroll the mouse wheel or make certain gestures on the touchpad, + * the status of the horizontal scroll axis changes. + * + * @since 12 + */ + AXIS_TYPE_SCROLL_HORIZONTAL, + + /** + * Indicates the pinch axis, which is used to describe a pinch gesture on the touchscreen or touchpad. + * + * @since 12 + */ + AXIS_TYPE_PINCH, + + /** + * Indicates the rotate axis, which is used to describe a rotate gesture on the touchpad. + * + * @since 12 + */ + AXIS_TYPE_ROTATE +} InputEvent_AxisType; + +/** + * @brief Enumerates axis event types. + * + * @since 12 + */ +typedef enum InputEvent_AxisEventType { + /** + * @brief Enumerates two-finger pinch events. The axis value can be AXIS_TYPE_PINCH or AXIS_TYPE_ROTATE. + * + * @since 12 + */ + AXIS_EVENT_TYPE_PINCH = 1, + /** + * @brief Enumerates scroll axis events. + * The axis value can be AXIS_TYPE_SCROLL_VERTICAL or AXIS_TYPE_SCROLL_HORIZONTAL. + * Wherein, the value of AXIS_TYPE_SCROLL_HORIZONTAL is 0 for a mouse wheel event. + * + * @since 12 + */ + AXIS_EVENT_TYPE_SCROLL = 2 +} InputEvent_AxisEventType; + +/** + * @brief Enumerates axis event source types. + * + * @since 12 + */ +typedef enum InputEvent_SourceType { + /** + * Indicates that the input source generates events similar to mouse cursor movement, + * button press and release, and wheel scrolling. + * + * @since 12 + */ + SOURCE_TYPE_MOUSE = 1, + /** + * Indicates that the input source generates a touchscreen multi-touch event. + * + * @since 12 + */ + SOURCE_TYPE_TOUCHSCREEN = 2, + /** + * Indicates that the input source generates a touchpad multi-touch event. + * + * @since 12 + */ + SOURCE_TYPE_TOUCHPAD = 3 +} InputEvent_SourceType; + +/** + * @brief Enumerates axis event actions. + * + * @since 12 + */ +typedef enum InputEvent_AxisAction { + /** + * Start action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_BEGIN = 5, + /** + * Update action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_UPDATE = 6, + /** + * End action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_END = 7, +} InputEvent_AxisAction; +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 7506a28f9f85bc13507c452b224163cd1e88a31c..5ae7d4df7ca6c5ca790b4b836841b8f168afaadc 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -37,6 +37,7 @@ #include +#include "oh_axis_type.h" #include "oh_key_code.h" #ifdef __cplusplus @@ -48,7 +49,7 @@ extern "C" { * * @since 12 */ -enum Input_KeyStateAction { +typedef enum Input_KeyStateAction { /** Default */ KEY_DEFAULT = -1, /** Pressing of a key */ @@ -59,14 +60,14 @@ enum Input_KeyStateAction { KEY_SWITCH_ON = 2, /** Key switch disabled */ KEY_SWITCH_OFF = 3 -}; +} Input_KeyStateAction; /** * @brief Enumerates key event types. * * @since 12 */ -typedef enum { +typedef enum Input_KeyEventAction { /** Cancellation of a key action. */ KEY_ACTION_CANCEL = 0, /** Pressing of a key. */ @@ -80,7 +81,7 @@ typedef enum { * * @since 12 */ -typedef enum { +typedef enum Input_MouseEventAction { /** Cancel. */ MOUSE_ACTION_CANCEL = 0, /** Moving of the mouse pointer. */ @@ -102,19 +103,19 @@ typedef enum { * * @since 12 */ -enum InputEvent_MouseAxis { +typedef enum InputEvent_MouseAxis { /** Vertical scroll axis */ MOUSE_AXIS_SCROLL_VERTICAL = 0, /** Horizontal scroll axis */ MOUSE_AXIS_SCROLL_HORIZONTAL = 1, -}; +} InputEvent_MouseAxis; /** * @brief Enumerated values of mouse event button. * * @since 12 */ -typedef enum { +typedef enum Input_MouseEventButton { /** Invalid button */ MOUSE_BUTTON_NONE = -1, /** Left button on the mouse. */ @@ -134,7 +135,7 @@ typedef enum { * * @since 12 */ -typedef enum { +typedef enum Input_TouchEventAction { /** Touch cancelled. */ TOUCH_ACTION_CANCEL = 0, /** Touch pressed. */ @@ -150,51 +151,115 @@ typedef enum { * * @since 12 */ -struct Input_KeyState; +typedef struct Input_KeyState Input_KeyState; /** * @brief The key event to be injected. * * @since 12 */ -struct Input_KeyEvent; +typedef struct Input_KeyEvent Input_KeyEvent; /** * @brief The mouse event to be injected. * * @since 12 */ -struct Input_MouseEvent; +typedef struct Input_MouseEvent Input_MouseEvent; /** * @brief The touch event to be injected. * * @since 12 */ -struct Input_TouchEvent; +typedef struct Input_TouchEvent Input_TouchEvent; /** - * @brief Enumerates the error codes. + * @brief Enumerates axis events. * * @since 12 */ -typedef enum { - /** @error Success return code on sucess*/ +typedef struct Input_AxisEvent Input_AxisEvent; + +/** + * @brief Enumerates error codes. + * + * @since 12 + */ +typedef enum Input_Result { + /** @error Success return code on success*/ INPUT_SUCCESS = 0, /** @error Permission verification failed */ INPUT_PERMISSION_DENIED = 201, /** @error Non-system application */ INPUT_NOT_SYSTEM_APPLICATION = 202, /** @error Parameter check failed */ - INPUT_PARAMETER_ERROR = 401 + INPUT_PARAMETER_ERROR = 401, + /** @error Service error */ + INPUT_SERVICE_EXCEPTION = 3800001, + /** @error Interceptor repeatedly created for an application */ + INPUT_REPEAT_INTERCEPTOR = 4200001 } Input_Result; +/** + * @brief Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed. + * + * @param keyEvent Key event object. + * @since 12 + */ +typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent); + +/** + * @brief Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed. + * + * @param mouseEvent Mouse event object. + * @since 12 + */ +typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent); + +/** + * @brief Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed. + * + * @param touchEvent Touch event object. + * @since 12 + */ +typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent); + +/** + * @brief Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed. + * + * @param axisEvent Axis event object. + * @since 12 + */ +typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent); + +/** + * @brief Defines the structure for the interceptor of event callbacks, + * including mouseCallback, touchCallback, and axisCallback. + * + * @since 12 + */ +typedef struct Input_InterceptorEventCallback { + /** Defines a lifecycle callback for **mouseEvent**. */ + Input_MouseEventCallback mouseCallback; + /** Defines a lifecycle callback for **touchEvent**. */ + Input_TouchEventCallback touchCallback; + /** Defines a lifecycle callback for **axisEvent**. */ + Input_AxisEventCallback axisCallback; +} Input_InterceptorEventCallback; + +/** + * @brief Defines event interceptor options. + * @since 12 + */ +typedef struct Input_InterceptorOptions Input_InterceptorOptions; + /** * @brief Queries the key state. * * @param keyState Key state. * @return OH_Input_GetKeyState function result code. - * {@link INPUT_SUCCESS} get KeyState sucess.\n + * {@link INPUT_SUCCESS} get KeyState success.\n * {@link INPUT_PARAMETER_ERROR} keyCode is invalid.\n * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -285,7 +350,7 @@ int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); * * @param keyEvent - the key event to be injected. * @return OH_Input_InjectKeyEvent function result code. - * {@link INPUT_SUCCESS} inject keyEvent sucess.\n + * {@link INPUT_SUCCESS} inject keyEvent success.\n * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n * {@link INPUT_PARAMETER_ERROR} keyCode is less 0, can not process.\n * @syscap SystemCapability.MultimodalInput.Input.Core @@ -377,7 +442,7 @@ int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); * * @param mouseEvent - the mouse event to be injected. * @return OH_Input_InjectMouseEvent function result code. - * {@link INPUT_SUCCESS} inject mouseEvent sucess.\n + * {@link INPUT_SUCCESS} inject mouseEvent success.\n * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n * @syscap SystemCapability.MultimodalInput.Input.Core @@ -508,7 +573,8 @@ int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent * @brief Sets the axis value for a mouse axis event. * * @param mouseEvent Mouse event object. - * @param axisType Axis value. A positive value means scrolling forward, and a negative number means scrolling backward. + * @param axisType Axis value. A positive value means scrolling forward, + * and a negative number means scrolling backward. * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ @@ -549,7 +615,7 @@ int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEve * * @param touchEvent - the touch event to be injected. * @return OH_Input_InjectTouchEvent function result code. - * {@link INPUT_SUCCESS} inject touchEvent sucess.\n + * {@link INPUT_SUCCESS} inject touchEvent success.\n * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -683,6 +749,431 @@ int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEve */ void OH_Input_CancelInjection(); +/** + * @brief Creates an axis event object. + * + * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned. + * If the operation fails, null is returned. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_AxisEvent* OH_Input_CreateAxisEvent(void); + +/** + * @brief Destroys an axis event object. + * + * @param axisEvent Pointer to the axis event object. + * @return OH_Input_DestroyAxisEvent function result code. + * {@link INPUT_SUCCESS} Destroys axisEvent success.\n + * {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent); + +/** + * @brief Sets the axis event action. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. + * @return OH_Input_SetAxisEventAction function result code. + * {@link INPUT_SUCCESS} Sets the axis event action success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action); + +/** + * @brief Obtains the axis event action. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. + * @return OH_Input_GetAxisEventAction function result code. + * {@link INPUT_SUCCESS} Obtains the axis event action success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action); + +/** + * @brief Sets the X coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayX X coordinate of the axis event. + * @return OH_Input_SetAxisEventDisplayX function result code. + * {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX); + +/** + * @brief Obtains the X coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayX X coordinate of the axis event. + * @return OH_Input_GetAxisEventDisplayX function result code. + * {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX); + +/** + * @brief Sets the Y coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayY Y coordinate of the axis event. + * @return OH_Input_SetAxisEventDisplayY function result code. + * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY); + +/** + * @brief Obtains the Y coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayY Y coordinate of the axis event. + * @return OH_Input_GetAxisEventDisplayY function result code. + * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY); + +/** + * @brief Sets the axis value of the axis type specified by the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. + * @param axisValue Axis value. + * @return OH_Input_SetAxisEventAxisValue function result code. + * {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent, + InputEvent_AxisType axisType, double axisValue); + +/** + * @brief Obtains the axis value for the specified axis type of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. + * @param axisValue Axis value. + * @return OH_Input_GetAxisEventAxisValue function result code. + * {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL, + * or the axisType not found in the axisEvent.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent, + InputEvent_AxisType axisType, double* axisValue); + +/** + * @brief Sets the time when an axis event occurs. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param actionTime Time when an axis event occurs. + * @return OH_Input_SetAxisEventActionTime function result code. + * {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime); + +/** + * @brief Obtains the time when an axis event occurs. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param actionTime Time when an axis event occurs. + * @return OH_Input_GetAxisEventActionTime function result code. + * {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime); + +/** + * @brief Sets the axis event type. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. + * @return OH_Input_SetAxisEventType function result code. + * {@link INPUT_SUCCESS} Sets the axis event type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType); + +/** + * @brief Obtains the axis event type. + * + * @param axisEvent Axis event object. + * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. + * @return OH_Input_GetAxisEventType function result code. + * {@link INPUT_SUCCESS} Obtains the axis event type success.\n + * {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType); + +/** + * @brief Sets the axis event source type. + * + * @param axisEvent Axis event object. + * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. + * @return OH_Input_SetAxisEventSourceType function result code. + * {@link INPUT_SUCCESS} Sets the axis event source type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType); + +/** + * @brief Obtains the axis event source type. + * + * @param axisEvent Axis event object. + * @param axisEventType Axis event source type. The values are defined in {@link InputEvent_SourceType}. + * @return OH_Input_GetAxisEventSourceType function result code. + * {@link INPUT_SUCCESS} Obtains the axis event source type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType); + +/** + * @brief Adds a listener of key events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive key events. + * @return OH_Input_AddKeyEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of key events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback); + +/** + * @brief Adds a listener for mouse events, including mouse click and movement events, + * but not scroll wheel events. Scroll wheel events are axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive mouse events. + * @return OH_Input_AddMouseEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback); + +/** + * @brief Add a listener for touch events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive touch events. + * @return OH_Input_AddTouchEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of touch events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback); + +/** + * @brief Adds a listener for all types of axis events. + * The axis event types are defined in {@Link InputEvent_AxisEventType}. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive axis events. + * @return OH_Input_AddAxisEventMonitorForAll function result code. + * {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback); + +/** + * @brief Adds a listener for the specified type of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}. + * @param callback - Callback used to receive the specified type of axis events. + * @return OH_Input_AddAxisEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); + +/** + * @brief Removes a key event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the key event listener. + * @return OH_Input_RemoveKeyEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a key event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback); + +/** + * @brief Removes a mouse event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the mouse event listener. + * @return OH_Input_RemoveMouseEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a mouse event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback); + +/** + * @brief Removes a touch event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the touch event listener. + * @return OH_Input_RemoveTouchEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a touch event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback); + +/** + * @brief Removes the listener for all types of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the listener used to listen for all types of axis events. + * @return OH_Input_RemoveAxisEventMonitorForAll function result code. + * {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback); + +/** + * @brief Removes the listener for the specified type of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}. + * @param callback - Callback for the listener used to listen for the specified type of axis events. + * @return OH_Input_RemoveAxisEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); + +/** + * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @param callback - Callback used to receive key events. + * @param option - Options for event interception. If **null** is passed, the default value is used. + * @return OH_Input_AddKeyEventInterceptor function result code. + * {@link INPUT_SUCCESS} Adds a key event interceptor success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option); + +/** + * @brief Adds an interceptor for input events, including mouse, touch, and axis events. + * If multiple interceptors are added, only the first one takes effect. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @param callback - Pointer to the structure of the callback for the input event interceptor. + * For details, see {@Link Input_InterceptorEventCallback}. + * @param option - Options for event interception. If **null** is passed, the default value is used. + * @return OH_Input_AddInputEventInterceptor function result code. + * {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback, + Input_InterceptorOptions *option); + +/** + * @brief Removes a key event interceptor. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @return OH_Input_RemoveKeyEventInterceptor function result code. + * {@link INPUT_SUCCESS}Removes a key event interceptor success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveKeyEventInterceptor(); + +/** + * @brief Removes an interceptor for input events, including mouse, touch, and axis events. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @return OH_Input_RemoveInputEventInterceptor function result code. + * {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveInputEventInterceptor(); #ifdef __cplusplus } #endif diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index cc28eac475c5554d3edf45fa448698accea8275e..cfbe993aee96320e1a73e14d8367836b29bd1ad1 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -194,5 +194,125 @@ { "first_introduced": "12", "name": "OH_Input_CancelInjection" + }, + { + "first_introduced": "12", + "name": "OH_Input_CreateAxisEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_DestroyAxisEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventType" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventSourceType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventSourceType" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddKeyEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddMouseEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddTouchEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddAxisEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddAxisEventMonitorForAll" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveKeyEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveMouseEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveTouchEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveAxisEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveAxisEventMonitorForAll" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddKeyEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddInputEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveKeyEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveInputEventInterceptor" } ] \ No newline at end of file