From a821fcf473985f3a1f4caa45f57b362024701368 Mon Sep 17 00:00:00 2001 From: l30054665 Date: Wed, 29 Nov 2023 22:28:47 +0800 Subject: [PATCH] delete inputtype Signed-off-by: l30054665 --- common/include/constants_dinput.h | 12 - common/include/input_check_param.cpp | 44 -- common/include/input_check_param.h | 3 - common/include/input_hub.cpp | 45 +- common/include/input_hub.h | 5 +- .../include/i_distributed_source_input.h | 14 - .../include/i_start_d_input_call_back.h | 40 -- frameworks/include/i_stop_d_input_call_back.h | 40 -- .../include/distributed_input_handler.h | 1 - .../src/distributed_input_handler.cpp | 7 - .../distributed_input_handler_test.cpp | 4 - interfaces/inner_kits/BUILD.gn | 4 - .../include/distributed_input_kit.h | 15 +- .../inner_kits/src/distributed_input_kit.cpp | 39 +- interfaces/inner_kits/test/unittest/BUILD.gn | 4 - .../unittest/distributed_input_inner_test.cpp | 101 ---- .../unittest/distributed_input_inner_test.h | 18 - .../mock/mock_distributed_input_client.cpp | 34 +- .../ipc/include/distributed_input_client.h | 16 +- .../include/distributed_input_source_proxy.h | 16 +- .../include/distributed_input_source_stub.h | 4 - .../include/start_d_input_call_back_proxy.h | 42 -- .../include/start_d_input_call_back_stub.h | 42 -- .../include/stop_d_input_call_back_proxy.h | 42 -- .../ipc/include/stop_d_input_call_back_stub.h | 42 -- .../ipc/src/distributed_input_client.cpp | 107 ++-- .../src/distributed_input_source_proxy.cpp | 130 ----- .../ipc/src/distributed_input_source_stub.cpp | 104 ---- .../ipc/src/start_d_input_call_back_proxy.cpp | 69 --- .../ipc/src/start_d_input_call_back_stub.cpp | 58 -- .../ipc/src/stop_d_input_call_back_proxy.cpp | 69 --- .../ipc/src/stop_d_input_call_back_stub.cpp | 58 -- .../BUILD.gn | 4 - .../add_white_list_infos_call_back_test.cpp | 37 -- .../add_white_list_infos_call_back_test.h | 24 - interfaces/ipc/test/clientunittest/BUILD.gn | 4 - .../distributed_input_client_test.cpp | 94 ---- .../distributed_input_client_test.h | 18 - .../dinputsourcecallbackunittest/BUILD.gn | 4 - .../dinput_source_callback_unittest.cpp | 128 +---- .../dinput_source_callback_unittest.h | 30 -- interfaces/ipc/test/ipcunittest/BUILD.gn | 4 - .../distributed_input_ipc_test.cpp | 38 -- .../include/dinput_sink_trans_callback.h | 6 - .../common/include/dinput_softbus_define.h | 2 - .../include/dinput_source_trans_callback.h | 7 - .../include/distributed_input_collector.h | 3 - .../src/distributed_input_collector.cpp | 29 +- .../distributed_input_collector_test.cpp | 45 -- .../include/distributed_input_sink_manager.h | 11 - .../src/distributed_input_sink_manager.cpp | 175 ------ .../distributed_input_sinkmanager_test.cpp | 8 - .../distributed_input_sink_transport.h | 6 - .../src/distributed_input_sink_transport.cpp | 105 ---- .../distributed_input_sinktrans_test.cpp | 10 - .../include/distributed_input_inject.h | 1 - .../include/distributed_input_node_manager.h | 2 - .../src/distributed_input_inject.cpp | 4 +- .../src/distributed_input_node_manager.cpp | 34 -- .../distributed_input_sourceinject_test.cpp | 42 +- services/source/sourcemanager/BUILD.gn | 4 - .../include/dinput_source_listener.h | 7 - .../dinput_source_manager_event_handler.h | 2 - .../distributed_input_source_manager.h | 63 --- .../src/dinput_source_listener.cpp | 127 +---- .../dinput_source_manager_event_handler.cpp | 109 ---- .../src/distributed_input_source_manager.cpp | 339 ------------ .../test/sourcemanagerunittest/BUILD.gn | 4 - .../distributed_input_sourcemanager_test.cpp | 502 ------------------ .../distributed_input_sourcemanager_test.h | 18 - .../distributed_input_source_transport.h | 20 - .../distributed_input_source_transport.cpp | 404 -------------- .../distributed_input_sourcetrans_test.cpp | 259 --------- .../include/distributed_input_sink_handler.h | 4 - .../src/distributed_input_sink_handler.cpp | 20 - .../mock/mock_distributed_input_client.cpp | 12 - .../mock/mock_distributed_input_client.cpp | 12 - .../distributed_input_kit_fuzzer.cpp | 36 -- utils/include/dinput_utils_tool.h | 1 - utils/src/dinput_utils_tool.cpp | 11 - 80 files changed, 112 insertions(+), 3946 deletions(-) delete mode 100644 frameworks/include/i_start_d_input_call_back.h delete mode 100644 frameworks/include/i_stop_d_input_call_back.h delete mode 100644 interfaces/ipc/include/start_d_input_call_back_proxy.h delete mode 100644 interfaces/ipc/include/start_d_input_call_back_stub.h delete mode 100644 interfaces/ipc/include/stop_d_input_call_back_proxy.h delete mode 100644 interfaces/ipc/include/stop_d_input_call_back_stub.h delete mode 100644 interfaces/ipc/src/start_d_input_call_back_proxy.cpp delete mode 100644 interfaces/ipc/src/start_d_input_call_back_stub.cpp delete mode 100644 interfaces/ipc/src/stop_d_input_call_back_proxy.cpp delete mode 100644 interfaces/ipc/src/stop_d_input_call_back_stub.cpp diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index 4543d32..96c6342 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -49,18 +49,6 @@ namespace DistributedInput { const uint32_t AUTH_SESSION_SIDE_SERVER = 0; const uint32_t IPC_VECTOR_MAX_SIZE = 32; - /* - * Device Type definitions - */ - enum class DInputDeviceType : uint32_t { - NONE = 0x0000, - MOUSE = 0x0001, - KEYBOARD = 0x0002, - TOUCHSCREEN = 0x0004, - TOUCHPAD = MOUSE, - ALL = MOUSE | KEYBOARD | TOUCHSCREEN, - }; - const char * const DEVICE_PATH = "/dev/input"; /* diff --git a/common/include/input_check_param.cpp b/common/include/input_check_param.cpp index af980bd..0964d34 100644 --- a/common/include/input_check_param.cpp +++ b/common/include/input_check_param.cpp @@ -39,50 +39,6 @@ bool DInputCheckParam::CheckParam(const std::string &deviceId, sptr callback) -{ - if (deviceId.empty() || deviceId.size() > DEV_ID_LENGTH_MAX) { - DHLOGE("CheckParam deviceId is empty or deviceId size too long."); - return false; - } - if (inputTypes > static_cast(DInputDeviceType::ALL) || - inputTypes == static_cast(DInputDeviceType::NONE) || - !(inputTypes & static_cast(DInputDeviceType::ALL))) { - DHLOGE("CheckParam, inputTypes is invalids."); - return false; - } - if (callback == nullptr) { - DHLOGE("CheckParam callback is null."); - return false; - } - return true; -} - -bool DInputCheckParam::CheckParam(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) -{ - if (srcId.empty() || srcId.size() > DEV_ID_LENGTH_MAX) { - DHLOGE("CheckParam srcId is empty or srcId size too long."); - return false; - } - if (sinkId.empty() || sinkId.size() > DEV_ID_LENGTH_MAX) { - DHLOGE("CheckParam sinkId is empty or sinkId size too long."); - return false; - } - if (inputTypes > static_cast(DInputDeviceType::ALL) || - inputTypes == static_cast(DInputDeviceType::NONE) || - !(inputTypes & static_cast(DInputDeviceType::ALL))) { - DHLOGE("CheckParam, inputTypes is invalids."); - return false; - } - if (callback == nullptr) { - DHLOGE("CheckParam callback is null."); - return false; - } - return true; -} - bool DInputCheckParam::CheckParam(const std::string &srcId, const std::string &sinkId, sptr callback) { diff --git a/common/include/input_check_param.h b/common/include/input_check_param.h index 1643726..b2f9dc0 100644 --- a/common/include/input_check_param.h +++ b/common/include/input_check_param.h @@ -27,9 +27,6 @@ class DInputCheckParam { public: static DInputCheckParam &GetInstance(void); bool CheckParam(const std::string &deviceId, sptr callback); - bool CheckParam(const std::string &deviceId, const uint32_t &inputTypes, sptr callback); - bool CheckParam(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); bool CheckParam(const std::string &srcId, const std::string &sinkId, sptr callback); bool CheckParam(const std::string &sinkId, const std::vector &dhIds, sptr callback); diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 4f08970..0877268 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -46,7 +46,7 @@ const std::string MOUSE_NODE_KEY = "mouse"; InputHub::InputHub() : epollFd_(0), iNotifyFd_(0), inputWd_(0), needToScanDevices_(true), nextDeviceId_(1), mPendingEventItems{}, pendingEventCount_(0), pendingEventIndex_(0), pendingINotify_(false), deviceChanged_(false), - inputTypes_(0), isStartCollectEvent_(false), isStartCollectHandler_(false) + isStartCollectEvent_(false), isStartCollectHandler_(false) { Initialize(); } @@ -847,7 +847,6 @@ int32_t InputHub::MakeDevice(int fd, std::unique_ptr device) device->identifier.classes = device->classes; - DHLOGI("inputType=%d", inputTypes_.load()); DHLOGI("New device: fd=%d, name='%s', classes=0x%x", fd, device->identifier.name.c_str(), device->classes); @@ -1166,23 +1165,6 @@ void InputHub::SaveAffectDhId(bool isEnable, const std::string &dhId, AffectDhId } } -AffectDhIds InputHub::SetSupportInputType(bool enabled, const uint32_t &inputTypes) -{ - AffectDhIds affDhIds; - inputTypes_ = inputTypes; - DHLOGI("SetSupportInputType: inputTypes=0x%x,", inputTypes_.load()); - std::lock_guard deviceLock(devicesMutex_); - for (const auto &[id, device] : devices_) { - if (device->classes & inputTypes_) { - device->isShare = enabled; - DHLOGW("ByType dhid:%s, isshare:%d", GetAnonyString(device->identifier.descriptor).c_str(), enabled); - SaveAffectDhId(enabled, device->identifier.descriptor, affDhIds); - } - } - - return affDhIds; -} - AffectDhIds InputHub::SetSharingDevices(bool enabled, std::vector dhIds) { AffectDhIds affDhIds; @@ -1253,30 +1235,6 @@ void InputHub::GetSharedKeyboardPathsByDhIds(const std::vector &dhI } } -void InputHub::GetDevicesInfoByType(const uint32_t inputTypes, std::map &datas) -{ - uint32_t dhType = 0; - - if ((inputTypes & static_cast(DInputDeviceType::MOUSE)) != 0) { - dhType |= INPUT_DEVICE_CLASS_CURSOR; - } - - if ((inputTypes & static_cast(DInputDeviceType::KEYBOARD)) != 0) { - dhType |= INPUT_DEVICE_CLASS_KEYBOARD; - } - - if ((inputTypes & static_cast(DInputDeviceType::TOUCHSCREEN)) != 0) { - dhType |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT; - } - - std::lock_guard deviceLock(devicesMutex_); - for (const auto &[id, device] : devices_) { - if (device->classes & dhType) { - datas.insert(std::pair(device->fd, device->identifier.descriptor)); - } - } -} - void InputHub::GetDevicesInfoByDhId(std::vector dhidsVec, std::map &datas) { for (auto dhId : dhidsVec) { @@ -1529,7 +1487,6 @@ void InputHub::CheckTargetKeyState(const InputHub::Device *dev, const unsigned l } } - void InputHub::CheckTargetDevicesState(std::vector targetDevices) { uint32_t count = 0; diff --git a/common/include/input_hub.h b/common/include/input_hub.h index d702e2d..1729574 100644 --- a/common/include/input_hub.h +++ b/common/include/input_hub.h @@ -82,11 +82,9 @@ public: void StopCollectInputHandler(); size_t DeviceIsExists(InputDeviceEvent *buffer, size_t bufferSize); std::vector GetAllInputDevices(); - // return efftive dhids - AffectDhIds SetSupportInputType(bool enabled, const uint32_t &inputTypes); + // return efftive dhids AffectDhIds SetSharingDevices(bool enabled, std::vector dhIds); - void GetDevicesInfoByType(const uint32_t inputTypes, std::map &datas); void GetDevicesInfoByDhId(std::vector dhidsVec, std::map &datas); void GetSharedMousePathByDhId(const std::vector &dhIds, std::string &sharedMousePath, std::string &sharedMouseDhId); @@ -225,7 +223,6 @@ private: std::mutex operationMutex_; std::atomic deviceChanged_; - std::atomic inputTypes_; std::atomic isStartCollectEvent_; std::atomic isStartCollectHandler_; std::unordered_map sharedDHIds_; diff --git a/frameworks/include/i_distributed_source_input.h b/frameworks/include/i_distributed_source_input.h index bb67a24..f583f1e 100644 --- a/frameworks/include/i_distributed_source_input.h +++ b/frameworks/include/i_distributed_source_input.h @@ -27,8 +27,6 @@ #include "i_del_white_list_infos_call_back.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" -#include "i_stop_d_input_call_back.h" #include "i_start_stop_d_inputs_call_back.h" #include "i_start_stop_result_call_back.h" #include "i_unprepare_d_input_call_back.h" @@ -60,18 +58,6 @@ public: virtual int32_t UnprepareRemoteInput(const std::string &deviceId, sptr callback) = 0; - virtual int32_t StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) = 0; - - virtual int32_t StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) = 0; - - virtual int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) = 0; - - virtual int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) = 0; - virtual int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) = 0; diff --git a/frameworks/include/i_start_d_input_call_back.h b/frameworks/include/i_start_d_input_call_back.h deleted file mode 100644 index 8c02692..0000000 --- a/frameworks/include/i_start_d_input_call_back.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021-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_START_D_INPUT_CALL_BACK_H -#define I_START_D_INPUT_CALL_BACK_H - -#include - -#include - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -class IStartDInputCallback : public IRemoteBroker { -public: - virtual void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) = 0; - - enum class Message { - RESULT, - }; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IStartDInputCallback"); -}; -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS - -#endif // I_START_D_INPUT_CALL_BACK_H diff --git a/frameworks/include/i_stop_d_input_call_back.h b/frameworks/include/i_stop_d_input_call_back.h deleted file mode 100644 index c54cd1d..0000000 --- a/frameworks/include/i_stop_d_input_call_back.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021-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_STOP_D_INPUT_CALL_BACK_H -#define I_STOP_D_INPUT_CALL_BACK_H - -#include - -#include - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -class IStopDInputCallback : public IRemoteBroker { -public: - virtual void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) = 0; - - enum class Message { - RESULT, - }; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IStopDInputCallback"); -}; -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS - -#endif // I_STOP_D_INPUT_CALL_BACK_H diff --git a/inputdevicehandler/include/distributed_input_handler.h b/inputdevicehandler/include/distributed_input_handler.h index 16087a8..59840e6 100644 --- a/inputdevicehandler/include/distributed_input_handler.h +++ b/inputdevicehandler/include/distributed_input_handler.h @@ -47,7 +47,6 @@ public: API_EXPORT void RegisterPluginListener(std::shared_ptr listener) override; API_EXPORT void UnRegisterPluginListener() override; - API_EXPORT void FindDevicesInfoByType(const uint32_t inputTypes, std::map &datas); API_EXPORT void FindDevicesInfoByDhId(std::vector dhidsVec, std::map &datas); private: DistributedInputHandler(); diff --git a/inputdevicehandler/src/distributed_input_handler.cpp b/inputdevicehandler/src/distributed_input_handler.cpp index 6972463..3da58df 100644 --- a/inputdevicehandler/src/distributed_input_handler.cpp +++ b/inputdevicehandler/src/distributed_input_handler.cpp @@ -95,13 +95,6 @@ int32_t DistributedInputHandler::Initialize() return DH_SUCCESS; } -void DistributedInputHandler::FindDevicesInfoByType(const uint32_t inputTypes, std::map &datas) -{ - if (inputHub_ != nullptr) { - inputHub_->GetDevicesInfoByType(inputTypes, datas); - } -} - void DistributedInputHandler::FindDevicesInfoByDhId( std::vector dhidsVec, std::map &datas) { diff --git a/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp b/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp index 979a5cd..38989c8 100644 --- a/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp +++ b/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp @@ -42,10 +42,8 @@ void DInputHandlerTest::TearDownTestCase() HWTEST_F(DInputHandlerTest, QueryExtraInfo_001, testing::ext::TestSize.Level1) { DistributedInputHandler dInputHandler; - uint32_t inputTypes = static_cast(DInputDeviceType::ALL); std::map datas; std::vector dhidsVec; - dInputHandler.FindDevicesInfoByType(inputTypes, datas); dInputHandler.FindDevicesInfoByDhId(dhidsVec, datas); std::map ret = dInputHandler.QueryExtraInfo(); EXPECT_EQ(0, ret.size()); @@ -55,11 +53,9 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le { DistributedInputHandler dInputHandler; dInputHandler.inputHub_ = nullptr; - uint32_t inputTypes = static_cast(DInputDeviceType::ALL); std::map datas; std::vector dhidsVec; std::string deviceId = "deviceId_test"; - dInputHandler.FindDevicesInfoByType(inputTypes, datas); dInputHandler.FindDevicesInfoByDhId(dhidsVec, datas); dInputHandler.Query(); dInputHandler.StartInputMonitorDeviceThread(deviceId); diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 0dc7ba2..081edd2 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -71,14 +71,10 @@ ohos_shared_library("libdinput_sdk") { "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", "${ipc_path}/src/start_stop_result_call_back_proxy.cpp", "${ipc_path}/src/start_stop_result_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", diff --git a/interfaces/inner_kits/include/distributed_input_kit.h b/interfaces/inner_kits/include/distributed_input_kit.h index 77eec80..9594f3b 100644 --- a/interfaces/inner_kits/include/distributed_input_kit.h +++ b/interfaces/inner_kits/include/distributed_input_kit.h @@ -24,8 +24,6 @@ #include "distributed_input_client.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" -#include "i_stop_d_input_call_back.h" #include "i_start_stop_d_inputs_call_back.h" #include "i_start_stop_result_call_back.h" #include "i_unregister_d_input_call_back.h" @@ -46,21 +44,11 @@ public: static int32_t UnprepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback); - static int32_t StartRemoteInput( - const std::string &sinkId, const uint32_t &inputTypes, sptr callback); - static int32_t StopRemoteInput( - const std::string &sinkId, const uint32_t &inputTypes, sptr callback); - static int32_t StartRemoteInput(const std::string &sinkId, const std::vector &dhIds, sptr callback); static int32_t StopRemoteInput(const std::string &sinkId, const std::vector &dhIds, sptr callback); - static int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - static int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - static int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const std::vector &dhIds, sptr callback); static int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, @@ -69,7 +57,6 @@ public: static bool IsNeedFilterOut(const std::string &sinkId, const BusinessEvent &event); static bool IsTouchEventNeedFilterOut(const TouchScreenEvent &event); - static DInputServerType IsStartDistributedInput(const uint32_t &inputType); /* * check is dhId sharing to other devices * true: dhId sharing to other device @@ -77,6 +64,8 @@ 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 663c696..f0c4caf 100644 --- a/interfaces/inner_kits/src/distributed_input_kit.cpp +++ b/interfaces/inner_kits/src/distributed_input_kit.cpp @@ -30,30 +30,6 @@ int32_t DistributedInputKit::UnprepareRemoteInput( return DistributedInputClient::GetInstance().UnprepareRemoteInput(sinkId, callback); } -int32_t DistributedInputKit::StartRemoteInput( - const std::string &sinkId, const uint32_t &inputTypes, sptr callback) -{ - return DistributedInputClient::GetInstance().StartRemoteInput(sinkId, inputTypes, callback); -} - -int32_t DistributedInputKit::StopRemoteInput( - const std::string &sinkId, const uint32_t &inputTypes, sptr callback) -{ - return DistributedInputClient::GetInstance().StopRemoteInput(sinkId, inputTypes, callback); -} - -int32_t DistributedInputKit::StartRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - return DistributedInputClient::GetInstance().StartRemoteInput(srcId, sinkId, inputTypes, callback); -} - -int32_t DistributedInputKit::StopRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - return DistributedInputClient::GetInstance().StopRemoteInput(srcId, sinkId, inputTypes, callback); -} - bool DistributedInputKit::IsNeedFilterOut(const std::string &sinkId, const BusinessEvent &event) { return DistributedInputClient::GetInstance().IsNeedFilterOut(sinkId, event); @@ -64,11 +40,6 @@ bool DistributedInputKit::IsTouchEventNeedFilterOut(const TouchScreenEvent &even return DistributedInputClient::GetInstance().IsTouchEventNeedFilterOut(event); } -DInputServerType DistributedInputKit::IsStartDistributedInput(const uint32_t &inputType) -{ - return DInputServerType::NULL_SERVER_TYPE; -} - bool DistributedInputKit::IsStartDistributedInput(const std::string &dhId) { return DistributedInputClient::GetInstance().IsStartDistributedInput(dhId); @@ -110,6 +81,16 @@ 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/BUILD.gn b/interfaces/inner_kits/test/unittest/BUILD.gn index c8ca062..e8120ac 100644 --- a/interfaces/inner_kits/test/unittest/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/BUILD.gn @@ -66,14 +66,10 @@ ohos_unittest("distributed_input_inner_test") { "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", "${ipc_path}/src/start_stop_result_call_back_proxy.cpp", "${ipc_path}/src/start_stop_result_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", 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 125e04c..4a795ed 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp @@ -59,24 +59,6 @@ void DistributedInputInnerTest::TestUnprepareDInputCallback::OnResult( return; } -void DistributedInputInnerTest::TestStartDInputCallback::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - -void DistributedInputInnerTest::TestStopDInputCallback::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - void DistributedInputInnerTest::TestStartStopDInputCallback::OnResultDhids( const std::string &devId, const int32_t &status) { @@ -229,24 +211,6 @@ HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput04, testing::ext::TestSi EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputInnerTest, StartRemoteInput01, testing::ext::TestSize.Level0) -{ - string deviceId = "StartRemoteInput01"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = - DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, StartRemoteInput02, testing::ext::TestSize.Level0) -{ - string deviceId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputInnerTest, StartRemoteInput03, testing::ext::TestSize.Level0) { std::string sinkId = "StartRemoteInput_sink"; @@ -265,26 +229,6 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput04, testing::ext::TestSize.L EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputInnerTest, StartRemoteInput05, testing::ext::TestSize.Level0) -{ - string srcId = "StartRemoteInput01-src"; - string sinkId = "StartRemoteInput01-sink"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = - DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, StartRemoteInput06, testing::ext::TestSize.Level0) -{ - string srcId = ""; - string sinkId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputInnerTest, StartRemoteInput07, testing::ext::TestSize.Level0) { string srcId = "StartRemoteInput01-src"; @@ -305,24 +249,6 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput08, testing::ext::TestSize.L EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputInnerTest, StopRemoteInput01, testing::ext::TestSize.Level0) -{ - string deviceId = "StopRemoteInput01"; - sptr callback(new TestStopDInputCallback()); - int32_t ret = - DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, StopRemoteInput02, testing::ext::TestSize.Level0) -{ - string deviceId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputInnerTest, StopRemoteInput03, testing::ext::TestSize.Level0) { std::string sinkId = "StartRemoteInput_test"; @@ -341,26 +267,6 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput04, testing::ext::TestSize.Le EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputInnerTest, StopRemoteInput05, testing::ext::TestSize.Level0) -{ - string srcId = "StopRemoteInput03-src"; - string sinkId = "StopRemoteInput03-sink"; - sptr callback(new TestStopDInputCallback()); - int32_t ret = - DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputInnerTest, StopRemoteInput06, testing::ext::TestSize.Level0) -{ - string srcId = ""; - string sinkId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputInnerTest, StopRemoteInput07, testing::ext::TestSize.Level0) { string srcId = "StartRemoteInput01-src"; @@ -438,13 +344,6 @@ HWTEST_F(DistributedInputInnerTest, IsTouchEventNeedFilterOut01, testing::ext::T EXPECT_EQ(false, ret); } -HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput01, testing::ext::TestSize.Level0) -{ - uint32_t flag = 1; - DInputServerType retFlag = DistributedInputKit::IsStartDistributedInput(flag); - EXPECT_EQ(DInputServerType::NULL_SERVER_TYPE, retFlag); -} - HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput02, testing::ext::TestSize.Level0) { std::string dhId = "IsStartDistributedInput02"; diff --git a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h index a9ab92b..5606bf7 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h @@ -33,8 +33,6 @@ #include "i_distributed_source_input.h" #include "start_stop_d_inputs_call_back_stub.h" #include "prepare_d_input_call_back_stub.h" -#include "start_d_input_call_back_stub.h" -#include "stop_d_input_call_back_stub.h" #include "simulation_event_listener_stub.h" #include "unprepare_d_input_call_back_stub.h" @@ -66,22 +64,6 @@ public: void OnResult(const std::string &deviceId, const int32_t &status); }; - class TestStartDInputCallback : public - OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { - public: - TestStartDInputCallback() = default; - virtual ~TestStartDInputCallback() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - - class TestStopDInputCallback : public - OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { - public: - TestStopDInputCallback() = default; - virtual ~TestStopDInputCallback() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - class TestStartStopDInputCallback : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { public: 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 7a1a039..c7964e0 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 @@ -139,42 +139,18 @@ int32_t DistributedInputClient::UnprepareRemoteInput( return DH_SUCCESS; } -int32_t DistributedInputClient::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - int32_t DistributedInputClient::StartRemoteInput( const std::string &sinkId, const std::vector &dhIds, sptr callback) { return DH_SUCCESS; } -int32_t DistributedInputClient::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - int32_t DistributedInputClient::StopRemoteInput( const std::string &sinkId, const std::vector &dhIds, sptr callback) { return DH_SUCCESS; } -int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputClient::StopRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId, const std::vector &dhIds, sptr callback) { @@ -218,6 +194,16 @@ 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 4ab2627..245573d 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -66,18 +66,6 @@ public: int32_t UnprepareRemoteInput(const std::string &deviceId, sptr callback); - int32_t StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback); - - int32_t StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback); - - int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - - int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback); int32_t UnprepareRemoteInput(const std::string &srcId, const std::string &sinkId, @@ -101,6 +89,9 @@ 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); @@ -180,7 +171,6 @@ private: static std::shared_ptr instance; DInputServerType serverType = DInputServerType::NULL_SERVER_TYPE; - DInputDeviceType inputTypes_ = DInputDeviceType::NONE; std::set> addWhiteListCallbacks_; std::set> delWhiteListCallbacks_; diff --git a/interfaces/ipc/include/distributed_input_source_proxy.h b/interfaces/ipc/include/distributed_input_source_proxy.h index 0cf8c50..d723e61 100644 --- a/interfaces/ipc/include/distributed_input_source_proxy.h +++ b/interfaces/ipc/include/distributed_input_source_proxy.h @@ -44,18 +44,6 @@ public: int32_t UnprepareRemoteInput(const std::string &deviceId, sptr callback) override; - int32_t StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) override; - - int32_t StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) override; - - int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) override; - - int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) override; - int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) override; @@ -76,7 +64,11 @@ 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 208faea..d58e8e1 100644 --- a/interfaces/ipc/include/distributed_input_source_stub.h +++ b/interfaces/ipc/include/distributed_input_source_stub.h @@ -42,10 +42,6 @@ private: int32_t HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply); int32_t HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply); int32_t HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply); - int32_t HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply); - int32_t HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply); - int32_t HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply); - int32_t HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply); int32_t HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply); int32_t HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply); int32_t HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/ipc/include/start_d_input_call_back_proxy.h b/interfaces/ipc/include/start_d_input_call_back_proxy.h deleted file mode 100644 index 7239628..0000000 --- a/interfaces/ipc/include/start_d_input_call_back_proxy.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021-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 START_D_INPUT_CALL_BACK_PROXY_H -#define START_D_INPUT_CALL_BACK_PROXY_H - -#include "i_start_d_input_call_back.h" - -#include - -#include "iremote_proxy.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -class StartDInputCallbackProxy : public IRemoteProxy { -public: - explicit StartDInputCallbackProxy(const sptr &object); - ~StartDInputCallbackProxy() override; - - void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS - -#endif // START_D_INPUT_CALL_BACK_PROXY_H diff --git a/interfaces/ipc/include/start_d_input_call_back_stub.h b/interfaces/ipc/include/start_d_input_call_back_stub.h deleted file mode 100644 index 7c3932a..0000000 --- a/interfaces/ipc/include/start_d_input_call_back_stub.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef START_D_INPUT_CALL_BACK_STUB_H -#define START_D_INPUT_CALL_BACK_STUB_H - -#include "i_start_d_input_call_back.h" - -#include - -#include "iremote_stub.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -class StartDInputCallbackStub : public IRemoteStub { -public: - StartDInputCallbackStub(); - ~StartDInputCallbackStub() override; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - DISALLOW_COPY_AND_MOVE(StartDInputCallbackStub); -}; -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS - -#endif // START_D_INPUT_CALL_BACK_STUB_H diff --git a/interfaces/ipc/include/stop_d_input_call_back_proxy.h b/interfaces/ipc/include/stop_d_input_call_back_proxy.h deleted file mode 100644 index 67def3c..0000000 --- a/interfaces/ipc/include/stop_d_input_call_back_proxy.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021-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 STOP_D_INPUT_CALL_BACK_PROXY_H -#define STOP_D_INPUT_CALL_BACK_PROXY_H - -#include "i_stop_d_input_call_back.h" - -#include - -#include "iremote_proxy.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -class StopDInputCallbackProxy : public IRemoteProxy { -public: - explicit StopDInputCallbackProxy(const sptr &object); - ~StopDInputCallbackProxy() override; - - void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS - -#endif // STOP_D_INPUT_CALL_BACK_PROXY_H diff --git a/interfaces/ipc/include/stop_d_input_call_back_stub.h b/interfaces/ipc/include/stop_d_input_call_back_stub.h deleted file mode 100644 index 3649a27..0000000 --- a/interfaces/ipc/include/stop_d_input_call_back_stub.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef STOP_D_INPUT_CALL_BACK_STUB_H -#define STOP_D_INPUT_CALL_BACK_STUB_H - -#include "i_stop_d_input_call_back.h" - -#include - -#include "iremote_stub.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -class StopDInputCallbackStub : public IRemoteStub { -public: - StopDInputCallbackStub(); - ~StopDInputCallbackStub() override; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - DISALLOW_COPY_AND_MOVE(StopDInputCallbackStub); -}; -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS - -#endif // STOP_D_INPUT_CALL_BACK_STUB_H diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index aed168d..1afb033 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -34,7 +34,7 @@ namespace DistributedHardware { namespace DistributedInput { std::shared_ptr DistributedInputClient::instance(new DistributedInputClient()); DistributedInputClient::DistributedInputClient() : isAddWhiteListCbReg(false), isDelWhiteListCbReg(false), - isNodeMonitorCbReg(false), isSimulationEventCbReg(false), isSharingDhIdsReg(false), isGetSinkScreenInfosCbReg(false) + isNodeMonitorCbReg(false), isSimulationEventCbReg(false), isSharingDhIdsReg(false) { DHLOGI("DistributedInputClient init start"); std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); @@ -277,7 +277,6 @@ int32_t DistributedInputClient::ReleaseSource() } serverType = DInputServerType::NULL_SERVER_TYPE; - inputTypes_ = DInputDeviceType::NONE; regNodeListener_ = nullptr; unregNodeListener_ = nullptr; regSimulationEventListener_ = nullptr; @@ -297,7 +296,6 @@ int32_t DistributedInputClient::ReleaseSink() return ERR_DH_INPUT_CLIENT_GET_SINK_PROXY_FAIL; } serverType = DInputServerType::NULL_SERVER_TYPE; - inputTypes_ = DInputDeviceType::NONE; { std::lock_guard lock(operationMutex_); getSinkScreenInfosCallbacks_.clear(); @@ -388,65 +386,6 @@ int32_t DistributedInputClient::UnprepareRemoteInput(const std::string &deviceId return DInputSAManager::GetInstance().dInputSourceProxy_->UnprepareRemoteInput(deviceId, callback); } -int32_t DistributedInputClient::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - DHLOGI("DinputStart called, deviceId: %s, inputTypes: %d.", GetAnonyString(deviceId).c_str(), inputTypes); - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("DinputStart client fail."); - return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; - } - if (!DInputCheckParam::GetInstance().CheckParam(deviceId, inputTypes, callback)) { - return ERR_DH_INPUT_CLIENT_START_FAIL; - } - return DInputSAManager::GetInstance().dInputSourceProxy_->StartRemoteInput(deviceId, inputTypes, callback); -} - -int32_t DistributedInputClient::StopRemoteInput(const std::string &deviceId, const uint32_t &inputTypes, - sptr callback) -{ - DHLOGI("DinputStop called, deviceId: %s, inputTypes: %d.", GetAnonyString(deviceId).c_str(), inputTypes); - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("DinputStop client fail."); - return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; - } - if (!DInputCheckParam::GetInstance().CheckParam(deviceId, inputTypes, callback)) { - return ERR_DH_INPUT_CLIENT_STOP_FAIL; - } - return DInputSAManager::GetInstance().dInputSourceProxy_->StopRemoteInput(deviceId, inputTypes, callback); -} - -int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - DHLOGI("DinputStart called, srcId: %s, sinkId: %s, inputTypes: %d.", GetAnonyString(srcId).c_str(), - GetAnonyString(sinkId).c_str(), inputTypes); - - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("DinputStart relay type client fail."); - return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; - } - if (!DInputCheckParam::GetInstance().CheckParam(srcId, sinkId, inputTypes, callback)) { - return ERR_DH_INPUT_CLIENT_START_FAIL; - } - return DInputSAManager::GetInstance().dInputSourceProxy_->StartRemoteInput(srcId, sinkId, inputTypes, callback); -} - -int32_t DistributedInputClient::StopRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - DHLOGI("DinputStop called, srcId: %s, sinkId: %s, inputTypes: %d.", GetAnonyString(srcId).c_str(), - GetAnonyString(sinkId).c_str(), inputTypes); - if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) { - DHLOGE("DinputStop relay type client fail."); - return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; - } - if (!DInputCheckParam::GetInstance().CheckParam(srcId, sinkId, inputTypes, callback)) { - return ERR_DH_INPUT_CLIENT_STOP_FAIL; - } - return DInputSAManager::GetInstance().dInputSourceProxy_->StopRemoteInput(srcId, sinkId, inputTypes, callback); -} - int32_t DistributedInputClient::PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) { @@ -566,6 +505,50 @@ 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 9dfe5f9..43f13af 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -176,136 +176,6 @@ int32_t DistributedInputSourceProxy::UnprepareRemoteInput(const std::string &dev return result; } -int32_t DistributedInputSourceProxy::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - DHLOGI("source proxy StartRemoteInput start"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - if (!data.WriteString(deviceId)) { - DHLOGE("DistributedInputSourceProxy write deviceId failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteUint32(inputTypes)) { - DHLOGE("DistributedInputSourceProxy write inputTypes failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("DistributedInputSourceProxy write callback failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_START_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::START_REMOTE_INPUT), data, reply); - if (ret) { - result = reply.ReadInt32(); - } - DHLOGI("source proxy StartRemoteInput end, result:%d.", result); - return result; -} - -int32_t DistributedInputSourceProxy::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - if (!data.WriteString(deviceId)) { - DHLOGE("DistributedInputSourceProxy write deviceId failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteUint32(inputTypes)) { - DHLOGE("DistributedInputSourceProxy write inputTypes failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("DistributedInputSourceProxy write callback failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_STOP_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::STOP_REMOTE_INPUT), data, reply); - if (ret) { - result = reply.ReadInt32(); - } - return result; -} - -int32_t DistributedInputSourceProxy::StartRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - DHLOGI("source proxy StartRemoteInput start"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - if (!data.WriteString(srcId)) { - DHLOGE("DistributedInputSourceProxy write srcId failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteString(sinkId)) { - DHLOGE("DistributedInputSourceProxy write sinkId failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteUint32(inputTypes)) { - DHLOGE("DistributedInputSourceProxy write inputTypes failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("DistributedInputSourceProxy write callback failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_START_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::START_RELAY_TYPE_REMOTE_INPUT), data, - reply); - if (ret) { - result = reply.ReadInt32(); - } - DHLOGI("source proxy StartRemoteInput end, result:%d.", result); - return result; -} - -int32_t DistributedInputSourceProxy::StopRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("DistributedInputSourceProxy write token valid failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - if (!data.WriteString(srcId)) { - DHLOGE("DistributedInputSourceProxy write srcId failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteString(sinkId)) { - DHLOGE("DistributedInputSourceProxy write sinkId failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteUint32(inputTypes)) { - DHLOGE("DistributedInputSourceProxy write inputTypes failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("DistributedInputSourceProxy write callback failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - MessageParcel reply; - int32_t result = ERR_DH_INPUT_SOURCE_PROXY_STOP_FAIL; - bool ret = SendRequest(static_cast(IDInputSourceInterfaceCode::STOP_RELAY_TYPE_REMOTE_INPUT), - data, reply); - if (ret) { - result = reply.ReadInt32(); - } - return result; -} - int32_t DistributedInputSourceProxy::PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) { diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index bba0223..650e951 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -45,22 +45,10 @@ void DistributedInputSourceStub::RegRespFunMap() &DistributedInputSourceStub::HandlePrepareRemoteInput; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNPREPARE_REMOTE_INPUT)] = &DistributedInputSourceStub::HandleUnprepareRemoteInput; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::START_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleStartRemoteInput; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::STOP_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleStopRemoteInput; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::START_RELAY_TYPE_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleStartRelayTypeRemoteInput; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::STOP_RELAY_TYPE_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleStopRelayTypeRemoteInput; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::PREPARE_RELAY_REMOTE_INPUT)] = &DistributedInputSourceStub::HandlePrepareRelayRemoteInput; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNPREPARE_RELAY_REMOTE_INPUT)] = &DistributedInputSourceStub::HandleUnprepareRelayRemoteInput; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::START_DHID_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleStartDhidRemoteInput; - memberFuncMap_[static_cast(IDInputSourceInterfaceCode::STOP_DHID_REMOTE_INPUT)] = - &DistributedInputSourceStub::HandleStopDhidRemoteInput; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::START_RELAY_DHID_REMOTE_INPUT)] = &DistributedInputSourceStub::HandleStartRelayDhidRemoteInput; memberFuncMap_[static_cast(IDInputSourceInterfaceCode::STOP_RELAY_DHID_REMOTE_INPUT)] = @@ -220,92 +208,6 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da return DH_SUCCESS; } -int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) -{ - if (!HasAccessDHPermission()) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; - } - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) -{ - if (!HasAccessDHPermission()) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; - } - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) -{ - if (!HasAccessDHPermission()) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; - } - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRelayTypeRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(srcId, sinkId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) -{ - if (!HasAccessDHPermission()) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_INPUT_SRC_ACCESS_PERMISSION_CHECK_FAIL; - } - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRelayTypeRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(srcId, sinkId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - return DH_SUCCESS; -} - int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { @@ -602,13 +504,7 @@ int32_t DistributedInputSourceStub::OnRemoteRequest( DHLOGE("DistributedInputSourceStub read token valid failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - if (code == static_cast(IDInputSourceInterfaceCode::REGISTER_REMOTE_INPUT)) { - DHLOGI("Receive Register DInput cmd"); - } - if (code == static_cast(IDInputSourceInterfaceCode::UNREGISTER_REMOTE_INPUT)) { - DHLOGI("Receive UnRegister DInput cmd"); - } if (code == static_cast(IDInputSourceInterfaceCode::INIT)) { return HandleInitDistributedHardware(reply); } else if (code == static_cast(IDInputSourceInterfaceCode::RELEASE)) { diff --git a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp deleted file mode 100644 index 7c06d7b..0000000 --- a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2021-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 "start_d_input_call_back_proxy.h" - -#include "ipc_types.h" -#include "parcel.h" - -#include "dinput_log.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -StartDInputCallbackProxy::StartDInputCallbackProxy(const sptr &object) - : IRemoteProxy(object) -{ -} - -StartDInputCallbackProxy::~StartDInputCallbackProxy() -{ -} - -void StartDInputCallbackProxy::OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) -{ - sptr remote = Remote(); - if (remote == nullptr) { - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("StartDInputCallbackProxy write token valid failed"); - return; - } - if (!data.WriteString(devId)) { - DHLOGE("StartDInputCallbackProxy write devId failed"); - return; - } - if (!data.WriteUint32(inputTypes)) { - DHLOGE("StartDInputCallbackProxy write inputTypes failed"); - return; - } - if (!data.WriteInt32(status)) { - DHLOGE("StartDInputCallbackProxy write status failed"); - return; - } - int32_t ret = remote->SendRequest( - static_cast(IStartDInputCallback::Message::RESULT), data, reply, option); - if (ret != 0) { - return; - } -} -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS diff --git a/interfaces/ipc/src/start_d_input_call_back_stub.cpp b/interfaces/ipc/src/start_d_input_call_back_stub.cpp deleted file mode 100644 index b9243b1..0000000 --- a/interfaces/ipc/src/start_d_input_call_back_stub.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "start_d_input_call_back_stub.h" - -#include "string_ex.h" - -#include "constants_dinput.h" -#include "dinput_errcode.h" -#include "dinput_log.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -StartDInputCallbackStub::StartDInputCallbackStub() -{ -} - -StartDInputCallbackStub::~StartDInputCallbackStub() -{ -} - -int32_t StartDInputCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (data.ReadInterfaceToken() != GetDescriptor()) { - DHLOGE("StartDInputCallbackStub read token valid failed"); - return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; - } - IStartDInputCallback::Message msgCode = static_cast(code); - switch (msgCode) { - case IStartDInputCallback::Message::RESULT: { - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - int32_t status = data.ReadInt32(); - OnResult(deviceId, inputTypes, status); - break; - } - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return DH_SUCCESS; -} -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS diff --git a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp deleted file mode 100644 index 8657cd0..0000000 --- a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2021-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 "stop_d_input_call_back_proxy.h" - -#include "ipc_types.h" -#include "parcel.h" - -#include "dinput_log.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -StopDInputCallbackProxy::StopDInputCallbackProxy(const sptr &object) - : IRemoteProxy(object) -{ -} - -StopDInputCallbackProxy::~StopDInputCallbackProxy() -{ -} - -void StopDInputCallbackProxy::OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) -{ - sptr remote = Remote(); - if (remote == nullptr) { - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - DHLOGE("StopDInputCallbackProxy write token valid failed"); - return; - } - if (!data.WriteString(devId)) { - DHLOGE("StopDInputCallbackProxy write devId failed"); - return; - } - if (!data.WriteUint32(inputTypes)) { - DHLOGE("StopDInputCallbackProxy write inputTypes failed"); - return; - } - if (!data.WriteInt32(status)) { - DHLOGE("StopDInputCallbackProxy write status failed"); - return; - } - int32_t ret = remote->SendRequest( - static_cast(IStopDInputCallback::Message::RESULT), data, reply, option); - if (ret != 0) { - return; - } -} -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS diff --git a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp deleted file mode 100644 index 64f8d5f..0000000 --- a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "stop_d_input_call_back_stub.h" - -#include "string_ex.h" - -#include "constants_dinput.h" -#include "dinput_errcode.h" -#include "dinput_log.h" - -namespace OHOS { -namespace DistributedHardware { -namespace DistributedInput { -StopDInputCallbackStub::StopDInputCallbackStub() -{ -} - -StopDInputCallbackStub::~StopDInputCallbackStub() -{ -} - -int32_t StopDInputCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (data.ReadInterfaceToken() != GetDescriptor()) { - DHLOGE("StopDInputCallbackStub read token valid failed"); - return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL; - } - IStopDInputCallback::Message msgCode = static_cast(code); - switch (msgCode) { - case IStopDInputCallback::Message::RESULT: { - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - int32_t status = data.ReadInt32(); - OnResult(deviceId, inputTypes, status); - break; - } - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return DH_SUCCESS; -} -} // namespace DistributedInput -} // namespace DistributedHardware -} // namespace OHOS diff --git a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn index a974bb9..2e18111 100644 --- a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn @@ -61,14 +61,10 @@ ohos_unittest("add_white_list_infos_callbackl_test") { "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", "${ipc_path}/src/start_stop_result_call_back_proxy.cpp", "${ipc_path}/src/start_stop_result_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "add_white_list_infos_call_back_test.cpp", ] diff --git a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.cpp b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.cpp index 6ffb823..b82d36a 100644 --- a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.cpp +++ b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.cpp @@ -122,13 +122,6 @@ int32_t AddWhiteListInfosCallbackTest::TestSimulationEventListenerStub::OnSimula value_ = value; return DH_SUCCESS; } -void AddWhiteListInfosCallbackTest::TestStartDInputCallbackStub::OnResult(const std::string &devId, - const uint32_t &inputTypes, const int32_t &status) -{ - devId_ = devId; - inputTypes_ = inputTypes; - status_ = status; -} void AddWhiteListInfosCallbackTest::TestStartStopDInputsCallbackStub::OnResultDhids(const std::string &devId, const int32_t &status) @@ -153,14 +146,6 @@ void AddWhiteListInfosCallbackTest::TestStartStopResultCallbackStub::OnStop(cons dhIds.swap(dhIds); } -void AddWhiteListInfosCallbackTest::TestStopDInputCallbackStub::OnResult(const std::string &devId, - const uint32_t &inputTypes, const int32_t &status) -{ - devId_ = devId; - inputTypes_ = inputTypes; - status_ = status; -} - int32_t AddWhiteListInfosCallbackTest::TestDistributedInputSinkStub::Init() { return DH_SUCCESS; @@ -298,17 +283,6 @@ HWTEST_F(AddWhiteListInfosCallbackTest, SimulationEventListenerStub01, testing:: EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(AddWhiteListInfosCallbackTest, StartDInputCallbackStub01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestStartDInputCallbackStub()); - StartDInputCallbackProxy callBackProxy(callBackStubPtr); - std::string devId = "devId_test"; - uint32_t inputTypes = static_cast(DInputDeviceType::ALL); - int32_t status = 1; - callBackProxy.OnResult(devId, inputTypes, status); - EXPECT_STREQ(devId.c_str(), ((sptr &)callBackStubPtr)->devId_.c_str()); -} - HWTEST_F(AddWhiteListInfosCallbackTest, StartStopDInputsCallbackStub01, testing::ext::TestSize.Level1) { sptr callBackStubPtr(new TestStartStopDInputsCallbackStub()); @@ -346,17 +320,6 @@ HWTEST_F(AddWhiteListInfosCallbackTest, StartStopResultCallbackStub02, testing:: EXPECT_STREQ(sinkId.c_str(), ((sptr &)callBackStubPtr)->sinkId_.c_str()); } -HWTEST_F(AddWhiteListInfosCallbackTest, StopDInputCallbackStub01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestStopDInputCallbackStub()); - StopDInputCallbackProxy callBackProxy(callBackStubPtr); - std::string devId = "devId_test"; - uint32_t inputTypes = static_cast(DInputDeviceType::ALL); - int32_t status = 1; - callBackProxy.OnResult(devId, inputTypes, status); - EXPECT_STREQ(devId.c_str(), ((sptr &)callBackStubPtr)->devId_.c_str()); -} - HWTEST_F(AddWhiteListInfosCallbackTest, DistributedInputSinkStub01, testing::ext::TestSize.Level1) { sptr sinkStubPtr(new TestDistributedInputSinkStub()); diff --git a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.h b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.h index 624f12c..e92d0d2 100644 --- a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.h +++ b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/add_white_list_infos_call_back_test.h @@ -33,13 +33,11 @@ #include "simulation_event_listener_proxy.h" #include "simulation_event_listener_stub.h" #include "start_d_input_call_back_proxy.h" -#include "start_d_input_call_back_stub.h" #include "start_stop_d_inputs_call_back_proxy.h" #include "start_stop_d_inputs_call_back_stub.h" #include "start_stop_result_call_back_proxy.h" #include "start_stop_result_call_back_stub.h" #include "stop_d_input_call_back_proxy.h" -#include "stop_d_input_call_back_stub.h" #include "register_d_input_call_back_proxy.h" #include "register_d_input_call_back_stub.h" @@ -130,17 +128,6 @@ public: int32_t value_ = 0; }; - class TestStartDInputCallbackStub : public - OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { - public: - TestStartDInputCallbackStub() = default; - virtual ~TestStartDInputCallbackStub() = default; - void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status); - std::string devId_; - uint32_t inputTypes_ = 0; - int32_t status_ = 0; - }; - class TestStartStopDInputsCallbackStub : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { public: @@ -163,17 +150,6 @@ public: std::vector dhIds_; }; - class TestStopDInputCallbackStub : public - OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { - public: - TestStopDInputCallbackStub() = default; - virtual ~TestStopDInputCallbackStub() = default; - void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status); - std::string devId_; - uint32_t inputTypes_ = 0; - int32_t status_ = 0; - }; - class TestDistributedInputSinkStub : public OHOS::DistributedHardware::DistributedInput::DistributedInputSinkStub { public: diff --git a/interfaces/ipc/test/clientunittest/BUILD.gn b/interfaces/ipc/test/clientunittest/BUILD.gn index 4a838f5..c75f824 100644 --- a/interfaces/ipc/test/clientunittest/BUILD.gn +++ b/interfaces/ipc/test/clientunittest/BUILD.gn @@ -76,14 +76,10 @@ ohos_unittest("distributed_input_client_test") { "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", "${ipc_path}/src/start_stop_result_call_back_proxy.cpp", "${ipc_path}/src/start_stop_result_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", diff --git a/interfaces/ipc/test/clientunittest/distributed_input_client_test.cpp b/interfaces/ipc/test/clientunittest/distributed_input_client_test.cpp index d08527b..564db7a 100644 --- a/interfaces/ipc/test/clientunittest/distributed_input_client_test.cpp +++ b/interfaces/ipc/test/clientunittest/distributed_input_client_test.cpp @@ -97,24 +97,6 @@ void DistributedInputClientTest::TestUnprepareDInputCallback::OnResult( return; } -void DistributedInputClientTest::TestStartDInputCallback::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - -void DistributedInputClientTest::TestStopDInputCallback::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - void DistributedInputClientTest::TestStartStopDInputCallback::OnResultDhids( const std::string &devId, const int32_t &status) { @@ -261,24 +243,6 @@ HWTEST_F(DistributedInputClientTest, UnprepareRemoteInput04, testing::ext::TestS EXPECT_EQ(ERR_DH_INPUT_CLIENT_UNPREPARE_FAIL, ret); } -HWTEST_F(DistributedInputClientTest, StartRemoteInput01, testing::ext::TestSize.Level0) -{ - string deviceId = "StartRemoteInput01"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = DistributedInputClient::GetInstance().StartRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -HWTEST_F(DistributedInputClientTest, StartRemoteInput02, testing::ext::TestSize.Level0) -{ - string deviceId = ""; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StartRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_START_FAIL, ret); -} - HWTEST_F(DistributedInputClientTest, StartRemoteInput03, testing::ext::TestSize.Level0) { std::string sinkId = "StartRemoteInput_sink"; @@ -297,26 +261,6 @@ HWTEST_F(DistributedInputClientTest, StartRemoteInput04, testing::ext::TestSize. EXPECT_EQ(ERR_DH_INPUT_CLIENT_START_FAIL, ret); } -HWTEST_F(DistributedInputClientTest, StartRemoteInput05, testing::ext::TestSize.Level0) -{ - string srcId = "StartRemoteInput01-src"; - string sinkId = "StartRemoteInput01-sink"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = DistributedInputClient::GetInstance().StartRemoteInput( - srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -HWTEST_F(DistributedInputClientTest, StartRemoteInput06, testing::ext::TestSize.Level0) -{ - string srcId = ""; - string sinkId = ""; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StartRemoteInput( - srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_START_FAIL, ret); -} - HWTEST_F(DistributedInputClientTest, StartRemoteInput07, testing::ext::TestSize.Level0) { string srcId = "StartRemoteInput01-src"; @@ -337,24 +281,6 @@ HWTEST_F(DistributedInputClientTest, StartRemoteInput08, testing::ext::TestSize. EXPECT_EQ(ERR_DH_INPUT_CLIENT_START_FAIL, ret); } -HWTEST_F(DistributedInputClientTest, StopRemoteInput01, testing::ext::TestSize.Level0) -{ - string deviceId = "StopRemoteInput01"; - sptr callback(new TestStopDInputCallback()); - int32_t ret = DistributedInputClient::GetInstance().StopRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - -HWTEST_F(DistributedInputClientTest, StopRemoteInput02, testing::ext::TestSize.Level0) -{ - string deviceId = ""; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StopRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_STOP_FAIL, ret); -} - HWTEST_F(DistributedInputClientTest, StopRemoteInput03, testing::ext::TestSize.Level0) { std::string sinkId = "StartRemoteInput_test"; @@ -373,26 +299,6 @@ HWTEST_F(DistributedInputClientTest, StopRemoteInput04, testing::ext::TestSize.L EXPECT_EQ(ERR_DH_INPUT_CLIENT_STOP_FAIL, ret); } -HWTEST_F(DistributedInputClientTest, StopRemoteInput05, testing::ext::TestSize.Level0) -{ - string srcId = "StopRemoteInput03-src"; - string sinkId = "StopRemoteInput03-sink"; - sptr callback(new TestStopDInputCallback()); - int32_t ret = DistributedInputClient::GetInstance().StopRemoteInput( - srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - -HWTEST_F(DistributedInputClientTest, StopRemoteInput06, testing::ext::TestSize.Level0) -{ - string srcId = ""; - string sinkId = ""; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StopRemoteInput( - srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_STOP_FAIL, ret); -} - HWTEST_F(DistributedInputClientTest, StopRemoteInput07, testing::ext::TestSize.Level0) { string srcId = "StartRemoteInput01-src"; diff --git a/interfaces/ipc/test/clientunittest/distributed_input_client_test.h b/interfaces/ipc/test/clientunittest/distributed_input_client_test.h index 09c674b..1b4476f 100644 --- a/interfaces/ipc/test/clientunittest/distributed_input_client_test.h +++ b/interfaces/ipc/test/clientunittest/distributed_input_client_test.h @@ -30,8 +30,6 @@ #include "simulation_event_listener_stub.h" #include "start_stop_d_inputs_call_back_stub.h" #include "prepare_d_input_call_back_stub.h" -#include "start_d_input_call_back_stub.h" -#include "stop_d_input_call_back_stub.h" #include "simulation_event_listener_stub.h" #include "unprepare_d_input_call_back_stub.h" @@ -77,22 +75,6 @@ public: void OnResult(const std::string &deviceId, const int32_t &status); }; - class TestStartDInputCallback : public - OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { - public: - TestStartDInputCallback() = default; - virtual ~TestStartDInputCallback() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - - class TestStopDInputCallback : public - OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { - public: - TestStopDInputCallback() = default; - virtual ~TestStopDInputCallback() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - class TestStartStopDInputCallback : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { public: diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn b/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn index df58c62..828061e 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn @@ -59,12 +59,8 @@ ohos_unittest("dinput_source_callback_test") { "${ipc_path}/src/register_d_input_call_back_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp index dfb97c8..06307ce 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.cpp @@ -108,46 +108,6 @@ int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnprepareRemoteI return DH_SUCCESS; } -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - (void)deviceId; - (void)inputTypes; - (void)callback; - return DH_SUCCESS; -} - -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - (void)deviceId; - (void)inputTypes; - (void)callback; - return DH_SUCCESS; -} - -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StartRemoteInput( - const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) -{ - (void)srcId; - (void)sinkId; - (void)inputTypes; - (void)callback; - return DH_SUCCESS; -} - -int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StopRemoteInput( - const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) -{ - (void)srcId; - (void)sinkId; - (void)inputTypes; - (void)callback; - return DH_SUCCESS; -} - int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::PrepareRemoteInput( const std::string &srcId, const std::string &sinkId, sptr callback) @@ -224,6 +184,30 @@ 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) { @@ -291,24 +275,6 @@ void DInputSourceCallBackTest::TestDInputUnprepareCallBack::OnResult( return; } -void DInputSourceCallBackTest::TestDInputStartCallBack::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - -void DInputSourceCallBackTest::TestDInputStopCallBack::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - void DInputSourceCallBackTest::TestVectorStartStopCallBackStub::OnResultDhids(const std::string &devId, const int32_t &status) { @@ -452,29 +418,6 @@ HWTEST_F(DInputSourceCallBackTest, UnprepareRemoteInput02, testing::ext::TestSiz EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DInputSourceCallBackTest, StartRemoteInput01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - const std::string devId = "d6f4s6d4f6"; - uint32_t inputTypes = 1; - sptr callback(new TestDInputStartCallBack()); - int32_t ret = callBackProxy.StartRemoteInput(devId, inputTypes, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DInputSourceCallBackTest, StartRemoteInput02, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - const std::string srcId = "d6f4s6d4f6"; - const std::string sinkId = "5sd45s4d5s4d5"; - uint32_t inputTypes = 1; - sptr callback(new TestDInputStartCallBack()); - int32_t ret = callBackProxy.StartRemoteInput(srcId, sinkId, inputTypes, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DInputSourceCallBackTest, StartRemoteInput03, testing::ext::TestSize.Level1) { sptr callBackStubPtr(new TestDInputSourceCallBackStub()); @@ -500,29 +443,6 @@ HWTEST_F(DInputSourceCallBackTest, StartRemoteInput04, testing::ext::TestSize.Le EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DInputSourceCallBackTest, StopRemoteInput01, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - const std::string devId = "d6f4s6d4f6"; - uint32_t inputTypes = 1; - sptr callback(new TestDInputStopCallBack()); - int32_t ret = callBackProxy.StopRemoteInput(devId, inputTypes, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DInputSourceCallBackTest, StopRemoteInput02, testing::ext::TestSize.Level1) -{ - sptr callBackStubPtr(new TestDInputSourceCallBackStub()); - DistributedInputSourceProxy callBackProxy(callBackStubPtr); - const std::string srcId = "d6f4s6d4f6"; - const std::string sinkId = "5sd45s4d5s4d5"; - uint32_t inputTypes = 1; - sptr callback(new TestDInputStopCallBack()); - int32_t ret = callBackProxy.StopRemoteInput(srcId, sinkId, inputTypes, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DInputSourceCallBackTest, StopRemoteInput03, 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 3ee72e9..644d9d8 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h @@ -26,8 +26,6 @@ #include "input_node_listener_stub.h" #include "prepare_d_input_call_back_stub.h" #include "register_d_input_call_back_stub.h" -#include "start_d_input_call_back_stub.h" -#include "stop_d_input_call_back_stub.h" #include "unprepare_d_input_call_back_stub.h" #include "unregister_d_input_call_back_stub.h" #include "start_stop_d_inputs_call_back_stub.h" @@ -66,18 +64,6 @@ public: int32_t UnprepareRemoteInput(const std::string &deviceId, sptr callback); - int32_t StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback); - - int32_t StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback); - - int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - - int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback); @@ -140,22 +126,6 @@ public: void OnResult(const std::string &deviceId, const int32_t &status); }; - class TestDInputStartCallBack : public - OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { - public: - TestDInputStartCallBack() = default; - virtual ~TestDInputStartCallBack() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - - class TestDInputStopCallBack : public - OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { - public: - TestDInputStopCallBack() = default; - virtual ~TestDInputStopCallBack() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - class TestVectorStartStopCallBackStub : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { public: diff --git a/interfaces/ipc/test/ipcunittest/BUILD.gn b/interfaces/ipc/test/ipcunittest/BUILD.gn index 8314577..cb225fa 100644 --- a/interfaces/ipc/test/ipcunittest/BUILD.gn +++ b/interfaces/ipc/test/ipcunittest/BUILD.gn @@ -68,14 +68,10 @@ ohos_unittest("distributed_input_ipc_test") { "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", "${ipc_path}/src/start_stop_result_call_back_proxy.cpp", "${ipc_path}/src/start_stop_result_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", diff --git a/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp b/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp index 11ce0d6..83deccf 100644 --- a/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp +++ b/interfaces/ipc/test/ipcunittest/distributed_input_ipc_test.cpp @@ -353,15 +353,6 @@ HWTEST_F(DistributedInputIpcTest, UnprepareRemoteInput01, testing::ext::TestSize EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); } -HWTEST_F(DistributedInputIpcTest, StartRemoteInput01, testing::ext::TestSize.Level0) -{ - string deviceId = "StartRemoteInput01"; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StartRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); -} - HWTEST_F(DistributedInputIpcTest, StartRemoteInput02, testing::ext::TestSize.Level0) { std::string sinkId = "StartRemoteInput_sink"; @@ -371,16 +362,6 @@ HWTEST_F(DistributedInputIpcTest, StartRemoteInput02, testing::ext::TestSize.Lev EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); } -HWTEST_F(DistributedInputIpcTest, StartRemoteInput03, testing::ext::TestSize.Level0) -{ - string srcId = "StartRemoteInput01-src"; - string sinkId = "StartRemoteInput01-sink"; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StartRemoteInput( - srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); -} - HWTEST_F(DistributedInputIpcTest, StartRemoteInput04, testing::ext::TestSize.Level0) { string srcId = "StartRemoteInput01-src"; @@ -391,15 +372,6 @@ HWTEST_F(DistributedInputIpcTest, StartRemoteInput04, testing::ext::TestSize.Lev EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); } -HWTEST_F(DistributedInputIpcTest, StopRemoteInput01, testing::ext::TestSize.Level0) -{ - string deviceId = "StopRemoteInput01"; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StopRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); -} - HWTEST_F(DistributedInputIpcTest, StopRemoteInput02, testing::ext::TestSize.Level0) { std::string sinkId = "StartRemoteInput_test"; @@ -409,16 +381,6 @@ HWTEST_F(DistributedInputIpcTest, StopRemoteInput02, testing::ext::TestSize.Leve EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); } -HWTEST_F(DistributedInputIpcTest, StopRemoteInput03, testing::ext::TestSize.Level0) -{ - string srcId = "StopRemoteInput03-src"; - string sinkId = "StopRemoteInput03-sink"; - sptr callback = nullptr; - int32_t ret = DistributedInputClient::GetInstance().StopRemoteInput( - srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); - EXPECT_EQ(ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL, ret); -} - HWTEST_F(DistributedInputIpcTest, StopRemoteInput04, testing::ext::TestSize.Level0) { string srcId = "StartRemoteInput01-src"; diff --git a/services/common/include/dinput_sink_trans_callback.h b/services/common/include/dinput_sink_trans_callback.h index d31e250..f194960 100644 --- a/services/common/include/dinput_sink_trans_callback.h +++ b/services/common/include/dinput_sink_trans_callback.h @@ -25,8 +25,6 @@ class DInputSinkTransCallback { public: virtual void OnPrepareRemoteInput(const int32_t &sessionId, const std::string &deviceId) = 0; virtual void OnUnprepareRemoteInput(const int32_t &sessionId) = 0; - virtual void OnStartRemoteInput(const int32_t &sessionId, const uint32_t &inputTypes) = 0; - virtual void OnStopRemoteInput(const int32_t &sessionId, const uint32_t &inputTypes) = 0; virtual void OnStartRemoteInputDhid(const int32_t &sessionId, const std::string &strDhids) = 0; virtual void OnStopRemoteInputDhid(const int32_t &sessionId, const std::string &strDhids) = 0; @@ -38,10 +36,6 @@ public: const std::string &deviceId, const std::string &strDhids) = 0; virtual void OnRelayStopDhidRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, const std::string &deviceId, const std::string &strDhids) = 0; - virtual void OnRelayStartTypeRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, - const std::string &deviceId, uint32_t inputTypes) = 0; - virtual void OnRelayStopTypeRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, - const std::string &deviceId, uint32_t inputTypes) = 0; virtual ~DInputSinkTransCallback() {} }; } // namespace DistributedInput diff --git a/services/common/include/dinput_softbus_define.h b/services/common/include/dinput_softbus_define.h index 70dd253..6e7140a 100644 --- a/services/common/include/dinput_softbus_define.h +++ b/services/common/include/dinput_softbus_define.h @@ -48,7 +48,6 @@ namespace DistributedInput { #define DINPUT_SOFTBUS_KEY_CMD_TYPE "dinput_softbus_key_cmd_type" #define DINPUT_SOFTBUS_KEY_DEVICE_ID "dinput_softbus_key_device_id" #define DINPUT_SOFTBUS_KEY_SESSION_ID "dinput_softbus_key_session_id" - #define DINPUT_SOFTBUS_KEY_INPUT_TYPE "dinput_softbus_key_input_type" #define DINPUT_SOFTBUS_KEY_VECTOR_DHID "dinput_softbus_key_vector_dhid" #define DINPUT_SOFTBUS_KEY_RESP_VALUE "dinput_softbus_key_resp_value" #define DINPUT_SOFTBUS_KEY_WHITE_LIST "dinput_softbus_key_list_list" @@ -88,7 +87,6 @@ namespace DistributedInput { const uint32_t TRANS_SINK_MSG_ON_RELAY_STOPDHID = 25; const uint32_t TRANS_SINK_MSG_ON_RELAY_STARTTYPE = 26; const uint32_t TRANS_SINK_MSG_ON_RELAY_STOPTYPE = 27; - const uint32_t TRANS_SINK_MSG_KEY_STATE_BATCH = 28; // src or sink const uint32_t TRANS_MSG_SRC_SINK_SPLIT = 30; diff --git a/services/common/include/dinput_source_trans_callback.h b/services/common/include/dinput_source_trans_callback.h index 35d348e..33213c0 100644 --- a/services/common/include/dinput_source_trans_callback.h +++ b/services/common/include/dinput_source_trans_callback.h @@ -27,13 +27,10 @@ public: bool result) = 0; virtual void OnResponsePrepareRemoteInput(const std::string deviceId, bool result, const std::string &object) = 0; virtual void OnResponseUnprepareRemoteInput(const std::string deviceId, bool result) = 0; - virtual void OnResponseStartRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) = 0; - virtual void OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) = 0; virtual void OnResponseStartRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) = 0; virtual void OnResponseStopRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) = 0; virtual void OnResponseKeyState(const std::string deviceId, const std::string &dhid, const uint32_t type, const uint32_t code, const uint32_t value) = 0; - virtual void OnResponseKeyStateBatch(const std::string deviceId, const std::string &object) = 0; virtual void OnReceivedEventRemoteInput(const std::string deviceId, const std::string &object) = 0; virtual void OnResponseRelayPrepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result, @@ -46,10 +43,6 @@ public: const std::string &dhids) = 0; virtual void OnReceiveRelayStopDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId, const std::string &dhids) = 0; - virtual void OnReceiveRelayStartTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, - uint32_t inputTypes) = 0; - virtual void OnReceiveRelayStopTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, - uint32_t inputTypes) = 0; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/services/sink/inputcollector/include/distributed_input_collector.h b/services/sink/inputcollector/include/distributed_input_collector.h index 5d49ef5..f47c652 100644 --- a/services/sink/inputcollector/include/distributed_input_collector.h +++ b/services/sink/inputcollector/include/distributed_input_collector.h @@ -43,7 +43,6 @@ public: void PreInit(); int32_t Init(std::shared_ptr sinkHandler); void Release(); - AffectDhIds SetSharingTypes(bool enabled, const uint32_t &inputType); AffectDhIds SetSharingDhIds(bool enabled, std::vector dhIds); void GetMouseNodePath(const std::vector &dhIds, std::string &mouseNodePath, std::string &dhid); void GetSharedKeyboardPathsByDhIds(const std::vector &dhIds, @@ -52,7 +51,6 @@ public: bool IsAllDevicesStoped(); int32_t RegisterSharingDhIdListener(sptr sharingDhIdListener); void ReportDhIdSharingState(const AffectDhIds &dhIds); - void GetDeviceInfoByType(const uint32_t inputTypes, std::map &deviceInfo); void ResetSpecEventStatus(); private: @@ -70,7 +68,6 @@ private: bool isStartGetDeviceHandlerThread; std::unique_ptr inputHub_; std::shared_ptr sinkHandler_; - uint32_t inputTypes_; std::mutex sharingDhIdListenerMtx_; std::set> sharingDhIdListeners_; diff --git a/services/sink/inputcollector/src/distributed_input_collector.cpp b/services/sink/inputcollector/src/distributed_input_collector.cpp index 52015c0..e5e8507 100644 --- a/services/sink/inputcollector/src/distributed_input_collector.cpp +++ b/services/sink/inputcollector/src/distributed_input_collector.cpp @@ -37,7 +37,7 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedInput { DistributedInputCollector::DistributedInputCollector() : mEventBuffer{}, collectThreadID_(-1), - isCollectingEvents_(false), isStartGetDeviceHandlerThread(false), inputTypes_(0) + isCollectingEvents_(false), isStartGetDeviceHandlerThread(false) { inputHub_ = std::make_unique(); } @@ -163,23 +163,6 @@ void DistributedInputCollector::StopCollectEventsThread() DHLOGW("DistributedInputCollector::StopCollectEventsThread exit!"); } -AffectDhIds DistributedInputCollector::SetSharingTypes(bool enabled, const uint32_t &inputType) -{ - inputTypes_ = 0; - if ((inputType & static_cast(DInputDeviceType::MOUSE)) != 0 || - (inputType & static_cast(DInputDeviceType::TOUCHPAD)) != 0) { - inputTypes_ |= INPUT_DEVICE_CLASS_CURSOR; - } - if ((inputType & static_cast(DInputDeviceType::KEYBOARD)) != 0) { - inputTypes_ |= INPUT_DEVICE_CLASS_KEYBOARD; - } - if ((inputType & static_cast(DInputDeviceType::TOUCHSCREEN)) != 0) { - inputTypes_ |= INPUT_DEVICE_CLASS_TOUCH_MT | INPUT_DEVICE_CLASS_TOUCH; - } - - return inputHub_->SetSupportInputType(enabled, inputTypes_); -} - void DistributedInputCollector::ReportDhIdSharingState(const AffectDhIds &dhIds) { std::lock_guard lock(sharingDhIdListenerMtx_); @@ -249,16 +232,6 @@ int32_t DistributedInputCollector::RegisterSharingDhIdListener(sptr &deviceInfo) -{ - if (inputHub_ == nullptr) { - DHLOGE("inputHub is nullptr!"); - return; - } - inputHub_->GetDevicesInfoByType(inputTypes, deviceInfo); -} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS diff --git a/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp b/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp index 6568284..8f9363d 100644 --- a/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp +++ b/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp @@ -67,51 +67,6 @@ HWTEST_F(DistributedInputCollectorTest, Init02, testing::ext::TestSize.Level1) int32_t ret = DistributedInputCollector::GetInstance().Init(eventHandler_); EXPECT_EQ(DH_SUCCESS, ret); } - -HWTEST_F(DistributedInputCollectorTest, IsAllDevicesStoped01, testing::ext::TestSize.Level1) -{ - uint32_t inputTypes = 1; - std::map deviceInfo; - std::vector dhIds; - std::string mouseNodePath = "mouseNodePath_test"; - std::string dhid = "dhid_test"; - DistributedInputCollector::GetInstance().GetDeviceInfoByType(inputTypes, deviceInfo); - DistributedInputCollector::GetInstance().GetMouseNodePath(dhIds, mouseNodePath, dhid); - bool isStop = DistributedInputCollector::GetInstance().IsAllDevicesStoped(); - EXPECT_EQ(true, isStop); -} - -HWTEST_F(DistributedInputCollectorTest, IsAllDevicesStoped02, testing::ext::TestSize.Level1) -{ - DistributedInputCollector::GetInstance().inputHub_ = nullptr; - uint32_t inputTypes = 1; - std::map deviceInfo; - std::vector dhIds; - std::string mouseNodePath = "mouseNodePath_test"; - std::string dhid = "dhid_test"; - DistributedInputCollector::GetInstance().GetDeviceInfoByType(inputTypes, deviceInfo); - DistributedInputCollector::GetInstance().GetMouseNodePath(dhIds, mouseNodePath, dhid); - bool isStop = DistributedInputCollector::GetInstance().IsAllDevicesStoped(); - EXPECT_EQ(false, isStop); -} - -HWTEST_F(DistributedInputCollectorTest, SetSharingTypes01, testing::ext::TestSize.Level1) -{ - DistributedInputCollector::GetInstance().inputHub_ = std::make_unique(); - bool enabled = true; - uint32_t inputType = static_cast(DInputDeviceType::ALL); - - AffectDhIds ret = DistributedInputCollector::GetInstance().SetSharingTypes(enabled, inputType); - EXPECT_EQ(0, ret.sharingDhIds.size()); - std::vector sharingDhIds; - sharingDhIds.push_back("sharingDhId_test"); - std::vector noSharingDhIds; - noSharingDhIds.push_back("noSharingDhId_test"); - AffectDhIds affectDhIds {sharingDhIds, noSharingDhIds}; - DistributedInputCollector::GetInstance().ReportDhIdSharingState(affectDhIds); - DistributedInputCollector::GetInstance().sharingDhIdListeners_.clear(); - DistributedInputCollector::GetInstance().ReportDhIdSharingState(affectDhIds); -} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/sink/sinkmanager/include/distributed_input_sink_manager.h b/services/sink/sinkmanager/include/distributed_input_sink_manager.h index f51a6d7..549b48d 100644 --- a/services/sink/sinkmanager/include/distributed_input_sink_manager.h +++ b/services/sink/sinkmanager/include/distributed_input_sink_manager.h @@ -69,8 +69,6 @@ public: ~DInputSinkListener() override; void OnPrepareRemoteInput(const int32_t &sessionId, const std::string &deviceId) override; void OnUnprepareRemoteInput(const int32_t &sessionId) override; - void OnStartRemoteInput(const int32_t &sessionId, const uint32_t &inputTypes) override; - void OnStopRemoteInput(const int32_t &sessionId, const uint32_t &inputTypes) override; void OnStartRemoteInputDhid(const int32_t &sessionId, const std::string &strDhids) override; void OnStopRemoteInputDhid(const int32_t &sessionId, const std::string &strDhids) override; @@ -82,10 +80,6 @@ public: const std::string &deviceId, const std::string &strDhids) override; void OnRelayStopDhidRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, const std::string &deviceId, const std::string &strDhids) override; - void OnRelayStartTypeRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, - const std::string &deviceId, uint32_t inputTypes) override; - void OnRelayStopTypeRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, - const std::string &deviceId, uint32_t inputTypes) override; private: DistributedInputSinkManager *sinkManagerObj_; @@ -139,10 +133,6 @@ public: void SetStartTransFlag(const DInputServerType flag); - uint32_t GetInputTypes(); - - void SetInputTypes(const uint32_t &inputTypes); - /* * GetEventHandler, get the ui_service manager service's handler. * @@ -177,7 +167,6 @@ private: std::shared_ptr handler_; std::mutex mutex_; bool InitAuto(); - DInputDeviceType inputTypes_; sptr projectWindowListener_ = nullptr; std::set sharingDhIds_; std::map> sharingDhIdsMap_; diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index 34b08a5..fcdd728 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -51,7 +51,6 @@ DistributedInputSinkManager::DistributedInputSinkManager(int32_t saId, bool runO : SystemAbility(saId, runOnCreate) { DHLOGI("DistributedInputSinkManager ctor!"); - inputTypes_ = DInputDeviceType::NONE; } DistributedInputSinkManager::~DistributedInputSinkManager() @@ -85,13 +84,11 @@ void DistributedInputSinkManager::DInputSinkMgrListener::ResetSinkMgrResStatus() DistributedInputSinkManager::DInputSinkListener::DInputSinkListener(DistributedInputSinkManager *manager) { sinkManagerObj_ = manager; - sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); DHLOGI("DInputSinkListener init."); } DistributedInputSinkManager::DInputSinkListener::~DInputSinkListener() { - sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); sinkManagerObj_ = nullptr; DHLOGI("DInputSinkListener destory."); } @@ -195,7 +192,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayUnprepareRemoteInpu { DHLOGI("OnRelayUnprepareRemoteInput called, toSinkSessionId: %d, devId: %s", toSinkSessionId, GetAnonyString(deviceId).c_str()); - DistributedInputCollector::GetInstance().SetSharingTypes(false, static_cast(DInputDeviceType::ALL)); DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); DistributedInputSinkSwitch::GetInstance().RemoveSession(toSinkSessionId); @@ -207,79 +203,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayUnprepareRemoteInpu DistributedInputSinkTransport::GetInstance().RespUnprepareRemoteInput(toSinkSessionId, smsg); } -void DistributedInputSinkManager::DInputSinkListener::OnStartRemoteInput( - const int32_t &sessionId, const uint32_t &inputTypes) -{ - DHLOGI("OnStartRemoteInput called, sessionId: %d, inputTypes: %u.", sessionId, inputTypes); - // set new session - int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(sessionId); - - sinkManagerObj_->SetStartTransFlag((startRes == DH_SUCCESS) ? DInputServerType::SINK_SERVER_TYPE - : DInputServerType::NULL_SERVER_TYPE); - - bool result = (startRes == DH_SUCCESS); - nlohmann::json jsonStrSta; - jsonStrSta[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONSTART; - jsonStrSta[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - jsonStrSta[DINPUT_SOFTBUS_KEY_RESP_VALUE] = result; - std::string smsg = jsonStrSta.dump(); - DistributedInputSinkTransport::GetInstance().RespStartRemoteInput(sessionId, smsg); - - if (startRes == DH_SUCCESS) { - sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() | inputTypes); - AffectDhIds affDhIds = DistributedInputCollector::GetInstance().SetSharingTypes(true, - sinkManagerObj_->GetInputTypes()); - sinkManagerObj_->StoreStartDhids(sessionId, affDhIds.sharingDhIds); - DistributedInputCollector::GetInstance().ReportDhIdSharingState(affDhIds); - } - - bool isMouse = (sinkManagerObj_->GetInputTypes() & static_cast(DInputDeviceType::MOUSE)) != 0; - if (isMouse) { - std::map deviceInfos; - DistributedInputCollector::GetInstance().GetDeviceInfoByType(static_cast(DInputDeviceType::MOUSE), - deviceInfos); - for (const auto &deviceInfo : deviceInfos) { - DHLOGI("deviceInfo dhId, %s", GetAnonyString(deviceInfo.second).c_str()); - std::vector devDhIds; - SplitStringToVector(deviceInfo.second, INPUT_STRING_SPLIT_POINT, devDhIds); - DInputState::GetInstance().RecordDhIds(devDhIds, DhIdState::THROUGH_OUT, sessionId); - } - } -} - -void DistributedInputSinkManager::DInputSinkListener::OnStopRemoteInput( - const int32_t &sessionId, const uint32_t &inputTypes) -{ - DHLOGI("OnStopRemoteInput called, sessionId: %d, inputTypes: %d, curInputTypes: %d", - sessionId, inputTypes, sinkManagerObj_->GetInputTypes()); - - sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() - - (sinkManagerObj_->GetInputTypes() & inputTypes)); - AffectDhIds affDhIds = DistributedInputCollector::GetInstance().SetSharingTypes(false, inputTypes); - std::vector stopIndeedDhIds; - sinkManagerObj_->DeleteStopDhids(sessionId, affDhIds.noSharingDhIds, stopIndeedDhIds); - AffectDhIds stopIndeedOnes; - stopIndeedOnes.noSharingDhIds = stopIndeedDhIds; - DistributedInputCollector::GetInstance().ReportDhIdSharingState(stopIndeedOnes); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONSTOP; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = true; - std::string smsg = jsonStr.dump(); - DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(sessionId, smsg); - - bool isAllClosed = DistributedInputCollector::GetInstance().IsAllDevicesStoped(); - if (isAllClosed) { - DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); - if (DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession() == - ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) { - DHLOGI("all session is stop."); - sinkManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE); - } - } -} - void DistributedInputSinkManager::DInputSinkListener::OnStartRemoteInputDhid(const int32_t &sessionId, const std::string &strDhids) { @@ -338,7 +261,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnStopRemoteInputDhid(cons bool isAllClosed = DistributedInputCollector::GetInstance().IsAllDevicesStoped(); if (isAllClosed) { DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); - sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); if (DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession() == ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) { DHLOGI("all session is stop."); @@ -403,93 +325,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput std::string smsg = jsonStr.dump(); DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(toSinkSessionId, smsg); - bool isAllClosed = DistributedInputCollector::GetInstance().IsAllDevicesStoped(); - if (!isAllClosed) { - DHLOGE("Not all devices are stopped."); - return; - } - DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); - sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); - if (DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession() == - ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) { - DHLOGI("All session is stop."); - sinkManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE); - } -} - -void DistributedInputSinkManager::DInputSinkListener::OnRelayStartTypeRemoteInput(const int32_t &toSrcSessionId, - const int32_t &toSinkSessionId, const std::string &deviceId, uint32_t inputTypes) -{ - DHLOGI("OnRelayStartTypeRemoteInput called, toSinkSessionId: %d", toSinkSessionId); - // set new session - int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(toSinkSessionId); - - sinkManagerObj_->SetStartTransFlag((startRes == DH_SUCCESS) ? DInputServerType::SINK_SERVER_TYPE - : DInputServerType::NULL_SERVER_TYPE); - bool result = (startRes == DH_SUCCESS); - nlohmann::json jsonStrSta; - jsonStrSta[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ON_RELAY_STARTTYPE; - jsonStrSta[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - jsonStrSta[DINPUT_SOFTBUS_KEY_RESP_VALUE] = result; - jsonStrSta[DINPUT_SOFTBUS_KEY_SESSION_ID] = toSrcSessionId; - std::string smsg = jsonStrSta.dump(); - DistributedInputSinkTransport::GetInstance().RespStartRemoteInput(toSinkSessionId, smsg); - - if (startRes != DH_SUCCESS) { - DHLOGE("OnRelayStartTypeRemoteInput startSwitch error."); - return; - } - - if (sinkManagerObj_->GetEventHandler() == nullptr) { - DHLOGE("eventhandler is null."); - return; - } - - sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() | inputTypes); - AffectDhIds affDhIds = DistributedInputCollector::GetInstance().SetSharingTypes(true, - sinkManagerObj_->GetInputTypes()); - sinkManagerObj_->StoreStartDhids(toSinkSessionId, affDhIds.sharingDhIds); - DistributedInputCollector::GetInstance().ReportDhIdSharingState(affDhIds); - - bool isMouse = (sinkManagerObj_->GetInputTypes() & static_cast(DInputDeviceType::MOUSE)) != 0; - if (!isMouse) { - DHLOGE("No mouse type."); - return; - } - std::map deviceInfos; - DistributedInputCollector::GetInstance().GetDeviceInfoByType(static_cast(DInputDeviceType::MOUSE), - deviceInfos); - for (auto deviceInfo : deviceInfos) { - DHLOGI("deviceInfo dhId, %s", GetAnonyString(deviceInfo.second).c_str()); - std::vector devDhIds; - SplitStringToVector(deviceInfo.second, INPUT_STRING_SPLIT_POINT, devDhIds); - DInputState::GetInstance().RecordDhIds(devDhIds, DhIdState::THROUGH_OUT, toSinkSessionId); - } -} - -void DistributedInputSinkManager::DInputSinkListener::OnRelayStopTypeRemoteInput(const int32_t &toSrcSessionId, - const int32_t &toSinkSessionId, const std::string &deviceId, uint32_t inputTypes) -{ - DHLOGI("OnRelayStopTypeRemoteInput called, sessionId: %d, inputTypes: %d, curInputTypes: %d", - toSinkSessionId, inputTypes, sinkManagerObj_->GetInputTypes()); - - sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() - - (sinkManagerObj_->GetInputTypes() & inputTypes)); - AffectDhIds affDhIds = DistributedInputCollector::GetInstance().SetSharingTypes(false, inputTypes); - std::vector stopIndeedDhIds; - sinkManagerObj_->DeleteStopDhids(toSinkSessionId, affDhIds.noSharingDhIds, stopIndeedDhIds); - AffectDhIds stopIndeedOnes; - stopIndeedOnes.noSharingDhIds = stopIndeedDhIds; - DistributedInputCollector::GetInstance().ReportDhIdSharingState(stopIndeedOnes); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ON_RELAY_STOPTYPE; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = true; - jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID] = toSrcSessionId; - std::string smsg = jsonStr.dump(); - DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(toSinkSessionId, smsg); - bool isAllClosed = DistributedInputCollector::GetInstance().IsAllDevicesStoped(); if (!isAllClosed) { DHLOGE("Not all devices are stopped."); @@ -729,16 +564,6 @@ void DistributedInputSinkManager::SetStartTransFlag(const DInputServerType flag) isStartTrans_ = flag; } -uint32_t DistributedInputSinkManager::GetInputTypes() -{ - return static_cast(inputTypes_); -} - -void DistributedInputSinkManager::SetInputTypes(const uint32_t &inputTypes) -{ - inputTypes_ = static_cast(inputTypes); -} - DistributedInputSinkManager::ProjectWindowListener::ProjectWindowListener(DistributedInputSinkManager *manager) { DHLOGI("ProjectWindowListener ctor!"); diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.cpp b/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.cpp index 3e61341..cdd9cf4 100644 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.cpp +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.cpp @@ -117,14 +117,6 @@ HWTEST_F(DistributedInputSinkManagerTest, GetStartTransFlag, testing::ext::TestS EXPECT_EQ(flag, retFlag); } -HWTEST_F(DistributedInputSinkManagerTest, GetInputTypes, testing::ext::TestSize.Level0) -{ - uint32_t inputTypes = static_cast(DInputDeviceType::MOUSE); - sinkManager_->SetInputTypes(inputTypes); - uint32_t retType = sinkManager_->GetInputTypes(); - EXPECT_EQ(inputTypes, retType); -} - HWTEST_F(DistributedInputSinkManagerTest, IsStopDhidOnCmdStillNeed01, testing::ext::TestSize.Level0) { int32_t sessionId = 1; diff --git a/services/sink/transport/include/distributed_input_sink_transport.h b/services/sink/transport/include/distributed_input_sink_transport.h index df48cc2..00db596 100644 --- a/services/sink/transport/include/distributed_input_sink_transport.h +++ b/services/sink/transport/include/distributed_input_sink_transport.h @@ -60,7 +60,6 @@ public: int32_t RespLatency(const int32_t sessionId, std::string &smsg); void SendKeyStateNodeMsg(const int32_t sessionId, const std::string &dhId, uint32_t type, const uint32_t btnCode, int32_t value); - void SendKeyStateNodeMsgBatch(const int32_t sessionId, const std::vector &events); class DInputSinkEventHandler : public AppExecFwk::EventHandler { public: @@ -80,8 +79,6 @@ private: void RegRespFunMap(); void NotifyPrepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void NotifyUnprepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyStartRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyStopRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void NotifyLatency(int32_t sessionId, const nlohmann::json &recMsg); void NotifyStartRemoteInputDhid(int32_t sessionId, const nlohmann::json &recMsg); void NotifyStopRemoteInputDhid(int32_t sessionId, const nlohmann::json &recMsg); @@ -90,11 +87,8 @@ private: void NotifyRelayUnprepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void NotifyRelayStartDhidRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void NotifyRelayStopDhidRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyRelayStartTypeRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyRelayStopTypeRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void RecordEventLog(const std::string &dhId, int32_t type, int32_t code, int32_t value); - void RecordEventLog(const std::vector &events); private: std::string mySessionName_; std::shared_ptr eventHandler_; diff --git a/services/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index 0025ea3..9905d50 100644 --- a/services/sink/transport/src/distributed_input_sink_transport.cpp +++ b/services/sink/transport/src/distributed_input_sink_transport.cpp @@ -225,46 +225,6 @@ void DistributedInputSinkTransport::SendKeyStateNodeMsg(const int32_t sessionId, RecordEventLog(dhId, type, btnCode, value); } -void DistributedInputSinkTransport::SendKeyStateNodeMsgBatch(const int32_t sessionId, - const std::vector &events) -{ - if (sessionId <= 0) { - DHLOGE("SendKeyStateNodeMsgBatch error, sessionId <= 0."); - return; - } - DHLOGI("SendKeyStateNodeMsgBatch sessionId: %d, event size: %d ", sessionId, events.size()); - - int64_t currentTimeNs = GetCurrentTime() * 1000LL; - std::shared_ptr eventsJsonArr = std::make_shared(); - for (const auto &ev : events) { - nlohmann::json tmpJson; - tmpJson[INPUT_KEY_WHEN] = currentTimeNs; - tmpJson[INPUT_KEY_TYPE] = ev.type; - tmpJson[INPUT_KEY_CODE] = ev.code; - tmpJson[INPUT_KEY_VALUE] = ev.value; - tmpJson[INPUT_KEY_DESCRIPTOR] = ev.descriptor; - tmpJson[INPUT_KEY_PATH] = ev.path; - eventsJsonArr->push_back(tmpJson); - } - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_KEY_STATE_BATCH; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_DATA] = eventsJsonArr->dump(); - std::string msg = jsonStr.dump(); - int32_t ret = SendMessage(sessionId, msg); - if (ret != DH_SUCCESS) { - DHLOGE("SendKeyStateNodeMsgBatch error, SendMessage fail."); - } - RecordEventLog(events); -} - -void DistributedInputSinkTransport::RecordEventLog(const std::vector &events) -{ - for (auto &ev : events) { - RecordEventLog(ev.descriptor, ev.type, ev.code, ev.value); - } -} - void DistributedInputSinkTransport::RecordEventLog(const std::string &dhId, int32_t type, int32_t code, int32_t value) { std::string eventType; @@ -330,33 +290,6 @@ void DistributedInputSinkTransport::NotifyUnprepareRemoteInput(int32_t sessionId callback_->OnUnprepareRemoteInput(sessionId); } -void DistributedInputSinkTransport::NotifyStartRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) -{ - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - DHLOGI("OnBytesRecei,ved cmdType is TRANS_SOURCE_MSG_START_TYPE deviceId:%s inputTypes:%d .", - GetAnonyString(deviceId).c_str(), inputTypes); - callback_->OnStartRemoteInput(sessionId, inputTypes); -} - -void DistributedInputSinkTransport::NotifyStopRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) -{ - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_MSG_STOP_TYPE deviceId:%s.", GetAnonyString(deviceId).c_str()); - callback_->OnStopRemoteInput(sessionId, inputTypes); -} - void DistributedInputSinkTransport::NotifyLatency(int32_t sessionId, const nlohmann::json &recMsg) { if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID)) { @@ -459,38 +392,6 @@ void DistributedInputSinkTransport::NotifyRelayStopDhidRemoteInput(int32_t sessi callback_->OnRelayStopDhidRemoteInput(toSrcSessionId, sessionId, deviceId, dhids); } -void DistributedInputSinkTransport::NotifyRelayStartTypeRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) -{ - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID) || - !IsInt32(recMsg, DINPUT_SOFTBUS_KEY_SESSION_ID) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - int32_t toSrcSessionId = recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_MSG_START_TYPE_FOR_REL deviceId:%s.", - GetAnonyString(deviceId).c_str()); - callback_->OnRelayStartTypeRemoteInput(toSrcSessionId, sessionId, deviceId, inputTypes); -} - -void DistributedInputSinkTransport::NotifyRelayStopTypeRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) -{ - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID) || - !IsInt32(recMsg, DINPUT_SOFTBUS_KEY_SESSION_ID) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - int32_t toSrcSessionId = recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_MSG_STOP_TYPE_FOR_REL deviceId:%s.", - GetAnonyString(deviceId).c_str()); - callback_->OnRelayStopTypeRemoteInput(toSrcSessionId, sessionId, deviceId, inputTypes); -} - void DistributedInputSinkTransport::DInputTransbaseSinkListener::NotifySessionClosed(int32_t sessionId) { DistributedInputSinkSwitch::GetInstance().RemoveSession(sessionId); @@ -506,8 +407,6 @@ void DistributedInputSinkTransport::RegRespFunMap() { memberFuncMap_[TRANS_SOURCE_MSG_PREPARE] = &DistributedInputSinkTransport::NotifyPrepareRemoteInput; memberFuncMap_[TRANS_SOURCE_MSG_UNPREPARE] = &DistributedInputSinkTransport::NotifyUnprepareRemoteInput; - memberFuncMap_[TRANS_SOURCE_MSG_START_TYPE] = &DistributedInputSinkTransport::NotifyStartRemoteInput; - memberFuncMap_[TRANS_SOURCE_MSG_STOP_TYPE] = &DistributedInputSinkTransport::NotifyStopRemoteInput; memberFuncMap_[TRANS_SOURCE_MSG_LATENCY] = &DistributedInputSinkTransport::NotifyLatency; memberFuncMap_[TRANS_SOURCE_MSG_START_DHID] = &DistributedInputSinkTransport::NotifyStartRemoteInputDhid; memberFuncMap_[TRANS_SOURCE_MSG_STOP_DHID] = &DistributedInputSinkTransport::NotifyStopRemoteInputDhid; @@ -518,10 +417,6 @@ void DistributedInputSinkTransport::RegRespFunMap() &DistributedInputSinkTransport::NotifyRelayStartDhidRemoteInput; memberFuncMap_[TRANS_SOURCE_MSG_STOP_DHID_FOR_REL] = &DistributedInputSinkTransport::NotifyRelayStopDhidRemoteInput; - memberFuncMap_[TRANS_SOURCE_MSG_START_TYPE_FOR_REL] = - &DistributedInputSinkTransport::NotifyRelayStartTypeRemoteInput; - memberFuncMap_[TRANS_SOURCE_MSG_STOP_TYPE_FOR_REL] = - &DistributedInputSinkTransport::NotifyRelayStopTypeRemoteInput; } void DistributedInputSinkTransport::HandleData(int32_t sessionId, const std::string &message) diff --git a/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.cpp b/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.cpp index 6bfa882..aaae09c 100644 --- a/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.cpp +++ b/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.cpp @@ -30,13 +30,11 @@ namespace { const int32_t SESSIONID = 1; const int32_t INT_DEVID = 1000; const int32_t INT_VECTORDHIDS = 123; - const uint32_t INPUTTYPE = static_cast(DInputDeviceType::ALL); const std::string DEVID = "umkyu1b165e1be98151891erbe8r91ev"; const std::string DHID = "Input_1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; const std::string SINKID = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; const std::string VECTORDHIDS = "Input_1ds56v18e1v21v8v1erv15r1v8r1j1ty8.Input_145adssphjknnk5877df"; const std::string STR_SESSIONID = "100"; - const std::string STR_INPUTTYPE = "111"; const std::string SOFTBUSCMDTYPE = "softbus_cmd_type"; } @@ -181,15 +179,11 @@ HWTEST_F(DistributedInputSinkTransTest, RespStartRemoteInput01, testing::ext::Te DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); jsonStr11_[DINPUT_SOFTBUS_KEY_SESSION_ID] = STR_SESSIONID; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); - jsonStr11_[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = STR_INPUTTYPE; - DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); jsonStr11_[DINPUT_SOFTBUS_KEY_DEVICE_ID] = DEVID; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); jsonStr11_[DINPUT_SOFTBUS_KEY_SESSION_ID] = SESSIONID; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); - jsonStr11_[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = INPUTTYPE; - DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); jsonStr10_[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_MSG_START_DHID_FOR_REL; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr10_.dump()); @@ -264,15 +258,11 @@ HWTEST_F(DistributedInputSinkTransTest, RespStopRemoteInput01, testing::ext::Tes DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr12_.dump()); jsonStr12_[DINPUT_SOFTBUS_KEY_SESSION_ID] = STR_SESSIONID; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr12_.dump()); - jsonStr12_[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = STR_INPUTTYPE; - DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr12_.dump()); jsonStr12_[DINPUT_SOFTBUS_KEY_DEVICE_ID] = DEVID; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr12_.dump()); jsonStr12_[DINPUT_SOFTBUS_KEY_SESSION_ID] = SESSIONID; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr12_.dump()); - jsonStr12_[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = INPUTTYPE; - DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr12_.dump()); jsonStr11_[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_MSG_STOP_DHID_FOR_REL; DistributedInputSinkTransport::GetInstance().HandleData(sessionId, jsonStr11_.dump()); diff --git a/services/source/inputinject/include/distributed_input_inject.h b/services/source/inputinject/include/distributed_input_inject.h index 7bb5028..b2855f4 100644 --- a/services/source/inputinject/include/distributed_input_inject.h +++ b/services/source/inputinject/include/distributed_input_inject.h @@ -35,7 +35,6 @@ public: const std::string ¶meters); int32_t UnregisterDistributedHardware(const std::string &devId, const std::string &dhId); int32_t RegisterDistributedEvent(RawEvent *buffer, size_t bufferSize); - int32_t RegisterDistributedEvent(const std::vector &events); int32_t StructTransJson(const InputDevice &pBuf, std::string &strDescriptor); void StartInjectThread(); void StopInjectThread(); diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index 9f5ead5..f2da03d 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -47,7 +47,6 @@ public: int32_t GetDevice(const std::string &dhId, VirtualDevice *&device); void ReportEvent(const RawEvent rawEvent); - void ReportEvent(const std::vector &events); int32_t CloseDeviceLocked(const std::string &dhId); void StartInjectThread(); void StopInjectThread(); @@ -57,7 +56,6 @@ public: int32_t GetVirtualTouchScreenFd(); int32_t GetDeviceInfo(std::string &deviceId); - void GetDevicesInfoByType(const std::string &networkId, uint32_t inputTypes, std::map &datas); void GetDevicesInfoByDhId(std::vector dhidsVec, std::map &datas); void ProcessInjectEvent(const std::shared_ptr &rawEvent); diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index d506584..893a697 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -83,8 +83,7 @@ int32_t DistributedInputInject::UnregisterDistributedHardware(const std::string return DH_SUCCESS; } -int32_t DistributedInputInject::GetDhIdsByInputType(const std::string &devId, const uint32_t &inputTypes, - std::vector &dhIds) +int32_t DistributedInputInject::RegisterInputNodeListener(sptr listener) { std::lock_guard lock(inputNodeManagerMutex_); if (inputNodeManager_ == nullptr) { @@ -92,7 +91,6 @@ int32_t DistributedInputInject::GetDhIdsByInputType(const std::string &devId, co return ERR_DH_INPUT_SERVER_SOURCE_INJECT_NODE_MANAGER_IS_NULL; } std::map datas; - inputNodeManager_->GetDevicesInfoByType(devId, inputTypes, datas); for (const auto &data_ : datas) { dhIds.push_back(data_.second); } diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 4e195d6..aeab8e2 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -427,15 +427,6 @@ void DistributedInputNodeManager::ReportEvent(const RawEvent rawEvent) conditionVariable_.notify_all(); } -void DistributedInputNodeManager::ReportEvent(const std::vector &events) -{ - std::lock_guard lockGuard(injectThreadMutex_); - for (auto ev : events) { - injectQueue_.push(std::make_shared(ev)); - } - conditionVariable_.notify_all(); -} - void DistributedInputNodeManager::InjectEvent() { int32_t ret = pthread_setname_np(pthread_self(), EVENT_INJECT_THREAD_NAME); @@ -523,31 +514,6 @@ int32_t DistributedInputNodeManager::GetDeviceInfo(std::string &deviceId) return DH_SUCCESS; } -void DistributedInputNodeManager::GetDevicesInfoByType(const std::string &networkId, uint32_t inputTypes, - std::map &datas) -{ - uint32_t inputType = 0; - - if ((inputTypes & static_cast(DInputDeviceType::MOUSE)) != 0) { - inputType |= INPUT_DEVICE_CLASS_CURSOR; - } - - if ((inputTypes & static_cast(DInputDeviceType::KEYBOARD)) != 0) { - inputType |= INPUT_DEVICE_CLASS_KEYBOARD; - } - - if ((inputTypes & static_cast(DInputDeviceType::MOUSE)) != 0) { - inputType |= INPUT_DEVICE_CLASS_TOUCH; - } - - std::lock_guard lock(virtualDeviceMapMutex_); - for (const auto &[id, virdevice] : virtualDeviceMap_) { - if ((virdevice->GetDeviceType() & inputType) && (virdevice->GetNetWorkId() == networkId)) { - datas.insert(std::pair(virdevice->GetDeviceFd(), id)); - } - } -} - void DistributedInputNodeManager::GetDevicesInfoByDhId( std::vector dhidsVec, std::map &datas) { 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 598f7a7..fef98b8 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -287,31 +287,17 @@ HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedEvent04, testing:: EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_INJECT_NODE_MANAGER_IS_NULL, ret); } -HWTEST_F(DistributedInputSourceInjectTest, GetDhIdsByInputType_001, testing::ext::TestSize.Level1) +HWTEST_F(DistributedInputSourceInjectTest, RegisterInputNodeListener, testing::ext::TestSize.Level1) { - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - std::vector dhIds; - std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; - dhIds.push_back(dhId); - std::shared_ptr rawEvent = nullptr; - DistributedInputInject::GetInstance().InputDeviceEventInject(rawEvent); - DistributedInputInject::GetInstance().inputNodeManager_ = std::make_unique(); - int32_t ret = DistributedInputInject::GetInstance().GetDhIdsByInputType(devId, - static_cast(DInputDeviceType::ALL), dhIds); + inputNodelistener_ = (std::make_unique()).release(); + int32_t ret = DistributedInputInject::GetInstance().RegisterInputNodeListener(inputNodelistener_); EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceInjectTest, GetDhIdsByInputType_002, testing::ext::TestSize.Level1) +HWTEST_F(DistributedInputSourceInjectTest, UnRegisterInputNodeListener, testing::ext::TestSize.Level1) { - DistributedInputInject::GetInstance().inputNodeManager_ = nullptr; - std::shared_ptr rawEvent = std::make_shared(); - DistributedInputInject::GetInstance().InputDeviceEventInject(rawEvent); - - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - std::vector dhIds; - int32_t ret = DistributedInputInject::GetInstance().GetDhIdsByInputType(devId, - static_cast(DInputDeviceType::ALL), dhIds); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_INJECT_NODE_MANAGER_IS_NULL, ret); + int32_t ret = DistributedInputInject::GetInstance().UnregisterInputNodeListener(inputNodelistener_); + EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputSourceInjectTest, GenerateVirtualTouchScreenDHId_001, testing::ext::TestSize.Level1) @@ -384,22 +370,6 @@ HWTEST_F(DistributedInputSourceInjectTest, RemoveVirtualTouchScreenNode_003, tes EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceInjectTest, GetVirtualTouchScreenFd_003, testing::ext::TestSize.Level1) -{ - std::string networkId = "umkyu1b165e1be98151891erbe8r91ev"; - uint32_t inputTypes = 1; - std::map datas; - DistributedInputInject::GetInstance().inputNodeManager_->GetDevicesInfoByType(networkId, inputTypes, datas); - - inputTypes = 2; - DistributedInputInject::GetInstance().inputNodeManager_->GetDevicesInfoByType(networkId, inputTypes, datas); - - std::vector dhidsVec; - DistributedInputInject::GetInstance().inputNodeManager_->GetDevicesInfoByDhId(dhidsVec, datas); - int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->GetVirtualTouchScreenFd(); - EXPECT_NE(-1, ret); -} - HWTEST_F(DistributedInputSourceInjectTest, GetDevice_001, testing::ext::TestSize.Level1) { std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; diff --git a/services/source/sourcemanager/BUILD.gn b/services/source/sourcemanager/BUILD.gn index c727c29..5cfd655 100644 --- a/services/source/sourcemanager/BUILD.gn +++ b/services/source/sourcemanager/BUILD.gn @@ -73,14 +73,10 @@ ohos_shared_library("libdinput_source") { "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${ipc_path}/src/simulation_event_listener_proxy.cpp", "${ipc_path}/src/simulation_event_listener_stub.cpp", - "${ipc_path}/src/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp", "${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp", "${ipc_path}/src/start_stop_result_call_back_proxy.cpp", "${ipc_path}/src/start_stop_result_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", diff --git a/services/source/sourcemanager/include/dinput_source_listener.h b/services/source/sourcemanager/include/dinput_source_listener.h index 5d5629d..c9a88ae 100644 --- a/services/source/sourcemanager/include/dinput_source_listener.h +++ b/services/source/sourcemanager/include/dinput_source_listener.h @@ -46,13 +46,10 @@ public: bool result) override; void OnResponsePrepareRemoteInput(const std::string deviceId, bool result, const std::string &object) override; void OnResponseUnprepareRemoteInput(const std::string deviceId, bool result) override; - void OnResponseStartRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override; - void OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override; void OnResponseStartRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override; void OnResponseStopRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override; void OnResponseKeyState(const std::string deviceId, const std::string &dhid, const uint32_t type, const uint32_t code, const uint32_t value) override; - void OnResponseKeyStateBatch(const std::string deviceId, const std::string &event) override; void OnReceivedEventRemoteInput(const std::string deviceId, const std::string &event) override; void OnResponseRelayPrepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result, const std::string &object) override; @@ -65,10 +62,6 @@ public: const std::string &dhids) override; void OnReceiveRelayStopDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId, const std::string &dhids) override; - void OnReceiveRelayStartTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, - uint32_t inputTypes) override; - void OnReceiveRelayStopTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, - uint32_t inputTypes) override; void RecordEventLog(int64_t when, int32_t type, int32_t code, int32_t value, const std::string &path); private: diff --git a/services/source/sourcemanager/include/dinput_source_manager_event_handler.h b/services/source/sourcemanager/include/dinput_source_manager_event_handler.h index a7dd636..549b1b6 100644 --- a/services/source/sourcemanager/include/dinput_source_manager_event_handler.h +++ b/services/source/sourcemanager/include/dinput_source_manager_event_handler.h @@ -50,8 +50,6 @@ private: void NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event); void NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event); void NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event); - void NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event); - void NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event); void NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); void NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); void NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event); diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index f709759..d298a9d 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -73,7 +73,6 @@ const uint32_t DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI = 19; const std::string INPUT_SOURCEMANAGER_KEY_SESSIONID = "sessionId"; const std::string INPUT_SOURCEMANAGER_KEY_DEVID = "deviceId"; const std::string INPUT_SOURCEMANAGER_KEY_HWID = "hardwareId"; -const std::string INPUT_SOURCEMANAGER_KEY_ITP = "inputTypes"; const std::string INPUT_SOURCEMANAGER_KEY_DHID = "dhids"; const std::string INPUT_SOURCEMANAGER_KEY_TYPE = "type"; const std::string INPUT_SOURCEMANAGER_KEY_CODE = "code"; @@ -143,18 +142,6 @@ public: int32_t UnprepareRemoteInput(const std::string &deviceId, sptr callback) override; - int32_t StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) override; - - int32_t StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) override; - - int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) override; - - int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback) override; - int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) override; @@ -251,8 +238,6 @@ public: void RunUnregisterCallback(const std::string &devId, const std::string &dhId, const int32_t &status); void RunPrepareCallback(const std::string &devId, const int32_t &status, const std::string &object); void RunUnprepareCallback(const std::string &devId, const int32_t &status); - void RunStartCallback(const std::string &devId, const uint32_t &inputTypes, const int32_t &status); - void RunStopCallback(const std::string &devId, const uint32_t &inputTypes, const int32_t &status); void RunStartDhidCallback(const std::string &sinkId, const std::string &dhIds, const int32_t &status); void RunStopDhidCallback(const std::string &sinkId, const std::string &dhIds, const int32_t &status); @@ -271,9 +256,6 @@ public: int32_t DeleteInputDeviceNodeInfo(const std::string &devId, const std::string &dhId, const std::vector::iterator &it); int32_t UnregCallbackNotify(const std::string &devId, const std::string &dhId); - void SetInputTypesMap(const std::string deviceId, uint32_t value); - uint32_t GetInputTypesMap(const std::string deviceId); - uint32_t GetAllInputTypesMap(); void ClearResourcesStatus(); public: @@ -283,10 +265,6 @@ public: const std::string &dhids); void RunRelayStopDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t status, const std::string &dhids); - void RunRelayStartTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t status, - uint32_t inputTypes); - void RunRelayStopTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t status, - uint32_t inputTypes); private: struct DInputClientRegistInfo { @@ -314,21 +292,6 @@ private: sptr unpreCallback = nullptr; }; - struct DInputClientStartInfo { - std::string devId; - uint32_t inputTypes; - sptr callback = nullptr; - DInputClientStartInfo(std::string deviceId, uint32_t types, sptr cb) - : devId(deviceId), inputTypes(types), callback(cb) {} - }; - - struct DInputClientStopInfo { - std::string devId; - uint32_t inputTypes; - sptr callback = nullptr; - DInputClientStopInfo(std::string deviceId, uint32_t types, sptr cb) - : devId(deviceId), inputTypes(types), callback(cb) {} - }; // add new prepare/start function struct DInputClientRelayPrepareInfo { std::string srcId; @@ -361,23 +324,6 @@ private: sptr callback = nullptr; }; - struct DInputClientStartTypeInfo { - std::string srcId; - std::string sinkId; - uint32_t inputTypes; - sptr callback = nullptr; - DInputClientStartTypeInfo(std::string sourceId, std::string sinkid, uint32_t types, - sptr cb) : srcId(sourceId), sinkId(sinkid), inputTypes(types), callback(cb) {} - }; - struct DInputClientStopTypeInfo { - std::string srcId; - std::string sinkId; - uint32_t inputTypes; - sptr callback = nullptr; - DInputClientStopTypeInfo(std::string sourceId, std::string sinkid, uint32_t types, - sptr cb) : srcId(sourceId), sinkId(sinkid), inputTypes(types), callback(cb) {} - }; - ServiceSourceRunningState serviceRunningState_ = ServiceSourceRunningState::STATE_NOT_START; DInputServerType isStartTrans_ = DInputServerType::NULL_SERVER_TYPE; std::shared_ptr statuslistener_; @@ -387,8 +333,6 @@ private: std::vector unregCallbacks_; std::vector preCallbacks_; std::vector unpreCallbacks_; - std::vector staCallbacks_; - std::vector stpCallbacks_; std::vector staStringCallbacks_; std::vector stpStringCallbacks_; @@ -397,15 +341,12 @@ private: std::vector relayUnpreCallbacks_; std::vector relayStaDhidCallbacks_; std::vector relayStpDhidCallbacks_; - std::vector relayStaTypeCallbacks_; - std::vector relayStpTypeCallbacks_; std::set> addWhiteListCallbacks_; std::set> delWhiteListCallbacks_; std::set> simulationEventCallbacks_; std::map DeviceMap_; - std::map InputTypesMap_; std::shared_ptr runner_; std::shared_ptr handler_; std::shared_ptr callBackHandler_; @@ -420,10 +361,6 @@ private: std::mutex valMutex_; - int32_t RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); - int32_t RelayStopRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, - sptr callback); int32_t RelayPrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback); int32_t RelayUnprepareRemoteInput(const std::string &srcId, const std::string &sinkId, diff --git a/services/source/sourcemanager/src/dinput_source_listener.cpp b/services/source/sourcemanager/src/dinput_source_listener.cpp index 1553424..d90ad72 100644 --- a/services/source/sourcemanager/src/dinput_source_listener.cpp +++ b/services/source/sourcemanager/src/dinput_source_listener.cpp @@ -177,64 +177,6 @@ void DInputSourceListener::OnResponseRelayUnprepareRemoteInput(int32_t toSrcSess sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } -void DInputSourceListener::OnResponseStartRemoteInput( - const std::string deviceId, const uint32_t inputTypes, bool result) -{ - DHLOGI("OnResponseStartRemoteInput called, deviceId: %s, inputTypes: %d, result: %s.", - GetAnonyString(deviceId).c_str(), inputTypes, result ? "success" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - sourceManagerObj_->RunStartCallback(deviceId, inputTypes, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - DHLOGE("GetCallbackEventHandler is null."); - return; - } - if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_ON); - } - - auto jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_ITP] = inputTypes; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_START_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DInputSourceListener::OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) -{ - DHLOGI("OnResponseStopRemoteInput called, deviceId: %s, inputTypes: %d, result: %s.", - GetAnonyString(deviceId).c_str(), inputTypes, result ? "true" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponseStopRemoteInput sourceManagerObj_ is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("OnResponseStopRemoteInput GetCallbackEventHandler is null."); - sourceManagerObj_->RunStopCallback(deviceId, inputTypes, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - return; - } - - auto jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_ITP] = inputTypes; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_STOP_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - void DInputSourceListener::OnResponseStartRemoteInputDhid( const std::string deviceId, const std::string &dhids, bool result) { @@ -325,14 +267,8 @@ void DInputSourceListener::OnResponseKeyState(const std::string deviceId, sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } - -void DInputSourceListener::OnResponseKeyStateBatch(const std::string deviceId, const std::string &event) -{ - DHLOGI("OnResponseKeyStateBatch events, deviceId: %s.", GetAnonyString(deviceId).c_str()); - OnReceivedEventRemoteInput(deviceId, event); -} - -void DInputSourceListener::OnReceivedEventRemoteInput(const std::string deviceId, const std::string &event) +void DInputSourceListener::OnReceivedEventRemoteInput( + const std::string deviceId, const std::string &event) { nlohmann::json inputData = nlohmann::json::parse(event, nullptr, false); if (inputData.is_discarded()) { @@ -345,11 +281,7 @@ void DInputSourceListener::OnReceivedEventRemoteInput(const std::string deviceId return; } - size_t jsonSize = inputData.size(); - DHLOGI("OnReceivedEventRemoteInput called, deviceId: %s, json size:%d.", - GetAnonyString(deviceId).c_str(), jsonSize); - - std::vector mEventBuffer(jsonSize); + RawEvent mEventBuffer[jsonSize]; int idx = 0; for (auto it = inputData.begin(); it != inputData.end(); ++it) { nlohmann::json oneData = (*it); @@ -369,8 +301,7 @@ void DInputSourceListener::OnReceivedEventRemoteInput(const std::string deviceId oneData[INPUT_KEY_VALUE], oneData[INPUT_KEY_PATH]); ++idx; } - - DistributedInputInject::GetInstance().RegisterDistributedEvent(mEventBuffer); + DistributedInputInject::GetInstance().RegisterDistributedEvent(mEventBuffer, jsonSize); } void DInputSourceListener::OnReceiveRelayPrepareResult(int32_t status, @@ -471,56 +402,6 @@ void DInputSourceListener::OnReceiveRelayStopDhidResult(int32_t status, sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } -void DInputSourceListener::OnReceiveRelayStartTypeResult(int32_t status, - const std::string &srcId, const std::string &sinkId, uint32_t inputTypes) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - - auto jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = inputTypes; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DInputSourceListener::OnReceiveRelayStopTypeResult(int32_t status, - const std::string &srcId, const std::string &sinkId, uint32_t inputTypes) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - - auto jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = inputTypes; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - void DInputSourceListener::RecordEventLog(int64_t when, int32_t type, int32_t code, int32_t value, const std::string &path) { diff --git a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp index 2f84018..e6e05fc 100644 --- a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp +++ b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp @@ -41,8 +41,6 @@ DInputSourceManagerEventHandler::DInputSourceManagerEventHandler( eventFuncMap_[DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG] = &DInputSourceManagerEventHandler::NotifyUnregisterCallback; eventFuncMap_[DINPUT_SOURCE_MANAGER_PREPARE_MSG] = &DInputSourceManagerEventHandler::NotifyPrepareCallback; eventFuncMap_[DINPUT_SOURCE_MANAGER_UNPREPARE_MSG] = &DInputSourceManagerEventHandler::NotifyUnprepareCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_START_MSG] = &DInputSourceManagerEventHandler::NotifyStartCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_MSG] = &DInputSourceManagerEventHandler::NotifyStopCallback; eventFuncMap_[DINPUT_SOURCE_MANAGER_START_DHID_MSG] = &DInputSourceManagerEventHandler::NotifyStartDhidCallback; eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_DHID_MSG] = &DInputSourceManagerEventHandler::NotifyStopDhidCallback; eventFuncMap_[DINPUT_SOURCE_MANAGER_KEY_STATE_MSG] = &DInputSourceManagerEventHandler::NotifyKeyStateCallback; @@ -59,10 +57,6 @@ DInputSourceManagerEventHandler::DInputSourceManagerEventHandler( &DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback; eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI] = &DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback; sourceManagerObj_ = manager; } @@ -164,69 +158,6 @@ void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk:: result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_MSG_IS_BAD); } -void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *it; - if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || - !IsUInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_ITP) || - !IsBoolean(innerMsg, INPUT_SOURCEMANAGER_KEY_RESULT)) { - DHLOGE("The key is invaild."); - return ; - } - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - DHLOGI("Start DInput Recv Callback ret: %s, devId: %s, inputTypes: %d", - result ? "true" : "false", GetAnonyString(deviceId).c_str(), inputTypes); - if (result) { - sourceManagerObj_->SetInputTypesMap( - deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) | inputTypes); - } - sourceManagerObj_->SetStartTransFlag((result && (sourceManagerObj_->GetInputTypesMap(deviceId) > 0)) ? - DInputServerType::SOURCE_SERVER_TYPE : DInputServerType::NULL_SERVER_TYPE); - sourceManagerObj_->RunStartCallback(deviceId, inputTypes, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD); -} - -void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *it; - if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || - !IsUInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_ITP) || - !IsBoolean(innerMsg, INPUT_SOURCEMANAGER_KEY_RESULT)) { - DHLOGE("The key is invaild."); - return ; - } - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - - DHLOGI("Stop DInput Recv Callback ret: %B, devId: %s, inputTypes: %d", - result, GetAnonyString(deviceId).c_str(), inputTypes); - if (result && (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)) { - sourceManagerObj_->SetInputTypesMap( - deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) - - (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)); - } - - if (sourceManagerObj_->GetInputTypesMap(deviceId) == 0) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); - } - - // DeviceMap_ all sink device switch is off,call isstart's callback - bool isAllDevSwitchOff = sourceManagerObj_->GetDeviceMapAllDevSwitchOff(); - if (isAllDevSwitchOff) { - DHLOGI("All Dev Switch Off"); - sourceManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE); - } - sourceManagerObj_->RunStopCallback(deviceId, inputTypes, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD); -} - void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); @@ -438,46 +369,6 @@ void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecF sourceManagerObj_->RunRelayStopDhidCallback(srcId, sinkId, status, dhids); } -void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *it; - if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || - !IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_SRC_DEVID) || - !IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_SINK_DEVID) || - !IsUInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_TYPE)) { - DHLOGE("The key is invaild."); - return ; - } - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - - sourceManagerObj_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); -} - -void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *it; - if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || - !IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_SRC_DEVID) || - !IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_SINK_DEVID) || - !IsUInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_TYPE)) { - DHLOGE("The key is invaild."); - return ; - } - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - - sourceManagerObj_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); -} - void DInputSourceManagerEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) { auto iter = eventFuncMap_.find(event->GetInnerEventId()); diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index a0fbb8a..84cfee1 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -180,7 +180,6 @@ int32_t DistributedInputSourceManager::Release() DistributedInputSourceTransport::GetInstance().Release(); inputDevice_.clear(); DeviceMap_.clear(); - InputTypesMap_.clear(); std::shared_ptr jsonArrayMsg = std::make_shared(); nlohmann::json tmpJson; @@ -555,257 +554,6 @@ int32_t DistributedInputSourceManager::UnprepareRemoteInput( return DH_SUCCESS; } -int32_t DistributedInputSourceManager::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_START_USE, deviceId, "Dinput start use call."); - if (!DInputCheckParam::GetInstance().CheckParam(deviceId, inputTypes, callback)) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start param is failed."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - - DHLOGI("Start called, deviceId: %s, inputTypes: %d", GetAnonyString(deviceId).c_str(), inputTypes); - for (auto iter : staCallbacks_) { - if (iter.devId == deviceId && iter.inputTypes == inputTypes) { - callback->OnResult(deviceId, inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in already started."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - } - - DInputClientStartInfo info {deviceId, inputTypes, callback}; - staCallbacks_.push_back(info); - DeviceMap_[deviceId] = DINPUT_SOURCE_SWITCH_OFF; - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput(deviceId, inputTypes); - if (ret != DH_SUCCESS) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in transport start"); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - DHLOGE("Start fail."); - for (auto iter = staCallbacks_.begin(); iter != staCallbacks_.end(); ++iter) { - if (iter->devId == deviceId && iter->inputTypes == inputTypes) { - iter->callback->OnResult(iter->devId, iter->inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL); - staCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceManager::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_STOP_USE, deviceId, "Dinput stop use call"); - if (!DInputCheckParam::GetInstance().CheckParam(deviceId, inputTypes, callback)) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop param is failed."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - - DHLOGI("Stop called, deviceId: %s, inputTypes: %d", GetAnonyString(deviceId).c_str(), inputTypes); - for (auto iter : stpCallbacks_) { - if (iter.devId == deviceId && iter.inputTypes == inputTypes) { - callback->OnResult(deviceId, inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in already stoped."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - } - - DInputClientStopInfo info {deviceId, inputTypes, callback}; - stpCallbacks_.push_back(info); - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(deviceId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("Stop fail."); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in transport stop."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - for (auto iter = stpCallbacks_.begin(); iter != stpCallbacks_.end(); ++iter) { - if (iter->devId == deviceId && iter->inputTypes == inputTypes) { - iter->callback->OnResult(iter->devId, iter->inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL); - stpCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_START_USE, sinkId, "Dinput start use call."); - if (!DInputCheckParam::GetInstance().CheckParam(srcId, sinkId, inputTypes, callback)) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start param is failed."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - - DHLOGI("StartRemoteInput called, srcId: %s, sinkId: %s, inputTypes: %d", GetAnonyString(srcId).c_str(), - GetAnonyString(sinkId).c_str(), inputTypes); - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in get local networkId error."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - if (srcId != localNetworkId) { - return RelayStartRemoteInputByType(srcId, sinkId, inputTypes, callback); - } - for (auto iter : staCallbacks_) { - if (iter.devId == sinkId && iter.inputTypes == inputTypes) { - DHLOGE("StartRemoteInput called, repeat call."); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in already started."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - } - - DInputClientStartInfo info {sinkId, inputTypes, callback}; - staCallbacks_.push_back(info); - DeviceMap_[sinkId] = DINPUT_SOURCE_SWITCH_OFF; // when sink device start success,set DINPUT_SOURCE_SWITCH_ON - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput(sinkId, inputTypes); - if (ret != DH_SUCCESS) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in transport start."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - DHLOGE("StartRemoteInput called, start fail."); - for (auto it = staCallbacks_.begin(); it != staCallbacks_.end(); ++it) { - if (it->devId == sinkId && it->inputTypes == inputTypes) { - staCallbacks_.erase(it); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_STOP_USE, sinkId, "Dinput stop use call."); - if (!DInputCheckParam::GetInstance().CheckParam(srcId, sinkId, inputTypes, callback)) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop param is failed."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - DHLOGI("StopRemoteInput called, srcId: %s, sinkId: %s, inputTypes: %d", GetAnonyString(srcId).c_str(), - GetAnonyString(sinkId).c_str(), inputTypes); - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in get networkId."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - if (srcId != localNetworkId) { - return RelayStopRemoteInputByType(srcId, sinkId, inputTypes, callback); - } - for (auto iter : stpCallbacks_) { - if (iter.devId == sinkId && iter.inputTypes == inputTypes) { - DHLOGE("StopRemoteInput called, repeat call."); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in already stoped."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - } - - DInputClientStopInfo info {sinkId, inputTypes, callback}; - stpCallbacks_.push_back(info); - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(sinkId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("StopRemoteInput called, stop fail."); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in transport stop."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - for (auto it = stpCallbacks_.begin(); it != stpCallbacks_.end(); ++it) { - if (it->devId == sinkId && it->inputTypes == inputTypes) { - stpCallbacks_.erase(it); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - return DH_SUCCESS; -} - -int32_t DistributedInputSourceManager::RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes, sptr callback) -{ - std::lock_guard lock(mutex_); - for (auto iter : relayStaTypeCallbacks_) { - if (iter.srcId == srcId && iter.sinkId == sinkId && iter.inputTypes == inputTypes) { - DHLOGE("Repeat call."); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - } - - DInputClientStartTypeInfo info(srcId, sinkId, inputTypes, callback); - relayStaTypeCallbacks_.push_back(info); - - int32_t ret = DistributedInputSourceTransport::GetInstance().SendRelayStartTypeRequest(srcId, sinkId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("Can not send message by softbus, start fail."); - for (auto iter = relayStaTypeCallbacks_.begin(); iter != relayStaTypeCallbacks_.end(); ++iter) { - if (iter->srcId == srcId && iter->sinkId == sinkId && iter->inputTypes == inputTypes) { - relayStaTypeCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; - } - - return DH_SUCCESS; -} - -int32_t DistributedInputSourceManager::RelayStopRemoteInputByType( - const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, sptr callback) -{ - std::lock_guard lock(mutex_); - for (auto iter : relayStpTypeCallbacks_) { - if (iter.srcId == srcId && iter.sinkId == sinkId && iter.inputTypes == inputTypes) { - DHLOGE("Repeat call."); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - } - - DInputClientStopTypeInfo info(srcId, sinkId, inputTypes, callback); - relayStpTypeCallbacks_.push_back(info); - - int32_t ret = DistributedInputSourceTransport::GetInstance().SendRelayStopTypeRequest(srcId, sinkId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("Can not send message by softbus, start fail."); - for (auto iter = relayStpTypeCallbacks_.begin(); iter != relayStpTypeCallbacks_.end(); ++iter) { - if (iter->srcId == srcId && iter->sinkId == sinkId && iter->inputTypes == inputTypes) { - relayStpTypeCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; - } - - return DH_SUCCESS; -} - int32_t DistributedInputSourceManager::PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, sptr callback) { @@ -1406,34 +1154,6 @@ void DistributedInputSourceManager::RunUnprepareCallback(const std::string &devI DHLOGE("ProcessEvent unparepareCallback is null."); } -void DistributedInputSourceManager::RunStartCallback( - const std::string &devId, const uint32_t &inputTypes, const int32_t &status) -{ - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - for (auto iter = staCallbacks_.begin(); iter != staCallbacks_.end(); ++iter) { - if (iter->devId == devId && iter->inputTypes == inputTypes) { - DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_START_MSG"); - iter->callback->OnResult(devId, inputTypes, status); - staCallbacks_.erase(iter); - break; - } - } -} - -void DistributedInputSourceManager::RunStopCallback( - const std::string &devId, const uint32_t &inputTypes, const int32_t &status) -{ - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - for (auto iter = stpCallbacks_.begin(); iter != stpCallbacks_.end(); ++iter) { - if (iter->devId == devId && iter->inputTypes == inputTypes) { - DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_STOP_MSG"); - iter->callback->OnResult(devId, inputTypes, status); - stpCallbacks_.erase(iter); - break; - } - } -} - void DistributedInputSourceManager::RunStartDhidCallback(const std::string &sinkId, const std::string &dhIds, const int32_t &status) { @@ -1523,47 +1243,6 @@ void DistributedInputSourceManager::RunRelayStopDhidCallback(const std::string & } } -void DistributedInputSourceManager::RunRelayStartTypeCallback(const std::string &srcId, const std::string &sinkId, - const int32_t status, uint32_t inputTypes) -{ - bool isCbRun = false; - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - for (std::vector::iterator iter = - relayStaTypeCallbacks_.begin(); iter != relayStaTypeCallbacks_.end(); ++iter) { - if (iter->srcId == srcId && iter->sinkId == sinkId && iter->inputTypes == inputTypes) { - DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI"); - iter->callback->OnResult(sinkId, inputTypes, status); - relayStaTypeCallbacks_.erase(iter); - isCbRun = true; - break; - } - } - - if (!isCbRun) { - DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI relayStaTypeCallbacks_ is null."); - } -} - -void DistributedInputSourceManager::RunRelayStopTypeCallback(const std::string &srcId, const std::string &sinkId, - const int32_t status, uint32_t inputTypes) -{ - bool isCbRun = false; - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - for (std::vector::iterator iter = - relayStpTypeCallbacks_.begin(); iter != relayStpTypeCallbacks_.end(); ++iter) { - if (iter->srcId == srcId && iter->sinkId == sinkId && iter->inputTypes == inputTypes) { - DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI"); - iter->callback->OnResult(sinkId, inputTypes, status); - relayStpTypeCallbacks_.erase(iter); - isCbRun = true; - break; - } - } - - if (!isCbRun) { - DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI relayStpTypeCallbacks_ is null."); - } -} void DistributedInputSourceManager::RunKeyStateCallback(const std::string &sinkId, const std::string &dhId, const uint32_t type, const uint32_t code, const uint32_t value) { @@ -1632,24 +1311,6 @@ void DistributedInputSourceManager::SetDeviceMapValue(const std::string deviceId DeviceMap_[deviceId] = value; } -uint32_t DistributedInputSourceManager::GetInputTypesMap(const std::string deviceId) -{ - auto key = InputTypesMap_.find(deviceId); - if (key != InputTypesMap_.end()) { - return InputTypesMap_[deviceId]; - } - return static_cast(DInputDeviceType::NONE); -} - -uint32_t DistributedInputSourceManager::GetAllInputTypesMap() -{ - uint32_t rInputTypes = static_cast(DInputDeviceType::NONE); - for (auto iter = InputTypesMap_.begin(); iter != InputTypesMap_.end(); ++iter) { - rInputTypes |= iter->second; - } - return rInputTypes; -} - void DistributedInputSourceManager::ClearResourcesStatus() { std::lock_guard lock(mutex_); diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn index 9018a55..03a4b74 100755 --- a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn +++ b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn @@ -75,10 +75,6 @@ ohos_unittest("distributed_input_sourcemanager_test") { "${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/start_d_input_call_back_proxy.cpp", - "${ipc_path}/src/start_d_input_call_back_stub.cpp", - "${ipc_path}/src/stop_d_input_call_back_proxy.cpp", - "${ipc_path}/src/stop_d_input_call_back_stub.cpp", "${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp", "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", 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 43ed88d..d07b09a 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -41,11 +41,6 @@ using namespace std; namespace OHOS { namespace DistributedHardware { namespace DistributedInput { -namespace { - const uint32_t INPUTTYPE = static_cast(DInputDeviceType::ALL); - const uint32_t INPUTTYPE_MOUSE = static_cast(DInputDeviceType::MOUSE); -} - void DistributedInputSourceManagerTest::SetUp() { sourceManager_ = new DistributedInputSourceManager(DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID, true); @@ -105,24 +100,6 @@ void DistributedInputSourceManagerTest::TestUnprepareDInputCallback::OnResult( return; } -void DistributedInputSourceManagerTest::TestStartDInputCallback::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - -void DistributedInputSourceManagerTest::TestStopDInputCallback::OnResult( - const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status) -{ - (void)deviceId; - (void)inputTypes; - (void)status; - return; -} - void DistributedInputSourceManagerTest::TestStartStopVectorCallbackStub::OnResultDhids(const std::string &devId, const int32_t &status) { @@ -466,238 +443,6 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_03, testing::ex EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret); } -/** - * @tc.name: StartRemoteInput - * @tc.desc: verify the function of starting distributed input on InputDeviceType. - * @tc.type: FUNC - * @tc.require: SR000H9J75 - */ -HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE_MOUSE, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_02, testing::ext::TestSize.Level1) -{ - std::string devId = ""; - sptr callback(new TestStartDInputCallback()); - int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); - devId = "umkyu1b165e1be98151891erbe8r91ev"; - DistributedInputSourceManager::DInputClientStartInfo info {devId, INPUTTYPE, callback}; - sourceManager_->staCallbacks_.push_back(info); - ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); - - ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_03, testing::ext::TestSize.Level1) -{ - std::string devId = "devId_4810input4809_test"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -/** - * @tc.name: StopRemoteInput - * @tc.desc: verify the function of stoping distributed input on InputDeviceType. - * @tc.type: FUNC - * @tc.require: SR000H9J75 - */ -HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStopDInputCallback()); - int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE_MOUSE, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_02, testing::ext::TestSize.Level1) -{ - std::string devId = ""; - sptr callback(new TestStopDInputCallback()); - int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); - devId = "umkyu1b165e1be98151891erbe8r91ev"; - DistributedInputSourceManager::DInputClientStopInfo info {devId, INPUTTYPE, callback}; - sourceManager_->stpCallbacks_.push_back(info); - ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_03, testing::ext::TestSize.Level1) -{ - sptr callback(new TestStopDInputCallback()); - std::string devId = "devId_4810input4809_test"; - int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - -/** - * @tc.name: StartRemoteInput - * @tc.desc: verify the function of starting distributed input on InputDeviceType. - * @tc.type: FUNC - * @tc.require: SR000H9J75 - */ -HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_04, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStartDInputCallback()); - int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE_MOUSE, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_05, testing::ext::TestSize.Level1) -{ - std::string srcId = ""; - std::string sinkId = ""; - sptr callback(new TestStartDInputCallback()); - int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); - srcId = "srcId_4810input4809_test"; - sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - DistributedInputSourceManager::DInputClientStartTypeInfo info(srcId, sinkId, INPUTTYPE, callback); - sourceManager_->relayStaTypeCallbacks_.push_back(info); - ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); - srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - DistributedInputSourceManager::DInputClientStartInfo startInfo {sinkId, INPUTTYPE, callback}; - sourceManager_->staCallbacks_.push_back(startInfo); - ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_06, testing::ext::TestSize.Level1) -{ - sptr callback(new TestStartDInputCallback()); - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "devId_4810input4809_test"; - int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -/** - * @tc.name: StopRemoteInput - * @tc.desc: verify the function of stoping distributed input on InputDeviceType. - * @tc.type: FUNC - * @tc.require: SR000H9J75 - */ -HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_04, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStopDInputCallback()); - int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE_MOUSE, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_05, testing::ext::TestSize.Level1) -{ - std::string srcId = ""; - std::string sinkId = ""; - sptr callback(new TestStopDInputCallback()); - int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, - INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); - srcId = "srcId_4810input4809_test"; - sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - DistributedInputSourceManager::DInputClientStopTypeInfo info(srcId, sinkId, INPUTTYPE, callback); - sourceManager_->relayStpTypeCallbacks_.push_back(info); - ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); - srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - DistributedInputSourceManager::DInputClientStopInfo stopInfo {sinkId, INPUTTYPE, callback}; - sourceManager_->stpCallbacks_.push_back(stopInfo); - ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_06, testing::ext::TestSize.Level1) -{ - sptr callback(new TestStopDInputCallback()); - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "devId_4810input4809_test"; - int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_01, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStartDInputCallback()); - int32_t sessionId = 1; - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId; - int32_t ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - sinkId = "sinkId_test"; - ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE_MOUSE, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_02, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStartDInputCallback()); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - int32_t ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_01, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStopDInputCallback()); - int32_t sessionId = 1; - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId; - int32_t ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - sinkId = "sinkId_test"; - ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(DH_SUCCESS, ret); - - ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE_MOUSE, callback); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_02, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - sptr callback(new TestStopDInputCallback()); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - int32_t ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE, callback); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); -} - /** * @tc.name: PrepareRemoteInput * @tc.desc: verify the function of distributing data from any device. @@ -1360,58 +1105,6 @@ HWTEST_F(DistributedInputSourceManagerTest, RunUnprepareCallback_01, testing::ex EXPECT_EQ(1, sourceManager_->unpreCallbacks_.size()); } -HWTEST_F(DistributedInputSourceManagerTest, RunStartCallback_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - int32_t status = 0; - uint32_t inputTypes = 1; - sptr callback(new TestStartDInputCallback()); - DistributedInputSourceManager::DInputClientStartInfo info {devId, inputTypes, callback}; - sourceManager_->staCallbacks_.push_back(info); - sourceManager_->RunStartCallback(devId, inputTypes, status); - EXPECT_EQ(0, sourceManager_->staCallbacks_.size()); - - DistributedInputSourceManager::DInputClientStartInfo startInfo {devId, inputTypes, callback}; - sourceManager_->staCallbacks_.push_back(startInfo); - devId = "devId_20221221_test"; - sourceManager_->RunStartCallback(devId, inputTypes, status); - EXPECT_EQ(1, sourceManager_->staCallbacks_.size()); - - inputTypes = 3; - sourceManager_->RunStartCallback(devId, inputTypes, status); - EXPECT_EQ(1, sourceManager_->staCallbacks_.size()); - - devId = "umkyu1b165e1be98151891erbe8r91ev"; - sourceManager_->RunStartCallback(devId, inputTypes, status); - EXPECT_EQ(1, sourceManager_->staCallbacks_.size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, RunStopCallback_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - int32_t status = 0; - uint32_t inputTypes = 1; - sptr callback(new TestStopDInputCallback()); - DistributedInputSourceManager::DInputClientStopInfo info {devId, inputTypes, callback}; - sourceManager_->stpCallbacks_.push_back(info); - sourceManager_->RunStopCallback(devId, inputTypes, status); - EXPECT_EQ(0, sourceManager_->stpCallbacks_.size()); - - DistributedInputSourceManager::DInputClientStopInfo stopInfo {devId, inputTypes, callback}; - sourceManager_->stpCallbacks_.push_back(stopInfo); - devId = "devId_20221221_test"; - sourceManager_->RunStopCallback(devId, inputTypes, status); - EXPECT_EQ(1, sourceManager_->stpCallbacks_.size()); - - inputTypes = 3; - sourceManager_->RunStopCallback(devId, inputTypes, status); - EXPECT_EQ(1, sourceManager_->stpCallbacks_.size()); - - devId = "umkyu1b165e1be98151891erbe8r91ev"; - sourceManager_->RunStopCallback(devId, inputTypes, status); - EXPECT_EQ(1, sourceManager_->stpCallbacks_.size()); -} - HWTEST_F(DistributedInputSourceManagerTest, RunStartDhidCallback_01, testing::ext::TestSize.Level1) { std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; @@ -1524,60 +1217,6 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_01, testing EXPECT_EQ(1, sourceManager_->relayStpDhidCallbacks_.size()); } -HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartTypeCallback_01, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - int32_t status = 0; - uint32_t inputTypes = 1; - sptr callback(new TestStartDInputCallback()); - DistributedInputSourceManager::DInputClientStartTypeInfo info(srcId, sinkId, inputTypes, callback); - sourceManager_->relayStaTypeCallbacks_.push_back(info); - sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(0, sourceManager_->relayStaTypeCallbacks_.size()); - - DistributedInputSourceManager::DInputClientStartTypeInfo startInfo(srcId, sinkId, inputTypes, callback); - sourceManager_->relayStaTypeCallbacks_.push_back(startInfo); - srcId = "devId_20221221_test"; - sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(1, sourceManager_->relayStaTypeCallbacks_.size()); - - sinkId = "sinkId_20221221_test"; - sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(1, sourceManager_->relayStaTypeCallbacks_.size()); - - inputTypes = 3; - sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(1, sourceManager_->relayStaTypeCallbacks_.size()); -} - -HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopTypeCallback_01, testing::ext::TestSize.Level1) -{ - std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; - int32_t status = 0; - uint32_t inputTypes = 1; - sptr callback(new TestStopDInputCallback()); - DistributedInputSourceManager::DInputClientStopTypeInfo info(srcId, sinkId, inputTypes, callback); - sourceManager_->relayStpTypeCallbacks_.push_back(info); - sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(0, sourceManager_->relayStpTypeCallbacks_.size()); - - DistributedInputSourceManager::DInputClientStopTypeInfo stopInfo(srcId, sinkId, inputTypes, callback); - sourceManager_->relayStpTypeCallbacks_.push_back(stopInfo); - srcId = "devId_20221221_test"; - sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(1, sourceManager_->relayStpTypeCallbacks_.size()); - - sinkId = "sinkId_20221221_test"; - sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(1, sourceManager_->relayStpTypeCallbacks_.size()); - - inputTypes = 3; - sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); - EXPECT_EQ(1, sourceManager_->relayStpTypeCallbacks_.size()); -} - HWTEST_F(DistributedInputSourceManagerTest, RemoveInputDeviceId_01, testing::ext::TestSize.Level1) { std::string deviceId = "umkyu1b165e1be98151891erbe8r91ev"; @@ -1607,31 +1246,6 @@ HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_02, test EXPECT_EQ(false, ret); } -HWTEST_F(DistributedInputSourceManagerTest, GetInputTypesMap_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - sourceManager_->InputTypesMap_[devId] = 1; - uint32_t ret = sourceManager_->GetInputTypesMap(devId); - EXPECT_EQ(static_cast(DInputDeviceType::MOUSE), ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, GetAllInputTypesMap_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - sourceManager_->InputTypesMap_[devId] = 1; - uint32_t ret = sourceManager_->GetAllInputTypesMap(); - EXPECT_EQ(static_cast(DInputDeviceType::MOUSE), ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, SetInputTypesMap_01, testing::ext::TestSize.Level1) -{ - std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; - uint32_t value = 0; - sourceManager_->InputTypesMap_[devId] = 1; - sourceManager_->SetInputTypesMap(devId, value); - EXPECT_EQ(true, sourceManager_->InputTypesMap_.empty()); -} - HWTEST_F(DistributedInputSourceManagerTest, Dump_01, testing::ext::TestSize.Level1) { int32_t fd = 1; @@ -1678,32 +1292,6 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_01, t EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); } -HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_01, testing::ext::TestSize.Level1) -{ - std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; - uint32_t inputTypes = 7; - bool result = true; - callback_->OnResponseStartRemoteInput(deviceId, inputTypes, result); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_01, testing::ext::TestSize.Level1) -{ - std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; - uint32_t inputTypes = 7; - bool result = true; - callback_->OnResponseStopRemoteInput(deviceId, inputTypes, result); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_01, testing::ext::TestSize.Level1) { std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1811,34 +1399,6 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_01, tes EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); } -HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_01, testing::ext::TestSize.Level1) -{ - int32_t status = 1; - std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; - std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; - uint32_t inputTypes = 7; - callback_->OnReceiveRelayStartTypeResult(status, srcId, sinkId, inputTypes); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_01, testing::ext::TestSize.Level1) -{ - int32_t status = 1; - std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; - std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; - uint32_t inputTypes = 7; - callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - HWTEST_F(DistributedInputSourceManagerTest, InitAuto_01, testing::ext::TestSize.Level1) { bool ret = sourceManager_->InitAuto(); @@ -1889,36 +1449,6 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_02, t EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); } -HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_02, testing::ext::TestSize.Level1) -{ - sourceManager_->InitAuto(); - - std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; - uint32_t inputTypes = 7; - bool result = true; - callback_->OnResponseStartRemoteInput(deviceId, inputTypes, result); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_02, testing::ext::TestSize.Level1) -{ - sourceManager_->InitAuto(); - - std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; - uint32_t inputTypes = 7; - bool result = true; - callback_->OnResponseStopRemoteInput(deviceId, inputTypes, result); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_02, testing::ext::TestSize.Level1) { sourceManager_->InitAuto(); @@ -2042,38 +1572,6 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_02, tes EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); } -HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_02, testing::ext::TestSize.Level1) -{ - sourceManager_->InitAuto(); - - int32_t status = 1; - std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; - std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; - uint32_t inputTypes = 7; - callback_->OnReceiveRelayStartTypeResult(status, srcId, sinkId, inputTypes); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_02, testing::ext::TestSize.Level1) -{ - sourceManager_->InitAuto(); - - int32_t status = 1; - std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; - std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; - uint32_t inputTypes = 7; - callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes); - - int32_t fd = 1; - std::vector args; - int32_t ret = sourceManager_->Dump(fd, args); - EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); -} - HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_01, testing::ext::TestSize.Level1) { DistributedInputSourceManager::StopDScreenListener stopListener; diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h index c47d5e0..3bcc374 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h @@ -29,8 +29,6 @@ #include "distributed_input_source_manager.h" #include "prepare_d_input_call_back_stub.h" #include "register_d_input_call_back_stub.h" -#include "start_d_input_call_back_stub.h" -#include "stop_d_input_call_back_stub.h" #include "unprepare_d_input_call_back_stub.h" #include "unregister_d_input_call_back_stub.h" #include "start_stop_d_inputs_call_back_stub.h" @@ -67,22 +65,6 @@ public: void OnResult(const std::string &deviceId, const int32_t &status); }; - class TestStartDInputCallback : public - OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { - public: - TestStartDInputCallback() = default; - virtual ~TestStartDInputCallback() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - - class TestStopDInputCallback : public - OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { - public: - TestStopDInputCallback() = default; - virtual ~TestStopDInputCallback() = default; - void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); - }; - class TestStartStopVectorCallbackStub : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { public: diff --git a/services/source/transport/include/distributed_input_source_transport.h b/services/source/transport/include/distributed_input_source_transport.h index 4634938..84c8f3a 100644 --- a/services/source/transport/include/distributed_input_source_transport.h +++ b/services/source/transport/include/distributed_input_source_transport.h @@ -61,8 +61,6 @@ public: int32_t PrepareRemoteInput(const std::string &deviceId); int32_t UnprepareRemoteInput(const std::string &deviceId); - int32_t StartRemoteInput(const std::string &deviceId, const uint32_t &inputTypes); - int32_t StopRemoteInput(const std::string &deviceId, const uint32_t &inputTypes); int32_t LatencyCount(const std::string &deviceId); void StartLatencyCount(const std::string &deviceId); void StartLatencyThread(const std::string &deviceId); @@ -84,8 +82,6 @@ public: const std::vector &dhids); int32_t SendRelayStopDhidRequest(const std::string &srcId, const std::string &sinkId, const std::vector &dhids); - int32_t SendRelayStartTypeRequest(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes); - int32_t SendRelayStopTypeRequest(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes); int32_t GetCurrentSessionId(); private: @@ -94,12 +90,9 @@ private: void SessionClosed(); void NotifyResponsePrepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void NotifyResponseUnprepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyResponseStartRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyResponseStopRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void NotifyResponseStartRemoteInputDhid(int32_t sessionId, const nlohmann::json &recMsg); void NotifyResponseStopRemoteInputDhid(int32_t sessionId, const nlohmann::json &recMsg); void NotifyResponseKeyState(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyResponseKeyStateBatch(int32_t sessionId, const nlohmann::json &recMsg); void NotifyReceivedEventRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); void ReceiveSrcTSrcRelayPrepare(int32_t sessionId, const nlohmann::json &recMsg); void ReceiveSrcTSrcRelayUnprepare(int32_t sessionId, const nlohmann::json &recMsg); @@ -121,19 +114,6 @@ private: void ReceiveRelayStartDhidResult(int32_t sessionId, const nlohmann::json &recMsg); void ReceiveRelayStopDhidResult(int32_t sessionId, const nlohmann::json &recMsg); - void ReceiveSrcTSrcRelayStartType(int32_t sessionId, const nlohmann::json &recMsg); - void ReceiveSrcTSrcRelayStopType(int32_t sessionId, const nlohmann::json &recMsg); - int32_t StartRemoteInputType(int32_t sessionId, const std::string &deviceId, const uint32_t &inputTypes); - int32_t StopRemoteInputType(int32_t sessionId, const std::string &deviceId, const uint32_t &inputTypes); - void NotifyResponseRelayStartTypeRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - void NotifyResponseRelayStopTypeRemoteInput(int32_t sessionId, const nlohmann::json &recMsg); - int32_t NotifyOriginStartTypeResult(int32_t sessionId, const std::string &srcId, const std::string &sinkId, - int32_t status, uint32_t inputTypes); - int32_t NotifyOriginStopTypeResult(int32_t sessionId, const std::string &srcId, const std::string &sinkId, - int32_t status, uint32_t inputTypes); - void ReceiveRelayStartTypeResult(int32_t sessionId, const nlohmann::json &recMsg); - void ReceiveRelayStopTypeResult(int32_t sessionId, const nlohmann::json &recMsg); - void CalculateLatency(int32_t sessionId, const nlohmann::json &recMsg); std::string JointDhIds(const std::vector &dhids); void RegRespFunMap(); diff --git a/services/source/transport/src/distributed_input_source_transport.cpp b/services/source/transport/src/distributed_input_source_transport.cpp index 63ac55c..af00a93 100644 --- a/services/source/transport/src/distributed_input_source_transport.cpp +++ b/services/source/transport/src/distributed_input_source_transport.cpp @@ -72,14 +72,11 @@ void DistributedInputSourceTransport::RegRespFunMap() { memberFuncMap_[TRANS_SINK_MSG_ONPREPARE] = &DistributedInputSourceTransport::NotifyResponsePrepareRemoteInput; memberFuncMap_[TRANS_SINK_MSG_ONUNPREPARE] = &DistributedInputSourceTransport::NotifyResponseUnprepareRemoteInput; - memberFuncMap_[TRANS_SINK_MSG_ONSTART] = &DistributedInputSourceTransport::NotifyResponseStartRemoteInput; - memberFuncMap_[TRANS_SINK_MSG_ONSTOP] = &DistributedInputSourceTransport::NotifyResponseStopRemoteInput; memberFuncMap_[TRANS_SINK_MSG_BODY_DATA] = &DistributedInputSourceTransport::NotifyReceivedEventRemoteInput; memberFuncMap_[TRANS_SINK_MSG_LATENCY] = &DistributedInputSourceTransport::CalculateLatency; memberFuncMap_[TRANS_SINK_MSG_DHID_ONSTART] = &DistributedInputSourceTransport::NotifyResponseStartRemoteInputDhid; memberFuncMap_[TRANS_SINK_MSG_DHID_ONSTOP] = &DistributedInputSourceTransport::NotifyResponseStopRemoteInputDhid; memberFuncMap_[TRANS_SINK_MSG_KEY_STATE] = &DistributedInputSourceTransport::NotifyResponseKeyState; - memberFuncMap_[TRANS_SINK_MSG_KEY_STATE_BATCH] = &DistributedInputSourceTransport::NotifyResponseKeyStateBatch; memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_PREPARE] = &DistributedInputSourceTransport::ReceiveSrcTSrcRelayPrepare; memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_PREPARE] = &DistributedInputSourceTransport::NotifyResponseRelayPrepareRemoteInput; @@ -103,18 +100,6 @@ void DistributedInputSourceTransport::RegRespFunMap() &DistributedInputSourceTransport::ReceiveRelayStartDhidResult; memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_DHID_RESULT] = &DistributedInputSourceTransport::ReceiveRelayStopDhidResult; - memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE] = - &DistributedInputSourceTransport::ReceiveSrcTSrcRelayStartType; - memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE] = - &DistributedInputSourceTransport::ReceiveSrcTSrcRelayStopType; - memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_STARTTYPE] = - &DistributedInputSourceTransport::NotifyResponseRelayStartTypeRemoteInput; - memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_STOPTYPE] = - &DistributedInputSourceTransport::NotifyResponseRelayStopTypeRemoteInput; - memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE_RESULT] = - &DistributedInputSourceTransport::ReceiveRelayStartTypeResult; - memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE_RESULT] = - &DistributedInputSourceTransport::ReceiveRelayStopTypeResult; } void DistributedInputSourceTransport::Release() @@ -341,60 +326,6 @@ int32_t DistributedInputSourceTransport::StopRemoteInputDhids(int32_t srcTsrcSeI return DH_SUCCESS; } -int32_t DistributedInputSourceTransport::StartRemoteInputType(int32_t srcTsrcSeId, const std::string &deviceId, - const uint32_t &inputTypes) -{ - int32_t sinkSessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(deviceId); - if (sinkSessionId < 0) { - DHLOGE("StartRemoteInputType error, not find this device:%s.", GetAnonyString(deviceId).c_str()); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("StartRemoteInputType srcTsrcSeId:%d, sinkSessionId:%d.", srcTsrcSeId, sinkSessionId); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_MSG_START_TYPE_FOR_REL; - jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; - jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID] = srcTsrcSeId; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(sinkSessionId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("StartRemoteInputType deviceId:%s, smsg:%s, SendMsg error, ret:%d.", - GetAnonyString(deviceId).c_str(), SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("StartRemoteInputType send success, devId:%s, msg:%s.", GetAnonyString(deviceId).c_str(), - SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - -int32_t DistributedInputSourceTransport::StopRemoteInputType(int32_t srcTsrcSeId, const std::string &deviceId, - const uint32_t &inputTypes) -{ - int32_t sinkSessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(deviceId); - if (sinkSessionId < 0) { - DHLOGE("StopRemoteInputType error, not find this device:%s.", GetAnonyString(deviceId).c_str()); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("StopRemoteInputType srcTsrcSeId:%d, sinkSessionId:%d.", srcTsrcSeId, sinkSessionId); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_MSG_STOP_TYPE_FOR_REL; - jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; - jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID] = srcTsrcSeId; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(sinkSessionId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("StopRemoteInputType deviceId:%s, smsg:%s, SendMsg error, ret:%d.", - GetAnonyString(deviceId).c_str(), SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("StopRemoteInputType send success, devId:%s, msg:%s.", GetAnonyString(deviceId).c_str(), - SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - int32_t DistributedInputSourceTransport::SendRelayPrepareRequest(const std::string &srcId, const std::string &sinkId) { int32_t sessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(srcId); @@ -529,103 +460,6 @@ int32_t DistributedInputSourceTransport::NotifyOriginStopDhidResult(int32_t srcT return DH_SUCCESS; } -int32_t DistributedInputSourceTransport::NotifyOriginStartTypeResult(int32_t srcTsrcSeId, const std::string &srcId, - const std::string &sinkId, int32_t status, uint32_t inputTypes) -{ - std::unique_lock sessionLock(operationMutex_); - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE_RESULT; - jsonStr[DINPUT_SOFTBUS_KEY_SRC_DEV_ID] = srcId; - jsonStr[DINPUT_SOFTBUS_KEY_SINK_DEV_ID] = sinkId; - jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = status; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(srcTsrcSeId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("NotifyOriginStartTypeResult srcTsrcSeId:%d, smsg:%s, SendMsg error, ret:%d.", - srcTsrcSeId, SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("NotifyOriginStartTypeResult srcTsrcSeId:%d, smsg:%s.", srcTsrcSeId, SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - -int32_t DistributedInputSourceTransport::NotifyOriginStopTypeResult(int32_t srcTsrcSeId, const std::string &srcId, - const std::string &sinkId, int32_t status, uint32_t inputTypes) -{ - std::unique_lock sessionLock(operationMutex_); - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE_RESULT; - jsonStr[DINPUT_SOFTBUS_KEY_SRC_DEV_ID] = srcId; - jsonStr[DINPUT_SOFTBUS_KEY_SINK_DEV_ID] = sinkId; - jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = status; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(srcTsrcSeId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("NotifyOriginStopTypeResult srcTsrcSeId:%d, smsg:%s, SendMsg error, ret:%d.", - srcTsrcSeId, SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("NotifyOriginStopTypeResult srcTsrcSeId:%d, smsg:%s.", srcTsrcSeId, SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - -int32_t DistributedInputSourceTransport::StartRemoteInput(const std::string &deviceId, const uint32_t &inputTypes) -{ - int32_t sessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(deviceId); - if (sessionId < 0) { - DHLOGE("StartRemoteInput error, not find this device:%s.", GetAnonyString(deviceId).c_str()); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("StartRemoteInput sessionId:%d.", sessionId); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_MSG_START_TYPE; - jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; - jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID] = sessionId; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(sessionId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("StartRemoteInput deviceId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.", - GetAnonyString(deviceId).c_str(), sessionId, SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("StartRemoteInput deviceId:%s, sessionId:%d, smsg:%s.", - GetAnonyString(deviceId).c_str(), sessionId, SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - -int32_t DistributedInputSourceTransport::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes) -{ - int32_t sessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(deviceId); - if (sessionId < 0) { - DHLOGE("StopRemoteInput error, not find this device:%s.", GetAnonyString(deviceId).c_str()); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("StopRemoteInput sessionId:%d.", sessionId); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_MSG_STOP_TYPE; - jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; - jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID] = sessionId; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(sessionId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("StopRemoteInput deviceId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.", - GetAnonyString(deviceId).c_str(), sessionId, SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("StopRemoteInput deviceId:%s, sessionId:%d, smsg:%s.", - GetAnonyString(deviceId).c_str(), sessionId, SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - int32_t DistributedInputSourceTransport::LatencyCount(const std::string &deviceId) { int32_t sessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(deviceId); @@ -840,58 +674,6 @@ int32_t DistributedInputSourceTransport::SendRelayStopDhidRequest(const std::str return DH_SUCCESS; } -int32_t DistributedInputSourceTransport::SendRelayStartTypeRequest(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes) -{ - int32_t sessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(srcId); - if (sessionId < 0) { - DHLOGE("SendRelayStartTypeRequest error, not find this device:%s.", GetAnonyString(srcId).c_str()); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("SendRelayStartTypeRequest sessionId:%d.", sessionId); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE; - jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = sinkId; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(sessionId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("SendRelayStartTypeRequest srcId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.", - GetAnonyString(srcId).c_str(), sessionId, SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL; - } - DHLOGI("SendRelayStartTypeRequest srcId:%s, sessionId:%d, smsg:%s.", - GetAnonyString(srcId).c_str(), sessionId, SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - -int32_t DistributedInputSourceTransport::SendRelayStopTypeRequest(const std::string &srcId, const std::string &sinkId, - const uint32_t &inputTypes) -{ - int32_t sessionId = DistributedInputTransportBase::GetInstance().GetSessionIdByDevId(srcId); - if (sessionId < 0) { - DHLOGE("SendRelayStopTypeRequest error, not find this device:%s.", GetAnonyString(srcId).c_str()); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("SendRelayStopTypeRequest sessionId:%d.", sessionId); - - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE; - jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = sinkId; - jsonStr[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - std::string smsg = jsonStr.dump(); - int32_t ret = SendMessage(sessionId, smsg); - if (ret != DH_SUCCESS) { - DHLOGE("SendRelayStopTypeRequest srcId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.", - GetAnonyString(srcId).c_str(), sessionId, SetAnonyId(smsg).c_str(), ret); - return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL; - } - DHLOGI("SendRelayStopTypeRequest srcId:%s, sessionId:%d, smsg:%s.", - GetAnonyString(srcId).c_str(), sessionId, SetAnonyId(smsg).c_str()); - return DH_SUCCESS; -} - std::string DistributedInputSourceTransport::JointDhIds(const std::vector &dhids) { if (dhids.size() <= 0) { @@ -959,40 +741,6 @@ void DistributedInputSourceTransport::NotifyResponseUnprepareRemoteInput(int32_t CloseInputSoftbus(deviceId, false); } -void DistributedInputSourceTransport::NotifyResponseStartRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SINK_MSG_ONSTART."); - if (!IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE) || - !IsBoolean(recMsg, DINPUT_SOFTBUS_KEY_RESP_VALUE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = DistributedInputTransportBase::GetInstance().GetDevIdBySessionId(sessionId); - if (deviceId.empty()) { - DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONSTART, deviceId is error."); - return; - } - callback_->OnResponseStartRemoteInput( - deviceId, recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE], recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); -} - -void DistributedInputSourceTransport::NotifyResponseStopRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SINK_MSG_ONSTOP."); - if (!IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE) || - !IsBoolean(recMsg, DINPUT_SOFTBUS_KEY_RESP_VALUE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = DistributedInputTransportBase::GetInstance().GetDevIdBySessionId(sessionId); - if (deviceId.empty()) { - DHLOGE("OnBytesReceived cmdType TRANS_SINK_MSG_ONSTOP, deviceId is error."); - return; - } - callback_->OnResponseStopRemoteInput( - deviceId, recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE], recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); -} - void DistributedInputSourceTransport::NotifyResponseStartRemoteInputDhid(int32_t sessionId, const nlohmann::json &recMsg) { @@ -1048,22 +796,6 @@ void DistributedInputSourceTransport::NotifyResponseKeyState(int32_t sessionId, recMsg[DINPUT_SOFTBUS_KEY_KEYSTATE_VALUE]); } -void DistributedInputSourceTransport::NotifyResponseKeyStateBatch(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SINK_MSG_KEY_STATE_BATCH."); - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_INPUT_DATA)) { - DHLOGE("The DINPUT_SOFTBUS_KEY_INPUT_DATA is invalid"); - return; - } - std::string deviceId = DistributedInputTransportBase::GetInstance().GetDevIdBySessionId(sessionId); - if (deviceId.empty()) { - DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_KEY_STATE_BATCH, deviceId is error."); - return; - } - std::string inputDataStr = recMsg[DINPUT_SOFTBUS_KEY_INPUT_DATA]; - callback_->OnResponseKeyStateBatch(deviceId, inputDataStr); -} - void DistributedInputSourceTransport::NotifyReceivedEventRemoteInput(int32_t sessionId, const nlohmann::json &recMsg) { DHLOGI("OnBytesReceived cmdType is TRANS_SINK_MSG_BODY_DATA."); @@ -1348,142 +1080,6 @@ void DistributedInputSourceTransport::ReceiveRelayStopDhidResult(int32_t session callback_->OnReceiveRelayStopDhidResult(status, srcId, sinkId, dhids); } -void DistributedInputSourceTransport::ReceiveSrcTSrcRelayStartType(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE."); - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID) || - !IsInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - int32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - int32_t ret = StartRemoteInputType(sessionId, deviceId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("Can not send message by softbus, start fail."); - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - DHLOGE("Could not get local device id."); - return; - } - NotifyOriginStartTypeResult(sessionId, localNetworkId, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD, inputTypes); - } -} - -void DistributedInputSourceTransport::ReceiveSrcTSrcRelayStopType(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE."); - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_DEVICE_ID) || - !IsInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - int32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - int32_t ret = StopRemoteInputType(sessionId, deviceId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("Can not send message by softbus, start fail."); - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - DHLOGE("Could not get local device id."); - return; - } - NotifyOriginStopTypeResult(sessionId, localNetworkId, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD, inputTypes); - } -} - -void DistributedInputSourceTransport::NotifyResponseRelayStartTypeRemoteInput(int32_t sessionId, - const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SINK_MSG_ON_RELAY_STARTTYPE."); - if (!IsInt32(recMsg, DINPUT_SOFTBUS_KEY_SESSION_ID) || - !IsBoolean(recMsg, DINPUT_SOFTBUS_KEY_RESP_VALUE) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string sinkDevId = DistributedInputTransportBase::GetInstance().GetDevIdBySessionId(sessionId); - if (sinkDevId.empty()) { - DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ON_RELAY_STARTTYPE, sinkDevId is error."); - return; - } - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - DHLOGE("Could not get local device id."); - return; - } - int32_t srcTsrcSeId = recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID]; - bool result = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - NotifyOriginStartTypeResult(srcTsrcSeId, localNetworkId, sinkDevId, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD, inputTypes); -} - -void DistributedInputSourceTransport::NotifyResponseRelayStopTypeRemoteInput(int32_t sessionId, - const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SINK_MSG_ON_RELAY_STOPTYPE."); - if (!IsInt32(recMsg, DINPUT_SOFTBUS_KEY_SESSION_ID) || - !IsBoolean(recMsg, DINPUT_SOFTBUS_KEY_RESP_VALUE) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - std::string sinkDevId = DistributedInputTransportBase::GetInstance().GetDevIdBySessionId(sessionId); - if (sinkDevId.empty()) { - DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ON_RELAY_STOPTYPE, sinkDevId is error."); - return; - } - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - DHLOGE("Could not get local device id."); - return; - } - int32_t srcTsrcSeId = recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID]; - bool result = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - NotifyOriginStopTypeResult(srcTsrcSeId, localNetworkId, sinkDevId, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD, inputTypes); -} - -void DistributedInputSourceTransport::ReceiveRelayStartTypeResult(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE_RESULT."); - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_SRC_DEV_ID) || - !IsString(recMsg, DINPUT_SOFTBUS_KEY_SINK_DEV_ID) || - !IsInt32(recMsg, DINPUT_SOFTBUS_KEY_RESP_VALUE) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - - std::string srcId = recMsg[DINPUT_SOFTBUS_KEY_SRC_DEV_ID]; - std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; - int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - callback_->OnReceiveRelayStartTypeResult(status, srcId, sinkId, inputTypes); -} - -void DistributedInputSourceTransport::ReceiveRelayStopTypeResult(int32_t sessionId, const nlohmann::json &recMsg) -{ - DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE_RESULT."); - if (!IsString(recMsg, DINPUT_SOFTBUS_KEY_SRC_DEV_ID) || - !IsString(recMsg, DINPUT_SOFTBUS_KEY_SINK_DEV_ID) || - !IsInt32(recMsg, DINPUT_SOFTBUS_KEY_RESP_VALUE) || - !IsUInt32(recMsg, DINPUT_SOFTBUS_KEY_INPUT_TYPE)) { - DHLOGE("The key is invaild."); - return; - } - - std::string srcId = recMsg[DINPUT_SOFTBUS_KEY_SRC_DEV_ID]; - std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; - int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; - uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; - callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes); -} - void DistributedInputSourceTransport::DInputTransbaseSourceListener::HandleSessionData(int32_t sessionId, const std::string &message) { diff --git a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp index 25c8d5f..1ec6d40 100644 --- a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp +++ b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp @@ -137,22 +137,6 @@ HWTEST_F(DistributedInputSourceTransTest, UnprepareRemoteInput_04, testing::ext: EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceTransTest, StartRemoteInput01, testing::ext::TestSize.Level0) -{ - std::string deviceId = ""; - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, StartRemoteInput02, testing::ext::TestSize.Level0) -{ - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputSourceTransTest, StartRemoteInput03, testing::ext::TestSize.Level0) { std::string deviceId = ""; @@ -191,40 +175,6 @@ HWTEST_F(DistributedInputSourceTransTest, StartRemoteInputDhids_02, testing::ext EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL, ret); } -HWTEST_F(DistributedInputSourceTransTest, StartRemoteInputType_01, testing::ext::TestSize.Level1) -{ - int32_t srcTsrcSeId = 1; - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInputType(srcTsrcSeId, deviceId, - static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, StartRemoteInputType_02, testing::ext::TestSize.Level1) -{ - int32_t srcTsrcSeId = 1; - std::string deviceId = ""; - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInputType(srcTsrcSeId, deviceId, - static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, StopRemoteInput01, testing::ext::TestSize.Level0) -{ - std::string deviceId = ""; - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, StopRemoteInput02, testing::ext::TestSize.Level0) -{ - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput( - deviceId, static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputSourceTransTest, StopRemoteInput03, testing::ext::TestSize.Level0) { std::string deviceId = ""; @@ -261,24 +211,6 @@ HWTEST_F(DistributedInputSourceTransTest, StopRemoteInputDhids_02, testing::ext: EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret); } -HWTEST_F(DistributedInputSourceTransTest, StopRemoteInputType_01, testing::ext::TestSize.Level1) -{ - int32_t srcTsrcSeId = 1; - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInputType(srcTsrcSeId, deviceId, - static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, StopRemoteInputType_02, testing::ext::TestSize.Level1) -{ - int32_t srcTsrcSeId = 1; - std::string deviceId = ""; - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInputType(srcTsrcSeId, deviceId, - static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret); -} - HWTEST_F(DistributedInputSourceTransTest, NotifyOriginPrepareResult01, testing::ext::TestSize.Level0) { std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; @@ -321,26 +253,6 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyOriginStopDhidResult01, testing: EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceTransTest, NotifyOriginStartTypeResult_01, testing::ext::TestSize.Level1) -{ - int32_t srcTsrcSeId = 2; - std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - std::string sinkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - int32_t ret = DistributedInputSourceTransport::GetInstance().NotifyOriginStartTypeResult(srcTsrcSeId, srcId, - sinkId, DH_SUCCESS, static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, NotifyOriginStopTypeResult_01, testing::ext::TestSize.Level1) -{ - int32_t srcTsrcSeId = 2; - std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - std::string sinkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - int32_t ret = DistributedInputSourceTransport::GetInstance().NotifyOriginStopTypeResult(srcTsrcSeId, srcId, - sinkId, DH_SUCCESS, static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputSourceTransTest, SendRelayPrepareRequest_01, testing::ext::TestSize.Level1) { std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; @@ -384,15 +296,6 @@ HWTEST_F(DistributedInputSourceTransTest, SendRelayStartDhidRequest_01, testing: EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceTransTest, SendRelayStartTypeRequest_01, testing::ext::TestSize.Level1) -{ - std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - std::string sinkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - int32_t ret = DistributedInputSourceTransport::GetInstance().SendRelayStartTypeRequest(srcId, sinkId, - static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputSourceTransTest, SendRelayStopDhidRequest_01, testing::ext::TestSize.Level1) { std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; @@ -403,15 +306,6 @@ HWTEST_F(DistributedInputSourceTransTest, SendRelayStopDhidRequest_01, testing:: EXPECT_EQ(DH_SUCCESS, ret); } -HWTEST_F(DistributedInputSourceTransTest, SendRelayStopTypeRequest_01, testing::ext::TestSize.Level1) -{ - std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - std::string sinkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - int32_t ret = DistributedInputSourceTransport::GetInstance().SendRelayStopTypeRequest(srcId, sinkId, - static_cast(DInputDeviceType::ALL)); - EXPECT_EQ(DH_SUCCESS, ret); -} - HWTEST_F(DistributedInputSourceTransTest, LatencyCount01, testing::ext::TestSize.Level0) { std::string deviceId = "deviceId"; @@ -456,34 +350,6 @@ HWTEST_F(DistributedInputSourceTransTest, SendRelayStopDhidRequest_02, testing:: EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret); } -HWTEST_F(DistributedInputSourceTransTest, SendRelayStartTypeRequest_02, testing::ext::TestSize.Level1) -{ - std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - std::string sinkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::vector dhids; - dhids.push_back("Input_1ds56v18e1v21v8v1erv15r1v8r1j1ty8"); - int32_t sessionId = -1; - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId; - int32_t ret = DistributedInputSourceTransport::GetInstance().SendRelayStartTypeRequest(srcId, sinkId, - static_cast(DInputDeviceType::ALL)); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, SendRelayStopTypeRequest_02, testing::ext::TestSize.Level1) -{ - std::string srcId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - std::string sinkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; - std::vector dhids; - dhids.push_back("Input_1ds56v18e1v21v8v1erv15r1v8r1j1ty8"); - int32_t sessionId = -1; - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId; - int32_t ret = DistributedInputSourceTransport::GetInstance().SendRelayStopTypeRequest(srcId, sinkId, - static_cast(DInputDeviceType::ALL)); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret); -} - HWTEST_F(DistributedInputSourceTransTest, JointDhIds01, testing::ext::TestSize.Level0) { std::vector dhids; @@ -560,50 +426,6 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseUnprepareRemoteInput01, EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } -HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStartRemoteInput01, testing::ext::TestSize.Level0) -{ - int32_t sessionId = 0; - nlohmann::json recMsg; - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = "false"; - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = "input_type"; - DistributedInputSourceTransport::GetInstance().NotifyResponseStartRemoteInput(sessionId, recMsg); - - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; - DistributedInputSourceTransport::GetInstance().NotifyResponseStartRemoteInput(sessionId, recMsg); - - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = 1; - DistributedInputSourceTransport::GetInstance().NotifyResponseStartRemoteInput(sessionId, recMsg); - std::string remoteId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[remoteId] = sessionId; - DistributedInputSourceTransport::GetInstance().NotifyResponseStartRemoteInput(sessionId, recMsg); - std::string message(MSG_MAX_SIZE + 1, 'a'); - int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); -} - -HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStopRemoteInput01, testing::ext::TestSize.Level0) -{ - int32_t sessionId = 0; - nlohmann::json recMsg; - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = "false"; - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = "input_type"; - DistributedInputSourceTransport::GetInstance().NotifyResponseStopRemoteInput(sessionId, recMsg); - - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; - DistributedInputSourceTransport::GetInstance().NotifyResponseStopRemoteInput(sessionId, recMsg); - - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = 1; - DistributedInputSourceTransport::GetInstance().NotifyResponseStopRemoteInput(sessionId, recMsg); - std::string remoteId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[remoteId] = sessionId; - DistributedInputSourceTransport::GetInstance().NotifyResponseStopRemoteInput(sessionId, recMsg); - std::string message(MSG_MAX_SIZE + 1, 'a'); - int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); -} - HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStartRemoteInputDhid01, testing::ext::TestSize.Level0) { int32_t sessionId = 0; @@ -904,87 +726,6 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayStopDhidResult01, testing: EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } -HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStartType01, testing::ext::TestSize.Level1) -{ - int32_t sessionId = 1; - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - nlohmann::json recMsg; - recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID] = 1; - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = "input_type_test"; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartType(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartType(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = 1; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartType(sessionId, recMsg); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartType(sessionId, recMsg); - std::string message(MSG_MAX_SIZE + 1, 'a'); - int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStopType01, testing::ext::TestSize.Level1) -{ - int32_t sessionId = 1; - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - nlohmann::json recMsg; - recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID] = 1; - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = "input_type_test"; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopType(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopType(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = 1; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopType(sessionId, recMsg); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; - DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopType(sessionId, recMsg); - std::string message(MSG_MAX_SIZE + 1, 'a'); - int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStartTypeRemoteInput01, testing::ext::TestSize.Level1) -{ - int32_t sessionId = 1; - nlohmann::json recMsg; - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = "false"; - recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID] = "1"; - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = "input_type_test"; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID] = sessionId; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = 1; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); - std::string message(MSG_MAX_SIZE + 1, 'a'); - int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); -} - -HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStopTypeRemoteInput01, testing::ext::TestSize.Level1) -{ - int32_t sessionId = 1; - std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; - nlohmann::json recMsg; - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = "false"; - recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID] = "1"; - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = "input_type_test"; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID] = sessionId; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = 1; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; - DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); - std::string message(MSG_MAX_SIZE + 1, 'a'); - int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); - EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); -} - HWTEST_F(DistributedInputSourceTransTest, HandleData01, testing::ext::TestSize.Level1) { int32_t sessionId = 1; diff --git a/sinkhandler/include/distributed_input_sink_handler.h b/sinkhandler/include/distributed_input_sink_handler.h index 01171b3..d20ec32 100644 --- a/sinkhandler/include/distributed_input_sink_handler.h +++ b/sinkhandler/include/distributed_input_sink_handler.h @@ -41,10 +41,6 @@ public: int32_t UnsubscribeLocalHardware(const std::string &dhId) override; void OnRemoteSinkSvrDied(const wptr &remote); void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); - int32_t RegisterPrivacyResources(std::shared_ptr listener) override; - int32_t PauseDistributedHardware(const std::string &networkId) override; - int32_t ResumeDistributedHardware(const std::string &networkId) override; - int32_t StopDistributedHardware(const std::string &networkId) override; public: class SALoadSinkCb : public OHOS::SystemAbilityLoadCallbackStub { diff --git a/sinkhandler/src/distributed_input_sink_handler.cpp b/sinkhandler/src/distributed_input_sink_handler.cpp index be4eeca..13ff24f 100644 --- a/sinkhandler/src/distributed_input_sink_handler.cpp +++ b/sinkhandler/src/distributed_input_sink_handler.cpp @@ -155,26 +155,6 @@ void DistributedInputSinkHandler::OnRemoteSinkSvrDied(const wptr dInputSinkProxy_ = nullptr; } -int32_t DistributedInputSinkHandler::RegisterPrivacyResources(std::shared_ptr listener) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputSinkHandler::PauseDistributedHardware(const std::string &networkId) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputSinkHandler::ResumeDistributedHardware(const std::string &networkId) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputSinkHandler::StopDistributedHardware(const std::string &networkId) -{ - return DH_SUCCESS; -} - IDistributedHardwareSink *GetSinkHardwareHandler() { return &DistributedInputSinkHandler::GetInstance(); diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index 8a5e798..1f88d12 100644 --- a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -122,18 +122,6 @@ int32_t DistributedInputClient::UnprepareRemoteInput( return DH_SUCCESS; } -int32_t DistributedInputClient::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputClient::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - bool DistributedInputClient::IsNeedFilterOut(const std::string &deviceId, const BusinessEvent &event) { return true; diff --git a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index ae72613..c7cd856 100644 --- a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -123,18 +123,6 @@ int32_t DistributedInputClient::UnprepareRemoteInput( return DH_SUCCESS; } -int32_t DistributedInputClient::StartRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - -int32_t DistributedInputClient::StopRemoteInput( - const std::string &deviceId, const uint32_t &inputTypes, sptr callback) -{ - return DH_SUCCESS; -} - bool DistributedInputClient::IsNeedFilterOut(const std::string &deviceId, const BusinessEvent &event) { return true; diff --git a/test/fuzztest/distributedinputkit_fuzzer/distributed_input_kit_fuzzer.cpp b/test/fuzztest/distributedinputkit_fuzzer/distributed_input_kit_fuzzer.cpp index 30217ec..bbe63c3 100644 --- a/test/fuzztest/distributedinputkit_fuzzer/distributed_input_kit_fuzzer.cpp +++ b/test/fuzztest/distributedinputkit_fuzzer/distributed_input_kit_fuzzer.cpp @@ -31,8 +31,6 @@ #include "i_distributed_sink_input.h" #include "i_distributed_source_input.h" #include "prepare_d_input_call_back_stub.h" -#include "start_d_input_call_back_stub.h" -#include "stop_d_input_call_back_stub.h" #include "unprepare_d_input_call_back_stub.h" namespace OHOS { @@ -61,30 +59,6 @@ public: }; }; -class TestStartDInputCallback : -public OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { -public: - void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) - { - (void)devId; - (void)inputTypes; - (void)status; - }; -}; - -class TestStopDInputCallback : -public OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { -public: - TestStopDInputCallback() = default; - virtual ~TestStopDInputCallback() = default; - void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status) - { - (void)devId; - (void)inputTypes; - (void)status; - }; -}; - class TestIStartStopDInputsCallback : public OHOS::DistributedHardware ::DistributedInput::IStartStopDInputsCallback { public: @@ -122,12 +96,7 @@ void StartRemoteInputFuzzTest(const uint8_t *data, size_t size) std::string srcId = "123"; std::string sinkId = "456"; - uint32_t inputTypes = *(reinterpret_cast(data)); std::vector dhIds= {}; - OHOS::sptr startCb(new (std::nothrow) TestStartDInputCallback()); - OHOS::sptr stopCb(new (std::nothrow) TestStopDInputCallback()); - DistributedInput::DistributedInputKit::StartRemoteInput(sinkId, inputTypes, startCb); - DistributedInput::DistributedInputKit::StartRemoteInput(srcId, sinkId, inputTypes, startCb); OHOS::sptr callback(new (std::nothrow) TestIStartStopDInputsCallback()); DistributedInput::DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback); DistributedInput::DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback); @@ -158,12 +127,7 @@ void StopRemoteInputFuzzTest(const uint8_t* data, size_t size) std::string srcId = "123"; std::string sinkId = "456"; - uint32_t inputTypes = *(reinterpret_cast(data)); std::vector dhIds = {}; - OHOS::sptr startCb(new (std::nothrow) TestStartDInputCallback()); - OHOS::sptr stopCb(new (std::nothrow) TestStopDInputCallback()); - DistributedInput::DistributedInputKit::StopRemoteInput(sinkId, inputTypes, stopCb); - DistributedInput::DistributedInputKit::StopRemoteInput(srcId, sinkId, inputTypes, stopCb); OHOS::sptr callback(new (std::nothrow) TestIStartStopDInputsCallback()); DistributedInput::DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback); DistributedInput::DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback); diff --git a/utils/include/dinput_utils_tool.h b/utils/include/dinput_utils_tool.h index b41e564..3176520 100644 --- a/utils/include/dinput_utils_tool.h +++ b/utils/include/dinput_utils_tool.h @@ -65,7 +65,6 @@ void ScanInputDevicesPath(const std::string &dirName, std::vector & void ResetVirtualDevicePressedKeys(const std::vector &nodePaths); std::string GetString(const std::vector &vec); -int32_t GetRandomInt32(); } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/src/dinput_utils_tool.cpp b/utils/src/dinput_utils_tool.cpp index bb0b59c..9eb87b7 100644 --- a/utils/src/dinput_utils_tool.cpp +++ b/utils/src/dinput_utils_tool.cpp @@ -15,11 +15,8 @@ #include "dinput_utils_tool.h" -#include #include #include -#include - #include #include #include @@ -442,14 +439,6 @@ std::string GetString(const std::vector &vec) retStr += "]"; return retStr; } - -int32_t GetRandomInt32() -{ - std::default_random_engine engine(time(nullptr)); - - std::uniform_int_distribution distribution(0, INT32_MAX); - return distribution(engine); -} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file -- Gitee