From 133364205c4e4517365331168b987e23ff4720b2 Mon Sep 17 00:00:00 2001 From: xxxx Date: Sat, 25 Jun 2022 09:22:35 +0800 Subject: [PATCH] Description:start 1,2;then stop 1, no effect Match-id-b881a02477efc503a68aa4e4ad687c0a26402fc1 --- common/include/constants_dinput.h | 30 +++------ .../unittest/distributed_input_inner_test.cpp | 28 +++++--- .../mock/mock_distributed_input_client.cpp | 6 +- .../ipc/include/distributed_input_client.h | 2 +- .../ipc/src/distributed_input_client.cpp | 23 ++++--- .../src/distributed_input_collector.cpp | 9 ++- .../include/distributed_input_sink_manager.h | 2 +- .../src/distributed_input_sink_manager.cpp | 66 +++++++++---------- .../src/distributed_input_source_manager.cpp | 13 ++-- .../distributed_input_sourcemanager_test.cpp | 12 ++-- .../distributed_input_sourcetrans_test.cpp | 12 ++-- .../mock/mock_distributed_input_client.cpp | 6 +- .../mock/mock_distributed_input_client.cpp | 6 +- 13 files changed, 108 insertions(+), 107 deletions(-) diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index c4b8937..89aca7a 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -64,24 +64,15 @@ namespace DistributedInput { constexpr int32_t FAILURE_UNREGISTING = -60003; /** - * Input Type NULL. + * Device Type definitions */ - constexpr uint32_t INPUT_TYPE_NULL = 0; - - /** - * Input Type MOUSE. - */ - constexpr uint32_t INPUT_TYPE_MOUSE = 1; - - /** - * Input Type KEYBOARD. - */ - constexpr uint32_t INPUT_TYPE_KEYBOARD = 2; - - /** - * Input Type TOUCH. - */ - constexpr uint32_t INPUT_TYPE_TOUCH = 4; + enum class DInputDeviceType : uint32_t { + NONE = 0x0000, + MOUSE = 0x0001, + KEYBOARD = 0x0002, + TOUCHPAD = MOUSE, + ALL = MOUSE | KEYBOARD, + }; /** * Maximum number of signalled FDs to handle at a time. @@ -93,11 +84,6 @@ namespace DistributedInput { */ constexpr uint32_t INPUT_EVENT_BUFFER_SIZE = 256; - /** - * Input Type ALL. - */ - constexpr uint32_t INPUT_TYPE_ALL = INPUT_TYPE_MOUSE | INPUT_TYPE_KEYBOARD | INPUT_TYPE_TOUCH; - constexpr int32_t INPUT_LOAD_SA_TIMEOUT_MS = 10000; constexpr int32_t SESSION_WAIT_TIMEOUT_SECOND = 5; 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 27d4200..4510965 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp @@ -189,7 +189,8 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput01, testing::ext::TestSize.L { string deviceId = "StartRemoteInput01"; sptr callback = new TestStartDInputCallback(); - int32_t ret = DistributedInputKit::StartRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -197,7 +198,8 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput02, testing::ext::TestSize.L { string deviceId = ""; sptr callback = new TestStartDInputCallback(); - int32_t ret = DistributedInputKit::StartRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -205,7 +207,8 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput03, testing::ext::TestSize.L { string deviceId = "StartRemoteInput01"; sptr callback = nullptr; - int32_t ret = DistributedInputKit::StartRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -213,7 +216,8 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput04, testing::ext::TestSize.L { string deviceId = ""; sptr callback = nullptr; - int32_t ret = DistributedInputKit::StartRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -221,7 +225,8 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput01, testing::ext::TestSize.Le { string deviceId = "StopRemoteInput01"; sptr callback = new TestStopDInputCallback(); - int32_t ret = DistributedInputKit::StopRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -229,7 +234,8 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput02, testing::ext::TestSize.Le { string deviceId = ""; sptr callback = new TestStopDInputCallback(); - int32_t ret = DistributedInputKit::StopRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -237,7 +243,8 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput03, testing::ext::TestSize.Le { string deviceId = "StopRemoteInput01"; sptr callback = nullptr; - int32_t ret = DistributedInputKit::StopRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -245,7 +252,8 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput04, testing::ext::TestSize.Le { string deviceId = ""; sptr callback = nullptr; - int32_t ret = DistributedInputKit::StopRemoteInput(deviceId, INPUT_TYPE_ALL, callback); + int32_t ret = + DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(SUCCESS, ret); } @@ -285,7 +293,7 @@ HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput1, testing::ext::Test { DistributedInputClient::GetInstance().ReleaseSource(); DistributedInputClient::GetInstance().InitSink(); - DInputServerType ret = DistributedInputKit::IsStartDistributedInput(INPUT_TYPE_ALL); + DInputServerType ret = DistributedInputKit::IsStartDistributedInput(static_cast(DInputDeviceType::ALL)); if (ret == DInputServerType::NULL_SERVER_TYPE) { EXPECT_EQ(SUCCESS, 0); @@ -296,7 +304,7 @@ HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput1, testing::ext::Test HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput2, testing::ext::TestSize.Level0) { - DInputServerType ret = DistributedInputKit::IsStartDistributedInput(INPUT_TYPE_ALL); + DInputServerType ret = DistributedInputKit::IsStartDistributedInput(static_cast(DInputDeviceType::ALL)); if (ret == DInputServerType::NULL_SERVER_TYPE) { EXPECT_EQ(SUCCESS, 0); 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 ccc69b5..16db85e 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 @@ -68,13 +68,13 @@ void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status { if (DInputServerType::SOURCE_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else if (DInputServerType::SINK_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else { DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = INPUT_TYPE_NULL; + DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE; } } diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index f4041b9..26d90a2 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -143,7 +143,7 @@ private: const std::string localDevId_ = "localNodeDevice"; DInputServerType serverType = DInputServerType::NULL_SERVER_TYPE; - uint32_t inputTypes = INPUT_TYPE_NULL; + DInputDeviceType inputTypes_ = DInputDeviceType::NONE; sptr callbackRegister = nullptr; sptr callbackUnregister = nullptr; diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index 390a698..5d75f39 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -110,13 +110,13 @@ void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status { if (DInputServerType::SOURCE_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else if (DInputServerType::SINK_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else { DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = INPUT_TYPE_NULL; + DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE; } } @@ -181,7 +181,7 @@ int32_t DistributedInputClient::ReleaseSource() } serverType = DInputServerType::NULL_SERVER_TYPE; - inputTypes = INPUT_TYPE_NULL; + inputTypes_ = DInputDeviceType::NONE; m_bIsAlreadyInitWhiteList = false; callbackRegister = nullptr; callbackUnregister = nullptr; @@ -199,7 +199,7 @@ int32_t DistributedInputClient::ReleaseSink() return ERR_DH_INPUT_CLIENT_GET_SINK_PROXY_FAIL; } serverType = DInputServerType::NULL_SERVER_TYPE; - inputTypes = INPUT_TYPE_NULL; + inputTypes_ = DInputDeviceType::NONE; m_bIsAlreadyInitWhiteList = false; sinkTypeCallback = nullptr; WhiteListUtil::GetInstance().ClearWhiteList(localDevId_); @@ -315,8 +315,9 @@ int32_t DistributedInputClient::StartRemoteInput( } if (deviceId.empty() || callback == nullptr || - inputTypes > INPUT_TYPE_ALL || inputTypes == INPUT_TYPE_NULL || - !(inputTypes & INPUT_TYPE_ALL)) { + inputTypes > static_cast(DInputDeviceType::ALL) || + inputTypes == static_cast(DInputDeviceType::NONE) || + !(inputTypes & static_cast(DInputDeviceType::ALL))) { return ERR_DH_INPUT_CLIENT_START_FAIL; } @@ -334,7 +335,9 @@ int32_t DistributedInputClient::StopRemoteInput( } if (deviceId.empty() || callback == nullptr || - inputTypes > INPUT_TYPE_ALL || inputTypes == INPUT_TYPE_NULL || !(inputTypes & INPUT_TYPE_ALL)) { + inputTypes > static_cast(DInputDeviceType::ALL) || + inputTypes == static_cast(DInputDeviceType::NONE) || + !(inputTypes & static_cast(DInputDeviceType::ALL))) { return ERR_DH_INPUT_CLIENT_STOP_FAIL; } @@ -367,7 +370,7 @@ bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& inputType) { - DHLOGI("%s called, inputType: %d, inputTypes: %d, ", __func__, inputType, inputTypes); + DHLOGI("%s called, inputType: %d, inputTypes: %d, ", __func__, inputType, static_cast(inputTypes_)); int32_t retSource = 0; int32_t retSink = 0; @@ -387,7 +390,7 @@ DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& serverType = DInputServerType::SINK_SERVER_TYPE; } - if (inputType & inputTypes) { + if (inputType & static_cast(inputTypes_)) { return serverType; } else { return DInputServerType::NULL_SERVER_TYPE; diff --git a/services/sink/inputcollector/src/distributed_input_collector.cpp b/services/sink/inputcollector/src/distributed_input_collector.cpp index 47afa0e..8ec7be9 100644 --- a/services/sink/inputcollector/src/distributed_input_collector.cpp +++ b/services/sink/inputcollector/src/distributed_input_collector.cpp @@ -140,15 +140,14 @@ void DistributedInputCollector::StopCollectEventsThread() void DistributedInputCollector::SetInputTypes(const uint32_t& inputType) { - if ((inputType & INPUT_TYPE_MOUSE) != 0) { + inputTypes_ = 0; + if ((inputType & static_cast(DInputDeviceType::MOUSE)) != 0) { inputTypes_ |= INPUT_DEVICE_CLASS_CURSOR; } - if ((inputType & INPUT_TYPE_KEYBOARD) != 0) { + if ((inputType & static_cast(DInputDeviceType::KEYBOARD)) != 0) { inputTypes_ |= INPUT_DEVICE_CLASS_KEYBOARD; } - if ((inputType & INPUT_TYPE_TOUCH) != 0) { - inputTypes_ |= INPUT_DEVICE_CLASS_CURSOR; - } + inputHub_->SetSupportInputType(inputTypes_); } diff --git a/services/sink/sinkmanager/include/distributed_input_sink_manager.h b/services/sink/sinkmanager/include/distributed_input_sink_manager.h index 0e7cbd1..03dcffb 100644 --- a/services/sink/sinkmanager/include/distributed_input_sink_manager.h +++ b/services/sink/sinkmanager/include/distributed_input_sink_manager.h @@ -98,7 +98,7 @@ private: std::shared_ptr runner_; std::shared_ptr handler_; bool InitAuto(); - uint32_t inputTypes_; + DInputDeviceType inputTypes_; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index bd9bc16..69af6f8 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -37,19 +37,19 @@ REGISTER_SYSTEM_ABILITY_BY_ID(DistributedInputSinkManager, DISTRIBUTED_HARDWARE_ DistributedInputSinkManager::DistributedInputSinkManager(int32_t saId, bool runOnCreate) : SystemAbility(saId, runOnCreate) { - inputTypes_ = 0; + inputTypes_ = DInputDeviceType::NONE; } DistributedInputSinkManager::DInputSinkListener::DInputSinkListener(DistributedInputSinkManager *manager) { sinkManagerObj_ = manager; - sinkManagerObj_->SetInputTypes(INPUT_TYPE_NULL); + sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); DHLOGI("DInputSinkListener init."); } DistributedInputSinkManager::DInputSinkListener::~DInputSinkListener() { - sinkManagerObj_->SetInputTypes(INPUT_TYPE_NULL); + sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); sinkManagerObj_ = nullptr; DHLOGI("DInputSinkListener destory."); } @@ -109,7 +109,7 @@ void DistributedInputSinkManager::DInputSinkListener::onPrepareRemoteInput( void DistributedInputSinkManager::DInputSinkListener::onUnprepareRemoteInput(const int32_t& sessionId) { DHLOGI("onUnprepareRemoteInput called, sessionId: %s", GetAnonyInt32(sessionId).c_str()); - onStopRemoteInput(sessionId, INPUT_TYPE_ALL); + onStopRemoteInput(sessionId, static_cast(DInputDeviceType::ALL)); DistributedInputSinkSwitch::GetInstance().RemoveSession(sessionId); nlohmann::json jsonStr; @@ -125,12 +125,30 @@ void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInput( int32_t curSessionId = DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession(); DHLOGI("onStartRemoteInput called, curSessionId:%s, new sessionId: %s", GetAnonyInt32(curSessionId).c_str(), GetAnonyInt32(sessionId).c_str()); - // set new session - int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(sessionId); - sinkManagerObj_->SetStartTransFlag((startRes == DH_SUCCESS) ? - DInputServerType::SINK_SERVER_TYPE : - DInputServerType::NULL_SERVER_TYPE); + int32_t startRes = DH_SUCCESS; + if (curSessionId == sessionId) { + DHLOGI("sessionId switch state is true, need not switch"); + } else { + DHLOGI("sessionId switch state is false, need to switch"); + int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(sessionId); + + sinkManagerObj_->SetStartTransFlag((startRes == DH_SUCCESS) ? + DInputServerType::SINK_SERVER_TYPE : + DInputServerType::NULL_SERVER_TYPE); + + if ((curSessionId != ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) && (startRes == DH_SUCCESS)) { + DHLOGI("notify curSessionId:%s Interrupted.", GetAnonyInt32(curSessionId).c_str()); + nlohmann::json jsonStrStp; + jsonStrStp[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONSTOP; + jsonStrStp[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; + jsonStrStp[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; + std::string smsgStp = jsonStrStp.dump(); + DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(curSessionId, smsgStp); + sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); + DistributedInputCollector::GetInstance().SetInputTypes(sinkManagerObj_->GetInputTypes()); + } + } bool result = (startRes == DH_SUCCESS) ? true : false; nlohmann::json jsonStrSta; @@ -141,24 +159,6 @@ void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInput( DistributedInputSinkTransport::GetInstance().RespStartRemoteInput(sessionId, smsgSta); - // Notify the interrupted master status - if (curSessionId == ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) { - DHLOGI("onStartRemoteInput called, this is the only session."); - } else if (result) { - DHLOGI("onStartRemoteInput called, notify curSessionId:%s Interrupted.", - GetAnonyInt32(curSessionId).c_str()); - nlohmann::json jsonStrStp; - jsonStrStp[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONSTOP; - jsonStrStp[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes; - jsonStrStp[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; - std::string smsgStp = jsonStrStp.dump(); - DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(curSessionId, smsgStp); - sinkManagerObj_->SetInputTypes(INPUT_TYPE_NULL); - DistributedInputCollector::GetInstance().SetInputTypes(sinkManagerObj_->GetInputTypes()); - } else { - DHLOGI("onStartRemoteInput called, new session is error, not notify curSession."); - } - // add the input type if (startRes == DH_SUCCESS) { sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() | inputTypes); @@ -191,18 +191,18 @@ void DistributedInputSinkManager::DInputSinkListener::onStopRemoteInput( std::string smsg = jsonStr.dump(); DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(sessionId, smsg); - if (sinkManagerObj_->GetInputTypes() == INPUT_TYPE_NULL) { + if (sinkManagerObj_->GetInputTypes() == static_cast(DInputDeviceType::NONE)) { DistributedInputSinkSwitch::GetInstance().StopSwitch(sessionId); if (DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession() == ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) { - DHLOGI("onStartRemoteInput called, all session is stop."); + DHLOGI("all session is stop."); sinkManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE); } } IStartDInputServerCallback *startServerCB = sinkManagerObj_->GetStartDInputServerCback(); if (startServerCB == nullptr) { - DHLOGE("onStartRemoteInput called, startServerCB is null."); + DHLOGE("startServerCB is null."); } else { startServerCB->OnResult( static_cast(sinkManagerObj_->GetStartTransFlag()), sinkManagerObj_->GetInputTypes()); @@ -348,12 +348,12 @@ void DistributedInputSinkManager::SetInitWhiteListFlag(bool isInit) uint32_t DistributedInputSinkManager::GetInputTypes() { - return inputTypes_; + return static_cast(inputTypes_); } -void DistributedInputSinkManager::SetInputTypes(const uint32_t& inputTypess) +void DistributedInputSinkManager::SetInputTypes(const uint32_t& inputTypes) { - inputTypes_ = inputTypess; + inputTypes_ = static_cast(inputTypes); } } // namespace DistributedInput } // namespace DistributedHardware diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index c39e6ea..fc9e5de 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -311,7 +311,7 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyUnreg std::string dhId = innerMsg[INPUT_SOURCEMANAGER_KEY_HWID]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, INPUT_TYPE_NULL); + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); } sourceManagerObj_->RunUnregisterCallback(deviceId, dhId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_MSG_IS_BAD); @@ -340,7 +340,7 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyUnpre std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, INPUT_TYPE_NULL); + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); } sourceManagerObj_->RunUnprepareCallback(deviceId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_MSG_IS_BAD); @@ -419,7 +419,8 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStart sourceManagerObj_->SetStartTransFlag(startTransFlag); if (sourceManagerObj_->GetStartDInputServerCback() != nullptr) { - sourceManagerObj_->GetStartDInputServerCback()->OnResult(serType, INPUT_TYPE_NULL); + sourceManagerObj_->GetStartDInputServerCback()->OnResult( + serType, static_cast(DInputDeviceType::NONE)); } else { DHLOGE("ProcessEvent GetStartDInputServerCback() is null."); } @@ -1106,12 +1107,12 @@ uint32_t DistributedInputSourceManager::GetInputTypesMap(const std::string devic if (key != InputTypesMap_.end()) { return InputTypesMap_[deviceId]; } - return INPUT_TYPE_NULL; + return static_cast(DInputDeviceType::NONE); } uint32_t DistributedInputSourceManager::GetAllInputTypesMap() { - uint32_t rInputTypes = INPUT_TYPE_NULL; + uint32_t rInputTypes = static_cast(DInputDeviceType::NONE); std::map::iterator iter; for (iter = InputTypesMap_.begin(); iter != InputTypesMap_.end(); iter++) { rInputTypes |= iter->second; @@ -1121,7 +1122,7 @@ uint32_t DistributedInputSourceManager::GetAllInputTypesMap() void DistributedInputSourceManager::SetInputTypesMap(const std::string deviceId, uint32_t value) { - if (value == INPUT_TYPE_NULL) { + if (value == static_cast(DInputDeviceType::NONE)) { std::map::iterator key = InputTypesMap_.find(deviceId); if (key != InputTypesMap_.end()) { InputTypesMap_.erase(key); 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 2f105a6..cf2229b 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -248,7 +248,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput01, testing::ext::Te { std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback = new TestStartDInputCallback(); - int32_t ret = sourceManager_->StartRemoteInput(devId, INPUT_TYPE_ALL, callback); + int32_t ret = sourceManager_->StartRemoteInput(devId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); } @@ -256,7 +256,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput02, testing::ext::Te { std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback; - int32_t ret = sourceManager_->StartRemoteInput(devId, INPUT_TYPE_ALL, callback); + int32_t ret = sourceManager_->StartRemoteInput(devId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); } @@ -264,7 +264,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput03, testing::ext::Te { std::string devId = ""; sptr callback = new TestStartDInputCallback(); - int32_t ret = sourceManager_->StartRemoteInput(devId, INPUT_TYPE_ALL, callback); + int32_t ret = sourceManager_->StartRemoteInput(devId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret); } @@ -272,7 +272,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput01, testing::ext::Tes { std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback = new TestStopDInputCallback(); - int32_t ret = sourceManager_->StopRemoteInput(devId, INPUT_TYPE_ALL, callback); + int32_t ret = sourceManager_->StopRemoteInput(devId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); } @@ -280,7 +280,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput02, testing::ext::Tes { std::string devId = ""; sptr callback = new TestStopDInputCallback(); - int32_t ret = sourceManager_->StopRemoteInput(devId, INPUT_TYPE_ALL, callback); + int32_t ret = sourceManager_->StopRemoteInput(devId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); } @@ -288,7 +288,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput03, testing::ext::Tes { std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback; - int32_t ret = sourceManager_->StopRemoteInput(devId, INPUT_TYPE_ALL, callback); + int32_t ret = sourceManager_->StopRemoteInput(devId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret); } 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 faaf9af..7623303 100644 --- a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp +++ b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp @@ -90,28 +90,32 @@ HWTEST_F(DistributedInputSourceTransTest, UnprepareRemoteInput03, testing::ext:: HWTEST_F(DistributedInputSourceTransTest, StartRemoteInput01, testing::ext::TestSize.Level0) { std::string deviceId = "tttt0001"; - int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput(deviceId, INPUT_TYPE_ALL); + 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, INPUT_TYPE_ALL); + 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, StopRemoteInput01, testing::ext::TestSize.Level0) { std::string deviceId = "tttt0001"; - int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(deviceId, INPUT_TYPE_ALL); + 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, INPUT_TYPE_ALL); + int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput( + deviceId, static_cast(DInputDeviceType::ALL)); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret); DistributedInputSourceTransport::GetInstance().CloseInputSoftbus(deviceId); } diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index f5a9929..9ac649a 100644 --- a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -64,13 +64,13 @@ void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status { if (DInputServerType::SOURCE_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else if (DInputServerType::SINK_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else { DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = INPUT_TYPE_NULL; + DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE; } } diff --git a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index c12cd15..dbbd434 100644 --- a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -64,13 +64,13 @@ void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status { if (DInputServerType::SOURCE_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else if (DInputServerType::SINK_SERVER_TYPE == static_cast(status)) { DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = inputTypes; + DistributedInputClient::GetInstance().inputTypes_ = static_cast(inputTypes); } else { DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE; - DistributedInputClient::GetInstance().inputTypes = INPUT_TYPE_NULL; + DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE; } }