From 7ec9c7388f94afd054abc39c86e5fe0b7bf257c2 Mon Sep 17 00:00:00 2001 From: cy7717 Date: Fri, 15 Aug 2025 16:51:01 +0800 Subject: [PATCH] mod for keyevent consumer Signed-off-by: cy7717 --- .../js_keyboard_delegate_setting.cpp | 26 ++++---- .../js_keyboard_delegate_setting.h | 7 ++- .../inputmethod_ability/IInputMethodAgent.idl | 3 +- .../include/input_data_channel_proxy_wrap.h | 1 + .../include/input_method_ability.h | 4 +- .../include/input_method_agent_service_impl.h | 2 +- .../src/input_method_ability.cpp | 15 ++++- .../src/input_method_agent_service_impl.cpp | 5 +- .../IInputDataChannel.idl | 1 + .../include/input_data_channel_service_impl.h | 1 + .../src/input_data_channel_service_impl.cpp | 11 ++++ .../src/input_method_controller.cpp | 60 +++++++++++++++++-- .../include/keyboard_listener.h | 4 +- .../include/input_method_controller.h | 14 +++++ .../include/keyboard_listener_test_impl.h | 3 +- .../src/keyboard_listener_test_impl.cpp | 2 +- .../inputmethodability_fuzzer.cpp | 3 +- .../unittest/cpp_test/src/ime_mirror_demo.cpp | 2 +- .../src/input_method_controller_test.cpp | 2 +- .../cpp_test/src/input_method_editor_test.cpp | 5 +- 20 files changed, 133 insertions(+), 38 deletions(-) diff --git a/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp b/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp index df4a5d71c..22ae35e82 100644 --- a/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp +++ b/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.cpp @@ -298,8 +298,8 @@ napi_value JsKeyboardDelegateSetting::GetResultOnKeyEvent(napi_env env, int32_t return KeyboardDelegate; } -bool JsKeyboardDelegateSetting::OnDealKeyEvent(const std::shared_ptr &keyEvent, - sptr &consumer) +bool JsKeyboardDelegateSetting::OnDealKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) { if (keyEvent == nullptr) { IMSA_HILOGE("keyEvent is nullptr"); @@ -321,16 +321,16 @@ bool JsKeyboardDelegateSetting::OnDealKeyEvent(const std::shared_ptrPostTask(task, "OnDealKeyEvent", 0, AppExecFwk::EventQueue::Priority::VIP); return true; } void JsKeyboardDelegateSetting::DealKeyEvent(const std::shared_ptr &keyEvent, - const std::shared_ptr &keyEventEntry, const std::shared_ptr &keyCodeEntry, - const sptr &consumer) + const std::shared_ptr &keyEventEntry, const std::shared_ptr &keyCodeEntry, uint64_t cbId, + const sptr &channel) { bool isKeyEventConsumed = false; bool isKeyCodeConsumed = false; @@ -371,16 +371,14 @@ void JsKeyboardDelegateSetting::DealKeyEvent(const std::shared_ptrvecCopy, { 1, getKeyEventProperty }, isKeyCodeConsumed); } bool consumeResult = isKeyEventConsumed || isKeyCodeConsumed; - if (consumer != nullptr) { - if (!consumeResult) { - if (keyEvent != nullptr && keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { - IMSA_HILOGW("keyEvent is not consumed by ime"); - } - consumeResult = InputMethodAbility::GetInstance().HandleUnconsumedKey(keyEvent); + if (!consumeResult) { + IMSA_HILOGW("%{public}" PRIu64 " is not consumed.", cbId); + if (keyEvent != nullptr && keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { + IMSA_HILOGW("keyEvent is not consumed by ime"); } - IMSA_HILOGD("final consumed result: %{public}d.", consumeResult); - consumer->OnKeyEventResult(consumeResult); + consumeResult = InputMethodAbility::GetInstance().HandleUnconsumedKey(keyEvent); } + InputMethodAbility::GetInstance().HandleKeyEventResult(cbId, consumeResult, channel); } bool JsKeyboardDelegateSetting::OnKeyEvent(const std::shared_ptr &keyEvent, diff --git a/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.h b/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.h index 315ecdadf..f785acc58 100644 --- a/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.h +++ b/frameworks/js/napi/inputmethodability/js_keyboard_delegate_setting.h @@ -46,7 +46,8 @@ public: void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) override; void OnTextChange(const std::string &text) override; void OnEditorAttributeChange(const InputAttribute &inputAttribute) override; - bool OnDealKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) override; + bool OnDealKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel); void OnKeyEventConsumeResult(bool isConsumed, sptr consumer); void OnKeyCodeConsumeResult(bool isConsumed, sptr consumer); @@ -98,8 +99,8 @@ private: std::shared_ptr GetEntry(const std::string &type, EntrySetter entrySetter = nullptr); uv_work_t *GetUVwork(const std::string &type, EntrySetter entrySetter = nullptr); static void DealKeyEvent(const std::shared_ptr &keyEvent, - const std::shared_ptr &keyEventEntry, const std::shared_ptr &keyCodeEntry, - const sptr &consumer); + const std::shared_ptr &keyEventEntry, const std::shared_ptr &keyCodeEntry, uint64_t cbId, + const sptr &channel); uv_loop_s *loop_ = nullptr; std::recursive_mutex mutex_; std::map>> jsCbMap_; diff --git a/frameworks/native/inputmethod_ability/IInputMethodAgent.idl b/frameworks/native/inputmethod_ability/IInputMethodAgent.idl index 66b5c61fe..7cc199a6e 100644 --- a/frameworks/native/inputmethod_ability/IInputMethodAgent.idl +++ b/frameworks/native/inputmethod_ability/IInputMethodAgent.idl @@ -18,9 +18,10 @@ sequenceable input_method_utils..OHOS.MiscServices.Value; sequenceable input_method_utils..OHOS.MiscServices.KeyEventValue; sequenceable input_method_utils..OHOS.MiscServices.ArrayBuffer; sequenceable input_method_utils..OHOS.MiscServices.ResponseDataInner; +sequenceable OHOS.IRemoteObject; interface OHOS.MiscServices.IKeyEventConsumer; interface OHOS.MiscServices.IInputMethodAgent { - [ipccode 0] void DispatchKeyEvent([in] KeyEventValue keyEvent, [in] IKeyEventConsumer consumer); + [ipccode 0] void DispatchKeyEvent([in] KeyEventValue keyEvent, [in] unsigned long cbId, [in] IRemoteObject channel); void OnCursorUpdate([in] int positionX, [in] int positionY, [in] int height); void OnSelectionChange([in] String text, [in] int oldBegin, [in] int oldEnd, [in] int newBegin, [in] int newEnd); void SetCallingWindow([in] unsigned int windowId); diff --git a/frameworks/native/inputmethod_ability/include/input_data_channel_proxy_wrap.h b/frameworks/native/inputmethod_ability/include/input_data_channel_proxy_wrap.h index 8c1794bbc..be48b3c83 100644 --- a/frameworks/native/inputmethod_ability/include/input_data_channel_proxy_wrap.h +++ b/frameworks/native/inputmethod_ability/include/input_data_channel_proxy_wrap.h @@ -70,6 +70,7 @@ public: const std::string &text, const RangeInner &range, const AsyncIpcCallBack &callback = nullptr); int32_t FinishTextPreview(const AsyncIpcCallBack &callback = nullptr); int32_t ClearRspHandlers(); + void HandleKeyEventResult(uint64_t cbId, const sptr &channel, bool consumeResult); public: int32_t HandleResponse(uint64_t msgId, const ResponseInfo &rspInfo); diff --git a/frameworks/native/inputmethod_ability/include/input_method_ability.h b/frameworks/native/inputmethod_ability/include/input_method_ability.h index e69116c88..6d0724076 100644 --- a/frameworks/native/inputmethod_ability/include/input_method_ability.h +++ b/frameworks/native/inputmethod_ability/include/input_method_ability.h @@ -72,7 +72,8 @@ public: int32_t MoveCursor(int32_t keyCode, const AsyncIpcCallBack &callback = nullptr); int32_t SelectByRange(int32_t start, int32_t end, const AsyncIpcCallBack &callback = nullptr); int32_t SelectByMovement(int32_t direction, const AsyncIpcCallBack &callback = nullptr); - int32_t DispatchKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer); + int32_t DispatchKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel); void SetCallingWindow(uint32_t windowId); int32_t GetEnterKeyType(int32_t &keyType); int32_t GetInputPattern(int32_t &inputPattern); @@ -114,6 +115,7 @@ public: int32_t OnResponse(uint64_t msgId, int32_t code, const ResponseData &data); int32_t IsCapacitySupport(int32_t capacity, bool &isSupport); AttachOptions GetAttachOptions(); + void HandleKeyEventResult(uint64_t cbId, bool consumeResult, const sptr &channelObject); public: /* called from TaskManager worker thread */ diff --git a/frameworks/native/inputmethod_ability/include/input_method_agent_service_impl.h b/frameworks/native/inputmethod_ability/include/input_method_agent_service_impl.h index b77a72e71..18eff30e2 100644 --- a/frameworks/native/inputmethod_ability/include/input_method_agent_service_impl.h +++ b/frameworks/native/inputmethod_ability/include/input_method_agent_service_impl.h @@ -30,7 +30,7 @@ public: InputMethodAgentServiceImpl(); ~InputMethodAgentServiceImpl(); ErrCode DispatchKeyEvent( - const MiscServices::KeyEventValue &keyEvent, const sptr &consumer) override; + const MiscServices::KeyEventValue &keyEvent, uint64_t cbId, const sptr &channel) override; ErrCode OnCursorUpdate(int32_t positionX, int32_t positionY, int height) override; ErrCode OnSelectionChange( const std::string& text, int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) override; diff --git a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp index 3b364924e..d5b67cd97 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp @@ -433,7 +433,7 @@ void InputMethodAbility::ClearBindInfo(const sptr &channel) } int32_t InputMethodAbility::DispatchKeyEvent( - const std::shared_ptr &keyEvent, sptr &consumer) + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) { if (keyEvent == nullptr) { IMSA_HILOGE("keyEvent is nullptr!"); @@ -445,7 +445,7 @@ int32_t InputMethodAbility::DispatchKeyEvent( } IMSA_HILOGD("InputMethodAbility, start."); - if (!kdListener_->OnDealKeyEvent(keyEvent, consumer)) { + if (!kdListener_->OnDealKeyEvent(keyEvent, cbId, channel)) { IMSA_HILOGE("keyEvent not deal!"); return ErrorCode::ERROR_DISPATCH_KEY_EVENT; } @@ -1966,5 +1966,16 @@ int32_t InputMethodAbility::OnNotifyPreemption() imeListener->NotifyPreemption(); return ErrorCode::NO_ERROR; } + +void InputMethodAbility::HandleKeyEventResult(uint64_t cbId, bool consumeResult, const sptr &channelObject) +{ + IMSA_HILOGD("run in:%{public}" PRIu64 ".", cbId); + if (channelObject == nullptr) { + IMSA_HILOGE("channelObject is nullptr:%{public}" PRIu64 ".", cbId); + return; + } + auto channel = std::make_shared(channelObject); + channel->HandleKeyEventResult(cbId, consumeResult); +} } // namespace MiscServices } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/inputmethod_ability/src/input_method_agent_service_impl.cpp b/frameworks/native/inputmethod_ability/src/input_method_agent_service_impl.cpp index 76f92e2fa..6df1a4f98 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_agent_service_impl.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_agent_service_impl.cpp @@ -31,10 +31,9 @@ InputMethodAgentServiceImpl::InputMethodAgentServiceImpl() {} InputMethodAgentServiceImpl::~InputMethodAgentServiceImpl() {} ErrCode InputMethodAgentServiceImpl::DispatchKeyEvent( - const MiscServices::KeyEventValue &keyEvent, const sptr &consumer) + const MiscServices::KeyEventValue &keyEvent, uint64_t cbId, const sptr &channel) { - sptr proxyConsumer = new (std::nothrow) KeyEventConsumerProxy(consumer->AsObject()); - return InputMethodAbility::GetInstance().DispatchKeyEvent(keyEvent.event, proxyConsumer); + return InputMethodAbility::GetInstance().DispatchKeyEvent(keyEvent.event, cbId, channel); } ErrCode InputMethodAgentServiceImpl::SetCallingWindow(uint32_t windowId) diff --git a/frameworks/native/inputmethod_controller/IInputDataChannel.idl b/frameworks/native/inputmethod_controller/IInputDataChannel.idl index 011eebb14..19940a67d 100644 --- a/frameworks/native/inputmethod_controller/IInputDataChannel.idl +++ b/frameworks/native/inputmethod_controller/IInputDataChannel.idl @@ -43,4 +43,5 @@ interface OHOS.MiscServices.IInputDataChannel { [oneway] void SetPreviewText([in] String text, [in] RangeInner rangeInner, [in] unsigned long msgId, [in] IRemoteObject agent); [oneway] void FinishTextPreview([in] unsigned long msgId, [in] IRemoteObject agent); void SendMessage([in] ArrayBuffer arraybuffer); + [oneway] void HandleKeyEventResult([in] unsigned long cbId, [in] boolean consumeResult); } diff --git a/frameworks/native/inputmethod_controller/include/input_data_channel_service_impl.h b/frameworks/native/inputmethod_controller/include/input_data_channel_service_impl.h index 4b0124877..5faf86e60 100644 --- a/frameworks/native/inputmethod_controller/include/input_data_channel_service_impl.h +++ b/frameworks/native/inputmethod_controller/include/input_data_channel_service_impl.h @@ -54,6 +54,7 @@ public: const sptr &agent) override; ErrCode FinishTextPreview(uint64_t msgId, const sptr &agent) override; ErrCode SendMessage(const ArrayBuffer &arraybuffer) override; + ErrCode HandleKeyEventResult(uint64_t cbId, bool consumeResult) override; }; } // namespace MiscServices } // namespace OHOS diff --git a/frameworks/native/inputmethod_controller/src/input_data_channel_service_impl.cpp b/frameworks/native/inputmethod_controller/src/input_data_channel_service_impl.cpp index 7a0d4e2ca..3fe14bf35 100644 --- a/frameworks/native/inputmethod_controller/src/input_data_channel_service_impl.cpp +++ b/frameworks/native/inputmethod_controller/src/input_data_channel_service_impl.cpp @@ -301,5 +301,16 @@ ErrCode InputDataChannelServiceImpl::SendMessage(const ArrayBuffer &arraybuffer) } return instance->RecvMessage(arraybuffer); } + +ErrCode InputDataChannelServiceImpl::HandleKeyEventResult(uint64_t cbId, bool consumeResult) +{ + auto instance = InputMethodController::GetInstance(); + if (instance == nullptr) { + IMSA_HILOGE("failed to get InputMethodController instance!"); + return ErrorCode::ERROR_EX_NULL_POINTER; + } + instance->HandleKeyEventResult(cbId, consumeResult); + return ERR_OK; +} } // namespace MiscServices } // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp index d0986b2e4..c90b07d75 100644 --- a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp @@ -974,22 +974,74 @@ int32_t InputMethodController::DispatchKeyEvent(std::shared_ptr k return ErrorCode::ERROR_IME_NOT_STARTED; } IMSA_HILOGD("start."); - sptr consumer = new (std::nothrow) KeyEventConsumerServiceImpl(callback, keyEvent); - if (consumer == nullptr) { - IMSA_HILOGE("consumer is nullptr!"); + auto channel = clientInfo_.channel; + if (channel == nullptr) { + IMSA_HILOGE("channel is nullptr!"); keyEventQueue_.Pop(); return ErrorCode::ERROR_EX_NULL_POINTER; } + auto cbId = AddKeyEventCbInfo({ keyEvent, callback }); KeyEventValue keyEventValue; keyEventValue.event = keyEvent; - auto ret = agent->DispatchKeyEvent(keyEventValue, consumer); + auto ret = agent->DispatchKeyEvent(keyEventValue, cbId, channel); if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("failed to DispatchKeyEvent: %{public}d", ret); + RemoveKeyEventCbInfo(cbId); } keyEventQueue_.Pop(); return ret; } +KeyEventCbInfo InputMethodController::GetKeyEventCbInfo(uint64_t cbId) +{ + std::lock_guard lock(keyEventCbHandlersMutex_); + auto iter = keyEventCbHandlers_.find(cbId); + if (iter != keyEventCbHandlers_.end()) { + return iter->second; + } + return {}; +} + +void InputMethodController::RemoveKeyEventCbInfo(uint64_t cbId) +{ + std::lock_guard lock(keyEventCbHandlersMutex_); + auto iter = keyEventCbHandlers_.find(cbId); + if (iter == keyEventCbHandlers_.end()) { + return; + } + keyEventCbHandlers_.erase(cbId); +} + +uint64_t InputMethodController::AddKeyEventCbInfo(const KeyEventCbInfo &cbInfo) +{ + std::lock_guard lock(keyEventCbHandlersMutex_); + auto cbId = GenerateKeyEventCbId(); + IMSA_HILOGD("%{public}" PRIu64 "add.", cbId); + keyEventCbHandlers_.insert({ cbId, cbInfo }); + return cbId; +} + +uint64_t InputMethodController::GenerateKeyEventCbId() +{ + uint32_t cbId = ++keyEventCbId_; + if (cbId == std::numeric_limits::max()) { + return ++keyEventCbId_; + } + return cbId; +} + +void InputMethodController::HandleKeyEventResult(uint64_t cbId, bool consumeResult) +{ + IMSA_HILOGD("result:%{public}" PRIu64 "/%{public}d.", cbId, consumeResult); + auto cbInfo = GetKeyEventCbInfo(cbId); + if (cbInfo.callback == nullptr) { + IMSA_HILOGE("%{public}" PRIu64 "callback is nullptr.", cbId); + return; + } + cbInfo.callback(cbInfo.keyEvent, consumeResult); + RemoveKeyEventCbInfo(cbId); +} + int32_t InputMethodController::GetEnterKeyType(int32_t &keyType) { IMSA_HILOGD("InputMethodController::GetEnterKeyType start."); diff --git a/interfaces/inner_api/inputmethod_ability/include/keyboard_listener.h b/interfaces/inner_api/inputmethod_ability/include/keyboard_listener.h index d1ab39894..5a1fdb7f1 100644 --- a/interfaces/inner_api/inputmethod_ability/include/keyboard_listener.h +++ b/interfaces/inner_api/inputmethod_ability/include/keyboard_listener.h @@ -24,8 +24,8 @@ namespace MiscServices { class KeyboardListener { public: virtual ~KeyboardListener() = default; - virtual bool OnDealKeyEvent(const std::shared_ptr &keyEvent, - sptr &consumer) = 0; + virtual bool OnDealKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) = 0; virtual bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr &consumer) = 0; virtual bool OnKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) = 0; virtual void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height) = 0; diff --git a/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h b/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h index 8a72a7a27..92d4756e5 100644 --- a/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h +++ b/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h @@ -146,6 +146,10 @@ private: using PrivateDataValue = std::variant; using KeyEventCallback = std::function &keyEvent, bool isConsumed)>; using WindowScaleCallback = std::function; +struct KeyEventCbInfo { + std::shared_ptr keyEvent{ nullptr }; + KeyEventCallback callback{ nullptr }; +}; class InputMethodController : public RefBase, public PrivateCommandInterface { public: /** @@ -980,6 +984,8 @@ public: */ IMF_API int32_t RegisterWindowScaleCallbackHandler(WindowScaleCallback&& callback); + void HandleKeyEventResult(uint64_t cbId, bool consumeResult); + private: InputMethodController(); ~InputMethodController(); @@ -1095,6 +1101,14 @@ private: std::mutex windowScaleCallbackMutex_; WindowScaleCallback windowScaleCallback_ = nullptr; + + std::mutex keyEventCbHandlersMutex_; + std::map keyEventCbHandlers_; + uint64_t keyEventCbId_{ 0 }; + KeyEventCbInfo GetKeyEventCbInfo(uint64_t cbId); + void RemoveKeyEventCbInfo(uint64_t cbId); + uint64_t AddKeyEventCbInfo(const KeyEventCbInfo &cbInfo); + uint64_t GenerateKeyEventCbId(); }; } // namespace MiscServices } // namespace OHOS diff --git a/test/common/include/keyboard_listener_test_impl.h b/test/common/include/keyboard_listener_test_impl.h index e0ec354f7..2cd08885c 100644 --- a/test/common/include/keyboard_listener_test_impl.h +++ b/test/common/include/keyboard_listener_test_impl.h @@ -32,7 +32,8 @@ public: { return false; } - bool OnDealKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) override; + bool OnDealKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) override; void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height) override; void OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) override; void OnTextChange(const std::string &text) override; diff --git a/test/common/src/keyboard_listener_test_impl.cpp b/test/common/src/keyboard_listener_test_impl.cpp index 1690e2f24..393bee78b 100644 --- a/test/common/src/keyboard_listener_test_impl.cpp +++ b/test/common/src/keyboard_listener_test_impl.cpp @@ -34,7 +34,7 @@ bool KeyboardListenerTestImpl::OnKeyEvent(int32_t keyCode, int32_t keyStatus, sp } bool KeyboardListenerTestImpl::OnDealKeyEvent( - const std::shared_ptr &keyEvent, sptr &consumer) + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) { bool isKeyCodeConsume = OnKeyEvent(keyEvent->GetKeyCode(), keyEvent->GetKeyAction(), consumer); bool isKeyEventConsume = OnKeyEvent(keyEvent, consumer); diff --git a/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp b/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp index 1da238790..282e419a7 100644 --- a/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp +++ b/test/fuzztest/inputmethodability_fuzzer/inputmethodability_fuzzer.cpp @@ -39,7 +39,8 @@ class KeyboardListenerImpl : public KeyboardListener { { return true; } - bool OnDealKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) + bool OnDealKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) { return true; } diff --git a/test/unittest/cpp_test/src/ime_mirror_demo.cpp b/test/unittest/cpp_test/src/ime_mirror_demo.cpp index 751e41c02..e399019fc 100644 --- a/test/unittest/cpp_test/src/ime_mirror_demo.cpp +++ b/test/unittest/cpp_test/src/ime_mirror_demo.cpp @@ -46,7 +46,7 @@ public: KeyboardListenerImpl() = default; ~KeyboardListenerImpl() = default; bool OnDealKeyEvent( - const std::shared_ptr &keyEvent, OHOS::sptr &consumer) override + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) override { return false; } diff --git a/test/unittest/cpp_test/src/input_method_controller_test.cpp b/test/unittest/cpp_test/src/input_method_controller_test.cpp index d54d1b50e..0a48eab3a 100644 --- a/test/unittest/cpp_test/src/input_method_controller_test.cpp +++ b/test/unittest/cpp_test/src/input_method_controller_test.cpp @@ -202,7 +202,7 @@ public: return true; } bool OnDealKeyEvent( - const std::shared_ptr &keyEvent, sptr &consumer) override + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) override { IMSA_HILOGI("KeyboardListenerImpl run in"); bool isKeyCodeConsume = OnKeyEvent(keyEvent->GetKeyCode(), keyEvent->GetKeyAction(), consumer); diff --git a/test/unittest/cpp_test/src/input_method_editor_test.cpp b/test/unittest/cpp_test/src/input_method_editor_test.cpp index ac118722c..a3ffd914e 100644 --- a/test/unittest/cpp_test/src/input_method_editor_test.cpp +++ b/test/unittest/cpp_test/src/input_method_editor_test.cpp @@ -58,7 +58,8 @@ public: static int32_t keyCode_; static int32_t keyStatus_; static CursorInfo cursorInfo_; - bool OnDealKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) override; + bool OnDealKeyEvent( + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) override; bool OnKeyEvent(int32_t keyCode, int32_t keyStatus, sptr &consumer) override; bool OnKeyEvent(const std::shared_ptr &keyEvent, sptr &consumer) override; void OnCursorUpdate(int32_t positionX, int32_t positionY, int32_t height) override; @@ -82,7 +83,7 @@ bool KeyboardListenerImpl::OnKeyEvent( return true; } bool KeyboardListenerImpl::OnDealKeyEvent( - const std::shared_ptr &keyEvent, sptr &consumer) + const std::shared_ptr &keyEvent, uint64_t cbId, const sptr &channel) { bool isKeyCodeConsume = OnKeyEvent(keyEvent->GetKeyCode(), keyEvent->GetKeyAction(), consumer); bool isKeyEventConsume = OnKeyEvent(keyEvent, consumer); -- Gitee