From 3448b15568b51d599a6ea5f671cea692301d0d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cry521=E2=80=9D?= Date: Tue, 17 Oct 2023 15:13:30 +0800 Subject: [PATCH 01/42] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “ry521” --- common/include/dinput_errcode.h | 5 ++ common/include/dinput_ipc_interface_code.h | 2 + .../include/i_distributed_source_input.h | 3 + frameworks/include/i_inject_event_callback.h | 40 ++++++++++++ interfaces/inner_kits/BUILD.gn | 2 + .../include/distributed_input_kit.h | 4 ++ .../inner_kits/src/distributed_input_kit.cpp | 8 +++ .../ipc/include/distributed_input_client.h | 3 + .../include/distributed_input_source_proxy.h | 3 + .../include/distributed_input_source_stub.h | 2 + .../register_inject_event_callback_proxy.h | 42 +++++++++++++ .../register_inject_event_callback_stub.h | 42 +++++++++++++ .../ipc/src/distributed_input_client.cpp | 22 +++++++ .../src/distributed_input_source_proxy.cpp | 41 ++++++++++++ .../ipc/src/distributed_input_source_stub.cpp | 39 ++++++++++++ .../register_inject_event_callback_proxy.cpp | 63 +++++++++++++++++++ .../register_inject_event_callback_stub.cpp | 57 +++++++++++++++++ .../inputinject/include/virtual_device.h | 5 ++ .../source/inputinject/src/virtual_device.cpp | 24 +++++++ services/source/sourcemanager/BUILD.gn | 2 + .../distributed_input_source_manager.h | 3 + .../src/distributed_input_source_manager.cpp | 16 +++++ 22 files changed, 428 insertions(+) create mode 100644 frameworks/include/i_inject_event_callback.h create mode 100644 interfaces/ipc/include/register_inject_event_callback_proxy.h create mode 100644 interfaces/ipc/include/register_inject_event_callback_stub.h create mode 100644 interfaces/ipc/src/register_inject_event_callback_proxy.cpp create mode 100644 interfaces/ipc/src/register_inject_event_callback_stub.cpp diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index 8d545bd..7e0b31d 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -110,6 +110,7 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_MANAGER_DH_FWK_KIT_IS_NULL = -65038; constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_MANAGER_NODE_LISTENER_CALLBACK_ERR = -65039; constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_MANAGER_SESSION_STATE_CB_IS_NULL = -65040; + constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INJECT_EVENT_CB_IS_NULL = -65041; // handler error code constexpr int32_t ERR_DH_INPUT_SINK_HANDLER_INIT_SINK_SA_FAIL = -66000; @@ -177,6 +178,10 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_CLIENT_UNREGISTER_SESSION_STATE_FAIL = -67058; constexpr int32_t ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL = -67059; constexpr int32_t ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL = -67060; + constexpr int32_t ERR_DH_INPUT_CLIENT_REGISTER_INJECT_EVENT_FAIL = -67061; + constexpr int32_t ERR_DH_INPUT_CLIENT_UNREGISTER_INJECT_EVENT_FAIL = -67062; + constexpr int32_t ERR_DH_INPUT_SRC_STUB_REGISTER_INJECT_EVENT_FAIL = -67063; + constexpr int32_t ERR_DH_INPUT_SRC_STUB_UNREGISTER_INJECT_EVENT_FAIL = -67064; // Hidump Helper error code constexpr int32_t ERR_DH_INPUT_HIDUMP_INVALID_ARGS = -68000; diff --git a/common/include/dinput_ipc_interface_code.h b/common/include/dinput_ipc_interface_code.h index e49f127..a535898 100644 --- a/common/include/dinput_ipc_interface_code.h +++ b/common/include/dinput_ipc_interface_code.h @@ -47,6 +47,8 @@ enum class IDInputSourceInterfaceCode : uint32_t { SYNC_NODE_INFO_REMOTE_INPUT = 0xf019U, REGISTER_SESSION_STATE_CB = 0xf01aU, UNREGISTER_SESSION_STATE_CB = 0xf01bU, + REGISTER_INJECT_EVENT_CB = 0xf01cU, + UNREGISTER_INJECT_EVENT_CB = 0xf01dU, }; /* SAID: 4810 */ diff --git a/frameworks/include/i_distributed_source_input.h b/frameworks/include/i_distributed_source_input.h index fbe654a..fbf38ec 100644 --- a/frameworks/include/i_distributed_source_input.h +++ b/frameworks/include/i_distributed_source_input.h @@ -33,6 +33,7 @@ #include "i_start_stop_result_call_back.h" #include "i_unprepare_d_input_call_back.h" #include "i_unregister_d_input_call_back.h" +#include "i_inject_event_callback.h" #include "i_input_node_listener.h" #include "i_simulation_event_listener.h" #include "i_session_state_callback.h" @@ -101,6 +102,8 @@ public: virtual int32_t UnregisterSimulationEventListener(sptr listener) = 0; virtual int32_t RegisterSessionStateCb(sptr callback) = 0; virtual int32_t UnregisterSessionStateCb() = 0; + virtual int32_t RegisterInjectEventCb(sptr callback) = 0; + virtual int32_t UnregisterInjectEventCb() = 0; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/frameworks/include/i_inject_event_callback.h b/frameworks/include/i_inject_event_callback.h new file mode 100644 index 0000000..a33d1c9 --- /dev/null +++ b/frameworks/include/i_inject_event_callback.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 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_REGISTER_SESSION_STATE_CALLBACK_H +#define I_REGISTER_SESSION_STATE_CALLBACK_H + +#include + +#include + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +class IInjectEventCallback : public IRemoteBroker { +public: + virtual void OnResult(const std::string &devId, const uint32_t status) = 0; + + enum class Message { + RESULT, + }; + + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IInjectEventCallback"); +}; +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS + +#endif // I_Inject_Event_CALLBACK_H \ No newline at end of file diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 4900ec4..bcb9c17 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -56,6 +56,8 @@ ohos_shared_library("libdinput_sdk") { "${ipc_path}/src/prepare_d_input_call_back_stub.cpp", "${ipc_path}/src/register_d_input_call_back_proxy.cpp", "${ipc_path}/src/register_d_input_call_back_stub.cpp", + "${ipc_path}/src/register_inject_event_callback_proxy.cpp", + "${ipc_path}/src/register_inject_event_callback_stub.cpp", "${ipc_path}/src/register_session_state_callback_proxy.cpp", "${ipc_path}/src/register_session_state_callback_stub.cpp", "${ipc_path}/src/sharing_dhid_listener_proxy.cpp", diff --git a/interfaces/inner_kits/include/distributed_input_kit.h b/interfaces/inner_kits/include/distributed_input_kit.h index e0ec439..4855e39 100644 --- a/interfaces/inner_kits/include/distributed_input_kit.h +++ b/interfaces/inner_kits/include/distributed_input_kit.h @@ -22,6 +22,7 @@ #include "constants_dinput.h" #include "dinput_log.h" #include "distributed_input_client.h" +#include "i_inject_event_callback.h" #include "i_prepare_d_input_call_back.h" #include "i_register_d_input_call_back.h" #include "i_start_d_input_call_back.h" @@ -84,6 +85,9 @@ public: static int32_t RegisterSessionStateCb(sptr callback); static int32_t UnregisterSessionStateCb(); + + static int32_t RegisterInjectEventCb(sptr callback); + static int32_t UnregisterInjectEventCb(); }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/interfaces/inner_kits/src/distributed_input_kit.cpp b/interfaces/inner_kits/src/distributed_input_kit.cpp index 2cdd774..7fcac83 100644 --- a/interfaces/inner_kits/src/distributed_input_kit.cpp +++ b/interfaces/inner_kits/src/distributed_input_kit.cpp @@ -138,6 +138,14 @@ int32_t DistributedInputKit::UnregisterSessionStateCb() { return DistributedInputClient::GetInstance().UnregisterSessionStateCb(); } +int32_t DistributedInputKit::RegisterInjectEventCb(sptr callback) +{ + return DistributedInputClient::GetInstance().RegisterInjectEventCb(callback); +} +int32_t DistributedInputKit::UnregisterInjectEventCb() +{ + return DistributedInputClient::GetInstance().UnregisterInjectEventCb(); +} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index c4449ec..957dbb5 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -110,6 +110,9 @@ public: int32_t RegisterSessionStateCb(sptr callback); int32_t UnregisterSessionStateCb(); + int32_t RegisterInjectEventCb(sptr callback); + int32_t UnregisterInjectEventCb(); + void CheckSourceRegisterCallback(); void CheckWhiteListCallback(); void CheckNodeMonitorCallback(); diff --git a/interfaces/ipc/include/distributed_input_source_proxy.h b/interfaces/ipc/include/distributed_input_source_proxy.h index 4824e30..1c9ea32 100644 --- a/interfaces/ipc/include/distributed_input_source_proxy.h +++ b/interfaces/ipc/include/distributed_input_source_proxy.h @@ -87,6 +87,9 @@ public: int32_t RegisterSessionStateCb(sptr callback) override; int32_t UnregisterSessionStateCb() override; + int32_t RegisterInjectEventCb(sptr callback) override; + int32_t UnregisterInjectEventCb() override; + private: bool SendRequest(const uint32_t code, MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/ipc/include/distributed_input_source_stub.h b/interfaces/ipc/include/distributed_input_source_stub.h index 19d3aa2..e20ce69 100644 --- a/interfaces/ipc/include/distributed_input_source_stub.h +++ b/interfaces/ipc/include/distributed_input_source_stub.h @@ -61,6 +61,8 @@ private: int32_t HandleUnregisterSimulationEventListener(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply); int32_t HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply); + int32_t HandleRegisterInjectEventCb(MessageParcel &data, MessageParcel &reply); + int32_t HandleUnregisterInjectEventCb(MessageParcel &data, MessageParcel &reply); bool HasEnableDHPermission(); bool HasAccessDHPermission(); DISALLOW_COPY_AND_MOVE(DistributedInputSourceStub); diff --git a/interfaces/ipc/include/register_inject_event_callback_proxy.h b/interfaces/ipc/include/register_inject_event_callback_proxy.h new file mode 100644 index 0000000..ae2d315 --- /dev/null +++ b/interfaces/ipc/include/register_inject_event_callback_proxy.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 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 REGISTER_SESSION_STATE_CALLBACK_PROXY_H +#define REGISTER_SESSION_STATE_CALLBACK_PROXY_H + +#include "i_inject_event_callback.h" + +#include + +#include "iremote_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +class RegisterInjectEventCallbackProxy : public IRemoteProxy { +public: + explicit RegisterInjectEventCallbackProxy(const sptr &object); + ~RegisterInjectEventCallbackProxy() override; + + void OnResult(const std::string &deviceId, const uint32_t status) override; + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS + +#endif // REGISTER_INJECT_EVENT_CALLBACK_PROXY_H \ No newline at end of file diff --git a/interfaces/ipc/include/register_inject_event_callback_stub.h b/interfaces/ipc/include/register_inject_event_callback_stub.h new file mode 100644 index 0000000..84e23f1 --- /dev/null +++ b/interfaces/ipc/include/register_inject_event_callback_stub.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 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 REGISTER_SESSION_STATE_CALLBACK_STUB_H +#define REGISTER_SESSION_STATE_CALLBACK_STUB_H + +#include "i_inject_event_callback.h" + +#include + +#include "iremote_stub.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +class RegisterInjectEventCallbackStub : public IRemoteStub { +public: + RegisterInjectEventCallbackStub(); + ~RegisterInjectEventCallbackStub() override; + + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + DISALLOW_COPY_AND_MOVE(RegisterInjectEventCallbackStub); +}; +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS + +#endif // REGISTER_SESSION_STATE_CALLBACK_STUB_H \ No newline at end of file diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index b70bf9f..4f52a91 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -818,6 +818,28 @@ int32_t DistributedInputClient::UnregisterSessionStateCb() } return DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterSessionStateCb(); } + +int32_t DistributedInputClient::RegisterInjectEventCb(sptr callback) +{ + if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { + DHLOGE("DinputStart client fail."); + return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; + } + if (callback == nullptr) { + DHLOGE("RegisterInjectEventCb callback is null."); + return ERR_DH_INPUT_CLIENT_REGISTER_INJECT_EVENT_FAIL; + } + return DInputSAManager::GetInstance().dInputSourceProxy_->RegisterInjectEventCb(callback); +} + +int32_t DistributedInputClient::UnregisterInjectEventCb() +{ + if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { + DHLOGE("DinputStart client fail."); + return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; + } + return DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterInjectEventCb(); +} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 8bd4d5d..4894cd3 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -743,6 +743,47 @@ int32_t DistributedInputSourceProxy::UnregisterSessionStateCb() return result; } +int32_t DistributedInputSourceProxy::RegisterInjectEventCb(sptr callback) +{ + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("RegisterInjectEventCb write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + + if (!data.WriteRemoteObject(callback->AsObject())) { + DHLOGE("RegisterInjectEventCb write callback failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + + MessageParcel reply; + int32_t result = ERR_DH_INPUT_SRC_STUB_REGISTER_INJECT_EVENT_FAIL; + bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::REGISTER_INJECT_EVENT_CB), + data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::UnregisterInjectEventeCb() +{ + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("UnregisterSessionStateCb write token valid failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + + MessageParcel reply; + int32_t result = ERR_DH_INPUT_SRC_STUB_UNREGISTER_INJECT_EVENT_FAIL; + bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::UNREGISTER_INJECT_EVENT_CB), + data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + bool DistributedInputSourceProxy::SendRequest(const uint32_t code, MessageParcel &data, MessageParcel &reply) { sptr remote = Remote(); diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index ec8200d..3f29eaa 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -83,6 +83,10 @@ void DistributedInputSourceStub::RegRespFunMap() &DistributedInputSourceStub::HandleRegisterSessionStateCb; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNREGISTER_SESSION_STATE_CB)] = &DistributedInputSourceStub::HandleUnregisterSessionStateCb; + memberFuncMap_[static_cast(IDInputSourceInterfaceCode::REGISTER_INJECT_EVENT_CB)] = + &DistributedInputSourceStub::HandleRegisterInjectEventCb; + memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNREGISTER_INJECT_EVENT_CB)] = + &DistributedInputSourceStub::HandleUnregisterInjectEventCb; } bool DistributedInputSourceStub::HasEnableDHPermission() @@ -647,6 +651,41 @@ int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel return DH_SUCCESS; } +int32_t DistributedInputSourceStub::HandleRegisterInjectEventCb(MessageParcel &data, MessageParcel &reply) +{ + if (!HasAccessDHPermission()) { + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterSessionStateCb failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = RegisterSessionStateCb(callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleRegisterSessionStateCb write ret failed, ret = %d", ret); + return ERR_DH_INPUT_SRC_STUB_REGISTER_INJECT_EVENT_FAIL; + } + + return DH_SUCCESS; +} + +int32_t DistributedInputSourceStub::HandleUnregisterInjectEventCb(MessageParcel &data, MessageParcel &reply) +{ + if (!HasAccessDHPermission()) { + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + int32_t ret = UnregisterSessionStateCb(); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnregisterSessionStateCb write ret failed, ret = %d", ret); + return ERR_DH_INPUT_SRC_STUB_UNREGISTER_INJECT_EVENT_FAIL; + } + + return DH_SUCCESS; +} + int32_t DistributedInputSourceStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { diff --git a/interfaces/ipc/src/register_inject_event_callback_proxy.cpp b/interfaces/ipc/src/register_inject_event_callback_proxy.cpp new file mode 100644 index 0000000..0399930 --- /dev/null +++ b/interfaces/ipc/src/register_inject_event_callback_proxy.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 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 "register_inject_event_callback_proxy.h" + +#include "ipc_types.h" +#include "parcel.h" + +#include "dinput_log.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +RegisterInjectEventCallbackProxy::RegisterInjectEventCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +RegisterInjectEventCallbackProxy::~RegisterInjectEventCallbackProxy() +{ +} + +void RegisterInjectEventCallbackProxy::OnResult(const std::string &deviceId, const uint32_t status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("RegisterSessionStateCallbackProxy write token valid failed"); + return; + } + if (!data.WriteString(deviceId)) { + return; + } + if (!data.WriteUint32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IInjectEventCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/ipc/src/register_inject_event_callback_stub.cpp b/interfaces/ipc/src/register_inject_event_callback_stub.cpp new file mode 100644 index 0000000..829cb9f --- /dev/null +++ b/interfaces/ipc/src/register_inject_event_callback_stub.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 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 "register_inject_event_callback_stub.h" + +#include "string_ex.h" + +#include "constants_dinput.h" +#include "dinput_errcode.h" +#include "dinput_log.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +RegisterInjectEventCallbackStub::RegisterInjectEventCallbackStub() +{ +} + +RegisterInjectEventCallbackStub::~RegisterInjectEventCallbackStub() +{ +} + +int32_t RegisterInjectEventCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("RegisterInjectEventCallbackStub read token valid failed"); + return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; + } + IInjectEventCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IInjectEventCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + uint32_t status = data.ReadUint32(); + OnResult(deviceId, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return DH_SUCCESS; +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/source/inputinject/include/virtual_device.h b/services/source/inputinject/include/virtual_device.h index bcec29e..aca795e 100644 --- a/services/source/inputinject/include/virtual_device.h +++ b/services/source/inputinject/include/virtual_device.h @@ -28,6 +28,7 @@ #include "linux/uinput.h" #include "constants_dinput.h" +#include "i_inject_event_callback.h" namespace OHOS { namespace DistributedHardware { @@ -66,6 +67,10 @@ private: private: void RecordEventLog(const input_event &event); + void RunInjectEventCallback(const uint32_t injectEvent); + void RegisterInjectEventCb(sptr callback); + void UnregisterInjectEventCb(); + sptr InjectEventCallback_; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index a0b83c5..0f758da 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -30,6 +30,7 @@ namespace { constexpr uint32_t ABS_MAX_POS = 2; constexpr uint32_t ABS_FUZZ_POS = 3; constexpr uint32_t ABS_FLAT_POS = 4; + constexpr uint32_t INJECT_EVENT_FAIL = 5; } VirtualDevice::VirtualDevice(const InputDevice &event) : deviceName_(event.name), busType_(event.bus), vendorId_(event.vendor), productId_(event.product), version_(event.version), classes_(event.classes) @@ -171,6 +172,7 @@ bool VirtualDevice::InjectInputEvent(const input_event &event) if (write(fd_, &event, sizeof(event)) < static_cast(sizeof(event))) { DHLOGE("could not inject event, removed? (fd: %d", fd_); + RunInjectEventCallback(INJECT_EVENT_FAIL); return false; } RecordEventLog(event); @@ -179,6 +181,28 @@ bool VirtualDevice::InjectInputEvent(const input_event &event) return true; } +void VirtualDevice::RegisterInjectEventCb(sptr callback) +{ + DHLOGI("RegisterSessionStateCb"); + InjectEventCallback_ = callback; +} + +void VirtualDevice::UnregisterInjectEventCb() +{ + DHLOGI("UnregisterSessionStateCb"); + InjectEventCallback_ = nullptr; +} + +void VirtualDevice::RunInjectEventCallback(const uint32_t injectEvent) +{ + DHLOGI("RunInjectEventCallback start."); + if (InjectEventCallback_ != nullptr) { +// InjectEventCallback_->OnResult(remoteDevId, sessionState); + return; + } + DHLOGI("RunInjectEventCallback SessionStateCallback_ is null."); +} + void VirtualDevice::SetNetWorkId(const std::string &netWorkId) { DHLOGI("SetNetWorkId %s\n", GetAnonyString(netWorkId).c_str()); diff --git a/services/source/sourcemanager/BUILD.gn b/services/source/sourcemanager/BUILD.gn index 7bfd57f..ed64f36 100644 --- a/services/source/sourcemanager/BUILD.gn +++ b/services/source/sourcemanager/BUILD.gn @@ -59,6 +59,8 @@ ohos_shared_library("libdinput_source") { "${ipc_path}/src/prepare_d_input_call_back_stub.cpp", "${ipc_path}/src/register_d_input_call_back_proxy.cpp", "${ipc_path}/src/register_d_input_call_back_stub.cpp", + "${ipc_path}/src/register_inject_event_callback_proxy.cpp", + "${ipc_path}/src/register_inject_event_callback_stub.cpp", "${ipc_path}/src/register_session_state_callback_proxy.cpp", "${ipc_path}/src/register_session_state_callback_stub.cpp", "${ipc_path}/src/sharing_dhid_listener_proxy.cpp", diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index dfad600..25006d4 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -187,6 +187,9 @@ public: int32_t RegisterSessionStateCb(sptr callback) override; int32_t UnregisterSessionStateCb() override; + int32_t RegisterInjectEventCb(sptr callback) override; + int32_t UnregisterInjectEventCb() override; + bool CheckRegisterParam(const std::string &devId, const std::string &dhId, const std::string ¶meters, sptr callback); bool CheckUnregisterParam(const std::string &devId, const std::string &dhId, diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 4cfaeb4..d853350 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -1222,6 +1222,22 @@ int32_t DistributedInputSourceManager::UnregisterSessionStateCb() return DH_SUCCESS; } +int32_t DistributedInputSourceManager::RegisterInjectEventCb(sptr callback) +{ + if (callback == nullptr) { + DHLOGE("RegisterInjectEventCb callback is null."); + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INJECT_EVENT_CB_IS_NULL; + } + DistributedInputTransportBase::GetInstance().RegisterInjectEventCb(callback); + return DH_SUCCESS; +} + +int32_t DistributedInputSourceManager::UnregisterInjectEventCb() +{ + DistributedInputTransportBase::GetInstance().UnregisterInjectEventCb(); + return DH_SUCCESS; +} + int32_t DistributedInputSourceManager::SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhId, const std::string &nodeDesc) { -- Gitee From c881aa5c7969d767234e9ad31029d369ccb72940 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 07:30:10 +0000 Subject: [PATCH 02/42] update services/source/inputinject/src/virtual_device.cpp. Signed-off-by: ry521 --- services/source/inputinject/src/virtual_device.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index 0f758da..3010787 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -197,7 +197,6 @@ void VirtualDevice::RunInjectEventCallback(const uint32_t injectEvent) { DHLOGI("RunInjectEventCallback start."); if (InjectEventCallback_ != nullptr) { -// InjectEventCallback_->OnResult(remoteDevId, sessionState); return; } DHLOGI("RunInjectEventCallback SessionStateCallback_ is null."); -- Gitee From c19eec84ebbc397a8986d2ce4ab6c899f12f6975 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 07:57:56 +0000 Subject: [PATCH 03/42] update services/source/inputinject/src/virtual_device.cpp. Signed-off-by: ry521 --- services/source/inputinject/src/virtual_device.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index 3010787..b86823e 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -183,13 +183,13 @@ bool VirtualDevice::InjectInputEvent(const input_event &event) void VirtualDevice::RegisterInjectEventCb(sptr callback) { - DHLOGI("RegisterSessionStateCb"); + DHLOGI("RegisterInjectEventCb"); InjectEventCallback_ = callback; } void VirtualDevice::UnregisterInjectEventCb() { - DHLOGI("UnregisterSessionStateCb"); + DHLOGI("UnregisterInjectEventCb"); InjectEventCallback_ = nullptr; } @@ -199,7 +199,7 @@ void VirtualDevice::RunInjectEventCallback(const uint32_t injectEvent) if (InjectEventCallback_ != nullptr) { return; } - DHLOGI("RunInjectEventCallback SessionStateCallback_ is null."); + DHLOGI("RunInjectEventCallback InjectEventCallback_ is null."); } void VirtualDevice::SetNetWorkId(const std::string &netWorkId) -- Gitee From 642f3e121b12809a288a3c538190cd58fbc2541c Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:27:42 +0000 Subject: [PATCH 04/42] update interfaces/ipc/include/distributed_input_client.h. Signed-off-by: ry521 --- interfaces/ipc/include/distributed_input_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index 957dbb5..8b4ee26 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -110,7 +110,7 @@ public: int32_t RegisterSessionStateCb(sptr callback); int32_t UnregisterSessionStateCb(); - int32_t RegisterInjectEventCb(sptr callback); + int32_t RegisterInjectEventCb(sptr callback); int32_t UnregisterInjectEventCb(); void CheckSourceRegisterCallback(); -- Gitee From d1c1f88f2acd65de67a6dc40010b1fbf3beb472f Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:28:32 +0000 Subject: [PATCH 05/42] update interfaces/ipc/include/distributed_input_source_proxy.h. Signed-off-by: ry521 --- interfaces/ipc/include/distributed_input_source_proxy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/include/distributed_input_source_proxy.h b/interfaces/ipc/include/distributed_input_source_proxy.h index 1c9ea32..d31d9bd 100644 --- a/interfaces/ipc/include/distributed_input_source_proxy.h +++ b/interfaces/ipc/include/distributed_input_source_proxy.h @@ -87,7 +87,7 @@ public: int32_t RegisterSessionStateCb(sptr callback) override; int32_t UnregisterSessionStateCb() override; - int32_t RegisterInjectEventCb(sptr callback) override; + int32_t RegisterInjectEventCb(sptr callback) override; int32_t UnregisterInjectEventCb() override; private: -- Gitee From e31f88f6e07962c7be59d1f14b82d9181d33e1f3 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:29:21 +0000 Subject: [PATCH 06/42] update interfaces/ipc/src/distributed_input_source_proxy.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_source_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 4894cd3..146985f 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -766,7 +766,7 @@ int32_t DistributedInputSourceProxy::RegisterInjectEventCb(sptr Date: Tue, 17 Oct 2023 12:31:45 +0000 Subject: [PATCH 07/42] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 3f29eaa..05125e0 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -653,18 +653,14 @@ int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel int32_t DistributedInputSourceStub::HandleRegisterInjectEventCb(MessageParcel &data, MessageParcel &reply) { - if (!HasAccessDHPermission()) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; - } sptr callback = iface_cast(data.ReadRemoteObject()); if (callback == nullptr) { - DHLOGE("HandleRegisterSessionStateCb failed, callback is nullptr."); + DHLOGE("HandleRegisterInjectEventCb failed, callback is nullptr."); return ERR_DH_INPUT_POINTER_NULL; } - int32_t ret = RegisterSessionStateCb(callback); + int32_t ret = RegisterInjectEventCb(callback); if (!reply.WriteInt32(ret)) { - DHLOGE("HandleRegisterSessionStateCb write ret failed, ret = %d", ret); + DHLOGE("HandleRegisterInjectEventCb write ret failed, ret = %d", ret); return ERR_DH_INPUT_SRC_STUB_REGISTER_INJECT_EVENT_FAIL; } @@ -673,13 +669,9 @@ int32_t DistributedInputSourceStub::HandleRegisterInjectEventCb(MessageParcel &d int32_t DistributedInputSourceStub::HandleUnregisterInjectEventCb(MessageParcel &data, MessageParcel &reply) { - if (!HasAccessDHPermission()) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; - } - int32_t ret = UnregisterSessionStateCb(); + int32_t ret = UnregisterInjectEventCb(); if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnregisterSessionStateCb write ret failed, ret = %d", ret); + DHLOGE("HandleUnregisterInjectEventCb write ret failed, ret = %d", ret); return ERR_DH_INPUT_SRC_STUB_UNREGISTER_INJECT_EVENT_FAIL; } -- Gitee From b1b545f9ab0346ea4147b1a5d2eb7f1edfd37022 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:33:11 +0000 Subject: [PATCH 08/42] update interfaces/ipc/src/register_inject_event_callback_proxy.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/register_inject_event_callback_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/register_inject_event_callback_proxy.cpp b/interfaces/ipc/src/register_inject_event_callback_proxy.cpp index 0399930..42b3e10 100644 --- a/interfaces/ipc/src/register_inject_event_callback_proxy.cpp +++ b/interfaces/ipc/src/register_inject_event_callback_proxy.cpp @@ -43,7 +43,7 @@ void RegisterInjectEventCallbackProxy::OnResult(const std::string &deviceId, con MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("RegisterSessionStateCallbackProxy write token valid failed"); + DHLOGE("RegisterInjectEventCallbackProxy write token valid failed"); return; } if (!data.WriteString(deviceId)) { -- Gitee From 20827ef909da3fdc82d210f2affd6a60082bb3cd Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:34:38 +0000 Subject: [PATCH 09/42] update services/source/inputinject/include/virtual_device.h. Signed-off-by: ry521 --- services/source/inputinject/include/virtual_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/inputinject/include/virtual_device.h b/services/source/inputinject/include/virtual_device.h index aca795e..c76e090 100644 --- a/services/source/inputinject/include/virtual_device.h +++ b/services/source/inputinject/include/virtual_device.h @@ -68,7 +68,7 @@ private: private: void RecordEventLog(const input_event &event); void RunInjectEventCallback(const uint32_t injectEvent); - void RegisterInjectEventCb(sptr callback); + void RegisterInjectEventCb(sptr callback); void UnregisterInjectEventCb(); sptr InjectEventCallback_; }; -- Gitee From 10880526ba10778bcf816a4b02695c845d45c1a9 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:41:37 +0000 Subject: [PATCH 10/42] update services/source/inputinject/src/virtual_device.cpp. Signed-off-by: ry521 --- services/source/inputinject/src/virtual_device.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index b86823e..3a9608e 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -172,7 +172,7 @@ bool VirtualDevice::InjectInputEvent(const input_event &event) if (write(fd_, &event, sizeof(event)) < static_cast(sizeof(event))) { DHLOGE("could not inject event, removed? (fd: %d", fd_); - RunInjectEventCallback(INJECT_EVENT_FAIL); + RunInjectEventCallback(netWorkId_,INJECT_EVENT_FAIL); return false; } RecordEventLog(event); @@ -197,6 +197,7 @@ void VirtualDevice::RunInjectEventCallback(const uint32_t injectEvent) { DHLOGI("RunInjectEventCallback start."); if (InjectEventCallback_ != nullptr) { + InjectEventCallback_->OnResult(netWorkId_, injectEvent); return; } DHLOGI("RunInjectEventCallback InjectEventCallback_ is null."); -- Gitee From e9e2ef795b00432bb63a80b8a4c3b7072c040c1a Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 17 Oct 2023 12:56:04 +0000 Subject: [PATCH 11/42] update services/source/inputinject/include/virtual_device.h. Signed-off-by: ry521 --- services/source/inputinject/include/virtual_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/inputinject/include/virtual_device.h b/services/source/inputinject/include/virtual_device.h index c76e090..e15578d 100644 --- a/services/source/inputinject/include/virtual_device.h +++ b/services/source/inputinject/include/virtual_device.h @@ -68,7 +68,7 @@ private: private: void RecordEventLog(const input_event &event); void RunInjectEventCallback(const uint32_t injectEvent); - void RegisterInjectEventCb(sptr callback); + void RegisterInjectEventCb(const std::string &remoteDevId, sptr callback); void UnregisterInjectEventCb(); sptr InjectEventCallback_; }; -- Gitee From ae6d8cda4416abea0f6f6b0ae62c926e097dd5b7 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 02:06:49 +0000 Subject: [PATCH 12/42] update common/include/dinput_errcode.h. Signed-off-by: ry521 --- common/include/dinput_errcode.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index 7e0b31d..cb420a0 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -178,10 +178,13 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_CLIENT_UNREGISTER_SESSION_STATE_FAIL = -67058; constexpr int32_t ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL = -67059; constexpr int32_t ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL = -67060; - constexpr int32_t ERR_DH_INPUT_CLIENT_REGISTER_INJECT_EVENT_FAIL = -67061; - constexpr int32_t ERR_DH_INPUT_CLIENT_UNREGISTER_INJECT_EVENT_FAIL = -67062; - constexpr int32_t ERR_DH_INPUT_SRC_STUB_REGISTER_INJECT_EVENT_FAIL = -67063; - constexpr int32_t ERR_DH_INPUT_SRC_STUB_UNREGISTER_INJECT_EVENT_FAIL = -67064; + constexpr int32_t ERR_DH_INPUT_SRC_ENABLE_PERMISSION_CHECK_FAIL = -67061; + constexpr int32_t ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL = -67062; + constexpr int32_t ERR_DH_INPUT_SINK_ENABLE_PERMISSION_CHECK_FAIL = -67063; + constexpr int32_t ERR_DH_INPUT_CLIENT_REGISTER_INJECT_EVENT_FAIL = -67064; + constexpr int32_t ERR_DH_INPUT_CLIENT_UNREGISTER_INJECT_EVENT_FAIL = -67065; + constexpr int32_t ERR_DH_INPUT_SRC_STUB_REGISTER_INJECT_EVENT_FAIL = -67066; + constexpr int32_t ERR_DH_INPUT_SRC_STUB_UNREGISTER_INJECT_EVENT_FAIL = -67067; // Hidump Helper error code constexpr int32_t ERR_DH_INPUT_HIDUMP_INVALID_ARGS = -68000; -- Gitee From 0d78af05a7849a6f86d6c5dbd50c2801d5dde6d7 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 02:09:35 +0000 Subject: [PATCH 13/42] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 300de42..819ca78 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -79,7 +79,7 @@ int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel & { if (!HasEnableDHPermission()) { DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SINK_ENABLE_PERMISSION_CHECK_FAIL; } DHLOGI("DistributedInputSinkStub InitInner start"); int32_t ret = Init(); @@ -94,7 +94,7 @@ int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParce { if (!HasEnableDHPermission()) { DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SINK_ENABLE_PERMISSION_CHECK_FAIL; } int32_t ret = Release(); if (!reply.WriteInt32(ret)) { -- Gitee From 67f83bbd398efaef80ba3b8f60a61228f0bc019e Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 02:14:16 +0000 Subject: [PATCH 14/42] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 05125e0..0fc0724 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -111,7 +111,7 @@ int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel { if (!HasEnableDHPermission()) { DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ENABLE_PERMISSION_CHECK_FAIL; } std::unique_lock lock(operatorMutex_); if (sourceManagerInitFlag_.load()) { @@ -131,7 +131,7 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc { if (!HasEnableDHPermission()) { DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ENABLE_PERMISSION_CHECK_FAIL; } std::unique_lock lock(operatorMutex_); if (!sourceManagerInitFlag_.load()) { @@ -151,7 +151,7 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar { if (!HasEnableDHPermission()) { DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ENABLE_PERMISSION_CHECK_FAIL; } std::string devId = data.ReadString(); std::string dhId = data.ReadString(); @@ -173,7 +173,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP { if (!HasEnableDHPermission()) { DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ENABLE_PERMISSION_CHECK_FAIL; } std::string devId = data.ReadString(); std::string dhId = data.ReadString(); @@ -194,7 +194,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string deviceId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); @@ -214,7 +214,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string deviceId = data.ReadString(); sptr callback = iface_cast(data.ReadRemoteObject()); @@ -234,7 +234,7 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string deviceId = data.ReadString(); uint32_t inputTypes = data.ReadUint32(); @@ -255,7 +255,7 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string deviceId = data.ReadString(); uint32_t inputTypes = data.ReadUint32(); @@ -276,7 +276,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -298,7 +298,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -320,7 +320,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -341,7 +341,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -362,7 +362,7 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string sinkId = data.ReadString(); @@ -399,7 +399,7 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string sinkId = data.ReadString(); @@ -436,7 +436,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -474,7 +474,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } std::string srcId = data.ReadString(); std::string sinkId = data.ReadString(); @@ -620,7 +620,7 @@ int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel & { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } sptr callback = iface_cast(data.ReadRemoteObject()); if (callback == nullptr) { @@ -640,7 +640,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel { if (!HasAccessDHPermission()) { DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; } int32_t ret = UnregisterSessionStateCb(); if (!reply.WriteInt32(ret)) { -- Gitee From 4dbb763ee381fe0b105852226628b73d84b453f7 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:06:15 +0000 Subject: [PATCH 15/42] update services/source/inputinject/src/virtual_device.cpp. Signed-off-by: ry521 --- .../source/inputinject/src/virtual_device.cpp | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index 3a9608e..a0b83c5 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -30,7 +30,6 @@ namespace { constexpr uint32_t ABS_MAX_POS = 2; constexpr uint32_t ABS_FUZZ_POS = 3; constexpr uint32_t ABS_FLAT_POS = 4; - constexpr uint32_t INJECT_EVENT_FAIL = 5; } VirtualDevice::VirtualDevice(const InputDevice &event) : deviceName_(event.name), busType_(event.bus), vendorId_(event.vendor), productId_(event.product), version_(event.version), classes_(event.classes) @@ -172,7 +171,6 @@ bool VirtualDevice::InjectInputEvent(const input_event &event) if (write(fd_, &event, sizeof(event)) < static_cast(sizeof(event))) { DHLOGE("could not inject event, removed? (fd: %d", fd_); - RunInjectEventCallback(netWorkId_,INJECT_EVENT_FAIL); return false; } RecordEventLog(event); @@ -181,28 +179,6 @@ bool VirtualDevice::InjectInputEvent(const input_event &event) return true; } -void VirtualDevice::RegisterInjectEventCb(sptr callback) -{ - DHLOGI("RegisterInjectEventCb"); - InjectEventCallback_ = callback; -} - -void VirtualDevice::UnregisterInjectEventCb() -{ - DHLOGI("UnregisterInjectEventCb"); - InjectEventCallback_ = nullptr; -} - -void VirtualDevice::RunInjectEventCallback(const uint32_t injectEvent) -{ - DHLOGI("RunInjectEventCallback start."); - if (InjectEventCallback_ != nullptr) { - InjectEventCallback_->OnResult(netWorkId_, injectEvent); - return; - } - DHLOGI("RunInjectEventCallback InjectEventCallback_ is null."); -} - void VirtualDevice::SetNetWorkId(const std::string &netWorkId) { DHLOGI("SetNetWorkId %s\n", GetAnonyString(netWorkId).c_str()); -- Gitee From 1277040e546ba9d579cc0f7dab9295f2e83d2d08 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:08:22 +0000 Subject: [PATCH 16/42] update services/source/inputinject/include/virtual_device.h. Signed-off-by: ry521 --- services/source/inputinject/include/virtual_device.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/services/source/inputinject/include/virtual_device.h b/services/source/inputinject/include/virtual_device.h index e15578d..bcec29e 100644 --- a/services/source/inputinject/include/virtual_device.h +++ b/services/source/inputinject/include/virtual_device.h @@ -28,7 +28,6 @@ #include "linux/uinput.h" #include "constants_dinput.h" -#include "i_inject_event_callback.h" namespace OHOS { namespace DistributedHardware { @@ -67,10 +66,6 @@ private: private: void RecordEventLog(const input_event &event); - void RunInjectEventCallback(const uint32_t injectEvent); - void RegisterInjectEventCb(const std::string &remoteDevId, sptr callback); - void UnregisterInjectEventCb(); - sptr InjectEventCallback_; }; } // namespace DistributedInput } // namespace DistributedHardware -- Gitee From 1a1ac35d6ea80abbb3b1ad48ec8e645f469d8ddc Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:12:05 +0000 Subject: [PATCH 17/42] update interfaces/ipc/include/register_inject_event_callback_proxy.h. Signed-off-by: ry521 --- interfaces/ipc/include/register_inject_event_callback_proxy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/include/register_inject_event_callback_proxy.h b/interfaces/ipc/include/register_inject_event_callback_proxy.h index ae2d315..b1653dc 100644 --- a/interfaces/ipc/include/register_inject_event_callback_proxy.h +++ b/interfaces/ipc/include/register_inject_event_callback_proxy.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef REGISTER_SESSION_STATE_CALLBACK_PROXY_H -#define REGISTER_SESSION_STATE_CALLBACK_PROXY_H +#ifndef REGISTER_INJECT_EVENT_CALLBACK_PROXY_H +#define REGISTER_INJECT_EVENT_CALLBACK_PROXY_H #include "i_inject_event_callback.h" -- Gitee From 37b1d4e5b5e63feff1c404cee34a7ece22f74119 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:12:29 +0000 Subject: [PATCH 18/42] update interfaces/ipc/include/register_inject_event_callback_stub.h. Signed-off-by: ry521 --- interfaces/ipc/include/register_inject_event_callback_stub.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/include/register_inject_event_callback_stub.h b/interfaces/ipc/include/register_inject_event_callback_stub.h index 84e23f1..2da11ce 100644 --- a/interfaces/ipc/include/register_inject_event_callback_stub.h +++ b/interfaces/ipc/include/register_inject_event_callback_stub.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef REGISTER_SESSION_STATE_CALLBACK_STUB_H -#define REGISTER_SESSION_STATE_CALLBACK_STUB_H +#ifndef REGISTER_INJECT_EVENT_CALLBACK_STUB_H +#define REGISTER_INJECT_EVENT_CALLBACK_STUB_H #include "i_inject_event_callback.h" -- Gitee From d94cb1aaaafa45d7a4e324a73afb843f97213351 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:38:55 +0000 Subject: [PATCH 19/42] update services/source/sourcemanager/src/distributed_input_source_manager.cpp. Signed-off-by: ry521 --- .../sourcemanager/src/distributed_input_source_manager.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index d853350..1edb55e 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -1228,14 +1228,12 @@ int32_t DistributedInputSourceManager::RegisterInjectEventCb(sptr Date: Wed, 18 Oct 2023 12:47:41 +0000 Subject: [PATCH 20/42] update services/source/inputinject/include/distributed_input_inject.h. Signed-off-by: ry521 --- services/source/inputinject/include/distributed_input_inject.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/source/inputinject/include/distributed_input_inject.h b/services/source/inputinject/include/distributed_input_inject.h index bd93c55..ed4a364 100644 --- a/services/source/inputinject/include/distributed_input_inject.h +++ b/services/source/inputinject/include/distributed_input_inject.h @@ -47,6 +47,8 @@ public: int32_t RegisterInputNodeListener(sptr listener); int32_t UnregisterInputNodeListener(sptr listener); int32_t GetDhIdsByInputType(const std::string &devId, const uint32_t &inputTypes, std::vector &dhIds); + int32_t RegisterInjectEventCb(sptr callback); + int32_t UnregisterInjectEventCb(); void NotifyNodeMgrScanVirNode(const std::string &dhId); void InputDeviceEventInject(const std::shared_ptr &rawEvent); -- Gitee From 4e1ef838efcae95e1432d2f0d17dfc4e467e8414 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:50:05 +0000 Subject: [PATCH 21/42] update services/source/inputinject/src/distributed_input_inject.cpp. Signed-off-by: ry521 --- .../src/distributed_input_inject.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index ea4a948..de00a12 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -256,6 +256,23 @@ int32_t DistributedInputInject::GetVirtualTouchScreenFd() return inputNodeManager_->GetVirtualTouchScreenFd(); } +int32_t DistributedInputInject::RegisterInjectEventCb(sptr callback) +{ + if (callback == nullptr) { + DHLOGE("RegisterInjectEventCb callback is null."); + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INJECT_EVENT_CB_IS_NULL; + } + DistributedInputNodeManager::GetInstance().RegisterInjectEventCb(callback); + return DH_SUCCESS; +} + +int32_t DistributedInputInject::UnregisterInjectEventCb() +{ + DistributedInputNodeManager::GetInstance().UnregisterInjectEventCb(); + return DH_SUCCESS; +} + + void DistributedInputInject::GetVirtualKeyboardPathsByDhIds(const std::vector &dhIds, std::vector &virKeyboardPaths, std::vector &virKeyboardDhIds) { -- Gitee From 3504230d202856c6e41ed3e79967aa96ea6b5e30 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 12:59:15 +0000 Subject: [PATCH 22/42] update services/source/inputinject/src/distributed_input_node_manager.cpp. Signed-off-by: ry521 --- .../src/distributed_input_node_manager.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index bdde0f5..7dde19b 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -453,6 +453,7 @@ void DistributedInputNodeManager::InjectInputEvent(const std::string &dhId, cons VirtualDevice* device = nullptr; if (GetDevice(dhId, device) < 0) { DHLOGE("could not find the device"); + RunInjectEventCallback(dhId); return; } if (device != nullptr) { @@ -460,6 +461,27 @@ void DistributedInputNodeManager::InjectInputEvent(const std::string &dhId, cons } } +void DistributedInputNodeManager::RegisterInjectEventCb(sptr callback) +{ + DHLOGI("RegisterInjectEventCb"); + InjectEventCallback_ = callback; +} + +void DistributedInputNodeManager::UnregisterInjectEventCb() +{ + DHLOGI("UnregisterInjectEventCb"); + InjectEventCallback_ = nullptr; +} + +void DistributedInputNodeManager::RunInjectEventCallback(const std::string &remoteDevId) +{ + DHLOGI("RunInjectEventCallback start."); + if (InjectEventCallback_ != nullptr) { + return; + } + DHLOGI("RunInjectEventCallback InjectEventCallback_ is null."); +} + void DistributedInputNodeManager::ProcessInjectEvent(const std::shared_ptr &rawEvent) { std::string dhId = rawEvent->descriptor; -- Gitee From 3e43469a5ca221bbcd5da00668ef8401c55dac84 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 13:01:22 +0000 Subject: [PATCH 23/42] update services/source/inputinject/include/distributed_input_inject.h. Signed-off-by: ry521 --- .../source/inputinject/include/distributed_input_inject.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/source/inputinject/include/distributed_input_inject.h b/services/source/inputinject/include/distributed_input_inject.h index ed4a364..497234e 100644 --- a/services/source/inputinject/include/distributed_input_inject.h +++ b/services/source/inputinject/include/distributed_input_inject.h @@ -24,6 +24,7 @@ #include "distributed_input_handler.h" #include "distributed_input_node_manager.h" #include "i_input_node_listener.h" +#include "i_inject_event_callback.h" namespace OHOS { namespace DistributedHardware { @@ -64,6 +65,10 @@ private: DistributedInputInject(); ~DistributedInputInject(); + void RunInjectEventCallback(const uint32_t injectEvent); + void RegisterInjectEventCb(sptr callback); + void UnregisterInjectEventCb(); + sptr InjectEventCallback_; std::unique_ptr inputNodeManager_; std::mutex inputNodeManagerMutex_; std::set> inputNodeListeners_; -- Gitee From 514aaa4242fe600f14c86feaa1419ec264d48b87 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 13:05:00 +0000 Subject: [PATCH 24/42] update services/source/inputinject/include/distributed_input_inject.h. Signed-off-by: ry521 --- .../source/inputinject/include/distributed_input_inject.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/services/source/inputinject/include/distributed_input_inject.h b/services/source/inputinject/include/distributed_input_inject.h index 497234e..ed4a364 100644 --- a/services/source/inputinject/include/distributed_input_inject.h +++ b/services/source/inputinject/include/distributed_input_inject.h @@ -24,7 +24,6 @@ #include "distributed_input_handler.h" #include "distributed_input_node_manager.h" #include "i_input_node_listener.h" -#include "i_inject_event_callback.h" namespace OHOS { namespace DistributedHardware { @@ -65,10 +64,6 @@ private: DistributedInputInject(); ~DistributedInputInject(); - void RunInjectEventCallback(const uint32_t injectEvent); - void RegisterInjectEventCb(sptr callback); - void UnregisterInjectEventCb(); - sptr InjectEventCallback_; std::unique_ptr inputNodeManager_; std::mutex inputNodeManagerMutex_; std::set> inputNodeListeners_; -- Gitee From 5206ef625fb44285876be98e2e19cb55b74442dc Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 13:05:28 +0000 Subject: [PATCH 25/42] update services/source/inputinject/include/distributed_input_node_manager.h. Signed-off-by: ry521 --- .../inputinject/include/distributed_input_node_manager.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index db423e4..78eec0c 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -93,6 +93,9 @@ private: bool IsVirtualDev(int fd); bool GetDevDhIdByFd(int fd, std::string &dhId, std::string &physicalPath); void SetPathForDevMap(const std::string &dhId, const std::string &devicePath); + void RunInjectEventCallback(const std::string &dhId); + void RegisterInjectEventCb(sptr callback); + void UnregisterInjectEventCb(); /* the key is dhId, and the value is virtualDevice */ std::map> virtualDeviceMap_; @@ -110,6 +113,7 @@ private: std::shared_ptr callBackHandler_; std::atomic isFirst_; DhIdState specEventState_; + sptr InjectEventCallback_; }; } // namespace DistributedInput } // namespace DistributedHardware -- Gitee From 1b7334b38e5886b9ca9ee513ee54942a5d0e42f1 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 18 Oct 2023 13:06:27 +0000 Subject: [PATCH 26/42] update services/source/inputinject/src/distributed_input_node_manager.cpp. Signed-off-by: ry521 --- .../source/inputinject/src/distributed_input_node_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 7dde19b..8ded05d 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -473,7 +473,7 @@ void DistributedInputNodeManager::UnregisterInjectEventCb() InjectEventCallback_ = nullptr; } -void DistributedInputNodeManager::RunInjectEventCallback(const std::string &remoteDevId) +void DistributedInputNodeManager::RunInjectEventCallback(const std::string &dhId) { DHLOGI("RunInjectEventCallback start."); if (InjectEventCallback_ != nullptr) { -- Gitee From 0fe78f9b1916654433d46d95321a26f7051acd40 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 01:30:05 +0000 Subject: [PATCH 27/42] update services/source/inputinject/include/distributed_input_node_manager.h. Signed-off-by: ry521 --- .../source/inputinject/include/distributed_input_node_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 78eec0c..6b71df8 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -94,7 +94,7 @@ private: bool GetDevDhIdByFd(int fd, std::string &dhId, std::string &physicalPath); void SetPathForDevMap(const std::string &dhId, const std::string &devicePath); void RunInjectEventCallback(const std::string &dhId); - void RegisterInjectEventCb(sptr callback); + void RegisterInjectEventCb(sptr callback); void UnregisterInjectEventCb(); /* the key is dhId, and the value is virtualDevice */ -- Gitee From 38f287b9661e08afd94d5d952c0de07c058db85b Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 01:39:24 +0000 Subject: [PATCH 28/42] update services/source/inputinject/src/distributed_input_inject.cpp. Signed-off-by: ry521 --- services/source/inputinject/src/distributed_input_inject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index de00a12..8253a21 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -256,7 +256,7 @@ int32_t DistributedInputInject::GetVirtualTouchScreenFd() return inputNodeManager_->GetVirtualTouchScreenFd(); } -int32_t DistributedInputInject::RegisterInjectEventCb(sptr callback) +int32_t DistributedInputInject::RegisterInjectEventCb(sptr callback) { if (callback == nullptr) { DHLOGE("RegisterInjectEventCb callback is null."); -- Gitee From 414e897521e5f94beabd07e9616b861889ead68a Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 01:44:44 +0000 Subject: [PATCH 29/42] update frameworks/include/i_inject_event_callback.h. Signed-off-by: ry521 --- frameworks/include/i_inject_event_callback.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/include/i_inject_event_callback.h b/frameworks/include/i_inject_event_callback.h index a33d1c9..ce6d308 100644 --- a/frameworks/include/i_inject_event_callback.h +++ b/frameworks/include/i_inject_event_callback.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef I_REGISTER_SESSION_STATE_CALLBACK_H -#define I_REGISTER_SESSION_STATE_CALLBACK_H +#ifndef I_REGISTER_INJECT_EVENT_CALLBACK_H +#define I_REGISTER_INJECT_EVENT_CALLBACK_H #include -- Gitee From 186d2e4755538d8af08dc99d61dc69b831133daf Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 01:52:41 +0000 Subject: [PATCH 30/42] update services/source/inputinject/include/distributed_input_node_manager.h. Signed-off-by: ry521 --- .../source/inputinject/include/distributed_input_node_manager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 6b71df8..442775a 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -30,6 +30,7 @@ #include "constants_dinput.h" #include "input_hub.h" #include "virtual_device.h" +#include "i_inject_event_callback.h" namespace OHOS { namespace DistributedHardware { -- Gitee From ce97448fddbe35ef1409bf3cc3cb397188a1239d Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 01:55:14 +0000 Subject: [PATCH 31/42] update services/source/inputinject/src/distributed_input_inject.cpp. Signed-off-by: ry521 --- services/source/inputinject/src/distributed_input_inject.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 8253a21..7b849ef 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -272,7 +272,6 @@ int32_t DistributedInputInject::UnregisterInjectEventCb() return DH_SUCCESS; } - void DistributedInputInject::GetVirtualKeyboardPathsByDhIds(const std::vector &dhIds, std::vector &virKeyboardPaths, std::vector &virKeyboardDhIds) { -- Gitee From 8e78af6a745ecf1fd496a5015103c0a6e23d5f4d Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 02:11:41 +0000 Subject: [PATCH 32/42] update interfaces/ipc/src/distributed_input_source_proxy.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_source_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 146985f..64f4f65 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -743,7 +743,7 @@ int32_t DistributedInputSourceProxy::UnregisterSessionStateCb() return result; } -int32_t DistributedInputSourceProxy::RegisterInjectEventCb(sptr callback) +int32_t DistributedInputSourceProxy::RegisterInjectEventCb(sptr callback) { MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor())) { -- Gitee From 6b364d0b7a9e076a975d09abe3dc2dd5ea4cd0d3 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 02:13:22 +0000 Subject: [PATCH 33/42] update services/source/sourcemanager/src/distributed_input_source_manager.cpp. Signed-off-by: ry521 --- .../sourcemanager/src/distributed_input_source_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 1edb55e..d2fcc40 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -1222,7 +1222,7 @@ int32_t DistributedInputSourceManager::UnregisterSessionStateCb() return DH_SUCCESS; } -int32_t DistributedInputSourceManager::RegisterInjectEventCb(sptr callback) +int32_t DistributedInputSourceManager::RegisterInjectEventCb(sptr callback) { if (callback == nullptr) { DHLOGE("RegisterInjectEventCb callback is null."); -- Gitee From f2a727ab0bf2dbaea87e9411ccef37cab717905f Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 02:37:28 +0000 Subject: [PATCH 34/42] update services/source/inputinject/src/distributed_input_inject.cpp. Signed-off-by: ry521 --- .../source/inputinject/src/distributed_input_inject.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 7b849ef..bec206f 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -262,14 +262,12 @@ int32_t DistributedInputInject::RegisterInjectEventCb(sptr DHLOGE("RegisterInjectEventCb callback is null."); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INJECT_EVENT_CB_IS_NULL; } - DistributedInputNodeManager::GetInstance().RegisterInjectEventCb(callback); - return DH_SUCCESS; + return DistributedInputNodeManager::GetInstance().RegisterInjectEventCb(callback); } int32_t DistributedInputInject::UnregisterInjectEventCb() { - DistributedInputNodeManager::GetInstance().UnregisterInjectEventCb(); - return DH_SUCCESS; + return DistributedInputNodeManager::GetInstance().UnregisterInjectEventCb(); } void DistributedInputInject::GetVirtualKeyboardPathsByDhIds(const std::vector &dhIds, -- Gitee From 80a5eda9306237b15c12c14e207d1ae2718c9f47 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 02:54:01 +0000 Subject: [PATCH 35/42] update services/source/inputinject/src/distributed_input_inject.cpp. Signed-off-by: ry521 --- services/source/inputinject/src/distributed_input_inject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index bec206f..1845be9 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -262,12 +262,12 @@ int32_t DistributedInputInject::RegisterInjectEventCb(sptr DHLOGE("RegisterInjectEventCb callback is null."); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INJECT_EVENT_CB_IS_NULL; } - return DistributedInputNodeManager::GetInstance().RegisterInjectEventCb(callback); + return inputNodeManager_->RegisterInjectEventCb(callback); } int32_t DistributedInputInject::UnregisterInjectEventCb() { - return DistributedInputNodeManager::GetInstance().UnregisterInjectEventCb(); + return inputNodeManager_->UnregisterInjectEventCb(); } void DistributedInputInject::GetVirtualKeyboardPathsByDhIds(const std::vector &dhIds, -- Gitee From 56e61177a2afdc24c8274f8a8dc238bcabc6276e Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 03:19:05 +0000 Subject: [PATCH 36/42] update services/source/inputinject/src/distributed_input_inject.cpp. Signed-off-by: ry521 --- .../source/inputinject/src/distributed_input_inject.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 1845be9..e63b00d 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -262,12 +262,14 @@ int32_t DistributedInputInject::RegisterInjectEventCb(sptr DHLOGE("RegisterInjectEventCb callback is null."); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INJECT_EVENT_CB_IS_NULL; } - return inputNodeManager_->RegisterInjectEventCb(callback); + inputNodeManager_->RegisterInjectEventCb(callback); + return DH_SUCCESS; } int32_t DistributedInputInject::UnregisterInjectEventCb() { - return inputNodeManager_->UnregisterInjectEventCb(); + inputNodeManager_->UnregisterInjectEventCb(); + return DH_SUCCESS; } void DistributedInputInject::GetVirtualKeyboardPathsByDhIds(const std::vector &dhIds, -- Gitee From bf4745357420d9018a1b0d5fd3d969448a9a7cfb Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 03:20:08 +0000 Subject: [PATCH 37/42] update services/source/inputinject/include/distributed_input_node_manager.h. Signed-off-by: ry521 --- .../inputinject/include/distributed_input_node_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 442775a..033e8a5 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -65,6 +65,8 @@ public: void UpdateSpecEventFirstStatus(bool status); void UpdateSpecEventState(DhIdState state); void InjectInputEvent(const std::string &dhId, const struct input_event &event); + void RegisterInjectEventCb(sptr callback); + void UnregisterInjectEventCb(); class DInputNodeManagerEventHandler : public AppExecFwk::EventHandler { public: @@ -95,8 +97,6 @@ private: bool GetDevDhIdByFd(int fd, std::string &dhId, std::string &physicalPath); void SetPathForDevMap(const std::string &dhId, const std::string &devicePath); void RunInjectEventCallback(const std::string &dhId); - void RegisterInjectEventCb(sptr callback); - void UnregisterInjectEventCb(); /* the key is dhId, and the value is virtualDevice */ std::map> virtualDeviceMap_; -- Gitee From 90a36b26b2cb09419506962a8c1cdb09845c248f Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 07:53:18 +0000 Subject: [PATCH 38/42] update interfaces/ipc/src/distributed_input_source_proxy.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_source_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 64f4f65..4d451c0 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -770,7 +770,7 @@ int32_t DistributedInputSourceProxy::UnregisterInjectEventCb() { MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("UnregisterSessionStateCb write token valid failed"); + DHLOGE("UnregisterInjectEventCb write token valid failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } -- Gitee From 24fec252940380db66de532ccd6275d2dd60da31 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 07:55:56 +0000 Subject: [PATCH 39/42] update services/source/inputinject/include/distributed_input_node_manager.h. Signed-off-by: ry521 --- .../inputinject/include/distributed_input_node_manager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 033e8a5..7c00ca9 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -36,6 +36,7 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedInput { constexpr uint32_t DINPUT_NODE_MANAGER_SCAN_ALL_NODE = 1; +constexpr uint32_t DINPUT_INJECT_EVENT_FAIL = 2; const std::string INPUT_NODE_DHID = "dhId"; class DistributedInputNodeManager { public: @@ -96,7 +97,7 @@ private: bool IsVirtualDev(int fd); bool GetDevDhIdByFd(int fd, std::string &dhId, std::string &physicalPath); void SetPathForDevMap(const std::string &dhId, const std::string &devicePath); - void RunInjectEventCallback(const std::string &dhId); + void RunInjectEventCallback(const std::string &dhId, const uint32_t InjectEvent); /* the key is dhId, and the value is virtualDevice */ std::map> virtualDeviceMap_; -- Gitee From b050d18b088389e23ce7079792b591faca82711c Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 08:01:01 +0000 Subject: [PATCH 40/42] update services/source/inputinject/src/distributed_input_node_manager.cpp. Signed-off-by: ry521 --- .../source/inputinject/src/distributed_input_node_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 8ded05d..f47c70f 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -453,7 +453,7 @@ void DistributedInputNodeManager::InjectInputEvent(const std::string &dhId, cons VirtualDevice* device = nullptr; if (GetDevice(dhId, device) < 0) { DHLOGE("could not find the device"); - RunInjectEventCallback(dhId); + RunInjectEventCallback(dhId, DINPUT_INJECT_EVENT_FAIL); return; } if (device != nullptr) { @@ -477,6 +477,7 @@ void DistributedInputNodeManager::RunInjectEventCallback(const std::string &dhId { DHLOGI("RunInjectEventCallback start."); if (InjectEventCallback_ != nullptr) { + InjectEventCallback_->OnResult(dhId, InjectEvent); return; } DHLOGI("RunInjectEventCallback InjectEventCallback_ is null."); -- Gitee From b79cf6953f48ee2485c8ccf5652524b4ffa7fd23 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 08:11:04 +0000 Subject: [PATCH 41/42] update services/source/inputinject/include/distributed_input_node_manager.h. Signed-off-by: ry521 --- .../source/inputinject/include/distributed_input_node_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 7c00ca9..af0588e 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -97,7 +97,7 @@ private: bool IsVirtualDev(int fd); bool GetDevDhIdByFd(int fd, std::string &dhId, std::string &physicalPath); void SetPathForDevMap(const std::string &dhId, const std::string &devicePath); - void RunInjectEventCallback(const std::string &dhId, const uint32_t InjectEvent); + void RunInjectEventCallback(const std::string &dhId, const uint32_t injectEvent); /* the key is dhId, and the value is virtualDevice */ std::map> virtualDeviceMap_; -- Gitee From 295c06b44f6b94b75d56cd12b53b3eb261ff18f7 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 19 Oct 2023 08:12:20 +0000 Subject: [PATCH 42/42] update services/source/inputinject/src/distributed_input_node_manager.cpp. Signed-off-by: ry521 --- .../source/inputinject/src/distributed_input_node_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index f47c70f..ed16726 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -473,11 +473,11 @@ void DistributedInputNodeManager::UnregisterInjectEventCb() InjectEventCallback_ = nullptr; } -void DistributedInputNodeManager::RunInjectEventCallback(const std::string &dhId) +void DistributedInputNodeManager::RunInjectEventCallback(const std::string &dhId, const uint32_t injectEvent) { DHLOGI("RunInjectEventCallback start."); if (InjectEventCallback_ != nullptr) { - InjectEventCallback_->OnResult(dhId, InjectEvent); + InjectEventCallback_->OnResult(dhId, injectEvent); return; } DHLOGI("RunInjectEventCallback InjectEventCallback_ is null."); -- Gitee