diff --git a/BUILD.gn b/BUILD.gn index 4e8a69f462567a90e187fe1571d663e204ecceb5..a3a0757c1761480108fc7c7d4cf4b9d38466437f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -137,7 +137,7 @@ group("input_jsapi_group") { group("mmi_tests") { testonly = true deps = [ - "common/anco/comm:AncoChannelStubTest", + #"common/anco/comm:AncoChannelStubTest", "frameworks/native/input:OHInputManagerTest", "frameworks/proxy:InputHandlerManagerTest", "frameworks/proxy:InputManagerFilterManualTest", @@ -152,10 +152,12 @@ group("mmi_tests") { "libudev:test", "service:AccountManagerTest", "service:ApplicationStateObserverTest", - "service:ConnectManagerEXTest", - "service:ConnectManagerOneTest", + + #"service:ConnectManagerEXTest", + #"service:ConnectManagerOneTest", "service:ConnectManagerProxyEXTest", - "service:ConnectManagerTest", + + #"service:ConnectManagerTest", "service:DelegateTaskTest", "service:DeviceConfigTest", "service:DeviceEventMonitorTest", diff --git a/bundle.json b/bundle.json index b07d717d46accbe0025313463e5eedbdfba0fc4d..800a984feb0bf243357f933d883b9b3e0c5cb7ad 100644 --- a/bundle.json +++ b/bundle.json @@ -99,7 +99,8 @@ "audio_framework", "graphic_surface", "ipc", - "sensor" + "sensor", + "idl_tool" ], "third_party": [ "libuv", @@ -138,7 +139,8 @@ "event/include/key_event.h", "event/include/pointer_event.h", "event/include/input_event.h", - "event/include/mmi_event_observer.h" + "event/include/mmi_event_observer.h", + "event/include/pointer_style.h" ], "header_base": "//foundation/multimodalinput/input/interfaces/native/innerkits" }, diff --git a/common/anco/comm/BUILD.gn b/common/anco/comm/BUILD.gn index 0ffa331e13903de0fe6f11c5341ada328cfecc15..d67eed2473879f063f237a8c543d7887a7b72582 100644 --- a/common/anco/comm/BUILD.gn +++ b/common/anco/comm/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -11,17 +11,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("//build/test.gni") import("../../../multimodalinput_mini.gni") module_output_path = "input/input" +idl_gen_interface("anco_channel_interface") { + src_idl = rebase_path("IAncoChannel.idl") +} + config("mmi_anco_channel_config") { include_dirs = [ "include", "${mmi_path}/interfaces/native/innerkits/event/include", "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${target_gen_dir}", ] if (input_ext_feature_anco) { @@ -37,8 +43,11 @@ ohos_source_set("mmi_anco_channel_proxy") { sources = [ "${mmi_path}/frameworks/proxy/events/src/i_anco_consumer.cpp", "src/anco_channel_death_recipient.cpp", - "src/anco_channel_proxy.cpp", ] + + output_values = get_target_outputs(":anco_channel_interface") + sources += filter_include(output_values, [ "*_proxy.cpp" ]) + branch_protector_ret = "pac_ret" sanitize = { cfi = true @@ -50,7 +59,10 @@ ohos_source_set("mmi_anco_channel_proxy") { public_configs = [ ":mmi_anco_channel_config" ] - deps = [ "${mmi_path}/util:libmmi-util" ] + deps = [ + ":anco_channel_interface", + "${mmi_path}/util:libmmi-util", + ] external_deps = [ "hilog:libhilog", @@ -69,8 +81,11 @@ ohos_source_set("mmi_anco_channel_stub") { sources = [ "${mmi_path}/frameworks/proxy/events/src/i_anco_consumer.cpp", "src/anco_channel.cpp", - "src/anco_channel_stub.cpp", ] + + output_values = get_target_outputs(":anco_channel_interface") + sources += filter_include(output_values, [ "*_stub.cpp" ]) + branch_protector_ret = "pac_ret" sanitize = { cfi = true @@ -82,7 +97,10 @@ ohos_source_set("mmi_anco_channel_stub") { public_configs = [ ":mmi_anco_channel_config" ] - deps = [ "${mmi_path}/util:libmmi-util" ] + deps = [ + ":anco_channel_interface", + "${mmi_path}/util:libmmi-util", + ] external_deps = [ "hilog:libhilog", diff --git a/service/filter/include/event_filter_proxy.h b/common/anco/comm/IAncoChannel.idl similarity index 39% rename from service/filter/include/event_filter_proxy.h rename to common/anco/comm/IAncoChannel.idl index 618dbbfc733de73dc214e075bb9e3b0e085156d3..60fd3fef09b009ffb785547bc06b96d4862a4e2f 100644 --- a/service/filter/include/event_filter_proxy.h +++ b/common/anco/comm/IAncoChannel.idl @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 + * 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, @@ -13,24 +13,14 @@ * limitations under the License. */ -#ifndef EVENT_FILTER_PROXY_H -#define EVENT_FILTER_PROXY_H -#include "iremote_proxy.h" - -#include "i_event_filter.h" - -namespace OHOS { -namespace MMI { -class EventFilterProxy final : public IRemoteProxy { -public: - explicit EventFilterProxy(const sptr &impl); - DISALLOW_COPY_AND_MOVE(EventFilterProxy); - ~EventFilterProxy() override = default; - bool HandleKeyEvent(const std::shared_ptr event) override; - bool HandlePointerEvent(const std::shared_ptr event) override; -private: - static inline BrokerDelegator delegator_; -}; -} // namespace MMI -} // namespace OHOS -#endif // EVENT_FILTER_PROXY_H \ No newline at end of file +sequenceable pointer_event..OHOS.MMI.PointerEvent; +sequenceable key_event..OHOS.MMI.KeyEvent; +sequenceable i_anco_consumer..OHOS.MMI.AncoWindows; +sequenceable i_anco_consumer..OHOS.MMI.AncoOneHandData; +interface OHOS.MMI.IAncoChannel { + void SyncInputPointEvent([in] PointerEvent pointerEvent); + void SyncInputKeyEvent([in] KeyEvent keyEvent); + void UpdateWindowInfo([in] AncoWindows windows); + void SyncKnuckleStatus([in] boolean isKnuckleEnable); + [oneway] void UpdateOneHandData([in] AncoOneHandData oneHandData); +} diff --git a/common/anco/comm/include/anco_channel.h b/common/anco/comm/include/anco_channel.h index 0fbf3a342b8b977f565040d571669c986d9445b8..1526d98b6ee3125455260e5c71c5620ce6d47df7 100644 --- a/common/anco/comm/include/anco_channel.h +++ b/common/anco/comm/include/anco_channel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -29,11 +29,11 @@ public: ~AncoChannel() = default; DISALLOW_COPY_AND_MOVE(AncoChannel); - int32_t SyncInputEvent(std::shared_ptr pointerEvent) override; - int32_t SyncInputEvent(std::shared_ptr keyEvent) override; - int32_t UpdateWindowInfo(std::shared_ptr windows) override; - int32_t SyncKnuckleStatus(bool isKnuckleEnable) override; - int32_t UpdateOneHandData(const AncoOneHandData &oneHandData) override; + ErrCode SyncInputPointEvent(const PointerEvent& pointerEvent) override; + ErrCode SyncInputKeyEvent(const KeyEvent& keyEvent) override; + ErrCode UpdateWindowInfo(const AncoWindows& windows) override; + ErrCode SyncKnuckleStatus(bool isKnuckleEnable) override; + ErrCode UpdateOneHandData(const AncoOneHandData &oneHandData) override; private: std::shared_ptr consumer_; diff --git a/common/anco/comm/include/anco_channel_proxy.h b/common/anco/comm/include/anco_channel_proxy.h deleted file mode 100644 index 9b718d12fb8a61b979268b3d878143d307e23fb8..0000000000000000000000000000000000000000 --- a/common/anco/comm/include/anco_channel_proxy.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -#ifndef ANCO_CHANNEL_PROXY_H -#define ANCO_CHANNEL_PROXY_H - -#include "iremote_object.h" -#include "iremote_proxy.h" -#include "nocopyable.h" - -#include "i_anco_channel.h" - -namespace OHOS { -namespace MMI { -class AncoChannelProxy final : public IRemoteProxy { -public: - explicit AncoChannelProxy(const sptr &remoteObj); - ~AncoChannelProxy() override = default; - DISALLOW_COPY_AND_MOVE(AncoChannelProxy); - - int32_t SyncInputEvent(std::shared_ptr pointerEvent) override; - int32_t SyncInputEvent(std::shared_ptr keyEvent) override; - int32_t UpdateWindowInfo(std::shared_ptr windows) override; - int32_t SyncKnuckleStatus(bool isKnuckleEnable) override; - int32_t UpdateOneHandData(const AncoOneHandData &oneHandData) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace MMI -} // namespace OHOS -#endif // ANCO_CHANNEL_PROXY_H diff --git a/common/anco/comm/include/anco_channel_stub.h b/common/anco/comm/include/anco_channel_stub.h deleted file mode 100644 index c1e071d68eec81e0e108f6ad8e81603527d18fde..0000000000000000000000000000000000000000 --- a/common/anco/comm/include/anco_channel_stub.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -#ifndef ANCO_CHANNEL_STUB_H -#define ANCO_CHANNEL_STUB_H - -#include -#include - -#include "iremote_stub.h" -#include "message_parcel.h" -#include "nocopyable.h" - -#include "i_anco_channel.h" - -namespace OHOS { -namespace MMI { -class AncoChannelStub : public IRemoteStub { -public: - AncoChannelStub(); - virtual ~AncoChannelStub() = default; - DISALLOW_COPY_AND_MOVE(AncoChannelStub); - - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& options) override; - -private: - int32_t StubSyncPointerEvent(MessageParcel &data, MessageParcel &reply); - int32_t StubSyncKeyEvent(MessageParcel &data, MessageParcel &reply); - int32_t StubUpdateWindowInfo(MessageParcel &data, MessageParcel &reply); - int32_t StubSyncKnuckleStatus(MessageParcel &data, MessageParcel &reply); - int32_t StubUpdateOneHandData(MessageParcel &data, MessageParcel &reply); - - std::map handlers_; -}; -} // namespace MMI -} // namespace OHOS -#endif // ANCO_CHANNEL_STUB_H diff --git a/common/anco/comm/include/i_anco_channel.h b/common/anco/comm/include/i_anco_channel.h deleted file mode 100644 index fa99c8f6ea1c59a90ced648cbe7d516867be302b..0000000000000000000000000000000000000000 --- a/common/anco/comm/include/i_anco_channel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -#ifndef I_ANCO_CHANNEL_H -#define I_ANCO_CHANNEL_H - -#include "i_anco_consumer.h" - -namespace OHOS { -namespace MMI { - -enum class AncoRequestId { - SYNC_POINTER_EVENT = 0, - SYNC_KEY_EVENT, - UPDATE_WINDOW_INFO, - SYNC_KNUCKLE_STATUS, - UPDATE_ONE_HAND_DATA, -}; - -class IAncoChannel : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.multimodalinput.IAncoChannel"); - - virtual int32_t SyncInputEvent(std::shared_ptr pointerEvent) = 0; - virtual int32_t SyncInputEvent(std::shared_ptr keyEvent) = 0; - virtual int32_t UpdateWindowInfo(std::shared_ptr windows) = 0; - virtual int32_t SyncKnuckleStatus(bool isKnuckleEnable) = 0; - virtual int32_t UpdateOneHandData(const AncoOneHandData &oneHandData) = 0; -}; -} // namespace MMI -} // namespace OHOS -#endif // I_ANCO_CHANNEL_H diff --git a/common/anco/comm/src/anco_channel.cpp b/common/anco/comm/src/anco_channel.cpp index 4186f66fd18feece41ab93f3f61f5adf07f787eb..223bf7e5e300ba43a2a9bc69fa9fb936294355cd 100644 --- a/common/anco/comm/src/anco_channel.cpp +++ b/common/anco/comm/src/anco_channel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -29,31 +29,37 @@ AncoChannel::AncoChannel(std::shared_ptr consumer) : consumer_(consumer) {} -int32_t AncoChannel::SyncInputEvent(std::shared_ptr pointerEvent) +ErrCode AncoChannel::SyncInputPointEvent(const PointerEvent &pointerEvent) { CHKPR(consumer_, RET_ERR); - return consumer_->SyncInputEvent(pointerEvent); + std::shared_ptr pointerEventPtr = std::make_shared(pointerEvent); + CHKPR(pointerEventPtr, RET_ERR); + return consumer_->SyncInputEvent(pointerEventPtr); } -int32_t AncoChannel::SyncInputEvent(std::shared_ptr keyEvent) +ErrCode AncoChannel::SyncInputKeyEvent(const KeyEvent &keyEvent) { CHKPR(consumer_, RET_ERR); - return consumer_->SyncInputEvent(keyEvent); + std::shared_ptr keyEventPtr = std::make_shared(keyEvent); + CHKPR(keyEventPtr, RET_ERR); + return consumer_->SyncInputEvent(keyEventPtr); } -int32_t AncoChannel::UpdateWindowInfo(std::shared_ptr windows) +ErrCode AncoChannel::UpdateWindowInfo(const AncoWindows &windows) { CHKPR(consumer_, RET_ERR); - return consumer_->UpdateWindowInfo(windows); + std::shared_ptr windowsPtr = std::make_shared(windows); + CHKPR(windowsPtr, RET_ERR); + return consumer_->UpdateWindowInfo(windowsPtr); } -int32_t AncoChannel::UpdateOneHandData(const AncoOneHandData &oneHandData) +ErrCode AncoChannel::UpdateOneHandData(const AncoOneHandData &oneHandData) { CHKPR(consumer_, RET_ERR); return consumer_->UpdateOneHandData(oneHandData); } -int32_t AncoChannel::SyncKnuckleStatus(bool isKnuckleEnable) +ErrCode AncoChannel::SyncKnuckleStatus(bool isKnuckleEnable) { CHKPR(consumer_, RET_ERR); return consumer_->SyncKnuckleStatus(isKnuckleEnable); diff --git a/common/anco/comm/src/anco_channel_proxy.cpp b/common/anco/comm/src/anco_channel_proxy.cpp deleted file mode 100644 index 97c74a8a7de7971540c5030cd94e7de20074725a..0000000000000000000000000000000000000000 --- a/common/anco/comm/src/anco_channel_proxy.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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. - */ - -#include "anco_channel_proxy.h" - -#include "message_option.h" - -#include "mmi_log.h" - -#undef MMI_LOG_DOMAIN -#define MMI_LOG_DOMAIN MMI_LOG_HANDLER -#undef MMI_LOG_TAG -#define MMI_LOG_TAG "AncoChannelProxy" - -namespace OHOS { -namespace MMI { - -AncoChannelProxy::AncoChannelProxy(const sptr &remoteObj) - : IRemoteProxy(remoteObj) -{} - -int32_t AncoChannelProxy::SyncInputEvent(std::shared_ptr pointerEvent) -{ - CALL_INFO_TRACE; - CHKPR(pointerEvent, RET_ERR); - MessageParcel data; - if (!data.WriteInterfaceToken(IAncoChannel::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return RET_ERR; - } - if (!pointerEvent->WriteToParcel(data)) { - MMI_HILOGE("Failed to marshal PointerEvent"); - return RET_ERR; - } - MessageParcel reply; - MessageOption option; - sptr remote = Remote(); - CHKPR(remote, RET_ERR); - int32_t ret = remote->SendRequest( - static_cast(AncoRequestId::SYNC_POINTER_EVENT), data, reply, option); - if (ret != RET_OK) { - MMI_HILOGE("SendRequest fail, error:%{public}d", ret); - return ret; - } - READINT32(reply, ret, RET_ERR); - return ret; -} - -int32_t AncoChannelProxy::SyncInputEvent(std::shared_ptr keyEvent) -{ - CALL_INFO_TRACE; - CHKPR(keyEvent, RET_ERR); - MessageParcel data; - if (!data.WriteInterfaceToken(IAncoChannel::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return RET_ERR; - } - if (!keyEvent->WriteToParcel(data)) { - MMI_HILOGE("Failed to marshal KeyEvent"); - return RET_ERR; - } - MessageParcel reply; - MessageOption option; - sptr remote = Remote(); - CHKPR(remote, RET_ERR); - int32_t ret = remote->SendRequest( - static_cast(AncoRequestId::SYNC_KEY_EVENT), data, reply, option); - if (ret != RET_OK) { - MMI_HILOGE("SendRequest fail, error:%{public}d", ret); - return ret; - } - READINT32(reply, ret, RET_ERR); - return ret; -} - -int32_t AncoChannelProxy::UpdateWindowInfo(std::shared_ptr windows) -{ - CALL_INFO_TRACE; - CHKPR(windows, RET_ERR); - MessageParcel data; - if (!data.WriteInterfaceToken(IAncoChannel::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return RET_ERR; - } - if (!AncoWindows::Marshalling(*windows, data)) { - MMI_HILOGE("Failed to marshal windows"); - return RET_ERR; - } - MessageParcel reply; - MessageOption option; - sptr remote = Remote(); - CHKPR(remote, RET_ERR); - int32_t ret = remote->SendRequest( - static_cast(AncoRequestId::UPDATE_WINDOW_INFO), data, reply, option); - if (ret != RET_OK) { - MMI_HILOGE("SendRequest fail, error:%{public}d", ret); - return ret; - } - READINT32(reply, ret, RET_ERR); - return ret; -} - -int32_t AncoChannelProxy::SyncKnuckleStatus(bool isKnuckleEnable) -{ - CALL_INFO_TRACE; - MessageParcel data; - if (!data.WriteInterfaceToken(IAncoChannel::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return RET_ERR; - } - if (!data.WriteBool(isKnuckleEnable)) { - MMI_HILOGE("Failed to write knuckle status"); - return RET_ERR; - } - MessageParcel reply; - MessageOption option; - sptr remote = Remote(); - CHKPR(remote, RET_ERR); - int32_t ret = remote->SendRequest( - static_cast(AncoRequestId::SYNC_KNUCKLE_STATUS), data, reply, option); - if (ret != RET_OK) { - MMI_HILOGE("SendRequest fail, error:%{public}d", ret); - return ret; - } - return ret; -} - -int32_t AncoChannelProxy::UpdateOneHandData(const AncoOneHandData &oneHandData) -{ - CALL_INFO_TRACE; - MessageParcel data; - if (!data.WriteInterfaceToken(IAncoChannel::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return RET_ERR; - } - if (!AncoOneHandData::Marshalling(oneHandData, data)) { - MMI_HILOGE("Failed to write one hand data"); - return RET_ERR; - } - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - sptr remote = Remote(); - CHKPR(remote, RET_ERR); - int32_t ret = remote->SendRequest( - static_cast(AncoRequestId::UPDATE_ONE_HAND_DATA), data, reply, option); - if (ret != RET_OK) { - MMI_HILOGE("SendRequest fail, error:%{public}d", ret); - return ret; - } - return ret; -} -} // namespace MMI -} // namespace OHOS diff --git a/common/anco/comm/src/anco_channel_stub.cpp b/common/anco/comm/src/anco_channel_stub.cpp deleted file mode 100644 index e4880be43c1e14d46657eb9b25b25cb2139e089d..0000000000000000000000000000000000000000 --- a/common/anco/comm/src/anco_channel_stub.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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. - */ - -#include "anco_channel_stub.h" - -#include "string_ex.h" - -#include "define_multimodal.h" - -#undef MMI_LOG_DOMAIN -#define MMI_LOG_DOMAIN MMI_LOG_HANDLER -#undef MMI_LOG_TAG -#define MMI_LOG_TAG "AncoChannelStub" - -namespace OHOS { -namespace MMI { - -AncoChannelStub::AncoChannelStub() -{ - handlers_ = { - { AncoRequestId::SYNC_POINTER_EVENT, &AncoChannelStub::StubSyncPointerEvent }, - { AncoRequestId::SYNC_KEY_EVENT, &AncoChannelStub::StubSyncKeyEvent }, - { AncoRequestId::UPDATE_WINDOW_INFO, &AncoChannelStub::StubUpdateWindowInfo }, - { AncoRequestId::SYNC_KNUCKLE_STATUS, &AncoChannelStub::StubSyncKnuckleStatus }, - { AncoRequestId::UPDATE_ONE_HAND_DATA, &AncoChannelStub::StubUpdateOneHandData }, - }; -} - -int32_t AncoChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - CALL_INFO_TRACE; - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IAncoChannel::GetDescriptor()) { - MMI_HILOGE("Got unexpected descriptor:%{public}s", Str16ToStr8(descriptor).c_str()); - return ERR_INVALID_STATE; - } - int32_t ret = RET_ERR; - auto cbIter = handlers_.find(static_cast(code)); - - if (cbIter == handlers_.end()) { - MMI_HILOGE("Unexpected request:%{public}u", code); - } else { - ret = (this->*(cbIter->second))(data, reply); - } - WRITEINT32(reply, ret); - return ret; -} - -int32_t AncoChannelStub::StubSyncPointerEvent(MessageParcel &data, MessageParcel &reply) -{ - CALL_INFO_TRACE; - auto pointerEvent = PointerEvent::Create(); - CHKPR(pointerEvent, RET_ERR); - if (!pointerEvent->ReadFromParcel(data)) { - MMI_HILOGE("Failed to unmarshal PointerEvent"); - return RET_ERR; - } - return SyncInputEvent(pointerEvent); -} - -int32_t AncoChannelStub::StubSyncKeyEvent(MessageParcel &data, MessageParcel &reply) -{ - auto keyEvent = KeyEvent::Create(); - CHKPR(keyEvent, RET_ERR); - if (!keyEvent->ReadFromParcel(data)) { - MMI_HILOGE("Failed to unmarshal KeyEvent"); - return RET_ERR; - } - return SyncInputEvent(keyEvent); -} - -int32_t AncoChannelStub::StubUpdateWindowInfo(MessageParcel &data, MessageParcel &reply) -{ - auto windows = std::make_shared(); - if (!AncoWindows::Unmarshalling(data, *windows)) { - MMI_HILOGE("Failed to unmarshal anco windows"); - return RET_ERR; - } - return UpdateWindowInfo(windows); -} - -int32_t AncoChannelStub::StubSyncKnuckleStatus(MessageParcel &data, MessageParcel &reply) -{ - bool touchType = false; - if (!data.ReadBool(touchType)) { - MMI_HILOGE("Failed to read status."); - return RET_ERR; - } - return SyncKnuckleStatus(touchType); -} - -int32_t AncoChannelStub::StubUpdateOneHandData(MessageParcel &data, MessageParcel &reply) -{ - AncoOneHandData oneHandData{}; - if (!AncoOneHandData::Unmarshalling(data, oneHandData)) { - MMI_HILOGE("Failed to read one hand data."); - return RET_ERR; - } - return UpdateOneHandData(oneHandData); -} -} // namespace MMI -} // namespace OHOS diff --git a/frameworks/napi/input_device/BUILD.gn b/frameworks/napi/input_device/BUILD.gn index d9d230150a4290105ebccffe1a4dee0c0e2b954f..8f85919965fe79cc36156182067334452ee3657d 100644 --- a/frameworks/napi/input_device/BUILD.gn +++ b/frameworks/napi/input_device/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -49,6 +49,7 @@ ohos_shared_library("inputdevice") { deps = [ "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/util:libmmi-util", ] diff --git a/frameworks/napi/pointer/BUILD.gn b/frameworks/napi/pointer/BUILD.gn index d7befd4fefa00f33924a227d78f245933b6bbf2e..07a7ce02909a93ecfea0139c78224e7f24c9b96c 100644 --- a/frameworks/napi/pointer/BUILD.gn +++ b/frameworks/napi/pointer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 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 @@ -49,6 +49,7 @@ ohos_shared_library("pointer") { deps = [ "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/util:libmmi-util", ] diff --git a/frameworks/native/input/BUILD.gn b/frameworks/native/input/BUILD.gn index 7e345ba2bcfb0ff7ee8f7ab9781e94a5f9895144..9e9476d3c472cc480e4a6b3060bc4283d0dc318d 100644 --- a/frameworks/native/input/BUILD.gn +++ b/frameworks/native/input/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -33,6 +33,11 @@ ohos_shared_library("oh_input_manager") { debug = false } + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + public_configs = [ ":oh_input_manager_config" ] include_dirs = [ @@ -119,6 +124,8 @@ ohos_unittest("OHInputManagerTest") { configs = [ "${mmi_path}:coverage_flags", "${mmi_path}/frameworks/proxy:libmmi_test_util", + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", ] deps = [ diff --git a/frameworks/proxy/BUILD.gn b/frameworks/proxy/BUILD.gn index 07348365150119ecc8b9679376c225d3b0083ea1..3b4d612dfe99374a3df937d29fd7b1ea9b228ab9 100644 --- a/frameworks/proxy/BUILD.gn +++ b/frameworks/proxy/BUILD.gn @@ -64,10 +64,17 @@ ohos_source_set("libmmi-common") { public_configs = [ ":libmmi_client_config" ] visibility = [ "${mmi_path}/*" ] branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + external_deps = [ "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", + "image_framework:image_native", "init:libbegetutil", ] @@ -126,6 +133,7 @@ ohos_shared_library("libmmi-client") { "${mmi_path}/util:libmmi_util_public_config", "${mmi_path}/service/filter:mmi_event_filter_config", "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", ] public_configs = [ ":libmmi_public_client_config" ] @@ -137,9 +145,7 @@ ohos_shared_library("libmmi-client") { "${mmi_path}/util:libmmi-util", ] - if (input_ext_feature_anco) { - deps += [ "${mmi_path}/common/anco/comm:mmi_anco_channel_stub" ] - } + deps += [ "${mmi_path}/common/anco/comm:mmi_anco_channel_stub" ] part_name = "input" subsystem_name = "multimodalinput" @@ -240,6 +246,9 @@ ohos_unittest("InputHandlerManagerTest") { "${mmi_path}:coverage_flags", ":libmmi_client_config", "${mmi_path}/service:libmmi_server_config", + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", ] cflags = [ @@ -322,6 +331,9 @@ ohos_unittest("SwitchEventInputSubscribeManagerTest") { configs = [ "${mmi_path}:coverage_flags", ":libmmi_test_util", + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", ] cflags = [ @@ -329,8 +341,17 @@ ohos_unittest("SwitchEventInputSubscribeManagerTest") { "-Dprotected=public", ] + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = true + blocklist = "./ipc_blocklist.txt" + } + deps = [ "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/util:libmmi-util", ] external_deps = [ @@ -363,15 +384,10 @@ ohos_unittest("InputMonitorManagerTest") { ] sources = [ - "${mmi_path}/common/anco/comm/src/anco_channel.cpp", - "${mmi_path}/common/anco/comm/src/anco_channel_stub.cpp", - "${mmi_path}/frameworks/proxy/events/src/i_anco_consumer.cpp", "${mmi_path}/service/connect_manager/src/input_binder_client_server.cpp", "${mmi_path}/service/connect_manager/src/input_binder_client_stub.cpp", "${mmi_path}/service/connect_manager/src/multimodal_input_connect_death_recipient.cpp", "${mmi_path}/service/connect_manager/src/multimodal_input_connect_manager.cpp", - "${mmi_path}/service/filter/src/event_filter_service.cpp", - "${mmi_path}/service/filter/src/event_filter_stub.cpp", "event_handler/src/anr_handler.cpp", "event_handler/src/bytrace_adapter.cpp", "event_handler/src/input_handler_manager.cpp", @@ -397,6 +413,8 @@ ohos_unittest("InputMonitorManagerTest") { configs = [ "${mmi_path}:coverage_flags", ":libmmi_test_util", + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", ] cflags = [ @@ -405,7 +423,10 @@ ohos_unittest("InputMonitorManagerTest") { ] deps = [ + "${mmi_path}/common/anco/comm:mmi_anco_channel_stub", + "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/service:libmmi-server", + "${mmi_path}/service/filter:mmi_event_filter_service", "${mmi_path}/util:libmmi-util", ] @@ -436,15 +457,10 @@ ohos_unittest("InputManagerImplTest") { ] sources = [ - "${mmi_path}/common/anco/comm/src/anco_channel.cpp", - "${mmi_path}/common/anco/comm/src/anco_channel_stub.cpp", - "${mmi_path}/frameworks/proxy/events/src/i_anco_consumer.cpp", "${mmi_path}/service/connect_manager/src/input_binder_client_server.cpp", "${mmi_path}/service/connect_manager/src/input_binder_client_stub.cpp", "${mmi_path}/service/connect_manager/src/multimodal_input_connect_death_recipient.cpp", "${mmi_path}/service/connect_manager/src/multimodal_input_connect_manager.cpp", - "${mmi_path}/service/filter/src/event_filter_service.cpp", - "${mmi_path}/service/filter/src/event_filter_stub.cpp", "event_handler/src/anr_handler.cpp", "event_handler/src/bytrace_adapter.cpp", "event_handler/src/input_handler_manager.cpp", @@ -462,6 +478,8 @@ ohos_unittest("InputManagerImplTest") { configs = [ "${mmi_path}:coverage_flags", ":libmmi_test_util", + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", ] cflags = [ @@ -470,7 +488,10 @@ ohos_unittest("InputManagerImplTest") { ] deps = [ + "${mmi_path}/common/anco/comm:mmi_anco_channel_stub", + "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/service:libmmi-server", + "${mmi_path}/service/filter:mmi_event_filter_service", "${mmi_path}/util:libmmi-util", ] @@ -524,8 +545,17 @@ ohos_unittest("InputManagerTest") { "-Dprotected=public", ] + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = true + blocklist = "./ipc_blocklist.txt" + } + deps = [ "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/util:libmmi-util", ] external_deps = [ diff --git a/frameworks/proxy/event_handler/include/input_manager_impl.h b/frameworks/proxy/event_handler/include/input_manager_impl.h index 30495e1974fb03663d3bce26bb59ce26b881b0b4..dce1367e94af62c332249c39c7838b5070b05ad7 100644 --- a/frameworks/proxy/event_handler/include/input_manager_impl.h +++ b/frameworks/proxy/event_handler/include/input_manager_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -18,7 +18,7 @@ #include "event_filter_service.h" #include "extra_data.h" -#include "i_anco_channel.h" +#include "ianco_channel.h" #include "i_anr_observer.h" #include "i_input_service_watcher.h" #include "i_window_checker.h" diff --git a/frameworks/proxy/event_handler/src/anr_handler.cpp b/frameworks/proxy/event_handler/src/anr_handler.cpp index d2698930ca67926793dc4dab1d37da6cbf9b8787..1d40e1fb850f8e97f25cb50324d3653c2001c2d1 100644 --- a/frameworks/proxy/event_handler/src/anr_handler.cpp +++ b/frameworks/proxy/event_handler/src/anr_handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -19,6 +19,7 @@ #include "bytrace_adapter.h" #include "multimodal_input_connect_manager.h" +#include "mmi_log.h" #undef MMI_LOG_DOMAIN #define MMI_LOG_DOMAIN MMI_LOG_ANRDETECT diff --git a/frameworks/proxy/event_handler/src/input_device_impl.cpp b/frameworks/proxy/event_handler/src/input_device_impl.cpp index 328f90c7b1c065c94cda2f8e3dfb90a73ee3af23..39d089cf2918eeb70aff3d07a97dac67bbee2740 100644 --- a/frameworks/proxy/event_handler/src/input_device_impl.cpp +++ b/frameworks/proxy/event_handler/src/input_device_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -17,6 +17,7 @@ #include "multimodal_input_connect_manager.h" #include "bytrace_adapter.h" +#include "mmi_log.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "InputDeviceImpl" diff --git a/frameworks/proxy/event_handler/src/input_handler_manager.cpp b/frameworks/proxy/event_handler/src/input_handler_manager.cpp index 024666d6f11b11802b155593d46ef17004396a24..c4b2ceba87a05e85f6f55c03129bc5ad6e660b4f 100644 --- a/frameworks/proxy/event_handler/src/input_handler_manager.cpp +++ b/frameworks/proxy/event_handler/src/input_handler_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -19,6 +19,8 @@ #include "bytrace_adapter.h" #include "multimodal_event_handler.h" #include "multimodal_input_connect_manager.h" +#include "mmi_log.h" +#include "error_multimodal.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "InputHandlerManager" diff --git a/frameworks/proxy/event_handler/src/input_monitor_manager.cpp b/frameworks/proxy/event_handler/src/input_monitor_manager.cpp index 753fc16fc7c9e0e7fd427be1c1a4323a2153f4f0..3c2dd375160b6e823c4cabdb14603982d9c7ca01 100644 --- a/frameworks/proxy/event_handler/src/input_monitor_manager.cpp +++ b/frameworks/proxy/event_handler/src/input_monitor_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -16,6 +16,7 @@ #include "input_monitor_manager.h" #include "multimodal_input_connect_manager.h" +#include "mmi_log.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "InputMonitorManager" diff --git a/frameworks/proxy/event_handler/src/pre_monitor_manager.cpp b/frameworks/proxy/event_handler/src/pre_monitor_manager.cpp index 2376cd5abe1eb6cdeeb588c8d4cc63b9135c8527..0a2d54df272a505c75fdb6a3b399b9225f7fa692 100644 --- a/frameworks/proxy/event_handler/src/pre_monitor_manager.cpp +++ b/frameworks/proxy/event_handler/src/pre_monitor_manager.cpp @@ -18,6 +18,7 @@ #include "bytrace_adapter.h" #include "multimodal_event_handler.h" #include "multimodal_input_connect_manager.h" +#include "mmi_log.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "PreMonitorManager" diff --git a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp index 4129b7d32691b34464dcac7cc1787e2db9eae147..0bd531a4d6f6e7e8d53cea0f785f25794a112925 100644 --- a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp +++ b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp @@ -219,7 +219,7 @@ HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetCustomCursor_01, TestSize int32_t focusY = 4; void* pixelMap = nullptr; int32_t winPid = InputMgrImpl.GetWindowPid(windowId); - EXPECT_FALSE(winPid == -1); + EXPECT_TRUE(winPid == -1); int32_t ret = InputMgrImpl.SetCustomCursor(windowId, focusX, focusY, pixelMap); EXPECT_NE(ret, RET_OK); } @@ -238,7 +238,7 @@ HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetMouseHotSpot_01, TestSize int32_t hotSpotY = 4; int32_t winPid = InputMgrImpl.GetWindowPid(windowId); - EXPECT_TRUE(winPid != -1); + EXPECT_TRUE(winPid == -1); int32_t ret = InputMgrImpl.SetMouseHotSpot(windowId, hotSpotX, hotSpotY); EXPECT_EQ(ret, RET_ERR); } @@ -680,10 +680,9 @@ HWTEST_F(InputManagerImplTest, InputManagerImplTest_Authorize_001, TestSize.Leve HWTEST_F(InputManagerImplTest, InputManagerImplTest_SubscribeLongPressEvent, TestSize.Level1) { CALL_TEST_DEBUG; - LongPressRequest longPR = { - .fingerCount = 3, - .duration = 2, - }; + LongPressRequest longPR; + longPR.fingerCount = 3; + longPR.duration = 2; int32_t ret = InputMgrImpl.SubscribeLongPressEvent(longPR, nullptr); ASSERT_EQ(ret, RET_ERR); } diff --git a/frameworks/proxy/event_handler/test/switch_event_input_subscribe_manager_test.cpp b/frameworks/proxy/event_handler/test/switch_event_input_subscribe_manager_test.cpp index 7550a355afa6b457ec922a2a796b7b979e8f13c1..3f44e740ed810312c4f55066d1b621a6828e34d5 100644 --- a/frameworks/proxy/event_handler/test/switch_event_input_subscribe_manager_test.cpp +++ b/frameworks/proxy/event_handler/test/switch_event_input_subscribe_manager_test.cpp @@ -41,13 +41,15 @@ public: class MyEventFilter : public IRemoteStub { public: - bool HandleKeyEvent(const std::shared_ptr event) override + ErrCode HandleKeyEvent(const std::shared_ptr& event, bool &resultValue) override { - return true; + resultValue = true; + return ERR_OK; } - bool HandlePointerEvent(const std::shared_ptr event) override + ErrCode HandlePointerEvent(const std::shared_ptr& event, bool &resultValue) override { - return true; + resultValue = true; + return ERR_OK; } }; diff --git a/frameworks/proxy/events/src/i_anco_consumer.cpp b/frameworks/proxy/events/src/i_anco_consumer.cpp index 6ab53a27a491d9844e94635c5fa6baa169c8bc6e..6807c7367d70fb7ab9b6605ed087760b6fbe3c4f 100644 --- a/frameworks/proxy/events/src/i_anco_consumer.cpp +++ b/frameworks/proxy/events/src/i_anco_consumer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -121,38 +121,53 @@ static bool UnmarshalWindowInfo(Parcel &parcel, AncoWindowInfo &windowInfo) return result; } -bool AncoWindows::Marshalling(const AncoWindows &windows, Parcel &parcel) +bool AncoWindows::Marshalling(Parcel &out) const { return ( - parcel.WriteUint32(static_cast(windows.updateType)) && - parcel.WriteInt32(windows.focusWindowId) && - MarshalVector(windows.windows, parcel, &MarshalWindowInfo) + out.WriteUint32(static_cast(updateType)) && + out.WriteInt32(focusWindowId) && + MarshalVector(windows, out, &MarshalWindowInfo) ); } -bool AncoWindows::Unmarshalling(Parcel &parcel, AncoWindows &windows) +bool AncoWindows::ReadFromParcel(Parcel &in) { - uint32_t updateType {}; + uint32_t updateTypeData = 0; + updateTypeData = in.ReadUint32(); + updateType = static_cast(updateTypeData); + focusWindowId = in.ReadInt32(focusWindowId); + return UnmarshalVector(in, windows, &UnmarshalWindowInfo); +} - bool result = ( - parcel.ReadUint32(updateType) && - parcel.ReadInt32(windows.focusWindowId) && - UnmarshalVector(parcel, windows.windows, &UnmarshalWindowInfo) - ); - windows.updateType = static_cast(updateType); - return result; +AncoWindows *AncoWindows::Unmarshalling(Parcel &in) +{ + AncoWindows *data = new (std::nothrow) AncoWindows(); + if (data && !data->ReadFromParcel(in)) { + delete data; + data = nullptr; + } + return data; +} +bool AncoOneHandData::Marshalling(Parcel &parcel) const +{ + return (parcel.WriteInt32(oneHandX) && parcel.WriteInt32(oneHandY) && + parcel.WriteInt32(expandHeight) && parcel.WriteInt32(scalePercent)); } -bool AncoOneHandData::Marshalling(const AncoOneHandData &oneHandData, Parcel &parcel) +bool AncoOneHandData::ReadFromParcel(Parcel &parcel) { - return (parcel.WriteInt32(oneHandData.oneHandX) && parcel.WriteInt32(oneHandData.oneHandY) && - parcel.WriteInt32(oneHandData.expandHeight) && parcel.WriteInt32(oneHandData.scalePercent)); + return (parcel.ReadInt32(oneHandX) && parcel.ReadInt32(oneHandY) && + parcel.ReadInt32(expandHeight) && parcel.ReadInt32(scalePercent)); } -bool AncoOneHandData::Unmarshalling(Parcel &parcel, AncoOneHandData &oneHandData) +AncoOneHandData *AncoOneHandData::Unmarshalling(Parcel &parcel) { - return (parcel.ReadInt32(oneHandData.oneHandX) && parcel.ReadInt32(oneHandData.oneHandY) && - parcel.ReadInt32(oneHandData.expandHeight) && parcel.ReadInt32(oneHandData.scalePercent)); + AncoOneHandData *data = new (std::nothrow) AncoOneHandData(); + if (data && !data->ReadFromParcel(parcel)) { + delete data; + data = nullptr; + } + return data; } } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/frameworks/proxy/events/src/input_event.cpp b/frameworks/proxy/events/src/input_event.cpp index 79e0705e961ebaaf5d1752b6d803425f6d1d29f4..452f6c62de9962de3947c1e4fa65a03fcb1aa7dd 100644 --- a/frameworks/proxy/events/src/input_event.cpp +++ b/frameworks/proxy/events/src/input_event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -345,6 +345,11 @@ bool InputEvent::WriteToParcel(Parcel &out) const return true; } +bool InputEvent::Marshalling(Parcel &out) const +{ + return WriteToParcel(out); +} + bool InputEvent::ReadFromParcel(Parcel &in) { #if defined(ANDROID_PLATFORM) || defined(IOS_PLATFORM) @@ -384,6 +389,16 @@ bool InputEvent::ReadFromParcel(Parcel &in) #endif // defined(ANDROID_PLATFORM) || defined(IOS_PLATFORM) } +InputEvent *InputEvent::Unmarshalling(Parcel &parcel) +{ + InputEvent *data = new (std::nothrow) InputEvent(InputEvent::EVENT_TYPE_BASE); + if (data && !data->ReadFromParcel(parcel)) { + delete data; + data = nullptr; + } + return data; +} + std::string_view InputEvent::ActionToShortStr(int32_t action) { switch (action) { diff --git a/frameworks/proxy/events/src/key_event.cpp b/frameworks/proxy/events/src/key_event.cpp index fbc8c623bf1cc6102b778519f5b10d71c6959258..fc06098c749f62d3abcfe45100521f40f40c86a3 100644 --- a/frameworks/proxy/events/src/key_event.cpp +++ b/frameworks/proxy/events/src/key_event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -1275,6 +1275,11 @@ bool KeyEvent::WriteToParcel(Parcel &out) const return true; } +bool KeyEvent::Marshalling(Parcel &out) const +{ + return WriteToParcel(out); +} + bool KeyEvent::ReadFromParcel(Parcel &in) { if (!InputEvent::ReadFromParcel(in)) { @@ -1306,6 +1311,16 @@ bool KeyEvent::ReadFromParcel(Parcel &in) return true; } +KeyEvent *KeyEvent::Unmarshalling(Parcel &parcel) +{ + KeyEvent *data = new (std::nothrow) KeyEvent(InputEvent::EVENT_TYPE_KEY); + if (data && !data->ReadFromParcel(parcel)) { + delete data; + data = nullptr; + } + return data; +} + #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT bool KeyEvent::ReadEnhanceDataFromParcel(Parcel &in) { diff --git a/frameworks/proxy/events/src/key_option.cpp b/frameworks/proxy/events/src/key_option.cpp index e2084aafe7c7adbe36c5fbc42819a1a774d60c26..1e65d45808fbc9b42ea4b238c1d4ba921a2ce12f 100644 --- a/frameworks/proxy/events/src/key_option.cpp +++ b/frameworks/proxy/events/src/key_option.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -172,21 +172,5 @@ void KeyMonitorOption::SetRepeat(bool repeat) { isRepeat_ = repeat; } - -bool KeyMonitorOption::Marshalling(Parcel &parcel) const -{ - return (parcel.WriteInt32(key_) && - parcel.WriteInt32(action_) && - parcel.WriteBool(isRepeat_)); -} - -bool KeyMonitorOption::Unmarshalling(Parcel &parcel) -{ - return ( - parcel.ReadInt32(key_) && - parcel.ReadInt32(action_) && - parcel.ReadBool(isRepeat_) - ); -} } // namespace MMI } // namespace OHOS diff --git a/frameworks/proxy/events/src/pointer_event.cpp b/frameworks/proxy/events/src/pointer_event.cpp index d07e470778b9beb975bbf70557b4f157717de8aa..fc730807784c6772dd3a15f2ad5b0aae87cf342f 100644 --- a/frameworks/proxy/events/src/pointer_event.cpp +++ b/frameworks/proxy/events/src/pointer_event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -1041,6 +1041,11 @@ bool PointerEvent::WriteToParcel(Parcel &out) const return true; } +bool PointerEvent::Marshalling(Parcel &out) const +{ + return WriteToParcel(out); +} + bool PointerEvent::ReadFromParcel(Parcel &in) { if (!InputEvent::ReadFromParcel(in)) { @@ -1125,6 +1130,16 @@ bool PointerEvent::ReadFromParcel(Parcel &in) return true; } +PointerEvent *PointerEvent::Unmarshalling(Parcel &parcel) +{ + PointerEvent *data = new (std::nothrow) PointerEvent(InputEvent::EVENT_TYPE_POINTER); + if (data && !data->ReadFromParcel(parcel)) { + delete data; + data = nullptr; + } + return data; +} + bool PointerEvent::ReadFixedModeFromParcel(Parcel &in) { int32_t value = 0; diff --git a/frameworks/proxy/events/src/pointer_style.cpp b/frameworks/proxy/events/src/pointer_style.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a5bd7ff6117809ae15f5cffb9db810ff0d19e44b --- /dev/null +++ b/frameworks/proxy/events/src/pointer_style.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2025 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 "pointer_style.h" + +#include "pixel_map.h" + +namespace OHOS { +namespace MMI { +CustomCursorParcel::CustomCursorParcel(void* pixelMap, int32_t focusX, int32_t focusY) + : Parcelable(), pixelMap(pixelMap), focusX(focusX), focusY(focusY) {} + +bool CustomCursorParcel::Marshalling(Parcel &out) const +{ + if (pixelMap == nullptr) { + return false; + } + OHOS::Media::PixelMap* pixelMapPtr = static_cast(pixelMap); + if (pixelMapPtr->GetCapacity() == 0) { + return false; + } + + if (!pixelMapPtr->Marshalling(out)) { + return false; + } + if (!out.WriteInt32(focusX)) { + return false; + } + if (!out.WriteInt32(focusY)) { + return false; + } + return true; +} + +bool CustomCursorParcel::ReadFromParcel(Parcel &in) +{ + OHOS::Media::PixelMap* pixelMapPtr = Media::PixelMap::Unmarshalling(in); + if (pixelMapPtr == nullptr) { + return false; + } + pixelMap = (void *)pixelMapPtr; + focusX = in.ReadInt32(); + focusY = in.ReadInt32(); + return true; +} + +CustomCursorParcel *CustomCursorParcel::Unmarshalling(Parcel &in) +{ + CustomCursorParcel *data = new (std::nothrow) CustomCursorParcel(); + if (data && !data->ReadFromParcel(in)) { + delete data; + data = nullptr; + } + return data; +} + +bool CursorOptionsParcel::Marshalling(Parcel &out) const +{ + if (!out.WriteBool(followSystem)) { + return false; + } + return true; +} + +bool CursorOptionsParcel::ReadFromParcel(Parcel &in) +{ + if (!in.ReadBool(followSystem)) { + return false; + } + return true; +} + +CursorOptionsParcel *CursorOptionsParcel::Unmarshalling(Parcel &in) +{ + CursorOptionsParcel *data = new (std::nothrow) CursorOptionsParcel(); + if (data && !data->ReadFromParcel(in)) { + delete data; + data = nullptr; + } + return data; +} + +bool CursorPixelMap::Marshalling(Parcel &out) const +{ + if (pixelMap == nullptr) { + return false; + } + OHOS::Media::PixelMap* pixelMapPtr = static_cast(pixelMap); + if (pixelMapPtr->GetCapacity() == 0) { + return false; + } + + if (!pixelMapPtr->Marshalling(out)) { + return false; + } + return true; +} + +bool CursorPixelMap::ReadFromParcel(Parcel &in) +{ + OHOS::Media::PixelMap* pixelMapPtr = Media::PixelMap::Unmarshalling(in); + if (pixelMapPtr == nullptr) { + return false; + } + pixelMap = (void *)pixelMapPtr; + return true; +} + +CursorPixelMap *CursorPixelMap::Unmarshalling(Parcel &in) +{ + CursorPixelMap *data = new (std::nothrow) CursorPixelMap(); + if (data && !data->ReadFromParcel(in)) { + delete data; + data = nullptr; + } + return data; +} +} // namespace MMI +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/proxy/events/test/input_manager_test.cpp b/frameworks/proxy/events/test/input_manager_test.cpp index a9aba5fd4d8522b200fad9708c180e88aa3ce6aa..c0945ee50f6747035537e45dcb84a870005bafcd 100644 --- a/frameworks/proxy/events/test/input_manager_test.cpp +++ b/frameworks/proxy/events/test/input_manager_test.cpp @@ -1819,7 +1819,7 @@ HWTEST_F(InputManagerTest, InputManagerTest_SetDisplayBind_001, TestSize.Level1) int32_t displayId = INVAID_VALUE; std::string msg; int32_t ret = InputManager::GetInstance()->SetDisplayBind(deviceId, displayId, msg); - ASSERT_TRUE(ret == RET_OK); + ASSERT_TRUE(ret != RET_OK); if (ret != RET_OK) { MMI_HILOGE("Call SetDisplayBind failed, ret:%{public}d", ret); } @@ -4627,10 +4627,10 @@ HWTEST_F(InputManagerTest, InputManagerTest_SkipPointerLayer_001, TestSize.Level CALL_TEST_DEBUG; bool isSkip = true; int32_t ret = InputManager::GetInstance()->SkipPointerLayer(isSkip); - EXPECT_EQ(ret, 305); + EXPECT_EQ(ret, RET_OK); isSkip = false; ret = InputManager::GetInstance()->SkipPointerLayer(isSkip); - EXPECT_EQ(ret, 305); + EXPECT_EQ(ret, RET_OK); } /** @@ -4914,10 +4914,9 @@ HWTEST_F(InputManagerTest, InputManagerTest_ShiftAppPointerEvent_001, TestSize.L CALL_TEST_DEBUG; int32_t sourceWindowId = 99; int32_t targetWindowId = 99; - ShiftWindowParam param { - .sourceWindowId = sourceWindowId, - .targetWindowId = targetWindowId, - }; + ShiftWindowParam param; + param.sourceWindowId = sourceWindowId; + param.targetWindowId = targetWindowId; bool autoGenDown = true; int32_t ret = InputManager::GetInstance()->ShiftAppPointerEvent(param, autoGenDown); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) @@ -4938,10 +4937,9 @@ HWTEST_F(InputManagerTest, InputManagerTest_ShiftAppPointerEvent_002, TestSize.L CALL_TEST_DEBUG; int32_t sourceWindowId = -150; int32_t targetWindowId = -99; - ShiftWindowParam param { - .sourceWindowId = sourceWindowId, - .targetWindowId = targetWindowId, - }; + ShiftWindowParam param; + param.sourceWindowId = sourceWindowId; + param.targetWindowId = targetWindowId; bool autoGenDown = true; int32_t ret = InputManager::GetInstance()->ShiftAppPointerEvent(param, autoGenDown); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) diff --git a/frameworks/proxy/ipc_blocklist.txt b/frameworks/proxy/ipc_blocklist.txt new file mode 100644 index 0000000000000000000000000000000000000000..e98f5cbbdc479a1af2a94440932b10b1d7379317 --- /dev/null +++ b/frameworks/proxy/ipc_blocklist.txt @@ -0,0 +1,21 @@ +# 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. + +[cfi] +src:*third_party/googletest/googletest/include/* +src:*switch_event_input_subscribe_manager_test.cpp +src:*foundation/multimodalinput/input/test/unittest/common/src/* +src:*foundation/multimodalinput/input/frameworks/proxy/events/test/input_manager_simulate_test.cpp +src:*foundation/multimodalinput/input/frameworks/proxy/events/test/input_manager_test.cpp +src:*foundation/multimodalinput/input/frameworks/proxy/events/test/input_manager_update_display_info_test.cpp +src:*foundation/multimodalinput/input/frameworks/proxy/events/test/virtual_input_device_test.cpp \ No newline at end of file diff --git a/frameworks/proxy/module_loader/src/mmi_client.cpp b/frameworks/proxy/module_loader/src/mmi_client.cpp index 2ec5a800d177bd704fa533e96578ec862eff81de..9ec6ba0782049cce00941d86a03dae465cfaab2c 100644 --- a/frameworks/proxy/module_loader/src/mmi_client.cpp +++ b/frameworks/proxy/module_loader/src/mmi_client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -278,13 +278,13 @@ int32_t MMIClient::Socket() { CALL_DEBUG_ENTER; int32_t ret = - MULTIMODAL_INPUT_CONNECT_MGR->AllocSocketPair(IMultimodalInputConnect::CONNECT_MODULE_TYPE_MMI_CLIENT); + MULTIMODAL_INPUT_CONNECT_MGR->AllocSocketPair(MultimodalInputConnectManager::CONNECT_MODULE_TYPE_MMI_CLIENT); if (ret != RET_OK) { MMI_HILOGE("Call AllocSocketPair return %{public}d", ret); - return IMultimodalInputConnect::INVALID_SOCKET_FD; + return MultimodalInputConnectManager::INVALID_SOCKET_FD; } fd_ = MULTIMODAL_INPUT_CONNECT_MGR->GetClientSocketFdOfAllocedSocketPair(); - if (fd_ == IMultimodalInputConnect::INVALID_SOCKET_FD) { + if (fd_ == MultimodalInputConnectManager::INVALID_SOCKET_FD) { MMI_HILOGE("Call GetClientSocketFdOfAllocedSocketPair return invalid fd"); } else { MMI_HILOGD("Call GetClientSocketFdOfAllocedSocketPair return fd:%{public}d", fd_); diff --git a/intention/cooperate/plugin/BUILD.gn b/intention/cooperate/plugin/BUILD.gn index 6b915536bb60922e693e574d5d6aaed2d95c4e44..f5b68efa5cb1d3725eb2bc957fb924deaba8fa0b 100644 --- a/intention/cooperate/plugin/BUILD.gn +++ b/intention/cooperate/plugin/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 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 @@ -68,6 +68,7 @@ ohos_shared_library("intention_cooperate") { ] external_deps = [ + "c_utils:utils", "hilog:libhilog", "samgr:samgr_proxy", ] diff --git a/multimodalinput_mini.gni b/multimodalinput_mini.gni index 1ceb68d3f1026d36e52dc4e2324f1035f718e2ab..ad029787f73a4e1bdbc291fe50416c28663a7112 100644 --- a/multimodalinput_mini.gni +++ b/multimodalinput_mini.gni @@ -90,6 +90,7 @@ declare_args() { "events/src/key_event.cpp", "events/src/key_option.cpp", "events/src/pointer_event.cpp", + "events/src/pointer_style.cpp", ] libmmi_client_sources = [ diff --git a/service/filter/BUILD.gn b/service/filter/BUILD.gn index efd49cf78e57177053b47d1f72ea6c86eb0921bd..838e19b6bacc926ecdf2597eed62688395a5d6c2 100644 --- a/service/filter/BUILD.gn +++ b/service/filter/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -11,10 +11,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("../../multimodalinput_mini.gni") event_filter_path = "${mmi_path}/service/filter" +idl_gen_interface("event_filter_interface") { + src_idl = rebase_path("IEventFilter.idl") +} + config("mmi_event_filter_config") { include_dirs = [ "${mmi_path}/interfaces/native/innerkits/common/include", @@ -28,6 +33,7 @@ config("mmi_event_filter_config") { "${mmi_path}/util/network/include", "${mmi_path}/util/socket/include", "${event_filter_path}/include", + "${target_gen_dir}", ] } @@ -40,10 +46,11 @@ ohos_source_set("mmi_event_filter_service") { cfi_cross_dso = true debug = false } - sources = [ - "${event_filter_path}/src/event_filter_service.cpp", - "${event_filter_path}/src/event_filter_stub.cpp", - ] + sources = [ "${event_filter_path}/src/event_filter_service.cpp" ] + + output_values = get_target_outputs(":event_filter_interface") + sources += filter_include(output_values, [ "*_stub.cpp" ]) + deps = [ ":event_filter_interface" ] configs = [ ":mmi_event_filter_config" ] @@ -67,9 +74,12 @@ ohos_source_set("mmi_event_filter_proxy") { sources = [ "${event_filter_path}/src/event_filter_death_recipient.cpp", "${event_filter_path}/src/event_filter_handler.cpp", - "${event_filter_path}/src/event_filter_proxy.cpp", ] + output_values = get_target_outputs(":event_filter_interface") + sources += filter_include(output_values, [ "*_proxy.cpp" ]) + deps = [ ":event_filter_interface" ] + configs = [ ":mmi_event_filter_config" ] defines = input_default_defines diff --git a/service/filter/include/i_event_filter.h b/service/filter/IEventFilter.idl similarity index 45% rename from service/filter/include/i_event_filter.h rename to service/filter/IEventFilter.idl index 88d474a454a421122ae92556f00bc7b5a231984c..ad6f5b00cd17c552998279709799425c444c8301 100644 --- a/service/filter/include/i_event_filter.h +++ b/service/filter/IEventFilter.idl @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 + * 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, @@ -13,22 +13,9 @@ * limitations under the License. */ -#ifndef I_EVENT_FILTER_H -#define I_EVENT_FILTER_H - -#include "iremote_broker.h" - -#include "key_event.h" -#include "pointer_event.h" - -namespace OHOS { -namespace MMI { -class IEventFilter : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.multimodalinput.IEventFilter"); - virtual bool HandleKeyEvent(const std::shared_ptr event) = 0; - virtual bool HandlePointerEvent(const std::shared_ptr event) = 0; -}; -} // namespace MMI -} // namespace OHOS -#endif // I_EVENT_FILTER_H \ No newline at end of file +sequenceable key_event..OHOS.MMI.KeyEvent; +sequenceable pointer_event..OHOS.MMI.PointerEvent; +interface OHOS.MMI.IEventFilter { + void HandleKeyEvent([in] sharedptr event, [out] boolean resultValue); + void HandlePointerEvent([in] sharedptr event, [out] boolean resultValue); +} \ No newline at end of file diff --git a/service/filter/include/event_filter_handler.h b/service/filter/include/event_filter_handler.h index c1461635400921a7de473edfebd4c15f15b89f70..7b18217ca2b0591988cb8afbd73cb101de60cb9f 100644 --- a/service/filter/include/event_filter_handler.h +++ b/service/filter/include/event_filter_handler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -17,7 +17,7 @@ #define EVENT_FILTER_HANDLER_H #include "event_filter_death_recipient.h" -#include "i_event_filter.h" +#include "ievent_filter.h" #include "i_input_event_handler.h" namespace OHOS { diff --git a/service/filter/include/event_filter_service.h b/service/filter/include/event_filter_service.h index 7233979fb7ee9fc8ee4f280d9e24975dc65d5faa..215da8931686fb0bd0c7100520f6006eb8d5770f 100644 --- a/service/filter/include/event_filter_service.h +++ b/service/filter/include/event_filter_service.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -28,8 +28,8 @@ public: EventFilterService(std::shared_ptr filter) : filter_(filter) {} DISALLOW_COPY_AND_MOVE(EventFilterService); ~EventFilterService() override = default; - bool HandleKeyEvent(const std::shared_ptr event) override; - bool HandlePointerEvent(const std::shared_ptr event) override; + ErrCode HandleKeyEvent(const std::shared_ptr& event, bool &resultValue) override; + ErrCode HandlePointerEvent(const std::shared_ptr& event, bool &resultValue) override; private: const std::shared_ptr filter_; static inline int32_t filterIdSeed_ { 0 }; diff --git a/service/filter/include/event_filter_stub.h b/service/filter/include/event_filter_stub.h deleted file mode 100644 index b379916745ac01263f6cb9a60efe59505ea57093..0000000000000000000000000000000000000000 --- a/service/filter/include/event_filter_stub.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021-2022 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 EVENT_FILTER_STUB_H -#define EVENT_FILTER_STUB_H - -#include "iremote_stub.h" - -#include "i_event_filter.h" - -namespace OHOS { -namespace MMI { -class EventFilterStub : public IRemoteStub { -public: - EventFilterStub() = default; - DISALLOW_COPY_AND_MOVE(EventFilterStub); - virtual ~EventFilterStub() = default; - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& options) override; -protected: - int32_t StubHandleKeyEvent(MessageParcel& data, MessageParcel& reply); - int32_t StubHandlePointerEvent(MessageParcel& data, MessageParcel& reply); -}; -} // namespace MMI -} // namespace OHOS -#endif // EVENT_FILTER_STUB_H \ No newline at end of file diff --git a/service/filter/src/event_filter_handler.cpp b/service/filter/src/event_filter_handler.cpp index baf256624a2790164725d4e69a00210bb63e0ff8..3e71051e1306765c192e2bf07ceb8bb060f15242 100644 --- a/service/filter/src/event_filter_handler.cpp +++ b/service/filter/src/event_filter_handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -175,7 +175,9 @@ bool EventFilterHandler::HandleKeyEventFilter(std::shared_ptr event) if (!inputDevice->HasCapability(i.deviceTags)) { continue; } - if (i.filter->HandleKeyEvent(event)) { + bool resultValue = false; + i.filter->HandleKeyEvent(event, resultValue); + if (resultValue) { MMI_HILOGD("Call HandleKeyEventFilter return true"); return true; } @@ -199,7 +201,9 @@ bool EventFilterHandler::HandlePointerEventFilter(std::shared_ptr if (inputDevice == nullptr && !CheckCapability(i.deviceTags, event)) { continue; } - if (i.filter->HandlePointerEvent(event)) { + bool resultValue = false; + i.filter->HandlePointerEvent(event, resultValue); + if (resultValue) { int32_t action = event->GetPointerAction(); if (action == PointerEvent::POINTER_ACTION_MOVE || action == PointerEvent::POINTER_ACTION_AXIS_UPDATE || diff --git a/service/filter/src/event_filter_proxy.cpp b/service/filter/src/event_filter_proxy.cpp deleted file mode 100644 index 4ff7d8df42d97134404157ace1d5ded7613b0448..0000000000000000000000000000000000000000 --- a/service/filter/src/event_filter_proxy.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2021-2022 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_proxy.h" - -#include "mmi_log.h" -#include "multimodalinput_ipc_interface_code.h" - -#undef MMI_LOG_DOMAIN -#define MMI_LOG_DOMAIN MMI_LOG_HANDLER -#undef MMI_LOG_TAG -#define MMI_LOG_TAG "EventFilterProxy" - -namespace OHOS { -namespace MMI { -EventFilterProxy::EventFilterProxy(const sptr &impl) : IRemoteProxy(impl) -{ - MMI_HILOGI("EventFilterProxy()"); -} - -bool EventFilterProxy::HandleKeyEvent(const std::shared_ptr event) -{ - CALL_DEBUG_ENTER; - CHKPF(event); - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(EventFilterProxy::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return false; - } - - if (!event->WriteToParcel(data)) { - MMI_HILOGE("Failed to write event to req"); - return false; - } - - sptr remote = Remote(); - CHKPF(remote); - const uint32_t code = static_cast(MultimodalinputEventInterfaceCode::HANDLE_KEY_EVENT); - int32_t ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - MMI_HILOGE("Send request failed, ret:%{public}d", ret); - return false; - } - - bool result = false; - READBOOL(reply, result); - return result; -} - -bool EventFilterProxy::HandlePointerEvent(const std::shared_ptr event) -{ - CALL_DEBUG_ENTER; - CHKPF(event); - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(EventFilterProxy::GetDescriptor())) { - MMI_HILOGE("Failed to write descriptor"); - return false; - } - - if (!event->WriteToParcel(data)) { - MMI_HILOGE("Failed to write event to req"); - return false; - } - - sptr remote = Remote(); - CHKPF(remote); - const uint32_t code = static_cast(MultimodalinputEventInterfaceCode::HANDLE_POINTER_EVENT); - int32_t ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - MMI_HILOGE("Send request failed, ret:%{public}d", ret); - return false; - } - - bool result = false; - READBOOL(reply, result); - return result; -} -} // namespace MMI -} // namespace OHOS diff --git a/service/filter/src/event_filter_service.cpp b/service/filter/src/event_filter_service.cpp index a7fa7f83b94afd4c5a99fff6c9d3290520a5678c..863369d28caed268380c0b4cc650de8f95aa255e 100644 --- a/service/filter/src/event_filter_service.cpp +++ b/service/filter/src/event_filter_service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -33,16 +33,18 @@ int32_t EventFilterService::GetNextId() return filterIdSeed_++; } -bool EventFilterService::HandleKeyEvent(const std::shared_ptr event) +ErrCode EventFilterService::HandleKeyEvent(const std::shared_ptr& event, bool &resultValue) { CHKPF(filter_); - return filter_->OnInputEvent(event); + resultValue = filter_->OnInputEvent(event); + return ERR_OK; } -bool EventFilterService::HandlePointerEvent(const std::shared_ptr event) +ErrCode EventFilterService::HandlePointerEvent(const std::shared_ptr& event, bool &resultValue) { CHKPF(filter_); - return filter_->OnInputEvent(event); + resultValue = filter_->OnInputEvent(event); + return ERR_OK; } } // namespace MMI } // namespace OHOS diff --git a/service/filter/src/event_filter_stub.cpp b/service/filter/src/event_filter_stub.cpp deleted file mode 100644 index bb80468275d0312a2d7a95841170b5b0ac89bb6c..0000000000000000000000000000000000000000 --- a/service/filter/src/event_filter_stub.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2021-2022 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_stub.h" - -#include "string_ex.h" - -#include "mmi_log.h" -#include "multimodalinput_ipc_interface_code.h" - -#undef MMI_LOG_DOMAIN -#define MMI_LOG_DOMAIN MMI_LOG_HANDLER -#undef MMI_LOG_TAG -#define MMI_LOG_TAG "EventFilterStub" - -namespace OHOS { -namespace MMI { -int32_t EventFilterStub::OnRemoteRequest( - uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -{ - CALL_DEBUG_ENTER; - MMI_HILOGD("code:%{public}u", code); - - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IEventFilter::GetDescriptor()) { - MMI_HILOGE("Get unexpect descriptor:%{public}s", Str16ToStr8(descriptor).c_str()); - return ERR_INVALID_STATE; - } - - switch (code) { - case static_cast(MultimodalinputEventInterfaceCode::HANDLE_KEY_EVENT): { - return StubHandleKeyEvent(data, reply); - } - case static_cast(MultimodalinputEventInterfaceCode::HANDLE_POINTER_EVENT): { - return StubHandlePointerEvent(data, reply); - } - default: { - MMI_HILOGE("Unknown code:%{public}u, go switch default", code); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - } -} - -int32_t EventFilterStub::StubHandleKeyEvent(MessageParcel& data, MessageParcel& reply) -{ - CALL_DEBUG_ENTER; - std::shared_ptr event = KeyEvent::Create(); - CHKPR(event, RET_ERR); - - if (!event->ReadFromParcel(data)) { - MMI_HILOGE("Read data error"); - return RET_ERR; - } - - bool ret = HandleKeyEvent(event); - WRITEBOOL(reply, ret, RET_ERR); - return RET_OK; -} - -int32_t EventFilterStub::StubHandlePointerEvent(MessageParcel& data, MessageParcel& reply) -{ - CALL_DEBUG_ENTER; - std::shared_ptr event = PointerEvent::Create(); - CHKPR(event, RET_ERR); - - if (!event->ReadFromParcel(data)) { - MMI_HILOGE("Read data error"); - return RET_ERR; - } - - bool ret = HandlePointerEvent(event); - WRITEBOOL(reply, ret, RET_ERR); - return RET_OK; -} -} // namespace MMI -} // namespace OHOS \ No newline at end of file diff --git a/service/filter/test/event_filter_handler_ex_test.cpp b/service/filter/test/event_filter_handler_ex_test.cpp index af150e2b2a17bc5e00549b2e1e2a546a4b0346e8..9daa5b8ef57dd8e2fe6cb78f70a91059a22c33d4 100644 --- a/service/filter/test/event_filter_handler_ex_test.cpp +++ b/service/filter/test/event_filter_handler_ex_test.cpp @@ -55,13 +55,15 @@ void EventFilterHandlerExTest::TearDownTestCase() class MyEventFilter : public IRemoteStub { public: - bool HandleKeyEvent(const std::shared_ptr event) override + ErrCode HandleKeyEvent(const std::shared_ptr& event, bool &resultValue) override { - return true; + resultValue = true; + return ERR_OK; } - bool HandlePointerEvent(const std::shared_ptr event) override + ErrCode HandlePointerEvent(const std::shared_ptr& event, bool &resultValue) override { - return true; + resultValue = true; + return ERR_OK; } }; diff --git a/service/filter/test/event_filter_handler_test.cpp b/service/filter/test/event_filter_handler_test.cpp index fce19b9f367a8633114ca4be8bd6440d77f7bf4c..94280f30292c3b3bd84f5ee9c49173f1d414ddd6 100644 --- a/service/filter/test/event_filter_handler_test.cpp +++ b/service/filter/test/event_filter_handler_test.cpp @@ -42,13 +42,15 @@ public: class MyEventFilter : public IRemoteStub { public: - bool HandleKeyEvent(const std::shared_ptr event) override + ErrCode HandleKeyEvent(const std::shared_ptr& event, bool &resultValue) override { - return true; + resultValue = true; + return ERR_OK; } - bool HandlePointerEvent(const std::shared_ptr event) override + ErrCode HandlePointerEvent(const std::shared_ptr& event, bool &resultValue) override { - return true; + resultValue = true; + return ERR_OK; } };