diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 3934be3b9a6cb19b0627d706c5bd9dc89ee03dfb..3c92876a5d9ac5ace1a0f1c1b89c35605e065c7d 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -166,6 +166,20 @@ typedef enum Input_KeyboardType { KEYBOARD_TYPE_REMOTE_CONTROL = 5, } Input_KeyboardType; +/** + * @brief Enumerates the injection authorization status. + * + * @since 20 + */ +typedef enum Input_InjectionStatus { + /** Unauthorized */ + UNAUTHORIZED = 0, + /** Authorizing */ + AUTHORIZING = 1, + /** Authorized */ + AUTHORIZED = 2, +} Input_InjectionStatus; + /** * @brief Enumerates event source types. * @@ -269,7 +283,27 @@ typedef enum Input_Result { * @error No keyboard device connected * @since 15 */ - INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002 + INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002, + /** + * @error Authorizing + * @since 20 + */ + INPUT_INJECTION_AUTHORIZING = 3900005, + /** + * @error Too many operations + * @since 20 + */ + INPUT_INJECTION_OPERATION_FREQUENT = 3900006, + /** + * @error Authorized + * @since 20 + */ + INPUT_INJECTION_AUTHORIZED = 3900007, + /** + * @error Authorized to other applications + * @since 20 + */ + INPUT_INJECTION_AUTHORIZED_OTHERS = 3900008, } Input_Result; /** @@ -331,6 +365,13 @@ typedef void (*Input_DeviceAddedCallback)(int32_t deviceId); */ typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId); +/** + * @brief Defines the event injection callback. + * @param authorizedStatus Authorization status. + * @since 20 + */ +typedef void (*Input_InjectAuthorizeCallback)(Input_InjectionStatus authorizedStatus); + /** * @brief Defines the structure for the interceptor of event callbacks, * including mouseCallback, touchCallback, and axisCallback. @@ -977,6 +1018,38 @@ int32_t OH_Input_GetTouchEventDisplayId(const struct Input_TouchEvent* touchEven */ void OH_Input_CancelInjection(); +/** + * @brief Requests for injection authorization. + * + * @param callback - callback used to return the result. + * @return OH_Input_RequestInjection function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * {@link INPUT_SERVICE_EXCEPTION} Service error.\n + * {@link INPUT_INJECTION_AUTHORIZING} Authorizing.\n + * {@link INPUT_INJECTION_OPERATION_FREQUENT} Too many operations.\n + * {@link INPUT_INJECTION_AUTHORIZED} Authorized.\n + * {@link INPUT_INJECTION_AUTHORIZED_OTHERS} Authorized to other applications.\n + * @since 20 + */ + +Input_Result OH_Input_RequestInjection(Input_InjectAuthorizeCallback callback); + +/** + * @brief Queries the injection authorization status. + * + * @param status Injection authorization status. For details, see {@Link Input_InjectionStatus}. + * @return OH_Input_QueryAuthorizedStatus function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The status is NULL\n + * {@link INPUT_SERVICE_EXCEPTION} Service error.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ + +Input_Result OH_Input_QueryAuthorizedStatus(Input_InjectionStatus* status); + /** * @brief Creates an axis event object. * diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index ed19a127abf21626e7e1cb6a0c0ca3786106effa..52c789b797b2972485a53e4f4c11c1c06a77cc6b 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -498,5 +498,13 @@ { "first_introduced": "15", "name": "OH_Input_GetAxisEventDisplayId" + }, + { + "first_introduced": "20", + "name": "OH_Input_RequestInjection" + }, + { + "first_introduced": "20", + "name": "OH_Input_QueryAuthorizedStatus" } ] \ No newline at end of file