From 49d6d9429baf85aa37697456cf42df2518b4d771 Mon Sep 17 00:00:00 2001 From: l30054665 Date: Tue, 30 Jan 2024 21:53:51 +0800 Subject: [PATCH 1/2] change 4.1 Signed-off-by: l30054665 --- common/include/input_hub.cpp | 4 +++- services/state/include/dinput_sink_state.h | 3 +++ services/state/src/dinput_sink_state.cpp | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index ef403e1..f6da779 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -143,7 +143,8 @@ size_t InputHub::StartCollectInputEvents(RawEvent *buffer, size_t bufferSize) break; } - if (RefreshEpollItem(false) < 0) { + bool flag = DInputSinkState::GetInstance().IsInThroughtOut(); + if (RefreshEpollItem(!flag) < 0) { break; } } @@ -475,6 +476,7 @@ int32_t InputHub::RefreshEpollItem(bool isSleep) } else { // Some events occurred. pendingEventCount_ = pollResult; + DHLOGD("Number of events is: %d", pollResult); } if (isSleep) { usleep(SLEEP_TIME_US); diff --git a/services/state/include/dinput_sink_state.h b/services/state/include/dinput_sink_state.h index 5844b1f..aa41ec9 100644 --- a/services/state/include/dinput_sink_state.h +++ b/services/state/include/dinput_sink_state.h @@ -48,6 +48,9 @@ public: int32_t RemoveDhIds(const std::vector &dhIds); DhIdState GetStateByDhid(const std::string &dhId); + /* Is some dhid in through out to the other side */ + bool IsInThroughtOut(); + void AddKeyDownState(struct RawEvent event); void RemoveKeyDownState(struct RawEvent event); /** diff --git a/services/state/src/dinput_sink_state.cpp b/services/state/src/dinput_sink_state.cpp index 5311a2b..6bb3265 100644 --- a/services/state/src/dinput_sink_state.cpp +++ b/services/state/src/dinput_sink_state.cpp @@ -242,6 +242,20 @@ void DInputSinkState::ClearDeviceStates() std::lock_guard mapLock(keyDownStateMapMtx_); keyDownStateMap_.clear(); } + +bool DInputSinkState::IsInThroughtOut() +{ + std::lock_guard mapLock(operationMutex_); + bool flag = false; + for (auto it : dhIdStateMap_) { + if (it.second == DhIdState::THROUGH_OUT) { + flag = true; + break; + } + } + DHLOGD("IsInThroughtOut: %d", flag); + return flag; +} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOSs \ No newline at end of file -- Gitee From 0d2e22e2463e342bcf7abbe4e9ecb35354afc3e3 Mon Sep 17 00:00:00 2001 From: l30054665 Date: Tue, 30 Jan 2024 22:27:09 +0800 Subject: [PATCH 2/2] kongge Signed-off-by: l30054665 --- services/state/src/dinput_sink_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/state/src/dinput_sink_state.cpp b/services/state/src/dinput_sink_state.cpp index 6bb3265..b56ac00 100644 --- a/services/state/src/dinput_sink_state.cpp +++ b/services/state/src/dinput_sink_state.cpp @@ -251,7 +251,7 @@ bool DInputSinkState::IsInThroughtOut() if (it.second == DhIdState::THROUGH_OUT) { flag = true; break; - } + } } DHLOGD("IsInThroughtOut: %d", flag); return flag; -- Gitee