diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index ef403e11f80231779dbe397e70dcf4feefc45d4a..f6da77957bb95cc402f88be9c5c867ca8b678641 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/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index 2c87c73e17a6693347b9949b688bdca8c2763605..c5126bd4392703c9f6c202e5a56561c03093078b 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -619,9 +619,9 @@ int32_t DistributedInputSinkManager::Init() DHLOGI("init InputCollector."); int result = DistributedInputCollector::GetInstance().StartCollectionThread( DistributedInputSinkTransport::GetInstance().GetEventHandler()); - if (result != DH_SUCCESS) { - DHLOGE("init InputCollector error."); - } + if (result != DH_SUCCESS) { + DHLOGE("init InputCollector error."); + } return DH_SUCCESS; } diff --git a/services/state/include/dinput_sink_state.h b/services/state/include/dinput_sink_state.h index 5844b1ff46b21db0c2c9309850a4e9e73fb838d7..aa41ec9ee7de29a5fa66dab313f5492307f798bf 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 5311a2b12d7f0dfdda3bc1de6496e90c2320eb4f..b56ac00d9edb17adc5a32f97dfdcc4f5cae29f83 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