diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..70e34ecb3dcc4c74a1f8635625e280b492849b5e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.errorSquiggles": "disabled" +} \ No newline at end of file diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index f4b2a4456b147feb24f1980dc94f26dc1d275cce..37d1b5c2e42cc390c7cdba4850abda4ef10e4f78 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -49,17 +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 af980bd84347b5089540650e3a901dbcbaa75a91..d2faca8cea4c2f84f54614c7e397e95d1a5c157b 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) { @@ -194,4 +150,4 @@ bool DInputCheckParam::CheckUnregisterParam(const std::string &devId, const std: } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/common/include/input_check_param.h b/common/include/input_check_param.h index 164372684eae88dc1fa68ec7ac57920395d42691..b2f9dc0f8c21578cb049a8cfbb016b38951cc6b8 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 afbbecbd2af4b00b85aaa8984ca63558d0baf030..b68127020e86bc9e4299d550040889620b854abc 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), mPendingEventItems{}, pendingEventCount_(0), pendingEventIndex_(0), pendingINotify_(false), deviceChanged_(false), - inputTypes_(0), isStartCollectEvent_(false), isStartCollectHandler_(false) + isStartCollectEvent_(false), isStartCollectHandler_(false) { Initialize(); } @@ -823,7 +823,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); @@ -1142,23 +1141,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; @@ -1229,30 +1211,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) { diff --git a/common/include/input_hub.h b/common/include/input_hub.h index 83ff3370e6310b1bc93bb73f78921a7b4f8669a7..bab6a797366fa0f5788ea7ed5859ec65ee884d17 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); @@ -223,7 +221,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 bb67a24646f842cb71ced759cee21df66afa221b..f583f1ee6617d134528f2be5672a4ae6b638d366 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 8c02692b073ea3275cabd5d91d31eda6d42c779b..0000000000000000000000000000000000000000 --- 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 c54cd1d8e8cd6cd0cdd1324478de5d4c716e3c71..0000000000000000000000000000000000000000 --- 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 c41d0958d6f3230eff48f0992d3ec4cb786264f5..6aeb012313ff2526090d46f44164c37a8e2a87a1 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 c99ff35a03c8c3b0e07a7e369a5d0798ee04d4d5..9c99d3cd177c4b4fdf65646b35beb7287a89ce85 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 bcf713bcab6e6372656a69be4f1edcbf4e8f1dc4..a458f170ed75d3962af49a0b306a25542ebdf654 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,10 +53,8 @@ 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; - dInputHandler.FindDevicesInfoByType(inputTypes, datas); dInputHandler.FindDevicesInfoByDhId(dhidsVec, datas); dInputHandler.Query(); dInputHandler.StartInputMonitorDeviceThread(); @@ -80,4 +76,4 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 0dc7ba2f150e6c194d690fe49787d798c2afda8c..081edd2bbc2f14d888f086a13540a3d3329bd356 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 77eec803531d2a349a699c495105dadb9c1f34e9..b8979e000030e8d23f222adbd40d66d64b2ea748 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 diff --git a/interfaces/inner_kits/src/distributed_input_kit.cpp b/interfaces/inner_kits/src/distributed_input_kit.cpp index 663c696bf94ffa7c3b31e7ce89fc433443c040c2..66688250bbf50a901f692534cb26186632e1e3ff 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); diff --git a/interfaces/inner_kits/test/unittest/BUILD.gn b/interfaces/inner_kits/test/unittest/BUILD.gn index 35e41258eb92c0c41124702bb2ae596ca3205ab5..d1c67aa1dff2ef264e5213423f69aba58696825b 100644 --- a/interfaces/inner_kits/test/unittest/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/BUILD.gn @@ -68,14 +68,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 5b56f2e6598420129da40136219bacffce8f5f90..8b26c0c7be837414dac8ed41aba600e272a11f43 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) { @@ -236,24 +218,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"; @@ -272,26 +236,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"; @@ -312,24 +256,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"; @@ -348,26 +274,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"; @@ -445,13 +351,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"; @@ -508,4 +407,4 @@ HWTEST_F(DistributedInputInnerTest, UnregisterSessionStateCb01, testing::ext::Te } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS 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 206089754f93a9731447a64351dabe0cbbd54e15..3209a81c998fa2a7bd37b47130d55a9f2c685fc6 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" #include "register_session_state_callback_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 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 683375c03ea1b3bab4778db8699763a8aa4cd691..c6bf751fe29c723e233b826307b419f122297bb7 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) { diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index 4ab262795c737ceb090bca8473fa524aefbf50f3..f7a6b8b18befb90dd0f0a5eead6153599de89504 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, @@ -180,7 +168,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 0cf8c50d19069e67bc4c964addb9d87e3de6543a..a9657d7b0b853e5410a35bc55635a36fbb9cd883 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; diff --git a/interfaces/ipc/include/distributed_input_source_stub.h b/interfaces/ipc/include/distributed_input_source_stub.h index 208faeab2e3e5a82979baac3ee9a72efb69f7634..d58e8e13e2fac5d18f3d75f445f98504307abf35 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 7239628360db8e6d08790a50835b25f2b1355896..0000000000000000000000000000000000000000 --- 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 7c3932a84e6bdaaf894c34f8bf02b8b66b5658f1..0000000000000000000000000000000000000000 --- 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 67def3ca94de8d0903663da34799ff4dee2a1d5c..0000000000000000000000000000000000000000 --- 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 3649a27ec3a26983c27bb7c0a608fa2ed802ab7c..0000000000000000000000000000000000000000 --- 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 aed168d5c35a0e56e17b68d072ef5db4829dc6f4..e2499186610676db6e3d815849b966bf6819ee1f 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -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) { diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index 9dfe5f9b738a898737409ddbe0a35390feced7dc..43f13af6e11e67439a2d9f6924539a67e874e1ac 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 bba0223b812054f63d0341162baf1fd97991e960..961b50422d4788203c174e5e497b4f500b0e5d42 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()) { 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 7c06d7b7a4b7aec546a981d9f987b46e32fe9d31..0000000000000000000000000000000000000000 --- 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 b9243b1b93fd5a7cf91400eb1226d4a4fe7594bd..0000000000000000000000000000000000000000 --- 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 8657cd016a84e5bb5a45286eb7bbe5097376e250..0000000000000000000000000000000000000000 --- 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 64f8d5f8914252d6b4f3d261c490bc8a309b4be8..0000000000000000000000000000000000000000 --- 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 a974bb994d099f7e3ef9c5ef9af058cd0268f08a..2e18111409ed0ed07ea510c775efc6891f6a5146 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 6ffb823f56b58c64d2963ca7ec4c038403a19fd8..5be8f25f5f24b7e34f32a0e52df8969773c09a31 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()); @@ -385,4 +348,4 @@ HWTEST_F(AddWhiteListInfosCallbackTest, DistributedInputSinkStub01, testing::ext } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS 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 624f12c3b2875f0162529e1be9270edb06c4e979..807deccb96b06bd44712f1006b40ff931dbbeb9a 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 @@ -32,14 +32,12 @@ #include "sharing_dhid_listener_stub.h" #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: @@ -190,4 +166,4 @@ public: } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS -#endif // ADD_WHITE_LIST_INFOS_CALLBACK_TEST_H \ No newline at end of file +#endif // ADD_WHITE_LIST_INFOS_CALLBACK_TEST_H diff --git a/interfaces/ipc/test/clientunittest/BUILD.gn b/interfaces/ipc/test/clientunittest/BUILD.gn index 4a838f5785b764882536724e09cb8dbd2554f335..c75f824687c239f063f653d86b92a6ba584e068c 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 d08527b97542f480fb0cbcb86e682b30a44fe5d0..66c9407405633cb4d378fbfdc6cd6956ffbec932 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"; @@ -469,4 +375,4 @@ HWTEST_F(DistributedInputClientTest, ProcessEvent04, testing::ext::TestSize.Leve } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/interfaces/ipc/test/clientunittest/distributed_input_client_test.h b/interfaces/ipc/test/clientunittest/distributed_input_client_test.h index 09c674b18fe1c97be37c11d1c9cf25f82a5ceaa0..1b4476f9d2deb0644862786aada3b6a176d886cd 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 df58c627a60378efc8e0a82a332135f38c77746f..828061e4d8f5902a38016221d59e815f35919651 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 dfb97c88609fcbf21f4c4956842520362a55b9ae..782500528acaf4ab0b3d99bd46f79ca5ff3a85bc 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) @@ -291,24 +251,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 +394,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 +419,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()); @@ -585,4 +481,4 @@ HWTEST_F(DInputSourceCallBackTest, UnregisterSimulationEventListener01, testing: } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h b/interfaces/ipc/test/dinputsourcecallbackunittest/dinput_source_callback_unittest.h index 3ee72e9ff008314c6cf6efba3a7ded355f062949..4854f3901e5b8670c5a1b0dad87d77e7658402ed 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: @@ -203,4 +173,4 @@ public: } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS -#endif // DINPUT_SOURCE_CALLBACK_TEST_H \ No newline at end of file +#endif // DINPUT_SOURCE_CALLBACK_TEST_H diff --git a/interfaces/ipc/test/ipcunittest/BUILD.gn b/interfaces/ipc/test/ipcunittest/BUILD.gn index 83145771ef751fccea8001f7a057d8a9472f3e89..cb225fa4ff6233055bd403a556e1d87e06392acb 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 11ce0d6680aa8fcb3d4c92379d0ad6d21bb2c545..a2314f958ceef36d67800173598a33244e999540 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"; @@ -431,4 +393,4 @@ HWTEST_F(DistributedInputIpcTest, StopRemoteInput04, testing::ext::TestSize.Leve } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/common/include/dinput_sink_trans_callback.h b/services/common/include/dinput_sink_trans_callback.h index d31e2506dfd1dcc80df01f8f826bbfafa4747e58..f194960ded4391917521668aa1716e487aa2831e 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 70dd253ac072f925df4ab79688052c81c197fb1c..f8e903f065e563b1f0f3be5c933b4c98e9f66e7f 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" diff --git a/services/common/include/dinput_source_trans_callback.h b/services/common/include/dinput_source_trans_callback.h index 35d348ea976fe297abf1cc96fbc8a9169e9c11a5..f2f574734e89ffe78310a7615b0a380f0411fc95 100644 --- a/services/common/include/dinput_source_trans_callback.h +++ b/services/common/include/dinput_source_trans_callback.h @@ -27,8 +27,6 @@ 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, @@ -46,10 +44,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 5d49ef5357452064317f294f19455bbfb4a6f28a..9787b6036ab3fd4fdf7027278d1fdc97fa0a0043 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_; @@ -79,4 +76,4 @@ private: } // namespace DistributedHardware } // namespace OHOS -#endif // DISTRIBUTED_INPUT_COLLECTOR_H \ No newline at end of file +#endif // DISTRIBUTED_INPUT_COLLECTOR_H diff --git a/services/sink/inputcollector/src/distributed_input_collector.cpp b/services/sink/inputcollector/src/distributed_input_collector.cpp index e70c1988b4e115d38c8eb977660a9ae17c9b3feb..b195bd3db5b8dc26d013ddd6077668bd3a3c6c3f 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 656828495b3c49ee1c517307b092ef2f5e13c86b..fe31fc731bba71a9b1499093070c8876f8fe5358 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 +} // namespace OHOS diff --git a/services/sink/sinkmanager/include/distributed_input_sink_manager.h b/services/sink/sinkmanager/include/distributed_input_sink_manager.h index f9157058703b6674c5b2d9428c318cd8749f5a5a..d71613d139c42d3e290865bba01621ee378a5451 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 b4ade6879c68489f17a2d2e9c4c136212af73a97..3adf7696b08e87721e339932eb004037ed078326 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -22,6 +22,7 @@ #include #include "dinput_softbus_define.h" +#include "dinput_state.h" #include "distributed_hardware_fwk_kit.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" @@ -51,7 +52,6 @@ DistributedInputSinkManager::DistributedInputSinkManager(int32_t saId, bool runO : SystemAbility(saId, runOnCreate) { DHLOGI("DistributedInputSinkManager ctor!"); - inputTypes_ = DInputDeviceType::NONE; } DistributedInputSinkManager::~DistributedInputSinkManager() @@ -85,13 +85,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."); } @@ -153,14 +151,30 @@ void DistributedInputSinkManager::DInputSinkListener::OnPrepareRemoteInput( void DistributedInputSinkManager::DInputSinkListener::OnUnprepareRemoteInput(const int32_t &sessionId) { DHLOGI("OnUnprepareRemoteInput called, sessionId: %d", sessionId); - OnStopRemoteInput(sessionId, static_cast(DInputDeviceType::ALL)); - DistributedInputSinkSwitch::GetInstance().RemoveSession(sessionId); + std::string Dhids; + std::map dhIdStateMap = DInputState::GetInstance().GetGhIdStateMap(); + if (!dhIdStateMap.empty()) { + for (auto it : dhIdStateMap) { + if (it.second == DhIdState::THROUGH_OUT) { + Dhids.append(it.first); + Dhids.append("."); + } + } + if (!Dhids.empty()) { + Dhids.pop_back(); + } + DHLOGI("GetGhIdStateMap success: %d", GetAnonyString(Dhids).c_str()); + OnStopRemoteInputDhid(sessionId, Dhids); + DistributedInputSinkSwitch::GetInstance().RemoveSession(sessionId); - nlohmann::json jsonStr; - jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONUNPREPARE; - jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = true; - std::string smsg = jsonStr.dump(); - DistributedInputSinkTransport::GetInstance().RespUnprepareRemoteInput(sessionId, smsg); + nlohmann::json jsonStr; + jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONUNPREPARE; + jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = true; + std::string smsg = jsonStr.dump(); + DistributedInputSinkTransport::GetInstance().RespUnprepareRemoteInput(sessionId, smsg); + } + DHLOGE("GetGhIdStateMap error."); + return; } void DistributedInputSinkManager::DInputSinkListener::OnRelayPrepareRemoteInput(const int32_t &toSrcSessionId, @@ -195,7 +209,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayUnprepareRemoteInpu { DHLOGI("OnRelayUnprepareRemoteInput called, toSinkSessionId: %d, devId: %s", toSinkSessionId, GetAnonyString(deviceId).c_str()); - OnStopRemoteInput(toSinkSessionId, static_cast(DInputDeviceType::ALL)); DistributedInputSinkSwitch::GetInstance().RemoveSession(toSinkSessionId); nlohmann::json jsonStr; @@ -206,79 +219,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) { @@ -337,7 +277,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."); @@ -408,7 +347,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput 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."); @@ -416,91 +354,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput } } -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."); - return; - } - 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::DeleteStopDhids(int32_t sessionId, const std::vector stopDhIds, std::vector &stopIndeedDhIds) @@ -706,16 +559,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 4e1ef2b6899fd3c8fdc9f9e75d5472da5729dac0..2ab5725d14891995d1787ecbbabcf67a686ce0da 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, DeleteStopDhids01, testing::ext::TestSize.Level0) { int32_t sessionId = 1; @@ -297,4 +289,4 @@ HWTEST_F(DistributedInputSinkManagerTest, Dump_01, testing::ext::TestSize.Level1 } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/sink/transport/include/distributed_input_sink_transport.h b/services/sink/transport/include/distributed_input_sink_transport.h index df48cc2967bd8419bbbf218dd4713ba4323574d4..de9b050c01b2197b02df81de09f57adfc085fef5 100644 --- a/services/sink/transport/include/distributed_input_sink_transport.h +++ b/services/sink/transport/include/distributed_input_sink_transport.h @@ -80,8 +80,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,8 +88,6 @@ 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); diff --git a/services/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index 69368ca13c47c20d1df4f5ccf6e4bbd497eff066..ffcf70ae4c92a508b120bdf9e32fc5a5f8cf6981 100644 --- a/services/sink/transport/src/distributed_input_sink_transport.cpp +++ b/services/sink/transport/src/distributed_input_sink_transport.cpp @@ -330,33 +330,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 +432,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 +447,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 +457,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 6bfa8824ae6bd987fac94e6da28d84b11448c152..560082b8ae0ae35daf62e5dc592447b880954254 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()); @@ -484,4 +474,4 @@ HWTEST_F(DistributedInputSinkTransTest, SendMessage_001, testing::ext::TestSize. } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/source/inputinject/include/distributed_input_inject.h b/services/source/inputinject/include/distributed_input_inject.h index cb4951a7ce057a48d7377f188ba037522deb0130..a4534b815bc5e28e7e1cd35b1e9365b91e9f0a63 100644 --- a/services/source/inputinject/include/distributed_input_inject.h +++ b/services/source/inputinject/include/distributed_input_inject.h @@ -61,4 +61,4 @@ private: } // namespace DistributedHardware } // namespace OHOS -#endif // DISTRIBUTED_INPUT_INJECT_H \ No newline at end of file +#endif // DISTRIBUTED_INPUT_INJECT_H diff --git a/services/source/inputinject/include/distributed_input_node_manager.h b/services/source/inputinject/include/distributed_input_node_manager.h index ace7b0ee437f9d7228a5f00b816458dbb652c64e..e28b0e89897c613756b1ac72b0de8070aedbe92d 100644 --- a/services/source/inputinject/include/distributed_input_node_manager.h +++ b/services/source/inputinject/include/distributed_input_node_manager.h @@ -134,4 +134,4 @@ private: } // namespace DistributedHardware } // namespace OHOS -#endif // DISTRIBUTED_INPUT_INJECT_H \ No newline at end of file +#endif // DISTRIBUTED_INPUT_INJECT_H diff --git a/services/source/sourcemanager/BUILD.gn b/services/source/sourcemanager/BUILD.gn index c727c29cb9edd65dcb55d31f4bba6cd072d33c4e..5cfd6556183d5b75052a5acdb17956314e2a1a4a 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 5d5629d002fdcfb78f33314ab1970ba02924caeb..0312441800bf9b5caa0be85ec7eaf50f8836fc7c 100644 --- a/services/source/sourcemanager/include/dinput_source_listener.h +++ b/services/source/sourcemanager/include/dinput_source_listener.h @@ -46,8 +46,6 @@ 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, @@ -65,10 +63,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: @@ -78,4 +72,4 @@ private: } // namespace DistributedHardware } // namespace OHOS -#endif // DINPUT_SOURCE_LISTENER_H \ No newline at end of file +#endif // DINPUT_SOURCE_LISTENER_H 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 a7dd636539bfd9f34f47c2b4424f35654014064a..f9520793d2b220ec42f12f8b6ef393a1cfbea72c 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); @@ -74,4 +72,4 @@ private: } // namespace DistributedHardware } // namespace OHOS -#endif // DINPUT_SOURCE_MANAGER_EVENT_HANDLER_H \ No newline at end of file +#endif // DINPUT_SOURCE_MANAGER_EVENT_HANDLER_H diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index 30cb31280e3d304983182854b8d342c707b6e3f3..17f8241b1720b6c673d173a5bada803d27823ace 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 { @@ -334,21 +312,6 @@ private: } }; - 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; @@ -403,23 +366,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_; @@ -429,8 +375,6 @@ private: std::vector unregCallbacks_; std::set preCallbacks_; std::set unpreCallbacks_; - std::vector staCallbacks_; - std::vector stpCallbacks_; std::vector staStringCallbacks_; std::vector stpStringCallbacks_; @@ -439,15 +383,12 @@ private: std::set 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_; @@ -465,10 +406,8 @@ private: sptr stopDScreenListener_ = nullptr; sptr deviceOfflineListener_ = nullptr; - 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); + std::mutex valMutex_; + 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 c35328d16283dc481d6675d135d60149557f5e42..a1ee2f1faf77891ef726d5501ce70ce93a70b65e 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) { @@ -471,56 +413,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) { @@ -544,4 +436,4 @@ void DInputSourceListener::RecordEventLog(int64_t when, int32_t type, int32_t co } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS 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 2f84018f3ed1a4e2a9fe5911749c552d0d9bafe1..162aadb69355bba7c53bd937109a42eb37a9a688 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()); @@ -490,4 +381,4 @@ void DInputSourceManagerEventHandler::ProcessEvent(const AppExecFwk::InnerEvent: } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index d3df09391acf59a94823ef43e7b5aff48caa8065..cc2fc0008176e681a2ae36b16a662851ed7fac8a 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; @@ -526,257 +525,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(startStopMutex_); - 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(startStopMutex_); - 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) { @@ -1334,34 +1082,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) { @@ -1451,47 +1171,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) { @@ -1561,24 +1240,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(prepareMutex_); @@ -1588,18 +1249,6 @@ void DistributedInputSourceManager::ClearResourcesStatus() relayUnpreCallbacks_.clear(); } -void DistributedInputSourceManager::SetInputTypesMap(const std::string deviceId, uint32_t value) -{ - if (value == static_cast(DInputDeviceType::NONE)) { - auto key = InputTypesMap_.find(deviceId); - if (key != InputTypesMap_.end()) { - InputTypesMap_.erase(key); - return; - } - } - InputTypesMap_[deviceId] = value; -} - void DistributedInputSourceManager::StartDScreenListener::OnMessage(const DHTopic topic, const std::string &message) { DHLOGI("StartDScreenListener OnMessage!"); diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn index 9018a55dbebb1e255be5710ac6289d936fd253a4..03a4b747847c8d420220d000fad2716f4eaf1ee4 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 a40774f2f88dd5c205604ba5b79a409c517ad710..5993554ac5641ea2cffbc8266f6a0426f4107539 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; @@ -2137,4 +1635,4 @@ HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_02, testing::ext::TestS } } // namespace DistributedInput } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS 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 c47d5e0981e5ca0cba7fe60b6e2baf601d990f0c..3bcc37400c45041a8096c284383017da08e81fa8 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 88bcba6b0f39a650389559698693422111689235..030b57c5071d96e1b70347e45d8156a53eda8503 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,8 +90,6 @@ 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); @@ -121,19 +115,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); std::vector SplitDhIdString(const std::string &dhIdsString); diff --git a/services/source/transport/src/distributed_input_source_transport.cpp b/services/source/transport/src/distributed_input_source_transport.cpp index 48fd7a7b5d607f1a49a6f8d2cc81f5b0c7d6dcd2..4f9271dd3ab615d28c7339dbe7231a6a6afaa396 100644 --- a/services/source/transport/src/distributed_input_source_transport.cpp +++ b/services/source/transport/src/distributed_input_source_transport.cpp @@ -75,8 +75,6 @@ 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; @@ -106,18 +104,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() @@ -346,60 +332,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); @@ -534,103 +466,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); @@ -845,58 +680,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) { @@ -971,40 +754,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) { @@ -1370,142 +1119,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 25c8d5f263c2501deb3780535245a1c9640ea5de..1ec6d40bbef066f815e927d28dbc7d073ee00376 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/services/state/include/dinput_state.h b/services/state/include/dinput_state.h index 5dfa229f1a08e06497852aff0cac4460ca1cd2c6..26e0df17a01e31172d7418a3fc289c0ccc3589b2 100644 --- a/services/state/include/dinput_state.h +++ b/services/state/include/dinput_state.h @@ -45,6 +45,7 @@ public: int32_t RecordDhIds(const std::vector &dhIds, DhIdState state, const int32_t sessionId); int32_t RemoveDhIds(const std::vector &dhIds); DhIdState GetStateByDhid(const std::string &dhId); + std::map GetGhIdStateMap(); void AddKeyDownState(struct RawEvent event); void RemoveKeyDownState(struct RawEvent event); diff --git a/services/state/src/dinput_state.cpp b/services/state/src/dinput_state.cpp index 846b5e2070f33fcba1aa3b47c132334713d73a0b..8a3338fbe34b474524ad5b6207332ee9625e70a9 100644 --- a/services/state/src/dinput_state.cpp +++ b/services/state/src/dinput_state.cpp @@ -94,6 +94,11 @@ DhIdState DInputState::GetStateByDhid(const std::string &dhId) return dhIdStateMap_[dhId]; } +std::map DInputState::GetGhIdStateMap() +{ + return dhIdStateMap_; +} + void DInputState::SimulateEventInjectToSrc(const int32_t sessionId, const std::vector &dhIds) { DHLOGI("SimulateEventInject enter, sessionId %d, dhIds size %d", sessionId, dhIds.size()); diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index 8a5e79846aaeb5c901652858079d40425ba67cfb..1f88d12476f156aab26688c2d72cbb80863d807f 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 ae726135bef2655c7b8b64a30631788643601cd9..c7cd856b3fbdb1bad0509351c341254eae0e20f6 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 30217ec80fc56f02f5df90bee4062abc7af8ff9d..33028a6aab9973ac1192246126c6bacec504c3fd 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); @@ -196,4 +160,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) OHOS::DistributedHardware::StopRemoteInputFuzzTest(data, size); OHOS::DistributedHardware::IsTouchEventNeedFilterOutFuzzTest(data, size); return 0; -} \ No newline at end of file +}