mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-20 21:41:02 -04:00
!110 优化unprepare和stop时控制参数处理,避免鼠标同时控制两侧设备的情况
Merge pull request !110 from zhangchuang/master
This commit is contained in:
@@ -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<std::string> stopDhIds,
|
||||
std::vector<std::string> &stopIndeedDhIds);
|
||||
bool IsStopDhidOnCmdStillNeed(int32_t sessionId, const std::string &stopDhId);
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -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<uint32_t>(DInputDeviceType::ALL));
|
||||
DistributedInputSinkSwitch::GetInstance().StopAllSwitch();
|
||||
OnStopRemoteInput(toSinkSessionId, static_cast<uint32_t>(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<std::string> stopDhIds,
|
||||
std::vector<std::string> &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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-26
@@ -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<std::string> dhIds;
|
||||
dhIds.push_back("Input_123123123123");
|
||||
dhIds.push_back("Input_456456456456");
|
||||
dhIds.push_back("Input_789789789789");
|
||||
sinkManager_->StoreStartDhids(100, dhIds);
|
||||
std::set<std::string> 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();
|
||||
|
||||
Reference in New Issue
Block a user