diff --git a/services/sink/sinkmanager/include/distributed_input_sink_manager.h b/services/sink/sinkmanager/include/distributed_input_sink_manager.h index f51a6d71cbd1cb8fec7561baa7c16eee5881bad7..f9157058703b6674c5b2d9428c318cd8749f5a5a 100644 --- a/services/sink/sinkmanager/include/distributed_input_sink_manager.h +++ b/services/sink/sinkmanager/include/distributed_input_sink_manager.h @@ -186,11 +186,10 @@ private: /* * Stop dhids on cmd, * stoDhIds: dhIds on cmd - * stopIndeedDhIds: dhId that no session (retmote node) need, stop capture event. + * stopIndeedDhIds: dhId that need stop capture event. */ void DeleteStopDhids(int32_t sessionId, const std::vector stopDhIds, std::vector &stopIndeedDhIds); - bool IsStopDhidOnCmdStillNeed(int32_t sessionId, const std::string &stopDhId); }; } // 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 34b08a59c5b3b55d4c7a9c45bedf9fb86fb5b419..b4ade6879c68489f17a2d2e9c4c136212af73a97 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -195,8 +195,7 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayUnprepareRemoteInpu { DHLOGI("OnRelayUnprepareRemoteInput called, toSinkSessionId: %d, devId: %s", toSinkSessionId, GetAnonyString(deviceId).c_str()); - DistributedInputCollector::GetInstance().SetSharingTypes(false, static_cast(DInputDeviceType::ALL)); - DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); + OnStopRemoteInput(toSinkSessionId, static_cast(DInputDeviceType::ALL)); DistributedInputSinkSwitch::GetInstance().RemoveSession(toSinkSessionId); nlohmann::json jsonStr; @@ -503,25 +502,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStopTypeRemoteInput } } -bool DistributedInputSinkManager::IsStopDhidOnCmdStillNeed(int32_t sessionId, const std::string &stopDhId) -{ - for (auto sessionDhid : sharingDhIdsMap_) { - if (sessionDhid.first == sessionId) { - DHLOGW("IsStopDhidOnCmdStillNeed sessionId=%d is self, ignore.", sessionId); - continue; - } - for (auto dhid : sessionDhid.second) { - if (stopDhId == dhid) { - DHLOGI("IsStopDhidOnCmdStillNeed stopDhId=%s is find in session: %d", GetAnonyString(stopDhId).c_str(), - sessionDhid.first); - return true; - } - } - } - DHLOGW("IsStopDhidOnCmdStillNeed stopDhId=%s is not find.", GetAnonyString(stopDhId).c_str()); - return false; -} - void DistributedInputSinkManager::DeleteStopDhids(int32_t sessionId, const std::vector stopDhIds, std::vector &stopIndeedDhIds) { @@ -541,13 +521,10 @@ void DistributedInputSinkManager::DeleteStopDhids(int32_t sessionId, const std:: } else { DHLOGI("DeleteStopDhids sessionId=%d after has dhid.size=%d.", sessionId, sharingDhIdsMap_[sessionId].size()); } - // find which dhid can be stop - for (auto tmp : stopDhIds) { - bool isFind = IsStopDhidOnCmdStillNeed(sessionId, tmp); - if (!isFind) { - stopIndeedDhIds.push_back(tmp); - sharingDhIds_.erase(tmp); - } + + stopIndeedDhIds.assign(stopDhIds.begin(), stopDhIds.end()); + for (auto &id : stopDhIds) { + sharingDhIds_.erase(id); } } 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 3e61341866097041bbad719083485cd76d15659a..bd62d525ed22d59f94e2da166d8485f315de3b68 100644 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.cpp +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.cpp @@ -125,31 +125,6 @@ HWTEST_F(DistributedInputSinkManagerTest, GetInputTypes, testing::ext::TestSize. EXPECT_EQ(inputTypes, retType); } -HWTEST_F(DistributedInputSinkManagerTest, IsStopDhidOnCmdStillNeed01, testing::ext::TestSize.Level0) -{ - int32_t sessionId = 1; - std::vector dhIds; - dhIds.push_back("Input_123123123123"); - dhIds.push_back("Input_456456456456"); - dhIds.push_back("Input_789789789789"); - sinkManager_->StoreStartDhids(100, dhIds); - std::set dhIdSet; - dhIdSet.insert("Input_123123123123"); - sinkManager_->sharingDhIdsMap_[sessionId] = dhIdSet; - sinkManager_->StoreStartDhids(sessionId, dhIds); - std::string stopDhId = "Input_123123123123"; - bool ret = sinkManager_->IsStopDhidOnCmdStillNeed(sessionId, stopDhId); - EXPECT_EQ(true, ret); -} - -HWTEST_F(DistributedInputSinkManagerTest, IsStopDhidOnCmdStillNeed02, testing::ext::TestSize.Level0) -{ - int32_t sessionId = 1000; - std::string stopDhId = "Input_123123123123"; - bool ret = sinkManager_->IsStopDhidOnCmdStillNeed(sessionId, stopDhId); - EXPECT_EQ(false, ret); -} - HWTEST_F(DistributedInputSinkManagerTest, DeleteStopDhids01, testing::ext::TestSize.Level0) { int32_t sessionId = 1; @@ -165,7 +140,6 @@ HWTEST_F(DistributedInputSinkManagerTest, DeleteStopDhids01, testing::ext::TestS EXPECT_EQ(0, sinkManager_->sharingDhIdsMap_.size()); } - HWTEST_F(DistributedInputSinkManagerTest, GetSinkScreenInfosCbackSize01, testing::ext::TestSize.Level0) { uint32_t ret = sinkManager_->GetSinkScreenInfosCbackSize();