From 91e59a5c22d0742c66064faafe8d5b92517cbde0 Mon Sep 17 00:00:00 2001 From: hwzhangchuang Date: Tue, 28 Nov 2023 17:49:56 +0800 Subject: [PATCH 1/4] remove no use node listener Signed-off-by: hwzhangchuang --- common/include/dinput_errcode.h | 5 -- common/include/dinput_ipc_interface_code.h | 2 - .../include/i_distributed_source_input.h | 4 - .../include/distributed_input_kit.h | 2 - .../inner_kits/src/distributed_input_kit.cpp | 10 --- .../unittest/distributed_input_inner_test.cpp | 28 ------- .../mock/mock_distributed_input_client.cpp | 10 --- .../ipc/include/distributed_input_client.h | 3 - .../include/distributed_input_source_proxy.h | 4 - .../include/distributed_input_source_stub.h | 3 - .../ipc/src/distributed_input_client.cpp | 58 -------------- .../src/distributed_input_source_proxy.cpp | 76 ------------------- .../ipc/src/distributed_input_source_stub.cpp | 52 ------------- .../dinput_source_callback_unittest.cpp | 53 ------------- .../dinput_source_callback_unittest.h | 4 - .../distributed_input_ipc_test.cpp | 28 ------- .../include/distributed_input_inject.h | 7 -- .../src/distributed_input_inject.cpp | 43 +---------- .../distributed_input_sourceinject_test.cpp | 13 ---- .../distributed_input_source_manager.h | 5 -- .../src/distributed_input_source_manager.cpp | 56 +------------- .../distributed_input_sourcemanager_test.cpp | 10 --- 22 files changed, 2 insertions(+), 474 deletions(-) diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index d439913..8cfa95c 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -152,13 +152,8 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_IS_START_INPUT_FAIL = -67032; constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_REGISTER_WHITELIST_FAIL = -67033; constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_WHITELIST_FAIL = -67034; - constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_REGISTER_NODE_LISTENER_FAIL = -67035; - constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_NODE_LISTENER_FAIL = -67036; constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_REGISTER_SIMULATION_LISTENER_FAIL = -67037; constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_SIMULATION_LISTENER_FAIL = -67038; - constexpr int32_t ERR_DH_INPUT_SOURCE_PROXY_SYNC_NODE_FAIL = -67039; - constexpr int32_t ERR_DH_INPUT_SOURCE_STUB_REGISTER_NODE_LISTENER_FAIL = -67040; - constexpr int32_t ERR_DH_INPUT_SOURCE_STUB_UNREGISTER_NODE_LISTENER_FAIL = -67041; constexpr int32_t ERR_DH_INPUT_SOURCE_STUB_REGISTER_SIMULATION_EVENT_LISTENER_FAIL = -67042; constexpr int32_t ERR_DH_INPUT_SOURCE_STUB_UNREGISTER_SIMULATION_EVENT_LISTENER_FAIL = -67043; constexpr int32_t ERR_DH_INPUT_SOURCE_STUB_ON_REMOTE_REQUEST_FAIL = -67044; diff --git a/common/include/dinput_ipc_interface_code.h b/common/include/dinput_ipc_interface_code.h index e49f127..43d8db4 100644 --- a/common/include/dinput_ipc_interface_code.h +++ b/common/include/dinput_ipc_interface_code.h @@ -40,8 +40,6 @@ enum class IDInputSourceInterfaceCode : uint32_t { STOP_RELAY_DHID_REMOTE_INPUT = 0xf011U, REGISTER_ADD_WHITE_LIST_CB_REMOTE_INPUT = 0xf013U, REGISTER_DEL_WHITE_LIST_CB_REMOTE_INPUT = 0xf014U, - REGISTER_NODE_LISTENER = 0xf015U, - UNREGISTER_NODE_LISTENER = 0xf016U, REGISTER_SIMULATION_EVENT_LISTENER = 0xf017U, UNREGISTER_SIMULATION_EVENT_LISTENER = 0xf018U, SYNC_NODE_INFO_REMOTE_INPUT = 0xf019U, diff --git a/frameworks/include/i_distributed_source_input.h b/frameworks/include/i_distributed_source_input.h index fbe654a..bb67a24 100644 --- a/frameworks/include/i_distributed_source_input.h +++ b/frameworks/include/i_distributed_source_input.h @@ -92,11 +92,7 @@ public: virtual int32_t RegisterAddWhiteListCallback(sptr addWhiteListCallback) = 0; virtual int32_t RegisterDelWhiteListCallback(sptr delWhiteListCallback) = 0; - virtual int32_t RegisterInputNodeListener(sptr listener) = 0; - virtual int32_t UnregisterInputNodeListener(sptr listener) = 0; - virtual int32_t SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhid, - const std::string &nodeDesc) = 0; virtual int32_t RegisterSimulationEventListener(sptr listener) = 0; virtual int32_t UnregisterSimulationEventListener(sptr listener) = 0; virtual int32_t RegisterSessionStateCb(sptr callback) = 0; diff --git a/interfaces/inner_kits/include/distributed_input_kit.h b/interfaces/inner_kits/include/distributed_input_kit.h index e0ec439..77eec80 100644 --- a/interfaces/inner_kits/include/distributed_input_kit.h +++ b/interfaces/inner_kits/include/distributed_input_kit.h @@ -77,8 +77,6 @@ public: */ static bool IsStartDistributedInput(const std::string &dhId); - static int32_t RegisterInputNodeListener(sptr listener); - static int32_t UnregisterInputNodeListener(sptr listener); static int32_t RegisterSimulationEventListener(sptr listener); static int32_t UnregisterSimulationEventListener(sptr listener); diff --git a/interfaces/inner_kits/src/distributed_input_kit.cpp b/interfaces/inner_kits/src/distributed_input_kit.cpp index 2cdd774..663c696 100644 --- a/interfaces/inner_kits/src/distributed_input_kit.cpp +++ b/interfaces/inner_kits/src/distributed_input_kit.cpp @@ -110,16 +110,6 @@ int32_t DistributedInputKit::StopRemoteInput(const std::string &srcId, const std return DistributedInputClient::GetInstance().StopRemoteInput(srcId, sinkId, dhIds, callback); } -int32_t DistributedInputKit::RegisterInputNodeListener(sptr listener) -{ - return DistributedInputClient::GetInstance().RegisterInputNodeListener(listener); -} - -int32_t DistributedInputKit::UnregisterInputNodeListener(sptr listener) -{ - return DistributedInputClient::GetInstance().UnregisterInputNodeListener(listener); -} - int32_t DistributedInputKit::RegisterSimulationEventListener(sptr listener) { return DistributedInputClient::GetInstance().RegisterSimulationEventListener(listener); diff --git a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp index f1ae4ca..125e04c 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp @@ -459,34 +459,6 @@ HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput03, testing::ext::Tes EXPECT_EQ(true, ret); } -HWTEST_F(DistributedInputInnerTest, RegisterInputNodeListener01, testing::ext::TestSize.Level0) -{ - sptr listener(new TestInputNodeListener()); - int32_t ret = DistributedInputKit::RegisterInputNodeListener(listener); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, RegisterInputNodeListener02, testing::ext::TestSize.Level0) -{ - sptr listener = nullptr; - int32_t ret = DistributedInputKit::RegisterInputNodeListener(listener); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, UnregisterInputNodeListener01, testing::ext::TestSize.Level0) -{ - sptr listener(new TestInputNodeListener()); - int32_t ret = DistributedInputKit::UnregisterInputNodeListener(listener); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, UnregisterInputNodeListener02, testing::ext::TestSize.Level0) -{ - sptr listener = nullptr; - int32_t ret = DistributedInputKit::UnregisterInputNodeListener(listener); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputInnerTest, RegisterSimulationEventListener01, testing::ext::TestSize.Level0) { sptr listener(new TestSimulationEventListenerStub()); diff --git a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp index 81a18cb..7a1a039 100644 --- a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp +++ b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp @@ -218,16 +218,6 @@ bool DistributedInputClient::IsStartDistributedInput(const std::string &dhId) return true; } -int32_t DistributedInputClient::RegisterInputNodeListener(sptr listener) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputClient::UnregisterInputNodeListener(sptr listener) -{ - return DH_SUCCESS; -} - int32_t DistributedInputClient::RegisterSimulationEventListener(sptr listener) { return DH_SUCCESS; diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index c4449ec..4ab2627 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -101,9 +101,6 @@ public: int32_t NotifyStartDScreen(const std::string &networkId, const std::string &srcDevId, const uint64_t srcWinId); int32_t NotifyStopDScreen(const std::string &networkId, const std::string &srcScreenInfoKey); - int32_t RegisterInputNodeListener(sptr listener); - int32_t UnregisterInputNodeListener(sptr listener); - int32_t RegisterSimulationEventListener(sptr listener); int32_t UnregisterSimulationEventListener(sptr listener); diff --git a/interfaces/ipc/include/distributed_input_source_proxy.h b/interfaces/ipc/include/distributed_input_source_proxy.h index 4824e30..0cf8c50 100644 --- a/interfaces/ipc/include/distributed_input_source_proxy.h +++ b/interfaces/ipc/include/distributed_input_source_proxy.h @@ -76,11 +76,7 @@ public: int32_t RegisterAddWhiteListCallback(sptr addWhiteListCallback) override; int32_t RegisterDelWhiteListCallback(sptr delWhiteListCallback) override; - int32_t RegisterInputNodeListener(sptr listener) override; - int32_t UnregisterInputNodeListener(sptr listener) override; - int32_t SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhid, - const std::string &nodeDesc) override; int32_t RegisterSimulationEventListener(sptr listener) override; int32_t UnregisterSimulationEventListener(sptr listener) override; diff --git a/interfaces/ipc/include/distributed_input_source_stub.h b/interfaces/ipc/include/distributed_input_source_stub.h index 19d3aa2..208faea 100644 --- a/interfaces/ipc/include/distributed_input_source_stub.h +++ b/interfaces/ipc/include/distributed_input_source_stub.h @@ -54,9 +54,6 @@ private: int32_t HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterAddWhiteListCallback(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterDelWhiteListCallback(MessageParcel &data, MessageParcel &reply); - int32_t HandleRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply); - int32_t HandleUnRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply); - int32_t HandleSyncNodeInfoRemoteInput(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterSimulationEventListener(MessageParcel &data, MessageParcel &reply); int32_t HandleUnregisterSimulationEventListener(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index 6c4107a..aed168d 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -160,7 +160,6 @@ void DistributedInputClient::CheckSourceRegisterCallback() isSimulationEventCbReg.load()); CheckWhiteListCallback(); - CheckNodeMonitorCallback(); CheckKeyStateCallback(); } @@ -223,19 +222,6 @@ void DistributedInputClient::CheckWhiteListCallback() } } -void DistributedInputClient::CheckNodeMonitorCallback() -{ - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("CheckNodeMonitorCallback client get source proxy fail"); - return; - } - if (!isNodeMonitorCbReg && regNodeListener_ != nullptr) { - DHLOGI("CheckNodeMonitorCallback need continue register regNodeListener_."); - DInputSAManager::GetInstance().dInputSourceProxy_->RegisterInputNodeListener(regNodeListener_); - isNodeMonitorCbReg = true; - } -} - void DistributedInputClient::CheckKeyStateCallback() { if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { @@ -580,50 +566,6 @@ bool DistributedInputClient::IsStartDistributedInput(const std::string &dhId) return sharingDhIds_.find(dhId) != sharingDhIds_.end(); } -int32_t DistributedInputClient::RegisterInputNodeListener(sptr listener) -{ - DHLOGI("RegisterInputNodeListener called"); - if (listener == nullptr) { - DHLOGE("RegisterInputNodeListener param error, client fail"); - return ERR_DH_INPUT_CLIENT_REG_NODE_CB_FAIL; - } - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("RegisterInputNodeListener proxy error, client fail"); - isNodeMonitorCbReg = false; - regNodeListener_ = listener; - return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; - } - - int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterInputNodeListener(listener); - if (ret == DH_SUCCESS) { - isNodeMonitorCbReg = true; - } else { - isNodeMonitorCbReg = false; - regNodeListener_ = listener; - DHLOGE("RegisterInputNodeListener Failed, ret = %d", ret); - } - return ret; -} - -int32_t DistributedInputClient::UnregisterInputNodeListener(sptr listener) -{ - DHLOGI("UnregisterInputNodeListener called"); - if (listener == nullptr) { - DHLOGE("UnregisterInputNodeListener param error, client fail"); - return ERR_DH_INPUT_CLIENT_UNREG_NODE_CB_FAIL; - } - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("UnregisterInputNodeListener proxy error, client fail"); - return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; - } - - int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterInputNodeListener(listener); - if (ret != DH_SUCCESS) { - DHLOGE("DInputSAManager UnregisterInputNodeListener Failed, ret = %d", ret); - } - return ret; -} - int32_t DistributedInputClient::RegisterSimulationEventListener(sptr listener) { DHLOGI("RegisterSimulationEventListener called Simulation Event Listener Register."); diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 8bd4d5d..9dfe5f9 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -580,82 +580,6 @@ int32_t DistributedInputSourceProxy::RegisterDelWhiteListCallback(sptr listener) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - if (!data.WriteRemoteObject(listener->AsObject())) { - DHLOGE("DistributedInputSourceProxy write callback failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_REGISTER_NODE_LISTENER_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::REGISTER_NODE_LISTENER), - data, reply); - if (ret) { - result = reply.ReadInt32(); - } - return result; -} - -int32_t DistributedInputSourceProxy::UnregisterInputNodeListener(sptr listener) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - - if (!data.WriteRemoteObject(listener->AsObject())) { - DHLOGE("DistributedInputSourceProxy write callback failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_UNREGISTER_NODE_LISTENER_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::UNREGISTER_NODE_LISTENER), - data, reply); - if (ret) { - result = reply.ReadInt32(); - } - return result; -} - -int32_t DistributedInputSourceProxy::SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhid, - const std::string &nodeDesc) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - if (!data.WriteString(userDevId)) { - DHLOGE("write SyncNodeInfoRemoteInput userDevId to parcel failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteString(dhid)) { - DHLOGE("write SyncNodeInfoRemoteInput dhid to parcel failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteString(nodeDesc)) { - DHLOGE("write SyncNodeInfoRemoteInput nodeDesc to parcel failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_SYNC_NODE_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::SYNC_NODE_INFO_REMOTE_INPUT), - data, reply); - if (ret) { - result = reply.ReadInt32(); - } - DHLOGI("SyncNodeInfoRemoteInput end, result=%d", result); - return result; -} - int32_t DistributedInputSourceProxy::RegisterSimulationEventListener(sptr listener) { MessageParcel data; diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 7c84fa8..bba0223 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -69,16 +69,10 @@ void DistributedInputSourceStub::RegRespFunMap() &DistributedInputSourceStub::HandleRegisterAddWhiteListCallback; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::REGISTER_DEL_WHITE_LIST_CB_REMOTE_INPUT)] = &DistributedInputSourceStub::HandleRegisterDelWhiteListCallback; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::REGISTER_NODE_LISTENER)] = - &DistributedInputSourceStub::HandleRegisterInputNodeListener; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNREGISTER_NODE_LISTENER)] = - &DistributedInputSourceStub::HandleUnRegisterInputNodeListener; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::REGISTER_SIMULATION_EVENT_LISTENER)] = &DistributedInputSourceStub::HandleRegisterSimulationEventListener; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNREGISTER_SIMULATION_EVENT_LISTENER)] = &DistributedInputSourceStub::HandleUnregisterSimulationEventListener; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::SYNC_NODE_INFO_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::REGISTER_SESSION_STATE_CB)] = &DistributedInputSourceStub::HandleRegisterSessionStateCb; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNREGISTER_SESSION_STATE_CB)] = @@ -504,20 +498,6 @@ int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel return DH_SUCCESS; } -int32_t DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput(MessageParcel &data, MessageParcel &reply) -{ - std::string userDevId = data.ReadString(); - std::string dhid = data.ReadString(); - std::string nodeDesc = data.ReadString(); - - int32_t ret = SyncNodeInfoRemoteInput(userDevId, dhid, nodeDesc); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleSyncNodeInfoRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - return DH_SUCCESS; -} - int32_t DistributedInputSourceStub::HandleRegisterAddWhiteListCallback(MessageParcel &data, MessageParcel &reply) { sptr callback = iface_cast(data.ReadRemoteObject()); @@ -548,38 +528,6 @@ int32_t DistributedInputSourceStub::HandleRegisterDelWhiteListCallback(MessagePa return DH_SUCCESS; } -int32_t DistributedInputSourceStub::HandleRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleRegisterInputNodeListener failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = RegisterInputNodeListener(callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleRegisterInputNodeListener write ret failed"); - return ERR_DH_INPUT_SOURCE_STUB_REGISTER_NODE_LISTENER_FAIL; - } - - return DH_SUCCESS; -} - -int32_t DistributedInputSourceStub::HandleUnRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnRegisterInputNodeListener failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = RegisterInputNodeListener(callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnRegisterInputNodeListener write ret failed"); - return ERR_DH_INPUT_SOURCE_STUB_UNREGISTER_NODE_LISTENER_FAIL; - } - - return DH_SUCCESS; -} - int32_t DistributedInputSourceStub::HandleRegisterSimulationEventListener(MessageParcel &data, MessageParcel &reply) { sptr callback = iface_cast(data.ReadRemoteObject()); diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp index 30a8de3..dfb97c8 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp @@ -224,30 +224,6 @@ int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterDelWhite return DH_SUCCESS; } -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterInputNodeListener( - sptr listener) -{ - (void)listener; - return DH_SUCCESS; -} - -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnregisterInputNodeListener( - sptr listener) -{ - (void)listener; - return DH_SUCCESS; -} - -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::SyncNodeInfoRemoteInput( - const std::string &userDevId, const std::string &dhid, - const std::string &nodeDesc) -{ - (void)userDevId; - (void)dhid; - (void)nodeDesc; - return DH_SUCCESS; -} - int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterSimulationEventListener( sptr listener) { @@ -590,35 +566,6 @@ HWTEST_F(DInputSourceCallBackTest, RegisterDelWhiteListCallback01, testing::ext: EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DInputSourceCallBackTest, RegisterInputNodeListener01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - sptr listener(new TestDInputNodeListenerCallBack()); - int32_t ret = callBackProxy.RegisterInputNodeListener(listener); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DInputSourceCallBackTest, UnregisterInputNodeListener01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - sptr listener(new TestDInputNodeListenerCallBack()); - int32_t ret = callBackProxy.UnregisterInputNodeListener(listener); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DInputSourceCallBackTest, SyncNodeInfoRemoteInput01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - const std::string userDevId = "a4sd654q8w7e9qwe"; - const std::string dhid = "Input_sd65f46df46s54f"; - const std::string nodeDesc = "65d4f6s54f6sd4f665d4sf6"; - int32_t ret = callBackProxy.SyncNodeInfoRemoteInput(userDevId, dhid, nodeDesc); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DInputSourceCallBackTest, RegisterSimulationEventListener01, testing::ext::TestSize.Level1) { sptr callBackStubPtr(new TestDInputSourceCallBackStub()); diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h index 115babd..3ee72e9 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h @@ -98,11 +98,7 @@ public: int32_t RegisterAddWhiteListCallback(sptr addWhiteListCallback); int32_t RegisterDelWhiteListCallback(sptr delWhiteListCallback); - int32_t RegisterInputNodeListener(sptr listener); - int32_t UnregisterInputNodeListener(sptr listener); - int32_t SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhid, - const std::string &nodeDesc); int32_t RegisterSimulationEventListener(sptr listener); int32_t UnregisterSimulationEventListener(sptr listener); int32_t RegisterSessionStateCb(sptr callback); diff --git a/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp b/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp index 12b00e0..11ce0d6 100644 --- a/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp +++ b/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp @@ -213,34 +213,6 @@ HWTEST_F(DistributedInputIpcTest, IsStartDistributedInput03, testing::ext::TestS EXPECT_EQ(false, ret); } -HWTEST_F(DistributedInputIpcTest, RegisterInputNodeListener01, testing::ext::TestSize.Level1) -{ - sptr listener = nullptr; - int32_t ret = DistributedInputClient::GetInstance().RegisterInputNodeListener(listener); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_REG_NODE_CB_FAIL, ret); -} - -HWTEST_F(DistributedInputIpcTest, RegisterInputNodeListener02, testing::ext::TestSize.Level1) -{ - sptr listener(new TestInputNodeListener()); - int32_t ret = DistributedInputClient::GetInstance().RegisterInputNodeListener(listener); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); -} - -HWTEST_F(DistributedInputIpcTest, UnregisterInputNodeListener01, testing::ext::TestSize.Level1) -{ - sptr listener = nullptr; - int32_t ret = DistributedInputClient::GetInstance().UnregisterInputNodeListener(listener); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_UNREG_NODE_CB_FAIL, ret); -} - -HWTEST_F(DistributedInputIpcTest, UnregisterInputNodeListener02, testing::ext::TestSize.Level1) -{ - sptr listener(new TestInputNodeListener()); - int32_t ret = DistributedInputClient::GetInstance().UnregisterInputNodeListener(listener); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); -} - HWTEST_F(DistributedInputIpcTest, RegisterSimulationEventListener01, testing::ext::TestSize.Level1) { sptr listener = nullptr; diff --git a/services/source/inputinject/include/distributed_input_inject.h b/services/source/inputinject/include/distributed_input_inject.h index d9f3c63..b2855f4 100644 --- a/services/source/inputinject/include/distributed_input_inject.h +++ b/services/source/inputinject/include/distributed_input_inject.h @@ -44,17 +44,12 @@ public: const uint32_t sourcePhyWidth, const uint32_t sourcePhyHeight); int32_t RemoveVirtualTouchScreenNode(const std::string &dhId); int32_t GetVirtualTouchScreenFd(); - 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); - void SyncNodeOfflineInfo(const std::string &srcDevId, const std::string &sinkDevId, const std::string &sinkNodeId); - void SyncNodeOnlineInfo(const std::string &srcDevId, const std::string &sinkDevId, const std::string &sinkNodeId, - const std::string &sinkNodeDesc); void GetVirtualKeyboardPathsByDhIds(const std::vector &dhIds, std::vector &virKeyboardPaths, std::vector &virKeyboardDhIds); private: @@ -63,8 +58,6 @@ private: std::unique_ptr inputNodeManager_; std::mutex inputNodeManagerMutex_; - std::set> inputNodeListeners_; - std::mutex inputNodeListenersMutex_; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 792ca4a..a2713ba 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -61,12 +61,7 @@ int32_t DistributedInputInject::RegisterDistributedHardware(const std::string &d return ERR_DH_INPUT_SERVER_SOURCE_INJECT_REGISTER_FAIL; } - std::string srcDevId; - inputNodeManager_->GetDeviceInfo(srcDevId); - DHLOGI("RegisterDistributedHardware called, device type = source, source networkId = %s, sink networkId = %s", - GetAnonyString(srcDevId).c_str(), GetAnonyString(devId).c_str()); - - SyncNodeOnlineInfo(srcDevId, devId, dhId, GetNodeDesc(parameters)); + DHLOGI("RegisterDistributedHardware success"); return DH_SUCCESS; } @@ -94,20 +89,6 @@ int32_t DistributedInputInject::UnregisterDistributedHardware(const std::string return DH_SUCCESS; } -int32_t DistributedInputInject::RegisterInputNodeListener(sptr listener) -{ - std::lock_guard lock(inputNodeListenersMutex_); - this->inputNodeListeners_.insert(listener); - return DH_SUCCESS; -} - -int32_t DistributedInputInject::UnregisterInputNodeListener(sptr listener) -{ - std::lock_guard lock(inputNodeListenersMutex_); - this->inputNodeListeners_.erase(listener); - return DH_SUCCESS; -} - int32_t DistributedInputInject::GetDhIdsByInputType(const std::string &devId, const uint32_t &inputTypes, std::vector &dhIds) { @@ -165,28 +146,6 @@ void DistributedInputInject::InputDeviceEventInject(const std::shared_ptrProcessInjectEvent(rawEvent); } -void DistributedInputInject::SyncNodeOnlineInfo(const std::string &srcDevId, - const std::string &sinkDevId, const std::string &sinkNodeId, const std::string &sinkNodeDesc) -{ - std::lock_guard lock(inputNodeListenersMutex_); - DHLOGI("SyncVirNodeOnlineInfo, srcId: %s, sinkId: %s, dhId: %s", GetAnonyString(srcDevId).c_str(), - GetAnonyString(sinkDevId).c_str(), GetAnonyString(sinkNodeId).c_str()); - for (const auto &listener : inputNodeListeners_) { - listener->OnNodeOnLine(srcDevId, sinkDevId, sinkNodeId, sinkNodeDesc); - } -} - -void DistributedInputInject::SyncNodeOfflineInfo(const std::string &srcDevId, - const std::string &sinkDevId, const std::string &sinkNodeId) -{ - std::lock_guard lock(inputNodeListenersMutex_); - DHLOGI("SyncVirNodeOfflineInfo, srcId: %s, sinkId: %s, dhId: %s", GetAnonyString(srcDevId).c_str(), - GetAnonyString(sinkDevId).c_str(), GetAnonyString(sinkNodeId).c_str()); - for (const auto &listener : inputNodeListeners_) { - listener->OnNodeOffLine(srcDevId, sinkDevId, sinkNodeId); - } -} - int32_t DistributedInputInject::RegisterDistributedEvent(RawEvent *buffer, size_t bufferSize) { std::lock_guard lock(inputNodeManagerMutex_); diff --git a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp index 0c929bb..598f7a7 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -287,19 +287,6 @@ HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedEvent04, testing:: EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_INJECT_NODE_MANAGER_IS_NULL, ret); } -HWTEST_F(DistributedInputSourceInjectTest, RegisterInputNodeListener, testing::ext::TestSize.Level1) -{ - inputNodelistener_ = (std::make_unique()).release(); - int32_t ret = DistributedInputInject::GetInstance().RegisterInputNodeListener(inputNodelistener_); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceInjectTest, UnRegisterInputNodeListener, testing::ext::TestSize.Level1) -{ - int32_t ret = DistributedInputInject::GetInstance().UnregisterInputNodeListener(inputNodelistener_); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputSourceInjectTest, GetDhIdsByInputType_001, testing::ext::TestSize.Level1) { std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index a25cb84..61b6945 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -175,11 +175,7 @@ public: int32_t RegisterAddWhiteListCallback(sptr addWhiteListCallback) override; int32_t RegisterDelWhiteListCallback(sptr delWhiteListCallback) override; - int32_t RegisterInputNodeListener(sptr listener) override; - int32_t UnregisterInputNodeListener(sptr listener) override; - int32_t SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhId, - const std::string &nodeDesc) override; int32_t RegisterSimulationEventListener(sptr listener) override; int32_t UnregisterSimulationEventListener(sptr listener) override; @@ -443,7 +439,6 @@ private: const std::vector &dhIds, sptr callback); bool IsStringDataSame(const std::vector &oldDhIds, std::vector newDhIds); void DeleteNodeInfoAndNotify(const std::string &offlineDevId); - void SendExistVirNodeInfos(sptr listener); std::set GetSyncNodeInfo(const std::string &devId); void UpdateSyncNodeInfo(const std::string &devId, const std::string &dhId, const std::string &nodeDesc); void DeleteSyncNodeInfo(const std::string &devId); diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 56297eb..1c1f293 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -301,16 +301,7 @@ int32_t DistributedInputSourceManager::RegisterDistributedHardware(const std::st // 4.notify source distributedfwk register hardware success callback->OnResult(devId, dhId, DH_SUCCESS); - // 5. notify remote side that this side is registerd remote dhid - sptr cli = DInputSourceSACliMgr::GetInstance().GetRemoteCli(devId); - if (cli == nullptr) { - DHLOGE("Get Remote DInput Source Proxy return null"); - return DH_SUCCESS; - } - - cli->SyncNodeInfoRemoteInput(GetLocalNetworkId(), dhId, GetNodeDesc(parameters)); - - // 6. Notify node mgr to scan vir dev node info + // 5. Notify node mgr to scan vir dev node info DistributedInputInject::GetInstance().NotifyNodeMgrScanVirNode(dhId); return DH_SUCCESS; } @@ -1147,41 +1138,6 @@ int32_t DistributedInputSourceManager::RegisterDelWhiteListCallback(sptr listener) -{ - DHLOGI("RegisterInputNodeListener."); - if (listener == nullptr) { - DHLOGE("RegisterInputNodeListener callback is null."); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_NODE_LISTENER_CALLBACK_ERR; - } - DistributedInputInject::GetInstance().RegisterInputNodeListener(listener); - SendExistVirNodeInfos(listener); - return DH_SUCCESS; -} - -int32_t DistributedInputSourceManager::UnregisterInputNodeListener(sptr listener) -{ - DHLOGI("UnregisterInputNodeListener."); - if (listener == nullptr) { - DHLOGE("UnregisterInputNodeListener callback is null."); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_NODE_LISTENER_CALLBACK_ERR; - } - DistributedInputInject::GetInstance().UnregisterInputNodeListener(listener); - return DH_SUCCESS; -} - -void DistributedInputSourceManager::SendExistVirNodeInfos(sptr listener) -{ - DHLOGI("SendExistVirNodeInfos call"); - std::lock_guard lock(operationMutex_); - DevInfo localDevInfo = GetLocalDeviceInfo(); - for (const auto &node : inputDevice_) { - DHLOGI("Send Exist Vir Node: srcId: %s, sinkId: %s, dhId: %s", GetAnonyString(localDevInfo.networkId).c_str(), - GetAnonyString(node.devId).c_str(), GetAnonyString(node.dhId).c_str()); - listener->OnNodeOnLine(localDevInfo.networkId, node.devId, node.dhId, node.nodeDesc); - } -} - int32_t DistributedInputSourceManager::RegisterSimulationEventListener(sptr listener) { DHLOGI("RegisterSimulationEventListener called."); @@ -1223,16 +1179,6 @@ int32_t DistributedInputSourceManager::UnregisterSessionStateCb() return DH_SUCCESS; } -int32_t DistributedInputSourceManager::SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhId, - const std::string &nodeDesc) -{ - // store info - UpdateSyncNodeInfo(userDevId, dhId, nodeDesc); - // notify multimodal - DistributedInputInject::GetInstance().SyncNodeOnlineInfo(userDevId, GetLocalNetworkId(), dhId, nodeDesc); - return DH_SUCCESS; -} - int32_t DistributedInputSourceManager::RelayPrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) { diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index e9c4c2d..9830edc 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -1073,16 +1073,6 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback02, test EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceManagerTest, RegisterInputNodeListener_01, testing::ext::TestSize.Level1) -{ - sptr callback = nullptr; - int32_t ret = sourceManager_->RegisterInputNodeListener(callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_NODE_LISTENER_CALLBACK_ERR, ret); - - ret = sourceManager_->UnregisterInputNodeListener(callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_NODE_LISTENER_CALLBACK_ERR, ret); -} - HWTEST_F(DistributedInputSourceManagerTest, RegisterSimulationEventListener_01, testing::ext::TestSize.Level1) { sptr callback = nullptr; -- Gitee From fb85d737730b67f53e28cb5e71f18e4251c02bf0 Mon Sep 17 00:00:00 2001 From: hwzhangchuang Date: Tue, 28 Nov 2023 17:56:20 +0800 Subject: [PATCH 2/4] add Signed-off-by: hwzhangchuang --- .../src/distributed_input_inject.cpp | 8 +--- .../distributed_input_source_manager.h | 10 +--- .../src/distributed_input_source_manager.cpp | 48 ------------------- .../distributed_input_sourcemanager_test.cpp | 41 ---------------- 4 files changed, 2 insertions(+), 105 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index a2713ba..65483fe 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -79,13 +79,7 @@ int32_t DistributedInputInject::UnregisterDistributedHardware(const std::string return ERR_DH_INPUT_SERVER_SOURCE_INJECT_UNREGISTER_FAIL; } - std::string srcDevId; - inputNodeManager_->GetDeviceInfo(srcDevId); - - DHLOGI("UnregisterDistributedHardware called, device = %s, dhId = %s, OnNodeOffLine", - GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); - SyncNodeOfflineInfo(srcDevId, devId, dhId); - + DHLOGI("UnregisterDistributedHardware success"); return DH_SUCCESS; } diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index 61b6945..f709759 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -225,9 +225,6 @@ public: void OnMessage(const DHTopic topic, const std::string &message) override; - private: - void DeleteNodeInfoAndNotify(const std::string &offlineDevId); - private: DistributedInputSourceManager *sourceManagerContext_; }; @@ -422,8 +419,6 @@ private: sptr deviceOfflineListener_ = nullptr; std::mutex valMutex_; - std::mutex syncNodeInfoMutex_; - std::map> syncNodeInfoMap_; int32_t RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, sptr callback); @@ -438,10 +433,7 @@ private: int32_t RelayStopRemoteInputByDhid(const std::string &srcId, const std::string &sinkId, const std::vector &dhIds, sptr callback); bool IsStringDataSame(const std::vector &oldDhIds, std::vector newDhIds); - void DeleteNodeInfoAndNotify(const std::string &offlineDevId); - std::set GetSyncNodeInfo(const std::string &devId); - void UpdateSyncNodeInfo(const std::string &devId, const std::string &dhId, const std::string &nodeDesc); - void DeleteSyncNodeInfo(const std::string &devId); + void UnregisterDHFwkPublisher(); }; } // namespace DistributedInput diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 1c1f293..a0fbb8a 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -1669,34 +1669,6 @@ void DistributedInputSourceManager::SetInputTypesMap(const std::string deviceId, InputTypesMap_[deviceId] = value; } -std::set DistributedInputSourceManager::GetSyncNodeInfo(const std::string &devId) -{ - std::lock_guard lock(syncNodeInfoMutex_); - if (syncNodeInfoMap_.find(devId) == syncNodeInfoMap_.end()) { - DHLOGI("syncNodeInfoMap find not the key: %s", GetAnonyString(devId).c_str()); - return {}; - } - return syncNodeInfoMap_[devId]; -} - -void DistributedInputSourceManager::UpdateSyncNodeInfo(const std::string &userDevId, const std::string &dhId, - const std::string &nodeDesc) -{ - std::lock_guard lock(syncNodeInfoMutex_); - if (syncNodeInfoMap_.find(userDevId) == syncNodeInfoMap_.end()) { - DHLOGI("syncNodeInfoMap has not the key: %s, So create this entry", GetAnonyString(userDevId).c_str()); - std::set syncNodeInfo; - syncNodeInfoMap_[userDevId] = syncNodeInfo; - } - syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); -} - -void DistributedInputSourceManager::DeleteSyncNodeInfo(const std::string &devId) -{ - std::lock_guard lock(syncNodeInfoMutex_); - syncNodeInfoMap_.erase(devId); -} - void DistributedInputSourceManager::StartDScreenListener::OnMessage(const DHTopic topic, const std::string &message) { DHLOGI("StartDScreenListener OnMessage!"); @@ -1887,26 +1859,6 @@ void DistributedInputSourceManager::DeviceOfflineListener::OnMessage(const DHTop DHLOGE("this message is empty"); return; } - DeleteNodeInfoAndNotify(message); -} - -void DistributedInputSourceManager::DeviceOfflineListener::DeleteNodeInfoAndNotify(const std::string &offlineDevId) -{ - DHLOGI("DeviceOfflineListener DeleteNodeInfoAndNotify!"); - if (sourceManagerContext_ == nullptr) { - DHLOGE("sourceManagerContext is nullptr!"); - return; - } - std::set nodeSet = sourceManagerContext_->GetSyncNodeInfo(offlineDevId); - std::string localNetWorkId = GetLocalNetworkId(); - for (const auto &node : nodeSet) { - DHLOGI("DeleteNodeInfoAndNotify device: %s, dhId: %s", GetAnonyString(offlineDevId).c_str(), - GetAnonyString(node.dhId).c_str()); - // Notify multimodal - DistributedInputInject::GetInstance().SyncNodeOfflineInfo(offlineDevId, localNetWorkId, node.dhId); - } - // Delete info - sourceManagerContext_->DeleteSyncNodeInfo(offlineDevId); } DistributedInputSourceManager::DScreenSourceSvrRecipient::DScreenSourceSvrRecipient(const std::string &srcDevId, diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index 9830edc..43ed88d 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -1632,47 +1632,6 @@ HWTEST_F(DistributedInputSourceManagerTest, SetInputTypesMap_01, testing::ext::T EXPECT_EQ(true, sourceManager_->InputTypesMap_.empty()); } -HWTEST_F(DistributedInputSourceManagerTest, GetSyncNodeInfo_01, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); - std::string devId = "sd6f4s6d5f46s5d4f654564sdfdfsdfsdfd55"; - sourceManager_->GetSyncNodeInfo(devId); - EXPECT_EQ(1, sourceManager_->GetSyncNodeInfo(userDevId).size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, UpdateSyncNodeInfo_01, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); - sourceManager_->UpdateSyncNodeInfo(userDevId, dhId, nodeDesc); - EXPECT_EQ(1, sourceManager_->syncNodeInfoMap_.size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, UpdateSyncNodeInfo_02, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_.clear(); - sourceManager_->UpdateSyncNodeInfo(userDevId, dhId, nodeDesc); - EXPECT_EQ(1, sourceManager_->syncNodeInfoMap_.size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, DeleteSyncNodeInfo_01, testing::ext::TestSize.Level1) -{ - std::string userDevId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhId = "input_slkdiek3kddkeojfe"; - std::string nodeDesc = "input_deviceid:umkyu1b165e1be98151891erbe8r91ev, input_dhid:slkdiek3kddkeojfe"; - sourceManager_->syncNodeInfoMap_[userDevId].insert({userDevId, dhId, nodeDesc}); - sourceManager_->DeleteSyncNodeInfo(userDevId); - EXPECT_EQ(0, sourceManager_->syncNodeInfoMap_.size()); -} - HWTEST_F(DistributedInputSourceManagerTest, Dump_01, testing::ext::TestSize.Level1) { int32_t fd = 1; -- Gitee From d4735895f7cb4fee1c8066a9d49613c5bf687ca2 Mon Sep 17 00:00:00 2001 From: hwzhangchuang Date: Tue, 28 Nov 2023 18:39:54 +0800 Subject: [PATCH 3/4] add Signed-off-by: hwzhangchuang --- services/source/inputinject/src/distributed_input_inject.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 65483fe..4adf230 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -15,8 +15,6 @@ #include "distributed_input_inject.h" -#include - #include "nlohmann/json.hpp" #include "dinput_errcode.h" -- Gitee From 8b5a64841bf752c76bc4078a9a5937fe8cf0aa89 Mon Sep 17 00:00:00 2001 From: hwzhangchuang Date: Tue, 28 Nov 2023 20:15:29 +0800 Subject: [PATCH 4/4] add Signed-off-by: hwzhangchuang --- services/source/inputinject/src/distributed_input_inject.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 4adf230..65483fe 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -15,6 +15,8 @@ #include "distributed_input_inject.h" +#include + #include "nlohmann/json.hpp" #include "dinput_errcode.h" -- Gitee