From 391b4441c4e3abb071ec6910aa03dcff135f2453 Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 14:35:46 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- .../event_handle/src/input_manager_impl.cpp | 8 +-- frameworks/proxy/events/src/input_manager.cpp | 2 +- .../event/include/input_manager_impl.h | 2 +- .../innerkits/proxy/include/input_manager.h | 2 +- .../include/i_multimodal_input_connect.h | 2 +- .../multimodal_input_connect_manager.h | 2 +- .../include/multimodal_input_connect_proxy.h | 2 +- .../multimodal_input_connect_service.h | 2 +- .../src/i_multimodal_input_connect_stub.cpp | 2 +- .../src/multimodal_input_connect_manager.cpp | 4 +- .../src/multimodal_input_connect_proxy.cpp | 2 +- .../src/multimodal_input_connect_service.cpp | 6 +- .../event_dispatch/include/event_dispatch.h | 5 +- service/event_dispatch/src/event_dispatch.cpp | 31 ++-------- service/event_filter_binder/BUILD.gn | 1 + .../include/event_filter_wrap.h | 36 +++++++++++ .../src/event_filter_wrap.cpp | 62 +++++++++++++++++++ .../include/input_event_handler.h | 2 +- .../event_handle/src/input_event_handler.cpp | 4 +- service/module_loader/include/mmi_service.h | 2 +- service/module_loader/src/mmi_service.cpp | 4 +- 21 files changed, 128 insertions(+), 55 deletions(-) create mode 100644 service/event_filter_binder/include/event_filter_wrap.h create mode 100644 service/event_filter_binder/src/event_filter_wrap.cpp diff --git a/frameworks/proxy/event_handle/src/input_manager_impl.cpp b/frameworks/proxy/event_handle/src/input_manager_impl.cpp index ea0889a7b1..81db9d79fa 100644 --- a/frameworks/proxy/event_handle/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handle/src/input_manager_impl.cpp @@ -57,7 +57,7 @@ void InputManagerImpl::UpdateDisplayInfo(const std::vector MMI_LOGD("InputManagerImpl::UpdateDisplayInfo leave!"); } -void InputManagerImpl::SetInputEventFilter(std::function)> filter) +void InputManagerImpl::AddInputEventFilter(std::function)> filter) { if (eventFilterService_ == nullptr) { eventFilterService_ = new EventFilterService(); @@ -72,12 +72,12 @@ void InputManagerImpl::SetInputEventFilter(std::functionSetInputEventFilter(eventFilterService_); + int32_t ret = MultimodalInputConnectManager::GetInstance()->AddInputEventFilter(eventFilterService_); if (ret == RET_OK) { hasSendToMmiServer = true; - MMI_LOGI("SetInputEventFilter has send to server success"); + MMI_LOGI("AddInputEventFilter has send to server success"); } else { - MMI_LOGE("SetInputEventFilter has send to server fail, ret = %{public}d", ret); + MMI_LOGE("AddInputEventFilter has send to server fail, ret = %{public}d", ret); } } } diff --git a/frameworks/proxy/events/src/input_manager.cpp b/frameworks/proxy/events/src/input_manager.cpp index 128471b09d..fe366fb007 100644 --- a/frameworks/proxy/events/src/input_manager.cpp +++ b/frameworks/proxy/events/src/input_manager.cpp @@ -45,7 +45,7 @@ void InputManager::UpdateDisplayInfo(const std::vector &phy InputManagerImpl::GetInstance()->UpdateDisplayInfo(physicalDisplays, logicalDisplays); } -void InputManager::SetInputEventFilter(std::function filter)>) {} +void InputManager::AddInputEventFilter(std::function filter)>) {} void InputManager::SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer) { diff --git a/interfaces/native/innerkits/event/include/input_manager_impl.h b/interfaces/native/innerkits/event/include/input_manager_impl.h index 37e2075dac..40dcf3e68d 100644 --- a/interfaces/native/innerkits/event/include/input_manager_impl.h +++ b/interfaces/native/innerkits/event/include/input_manager_impl.h @@ -35,7 +35,7 @@ public: void UpdateDisplayInfo(const std::vector &physicalDisplays, const std::vector &logicalDisplays); // 建议本地调用,可IPC - void SetInputEventFilter(std::function filter)>); // 只能本地 + void AddInputEventFilter(std::function filter)>); // 只能本地 void SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer); diff --git a/interfaces/native/innerkits/proxy/include/input_manager.h b/interfaces/native/innerkits/proxy/include/input_manager.h index e628dd7375..0e168ab17d 100644 --- a/interfaces/native/innerkits/proxy/include/input_manager.h +++ b/interfaces/native/innerkits/proxy/include/input_manager.h @@ -34,7 +34,7 @@ public: void UpdateDisplayInfo(const std::vector &physicalDisplays, const std::vector &logicalDisplays); // 建议本地调用,可IPC - void SetInputEventFilter(std::function filter)>); // 只能本地 + void AddInputEventFilter(std::function filter)>); // 只能本地 void SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer); diff --git a/service/connect_manager/include/i_multimodal_input_connect.h b/service/connect_manager/include/i_multimodal_input_connect.h index a7e4e2aca6..960f7a5201 100644 --- a/service/connect_manager/include/i_multimodal_input_connect.h +++ b/service/connect_manager/include/i_multimodal_input_connect.h @@ -28,7 +28,7 @@ public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.multimodalinput.IConnectManager"); virtual int32_t AllocSocketFd(const std::string &programName, const int moduleType, int &socketFd) = 0; - virtual int32_t SetInputEventFilter(sptr filter) = 0; + virtual int32_t AddInputEventFilter(sptr filter) = 0; enum { ALLOC_SOCKET_FD = 0, diff --git a/service/connect_manager/include/multimodal_input_connect_manager.h b/service/connect_manager/include/multimodal_input_connect_manager.h index 5b3f408293..1405f7df73 100644 --- a/service/connect_manager/include/multimodal_input_connect_manager.h +++ b/service/connect_manager/include/multimodal_input_connect_manager.h @@ -31,7 +31,7 @@ public: static std::shared_ptr GetInstance(); int32_t AllocSocketPair(const int moduleType); int GetClientSocketFdOfAllocedSocketPair() const; - int32_t SetInputEventFilter(sptr filter); + int32_t AddInputEventFilter(sptr filter); private: MultimodalInputConnectManager() = default; MultimodalInputConnectManager(const MultimodalInputConnectManager &manager) = delete; diff --git a/service/connect_manager/include/multimodal_input_connect_proxy.h b/service/connect_manager/include/multimodal_input_connect_proxy.h index 67406405f1..c76349ed3a 100644 --- a/service/connect_manager/include/multimodal_input_connect_proxy.h +++ b/service/connect_manager/include/multimodal_input_connect_proxy.h @@ -30,7 +30,7 @@ public: explicit MultimodalInputConnectProxy(const sptr &impl); virtual ~MultimodalInputConnectProxy() override; virtual int32_t AllocSocketFd(const std::string &programName, const int moduleType, int &socketFd) override; - virtual int32_t SetInputEventFilter(sptr filter) override; + virtual int32_t AddInputEventFilter(sptr filter) override; private: static inline BrokerDelegator delegator_; }; diff --git a/service/connect_manager/include/multimodal_input_connect_service.h b/service/connect_manager/include/multimodal_input_connect_service.h index 9ed33e0359..6bf44adc82 100644 --- a/service/connect_manager/include/multimodal_input_connect_service.h +++ b/service/connect_manager/include/multimodal_input_connect_service.h @@ -36,7 +36,7 @@ public: void OnStop() override; void OnDump() override; virtual int32_t AllocSocketFd(const std::string &programName, const int moduleType, int &socketFd) override; - virtual int32_t SetInputEventFilter(sptr filter) override; + virtual int32_t AddInputEventFilter(sptr filter) override; protected: virtual int32_t HandleAllocSocketFd(MessageParcel &data, MessageParcel &reply) override; diff --git a/service/connect_manager/src/i_multimodal_input_connect_stub.cpp b/service/connect_manager/src/i_multimodal_input_connect_stub.cpp index d48e494526..ed05a6df49 100644 --- a/service/connect_manager/src/i_multimodal_input_connect_stub.cpp +++ b/service/connect_manager/src/i_multimodal_input_connect_stub.cpp @@ -92,7 +92,7 @@ int32_t IMultimodalInputConnectStub::StubSetInputEventFilter(MessageParcel& data break; } - ret = SetInputEventFilter(filter); + ret = AddInputEventFilter(filter); } while (0); reply.WriteInt32(ret); diff --git a/service/connect_manager/src/multimodal_input_connect_manager.cpp b/service/connect_manager/src/multimodal_input_connect_manager.cpp index e4f2bdec67..dacbc6e372 100644 --- a/service/connect_manager/src/multimodal_input_connect_manager.cpp +++ b/service/connect_manager/src/multimodal_input_connect_manager.cpp @@ -69,7 +69,7 @@ int MultimodalInputConnectManager::GetClientSocketFdOfAllocedSocketPair() const return socketFd_; } -int32_t MultimodalInputConnectManager::SetInputEventFilter(sptr filter) +int32_t MultimodalInputConnectManager::AddInputEventFilter(sptr filter) { std::lock_guard guard(lock_); if (multimodalInputConnectService_ == nullptr) { @@ -77,7 +77,7 @@ int32_t MultimodalInputConnectManager::SetInputEventFilter(sptr fi return false; } - return multimodalInputConnectService_->SetInputEventFilter(filter); + return multimodalInputConnectService_->AddInputEventFilter(filter); } bool MultimodalInputConnectManager::ConnectMultimodalInputService() diff --git a/service/connect_manager/src/multimodal_input_connect_proxy.cpp b/service/connect_manager/src/multimodal_input_connect_proxy.cpp index b81c96eb4b..328a2c8a0f 100644 --- a/service/connect_manager/src/multimodal_input_connect_proxy.cpp +++ b/service/connect_manager/src/multimodal_input_connect_proxy.cpp @@ -78,7 +78,7 @@ int32_t MultimodalInputConnectProxy::AllocSocketFd(const std::string &programNam return RET_OK; } -int32_t MultimodalInputConnectProxy::SetInputEventFilter(sptr filter) +int32_t MultimodalInputConnectProxy::AddInputEventFilter(sptr filter) { MMI_LOGE("enter"); MessageParcel data; diff --git a/service/connect_manager/src/multimodal_input_connect_service.cpp b/service/connect_manager/src/multimodal_input_connect_service.cpp index 5805b9edff..1dda21b77d 100644 --- a/service/connect_manager/src/multimodal_input_connect_service.cpp +++ b/service/connect_manager/src/multimodal_input_connect_service.cpp @@ -56,7 +56,7 @@ int32_t MultimodalInputConnectService::AllocSocketFd(const std::string &programN return RET_OK; } -int32_t MultimodalInputConnectService::SetInputEventFilter(sptr filter) +int32_t MultimodalInputConnectService::AddInputEventFilter(sptr filter) { MMI_LOGI("enter"); if (udsServer_ == nullptr) { @@ -64,9 +64,9 @@ int32_t MultimodalInputConnectService::SetInputEventFilter(sptr fi return RET_ERR; } - const int32_t ret = udsServer_->SetInputEventFilter(filter); + const int32_t ret = udsServer_->AddInputEventFilter(filter); if (ret != RET_OK) { - MMI_LOGE("call SetInputEventFilter return %{public}d.", ret); + MMI_LOGE("call AddInputEventFilter return %{public}d.", ret); return RET_ERR; } diff --git a/service/event_dispatch/include/event_dispatch.h b/service/event_dispatch/include/event_dispatch.h index 22f4da9813..81de65edc1 100644 --- a/service/event_dispatch/include/event_dispatch.h +++ b/service/event_dispatch/include/event_dispatch.h @@ -29,7 +29,7 @@ class EventDispatch : public std::enable_shared_from_this { public: EventDispatch(); virtual ~EventDispatch(); - virtual int32_t SetInputEventFilter(sptr filter); + virtual int32_t AddInputEventFilter(sptr filter); int32_t DispatchGestureNewEvent(UDSServer& udsServer, libinput_event& event, std::shared_ptr pointer, const uint64_t preHandlerTime); int32_t DispatchGestureEvent(UDSServer& udsServer, libinput_event& event, EventGesture& gesture, @@ -71,9 +71,6 @@ protected: int32_t touchDownFocusSurfaceId_ = 0; EventPackage eventPackage_; StandardEventHandler standardEvent_; - std::mutex lockInputEventFilter_; - sptr filter_ {nullptr}; - sptr eventFilterRecipient_ {nullptr}; #ifdef DEBUG_CODE_TEST private: const size_t windowCount_ = 2; diff --git a/service/event_dispatch/src/event_dispatch.cpp b/service/event_dispatch/src/event_dispatch.cpp index 482ac276da..492054ebf4 100644 --- a/service/event_dispatch/src/event_dispatch.cpp +++ b/service/event_dispatch/src/event_dispatch.cpp @@ -16,6 +16,7 @@ #include "event_dispatch.h" #include #include "ability_launch_manager.h" +#include "event_filter_wrap.h" #include "input_event_data_transformation.h" #include "input_event_monitor_manager.h" #include "input_handler_manager_global.h" @@ -24,8 +25,6 @@ #include "outer_interface.h" #include "system_event_handler.h" #include "util.h" -#include "event_filter_death_recipient.h" - namespace OHOS::MMI { namespace { @@ -346,11 +345,7 @@ int32_t OHOS::MMI::EventDispatch::DispatchTabletToolEvent(UDSServer& udsServer, bool OHOS::MMI::EventDispatch::HandlePointerEventFilter(std::shared_ptr point) { - std::lock_guard guard(lockInputEventFilter_); - if (filter_ != nullptr && filter_->HandlePointerEvent(point)) { - return true; - } - return false; + return EventFilterWrap::GetInstance().HandlePointerEventFilter(point); } int32_t OHOS::MMI::EventDispatch::handlePointerEvent(std::shared_ptr point) @@ -842,27 +837,9 @@ int32_t OHOS::MMI::EventDispatch::DispatchKeyEvent(UDSServer& udsServer, libinpu return ret; } -int32_t OHOS::MMI::EventDispatch::SetInputEventFilter(sptr filter) +int32_t OHOS::MMI::EventDispatch::AddInputEventFilter(sptr filter) { - std::lock_guard guard(lockInputEventFilter_); - filter_ = filter; - - if (filter_ != nullptr) { - std::weak_ptr weakPtr = shared_from_this(); - auto deathCallback = [weakPtr](const wptr &object) { - auto sharedPtr = weakPtr.lock(); - if (sharedPtr) { - sharedPtr->SetInputEventFilter(nullptr); - } - }; - - eventFilterRecipient_ = new EventFilterDeathRecipient(deathCallback); - - auto client = filter->AsObject().GetRefPtr(); - client->AddDeathRecipient(eventFilterRecipient_); - } - - return RET_OK; + return EventFilterWrap::GetInstance().AddInputEventFilter(filter); } int32_t OHOS::MMI::EventDispatch::DispatchGestureNewEvent(UDSServer& udsServer, libinput_event& event, diff --git a/service/event_filter_binder/BUILD.gn b/service/event_filter_binder/BUILD.gn index 9e702a5892..db61b64aa3 100644 --- a/service/event_filter_binder/BUILD.gn +++ b/service/event_filter_binder/BUILD.gn @@ -52,6 +52,7 @@ ohos_source_set("mmi_event_filter_proxy") { "${event_filter_path}/src/event_filter_death_recipient.cpp", "${event_filter_path}/src/event_filter_parcel.cpp", "${event_filter_path}/src/event_filter_proxy.cpp", + "${event_filter_path}/src/event_filter_wrap.cpp", ] public_configs = [ ":mmi_event_filter_config" ] diff --git a/service/event_filter_binder/include/event_filter_wrap.h b/service/event_filter_binder/include/event_filter_wrap.h new file mode 100644 index 0000000000..915c2e2204 --- /dev/null +++ b/service/event_filter_binder/include/event_filter_wrap.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_EVENT_FILTER_WRAP_H +#define OHOS_EVENT_FILTER_WRAP_H + +#include "i_event_filter.h" +#include "singleton.h" + +namespace OHOS { +namespace MMI { +class EventFilterWrap : public Singleton { +public: + EventFilterWrap(); + ~EventFilterWrap(); + int32_t AddInputEventFilter(sptr filter); + bool HandlePointerEventFilter(std::shared_ptr point); +private: + std::mutex lockInputEventFilter_; + sptr filter_ {nullptr}; +}; +} // namespace MMI +} // namespace OHOS +#endif // OHOS_EVENT_FILTER_WRAP_H diff --git a/service/event_filter_binder/src/event_filter_wrap.cpp b/service/event_filter_binder/src/event_filter_wrap.cpp new file mode 100644 index 0000000000..b136e32e5c --- /dev/null +++ b/service/event_filter_binder/src/event_filter_wrap.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 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. + */ + +#include "event_filter_wrap.h" +#include "log.h" + +namespace OHOS { +namespace MMI { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "EventFilterWrap" }; +} + +EventFilterWrap::EventFilterWrap() +{ + MMI_LOGT("enter"); +} + +EventFilterWrap::~EventFilterWrap() +{ + MMI_LOGT("enter"); +} + +int32_t EventFilterWrap::AddInputEventFilter(sptr filter) +{ + MMI_LOGT("enter"); + std::lock_guard guard(lockInputEventFilter_); + filter_ = filter; + + return RET_OK; +} + +bool EventFilterWrap::HandlePointerEventFilter(std::shared_ptr point) +{ + MMI_LOGT("enter"); + std::lock_guard guard(lockInputEventFilter_); + if (filter_ == nullptr) { + MMI_LOGD("filter_ is nullptr"); + return false; + } + + if (filter_->HandlePointerEvent(point)) { + MMI_LOGD("call HandlePointerEvent return true"); + return true; + } + + MMI_LOGT("leave"); + return false; +} +} // namespace MMI +} // namespace OHOS diff --git a/service/event_handle/include/input_event_handler.h b/service/event_handle/include/input_event_handler.h index 571afb28a5..91db1b26fe 100644 --- a/service/event_handle/include/input_event_handler.h +++ b/service/event_handle/include/input_event_handler.h @@ -37,7 +37,7 @@ public: void RegistnotifyDeviceChange(NotifyDeviceChange cb); int32_t OnMouseEventTimerHanler(std::shared_ptr mouse_event); UDSServer *GetUDSServer(); - int32_t SetInputEventFilter(sptr filter); + int32_t AddInputEventFilter(sptr filter); protected: int32_t OnEventDeviceAdded(multimodal_libinput_event& event); int32_t OnEventDeviceRemoved(multimodal_libinput_event& event); diff --git a/service/event_handle/src/input_event_handler.cpp b/service/event_handle/src/input_event_handler.cpp index c2c0468bbe..44dfcbe1ec 100644 --- a/service/event_handle/src/input_event_handler.cpp +++ b/service/event_handle/src/input_event_handler.cpp @@ -264,9 +264,9 @@ OHOS::MMI::UDSServer* OHOS::MMI::InputEventHandler::GetUDSServer() return udsServer_; } -int32_t OHOS::MMI::InputEventHandler::SetInputEventFilter(sptr filter) +int32_t OHOS::MMI::InputEventHandler::AddInputEventFilter(sptr filter) { - return eventDispatch_.SetInputEventFilter(filter); + return eventDispatch_.AddInputEventFilter(filter); } int32_t OHOS::MMI::InputEventHandler::OnEventDeviceAdded(multimodal_libinput_event &ev) diff --git a/service/module_loader/include/mmi_service.h b/service/module_loader/include/mmi_service.h index 463617fbf5..a8624814c7 100644 --- a/service/module_loader/include/mmi_service.h +++ b/service/module_loader/include/mmi_service.h @@ -48,7 +48,7 @@ public: virtual void OnStop() override; virtual void OnDump() override; virtual int32_t AllocSocketFd(const std::string &programName, const int moduleType, int &socketFd) override; - virtual int32_t SetInputEventFilter(sptr filter) override; + virtual int32_t AddInputEventFilter(sptr filter) override; protected: virtual void OnConnected(SessionPtr s) override; diff --git a/service/module_loader/src/mmi_service.cpp b/service/module_loader/src/mmi_service.cpp index 8a0020b9d4..4669f45e63 100644 --- a/service/module_loader/src/mmi_service.cpp +++ b/service/module_loader/src/mmi_service.cpp @@ -329,14 +329,14 @@ int32_t MMIService::HandleAllocSocketFd(MessageParcel& data, MessageParcel& repl return RET_OK; } -int32_t MMIService::SetInputEventFilter(sptr filter) +int32_t MMIService::AddInputEventFilter(sptr filter) { if (inputEventHdr_ == nullptr) { MMI_LOGE("inputEventHdr_ is nullptr"); return NULL_POINTER; } - return inputEventHdr_->SetInputEventFilter(filter); + return inputEventHdr_->AddInputEventFilter(filter); } void MMIService::OnTimer() -- Gitee From 067e181e6c62aab63a5a29703fd1d8018a81f886 Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 15:59:43 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- .../event_handle/src/input_manager_impl.cpp | 11 +++++++++-- frameworks/proxy/events/src/input_manager.cpp | 5 ++++- .../event/include/input_manager_impl.h | 2 +- .../innerkits/proxy/include/input_manager.h | 2 +- .../include/i_multimodal_input_connect_stub.h | 2 +- .../src/i_multimodal_input_connect_stub.cpp | 17 +++++++++++++---- .../src/multimodal_input_connect_manager.cpp | 2 +- .../src/multimodal_input_connect_service.cpp | 16 ++-------------- .../include/event_filter_stub.h | 2 +- .../include/event_filter_wrap.h | 1 + .../src/event_filter_proxy.cpp | 16 ++++++++-------- .../src/event_filter_stub.cpp | 18 +++++++++++++----- .../src/event_filter_wrap.cpp | 1 + 13 files changed, 56 insertions(+), 39 deletions(-) diff --git a/frameworks/proxy/event_handle/src/input_manager_impl.cpp b/frameworks/proxy/event_handle/src/input_manager_impl.cpp index 81db9d79fa..49ceb91acb 100644 --- a/frameworks/proxy/event_handle/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handle/src/input_manager_impl.cpp @@ -57,15 +57,17 @@ void InputManagerImpl::UpdateDisplayInfo(const std::vector MMI_LOGD("InputManagerImpl::UpdateDisplayInfo leave!"); } -void InputManagerImpl::AddInputEventFilter(std::function)> filter) +int32_t InputManagerImpl::AddInputEventFilter(std::function)> filter) { + MMI_LOGT("enter"); if (eventFilterService_ == nullptr) { eventFilterService_ = new EventFilterService(); + MMI_LOGD("new EventFilterService"); } if (eventFilterService_ == nullptr) { MMI_LOGE("eventFilterService_ is nullptr"); - return; + return RET_ERR; } eventFilterService_->SetPointerEventPtr(filter); @@ -76,10 +78,15 @@ void InputManagerImpl::AddInputEventFilter(std::function inputEventConsumer) diff --git a/frameworks/proxy/events/src/input_manager.cpp b/frameworks/proxy/events/src/input_manager.cpp index fe366fb007..12f68b7c79 100644 --- a/frameworks/proxy/events/src/input_manager.cpp +++ b/frameworks/proxy/events/src/input_manager.cpp @@ -45,7 +45,10 @@ void InputManager::UpdateDisplayInfo(const std::vector &phy InputManagerImpl::GetInstance()->UpdateDisplayInfo(physicalDisplays, logicalDisplays); } -void InputManager::AddInputEventFilter(std::function filter)>) {} +int32_t InputManager::AddInputEventFilter(std::function filter)>) +{ + return InputManagerImpl::GetInstance()->AddInputEventFilter(filter); +} void InputManager::SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer) { diff --git a/interfaces/native/innerkits/event/include/input_manager_impl.h b/interfaces/native/innerkits/event/include/input_manager_impl.h index 40dcf3e68d..47a6411f6e 100644 --- a/interfaces/native/innerkits/event/include/input_manager_impl.h +++ b/interfaces/native/innerkits/event/include/input_manager_impl.h @@ -35,7 +35,7 @@ public: void UpdateDisplayInfo(const std::vector &physicalDisplays, const std::vector &logicalDisplays); // 建议本地调用,可IPC - void AddInputEventFilter(std::function filter)>); // 只能本地 + int32_t AddInputEventFilter(std::function)> filter); void SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer); diff --git a/interfaces/native/innerkits/proxy/include/input_manager.h b/interfaces/native/innerkits/proxy/include/input_manager.h index 0e168ab17d..d5f610ff58 100644 --- a/interfaces/native/innerkits/proxy/include/input_manager.h +++ b/interfaces/native/innerkits/proxy/include/input_manager.h @@ -34,7 +34,7 @@ public: void UpdateDisplayInfo(const std::vector &physicalDisplays, const std::vector &logicalDisplays); // 建议本地调用,可IPC - void AddInputEventFilter(std::function filter)>); // 只能本地 + int32_t AddInputEventFilter(std::function)> filter); void SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer); diff --git a/service/connect_manager/include/i_multimodal_input_connect_stub.h b/service/connect_manager/include/i_multimodal_input_connect_stub.h index 220302ad96..4a5c58c310 100644 --- a/service/connect_manager/include/i_multimodal_input_connect_stub.h +++ b/service/connect_manager/include/i_multimodal_input_connect_stub.h @@ -37,7 +37,7 @@ protected: int32_t GetCallingUid() const; int32_t GetCallingPid() const; virtual int32_t HandleAllocSocketFd(MessageParcel &data, MessageParcel &reply) = 0; - int32_t StubSetInputEventFilter(MessageParcel& data, MessageParcel& reply); + int32_t StubAddInputEventFilter(MessageParcel& data, MessageParcel& reply); private: static const int SYSTEM_UID = 1000; diff --git a/service/connect_manager/src/i_multimodal_input_connect_stub.cpp b/service/connect_manager/src/i_multimodal_input_connect_stub.cpp index ed05a6df49..43984c105b 100644 --- a/service/connect_manager/src/i_multimodal_input_connect_stub.cpp +++ b/service/connect_manager/src/i_multimodal_input_connect_stub.cpp @@ -44,7 +44,7 @@ int32_t IMultimodalInputConnectStub::OnRemoteRequest( case static_cast(IMultimodalInputConnect::ALLOC_SOCKET_FD): return HandleAllocSocketFd(data, reply); case static_cast(IMultimodalInputConnect::SET_EVENT_POINTER_FILTER): - return StubSetInputEventFilter(data, reply); + return StubAddInputEventFilter(data, reply); default: MMI_LOGE("unknown code: %{public}u, go switch defaut", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -68,12 +68,15 @@ int32_t IMultimodalInputConnectStub::GetCallingPid() const return IPCSkeleton::GetCallingPid(); } -int32_t IMultimodalInputConnectStub::StubSetInputEventFilter(MessageParcel& data, MessageParcel& reply) +int32_t IMultimodalInputConnectStub::StubAddInputEventFilter(MessageParcel& data, MessageParcel& reply) { + MMI_LOGT("enter"); int32_t ret = RET_OK; do { - if (GetCallingUid() != SYSTEM_UID) { + const int uid = GetCallingUid(); + if (uid != SYSTEM_UID && uid != ROOT_UID) { + MMI_LOGE("uid is not root or system"); ret = SASERVICE_PERMISSION_FAIL; break; } @@ -92,11 +95,17 @@ int32_t IMultimodalInputConnectStub::StubSetInputEventFilter(MessageParcel& data break; } + MMI_LOGT("filter iface_cast succeeded"); + ret = AddInputEventFilter(filter); } while (0); - reply.WriteInt32(ret); + if (!reply.WriteInt32(ret)) { + MMI_LOGE("WriteInt32(%{public}d) fail", ret); + return IPC_STUB_WRITE_PARCEL_ERR; + } + MMI_LOGT("leave"); return RET_OK; } } // namespace MMI diff --git a/service/connect_manager/src/multimodal_input_connect_manager.cpp b/service/connect_manager/src/multimodal_input_connect_manager.cpp index dacbc6e372..dd88948436 100644 --- a/service/connect_manager/src/multimodal_input_connect_manager.cpp +++ b/service/connect_manager/src/multimodal_input_connect_manager.cpp @@ -74,7 +74,7 @@ int32_t MultimodalInputConnectManager::AddInputEventFilter(sptr fi std::lock_guard guard(lock_); if (multimodalInputConnectService_ == nullptr) { MMI_LOGE("multimodalInputConnectService_ is nullptr"); - return false; + return RET_ERR; } return multimodalInputConnectService_->AddInputEventFilter(filter); diff --git a/service/connect_manager/src/multimodal_input_connect_service.cpp b/service/connect_manager/src/multimodal_input_connect_service.cpp index 1dda21b77d..80777fcbad 100644 --- a/service/connect_manager/src/multimodal_input_connect_service.cpp +++ b/service/connect_manager/src/multimodal_input_connect_service.cpp @@ -58,20 +58,8 @@ int32_t MultimodalInputConnectService::AllocSocketFd(const std::string &programN int32_t MultimodalInputConnectService::AddInputEventFilter(sptr filter) { - MMI_LOGI("enter"); - if (udsServer_ == nullptr) { - MMI_LOGE("called, udsServer_ is nullptr."); - return RET_ERR; - } - - const int32_t ret = udsServer_->AddInputEventFilter(filter); - if (ret != RET_OK) { - MMI_LOGE("call AddInputEventFilter return %{public}d.", ret); - return RET_ERR; - } - - MMI_LOGI("leave, success."); - return RET_OK; + MMI_LOGI("enter, this code is discarded, and it runs with Weston"); + return RET_ERR; } MultimodalInputConnectService::MultimodalInputConnectService() diff --git a/service/event_filter_binder/include/event_filter_stub.h b/service/event_filter_binder/include/event_filter_stub.h index 4ca7ce2dbd..ffe4fcba31 100644 --- a/service/event_filter_binder/include/event_filter_stub.h +++ b/service/event_filter_binder/include/event_filter_stub.h @@ -29,7 +29,7 @@ public: virtual ~EventFilterStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& options) override; protected: - bool StubHandlePointerEvent(MessageParcel& data, MessageParcel& reply); + int32_t StubHandlePointerEvent(MessageParcel& data, MessageParcel& reply); }; } // namespace MMI } // namespace OHOS diff --git a/service/event_filter_binder/include/event_filter_wrap.h b/service/event_filter_binder/include/event_filter_wrap.h index 915c2e2204..f75ef04dab 100644 --- a/service/event_filter_binder/include/event_filter_wrap.h +++ b/service/event_filter_binder/include/event_filter_wrap.h @@ -16,6 +16,7 @@ #ifndef OHOS_EVENT_FILTER_WRAP_H #define OHOS_EVENT_FILTER_WRAP_H +#include #include "i_event_filter.h" #include "singleton.h" diff --git a/service/event_filter_binder/src/event_filter_proxy.cpp b/service/event_filter_binder/src/event_filter_proxy.cpp index 2df9e7a1e8..3fc93d5f32 100644 --- a/service/event_filter_binder/src/event_filter_proxy.cpp +++ b/service/event_filter_binder/src/event_filter_proxy.cpp @@ -38,7 +38,7 @@ EventFilterProxy::~EventFilterProxy() bool EventFilterProxy::HandlePointerEvent(const std::shared_ptr event) { - MMI_LOGE("enter"); + MMI_LOGT("enter"); MessageParcel data; MessageParcel reply; MessageOption option; @@ -53,7 +53,7 @@ bool EventFilterProxy::HandlePointerEvent(const std::shared_ptr ev return false; } - if (event->WriteToParcel(data)) { + if (!event->WriteToParcel(data)) { MMI_LOGE("Failed to write event to req"); return false; } @@ -65,16 +65,16 @@ bool EventFilterProxy::HandlePointerEvent(const std::shared_ptr ev return false; } - MMI_LOGE("have recieve message from server"); + MMI_LOGT("have recieve message from server"); - int result = reply.ReadInt32(); - MMI_LOGE("result = %{public}d", result); - if (result != RET_OK) { - MMI_LOGE("responce return error: %{public}d", result); + bool result = false; + if (!reply.ReadBool(result)) { + MMI_LOGE("reply ReadBool fail"); return false; } - return true; + MMI_LOGT("leave"); + return result; } } // namespace MMI } // namespace OHOS diff --git a/service/event_filter_binder/src/event_filter_stub.cpp b/service/event_filter_binder/src/event_filter_stub.cpp index ab115fd97c..ee6ca0b273 100644 --- a/service/event_filter_binder/src/event_filter_stub.cpp +++ b/service/event_filter_binder/src/event_filter_stub.cpp @@ -47,20 +47,28 @@ int32_t EventFilterStub::OnRemoteRequest( } } -bool EventFilterStub::StubHandlePointerEvent(MessageParcel& data, MessageParcel& reply) -{ +int32_t EventFilterStub::StubHandlePointerEvent(MessageParcel& data, MessageParcel& reply) +{ + MMI_LOGT("enter"); std::shared_ptr event = PointerEvent::Create(); if (event == nullptr) { MMI_LOGE("event is nullptr."); - return false; + return NULL_POINTER; } if (!event->ReadFromParcel(data)) { MMI_LOGE("read data error."); - return false; + return RET_ERR; + } + + bool ret = HandlePointerEvent(event); + if (!reply.WriteBool(ret)) { + MMI_LOGE("WriteBool(%{public}d) fail", ret); + return RET_ERR; } - return HandlePointerEvent(event); + MMI_LOGT("leave"); + return RET_OK; } } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/event_filter_binder/src/event_filter_wrap.cpp b/service/event_filter_binder/src/event_filter_wrap.cpp index b136e32e5c..05f7889a3c 100644 --- a/service/event_filter_binder/src/event_filter_wrap.cpp +++ b/service/event_filter_binder/src/event_filter_wrap.cpp @@ -38,6 +38,7 @@ int32_t EventFilterWrap::AddInputEventFilter(sptr filter) std::lock_guard guard(lockInputEventFilter_); filter_ = filter; + MMI_LOGT("leave"); return RET_OK; } -- Gitee From 9bc67153426d696c5b6033390b23d991f70db094 Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 17:19:10 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- frameworks/proxy/BUILD.gn | 56 ++++++++ .../events/test/input_manager_manual_test.cpp | 133 ++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 frameworks/proxy/events/test/input_manager_manual_test.cpp diff --git a/frameworks/proxy/BUILD.gn b/frameworks/proxy/BUILD.gn index 662dcfe9a8..5ced4ce5f5 100644 --- a/frameworks/proxy/BUILD.gn +++ b/frameworks/proxy/BUILD.gn @@ -378,6 +378,62 @@ ohos_unittest("InputManagerTest") { external_deps = [ "hiviewdfx_hilog_native:libhilog" ] } +ohos_unittest("InputManagerManualTest") { + module_out_path = module_output_path + include_dirs = [ + "//utils/native/base/include", + "//third_party/googletest/googletest/include", + "${mmi_path}/frameworks/util/common", + "${mmi_path}/frameworks/util/common/include", + "${mmi_path}/frameworks/util/network", + "${mmi_path}/frameworks/util/network/include", + "${mmi_path}/frameworks/util/socket", + "${mmi_path}/frameworks/util/socket/include", + "${mmi_path}/frameworks/proxy/event_handle", + "${mmi_path}/frameworks/proxy/event_handle/include", + "${mmi_path}/frameworks/proxy/module_loader", + "${mmi_path}/frameworks/proxy/module_loader/include", + "${mmi_path}/common/include", + "${mmi_path}/interfaces/native/innerkits/common/include", + "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${mmi_path}/interfaces/native/innerkits/event/include", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + ] + + if (is_mmi_have_libinput) { + include_dirs += [ "$root_out_dir/diff_libinput_mmi/src" ] + } + + cflags = [ "-DOHOS_BUILD" ] + + if (is_mmi_have_debug) { + cflags += [ "-DOHOS_BUILD_MMI_DEBUG" ] + } + + if (is_mmi_have_libinput) { + cflags += [ "-DOHOS_BUILD_LIBINPUT" ] + } + + if (is_mmi_have_hdf) { + cflags += [ "-DOHOS_BUILD_HDF" ] + } + + if (is_mmi_have_ai) { + cflags += [ "-DOHOS_BUILD_AI" ] + } + + sources = [ "events/test/input_manager_manual_test.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/util:libmmi-util", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] +} + ohos_unittest("PointerEventTest") { module_out_path = module_output_path include_dirs = [ diff --git a/frameworks/proxy/events/test/input_manager_manual_test.cpp b/frameworks/proxy/events/test/input_manager_manual_test.cpp new file mode 100644 index 0000000000..6da2149ffd --- /dev/null +++ b/frameworks/proxy/events/test/input_manager_manual_test.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2021 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. + */ + +#include "input_manager.h" +#include "error_multimodal.h" +#include +#include +#include +#include +#include "define_multimodal.h" +#include "input_handler_manager.h" +#include "input_event_monitor_manager.h" +#include "interceptor_manager.h" +#include "input_manager.h" +#include "key_event_pre.h" +#include "multimodal_event_handler.h" +#include "pointer_event.h" +#include "proto.h" +#include "run_shell_util.h" + +namespace { +using namespace testing::ext; +using namespace OHOS; +using namespace MMI; +namespace { +constexpr int32_t TIME_WAIT_FOR_OP = 500; +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "InputManagerManualTest" }; +} + +class InputManagerManualTest : public testing::Test { +public: + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + + void SetUp(); + void TearDown() {} + +protected: + void AddInputEventFilter(); + void SimulateInputEventHelper(int32_t globalX, int32_t globalY, int32_t expectVal); +private: + int32_t callbackRet = 0; +}; + +void InputManagerManualTest::SetUp() +{ + callbackRet = 0; +} + +void InputManagerManualTest::AddInputEventFilter() +{ + MMI_LOGT("enter"); + auto callback = [](std::shared_ptr pointer) -> bool { + MMI_LOGT("enter"); + if (pointer == nullptr) { + MMI_LOGE("pointer is null"); + return false; + } + + const std::vector ids = pointer->GetPointersIdList(); + if (ids.empty()) { + MMI_LOGE("ids is empty"); + return false; + } + + const int firstPointerId = ids[0]; + PointerItem item; + if (!pointer->GetPointerItem(firstPointerId, item)) { + MMI_LOGE("GetPointerItem(%{public}d) fail", firstPointerId); + return false; + } + + const int32_t x = item.GetGlobalX(); + const int32_t y = item.GetGlobalY(); + if (x == 10 && y == 10) { + MMI_LOGI("The values of X and y are both 10, which meets the expectation and callbackRet is set to 1"); + callbackRet = 1; + return true; + } + + MMI_LOGI("The values of X and y are not 10, which meets the expectation and callbackRet is set to 2") + callbackRet = 2; + return false; + }; + + int ret = InputManager::GetInstance()->AddInputEventFilter(callback); + ASSERT_EQ(ret, RET_OK); + MMI_LOGT("leave"); +} + +void InputManagerManualTest::SimulateInputEventHelper(int32_t globalX, int32_t globalY, int32_t expectVal) +{ + MMI_LOGT("enter"); + const int32_t pointerId = 0; + PointerEvent::PointerItem item; + item.SetPointerId(pointerId); + item.SetGlobalX(globalX); + item.SetGlobalY(globalY); + + auto pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + pointerEvent->AddPointerItem(item); + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); + pointerEvent->SetSourceType(-1); + pointerEvent->SetPointerId(pointerId); + + MMI_LOGI("Call InputManager::SimulateInputEvent"); + InputManager::GetInstance()->SimulateInputEvent(pointerEvent); + std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP)); + EXPECT_EQ(callbackRet, expectVal); + MMI_LOGT("leave"); +} + +HWTEST_F(InputManagerManualTest, HandlePointerEventFilter_001, TestSize.Level1) +{ + MMI_LOGT("enter"); + AddInputEventFilter(); + SimulateInputEventHelper(10, 10, 1); // set global x and global y are 10, will expect value is 1 + SimulateInputEventHelper(0, 0, 2); // set global x and global y are not 10, will expect value is 2 +} +} \ No newline at end of file -- Gitee From 218cce674cf62fced2ed1604d5171eee41955bfc Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 17:41:29 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- frameworks/proxy/event_handle/src/input_manager_impl.cpp | 2 +- frameworks/proxy/events/src/input_manager.cpp | 2 +- .../connect_manager/src/i_multimodal_input_connect_stub.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/proxy/event_handle/src/input_manager_impl.cpp b/frameworks/proxy/event_handle/src/input_manager_impl.cpp index 49ceb91acb..e601bbfa92 100644 --- a/frameworks/proxy/event_handle/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handle/src/input_manager_impl.cpp @@ -85,7 +85,7 @@ int32_t InputManagerImpl::AddInputEventFilter(std::function &phy InputManagerImpl::GetInstance()->UpdateDisplayInfo(physicalDisplays, logicalDisplays); } -int32_t InputManager::AddInputEventFilter(std::function filter)>) +int32_t InputManager::AddInputEventFilter(std::function)> filter) { return InputManagerImpl::GetInstance()->AddInputEventFilter(filter); } diff --git a/service/connect_manager/src/i_multimodal_input_connect_stub.cpp b/service/connect_manager/src/i_multimodal_input_connect_stub.cpp index 43984c105b..f6460dddfd 100644 --- a/service/connect_manager/src/i_multimodal_input_connect_stub.cpp +++ b/service/connect_manager/src/i_multimodal_input_connect_stub.cpp @@ -74,7 +74,7 @@ int32_t IMultimodalInputConnectStub::StubAddInputEventFilter(MessageParcel& data int32_t ret = RET_OK; do { - const int uid = GetCallingUid(); + const int32_t uid = GetCallingUid(); if (uid != SYSTEM_UID && uid != ROOT_UID) { MMI_LOGE("uid is not root or system"); ret = SASERVICE_PERMISSION_FAIL; @@ -105,7 +105,7 @@ int32_t IMultimodalInputConnectStub::StubAddInputEventFilter(MessageParcel& data return IPC_STUB_WRITE_PARCEL_ERR; } - MMI_LOGT("leave"); + MMI_LOGT("leave, ret = %{public}d", ret); return RET_OK; } } // namespace MMI -- Gitee From 5f2c4173b593496872b80d202e666a94b89428b0 Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 17:48:03 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- frameworks/proxy/events/src/input_manager.cpp | 2 +- .../proxy/events/test/input_manager_manual_test.cpp | 12 ++++-------- .../src/multimodal_input_connect_service.cpp | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/frameworks/proxy/events/src/input_manager.cpp b/frameworks/proxy/events/src/input_manager.cpp index f5dfc651f4..fc078df648 100644 --- a/frameworks/proxy/events/src/input_manager.cpp +++ b/frameworks/proxy/events/src/input_manager.cpp @@ -47,7 +47,7 @@ void InputManager::UpdateDisplayInfo(const std::vector &phy int32_t InputManager::AddInputEventFilter(std::function)> filter) { - return InputManagerImpl::GetInstance()->AddInputEventFilter(filter); + return InputManagerImpl::GetInstance()->AddInputEventFilter(filter); } void InputManager::SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer) diff --git a/frameworks/proxy/events/test/input_manager_manual_test.cpp b/frameworks/proxy/events/test/input_manager_manual_test.cpp index 6da2149ffd..b806ea5cd0 100644 --- a/frameworks/proxy/events/test/input_manager_manual_test.cpp +++ b/frameworks/proxy/events/test/input_manager_manual_test.cpp @@ -13,17 +13,13 @@ * limitations under the License. */ -#include "input_manager.h" -#include "error_multimodal.h" -#include -#include -#include #include #include "define_multimodal.h" -#include "input_handler_manager.h" +#include "error_multimodal.h" #include "input_event_monitor_manager.h" -#include "interceptor_manager.h" +#include "input_handler_manager.h" #include "input_manager.h" +#include "interceptor_manager.h" #include "key_event_pre.h" #include "multimodal_event_handler.h" #include "pointer_event.h" @@ -120,7 +116,7 @@ void InputManagerManualTest::SimulateInputEventHelper(int32_t globalX, int32_t g InputManager::GetInstance()->SimulateInputEvent(pointerEvent); std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP)); EXPECT_EQ(callbackRet, expectVal); - MMI_LOGT("leave"); + MMI_LOGT("leave"); } HWTEST_F(InputManagerManualTest, HandlePointerEventFilter_001, TestSize.Level1) diff --git a/service/connect_manager/src/multimodal_input_connect_service.cpp b/service/connect_manager/src/multimodal_input_connect_service.cpp index 80777fcbad..bf9cd0034b 100644 --- a/service/connect_manager/src/multimodal_input_connect_service.cpp +++ b/service/connect_manager/src/multimodal_input_connect_service.cpp @@ -58,8 +58,8 @@ int32_t MultimodalInputConnectService::AllocSocketFd(const std::string &programN int32_t MultimodalInputConnectService::AddInputEventFilter(sptr filter) { - MMI_LOGI("enter, this code is discarded, and it runs with Weston"); - return RET_ERR; + MMI_LOGF("enter, this code is discarded, and it runs with Weston"); + return RET_ERR; } MultimodalInputConnectService::MultimodalInputConnectService() -- Gitee From 3fc6aebacf084b41c0a1b5afe0f01ed745346e4a Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 18:25:51 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- service/event_filter_binder/src/event_filter_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/event_filter_binder/src/event_filter_stub.cpp b/service/event_filter_binder/src/event_filter_stub.cpp index ee6ca0b273..ad6ba20062 100644 --- a/service/event_filter_binder/src/event_filter_stub.cpp +++ b/service/event_filter_binder/src/event_filter_stub.cpp @@ -53,7 +53,7 @@ int32_t EventFilterStub::StubHandlePointerEvent(MessageParcel& data, MessageParc std::shared_ptr event = PointerEvent::Create(); if (event == nullptr) { MMI_LOGE("event is nullptr."); - return NULL_POINTER; + return RET_ERR; } if (!event->ReadFromParcel(data)) { -- Gitee From fdea68134399542ddc2cc29a6bf4677819b4c08c Mon Sep 17 00:00:00 2001 From: zhangpengcheng Date: Mon, 17 Jan 2022 19:59:13 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=BB=A4BINDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangpengcheng --- frameworks/proxy/events/test/input_manager_manual_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/proxy/events/test/input_manager_manual_test.cpp b/frameworks/proxy/events/test/input_manager_manual_test.cpp index b806ea5cd0..3489ab27a0 100644 --- a/frameworks/proxy/events/test/input_manager_manual_test.cpp +++ b/frameworks/proxy/events/test/input_manager_manual_test.cpp @@ -58,7 +58,7 @@ void InputManagerManualTest::SetUp() void InputManagerManualTest::AddInputEventFilter() { MMI_LOGT("enter"); - auto callback = [](std::shared_ptr pointer) -> bool { + auto callback = [this](std::shared_ptr pointer) -> bool { MMI_LOGT("enter"); if (pointer == nullptr) { MMI_LOGE("pointer is null"); @@ -72,7 +72,7 @@ void InputManagerManualTest::AddInputEventFilter() } const int firstPointerId = ids[0]; - PointerItem item; + PointerEvent::PointerItem item; if (!pointer->GetPointerItem(firstPointerId, item)) { MMI_LOGE("GetPointerItem(%{public}d) fail", firstPointerId); return false; @@ -86,7 +86,7 @@ void InputManagerManualTest::AddInputEventFilter() return true; } - MMI_LOGI("The values of X and y are not 10, which meets the expectation and callbackRet is set to 2") + MMI_LOGI("The values of X and y are not 10, which meets the expectation and callbackRet is set to 2"); callbackRet = 2; return false; }; -- Gitee