diff options
| author | 2024-02-07 18:52:26 +0000 | |
|---|---|---|
| committer | 2024-02-07 18:52:26 +0000 | |
| commit | 3de7998ac795eb3438a014884e56f01a7a510f8e (patch) | |
| tree | 689e5187b2a8633d709b7851f280cdf8f5fced66 | |
| parent | c5fc7d48b7eaf22ce569bf0b83760065f260a726 (diff) | |
| parent | feca057f5ff68a583c56968faa9e2b978e8ed5c3 (diff) | |
Merge changes I3bedc2c2,Ic56a6f2c into main
* changes:
InputDispatcher: Ensure pointer down is generated for touched window
InputTracer: Use explicit thread wake conditions
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 7 | ||||
| -rw-r--r-- | services/inputflinger/dispatcher/trace/InputTracer.cpp | 16 |
2 files changed, 15 insertions, 8 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index aeab1f8fa1..3e999c702d 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -4192,7 +4192,12 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( connection->getInputChannelName().c_str(), downEvents.size()); } - sp<WindowInfoHandle> windowHandle = getWindowHandleLocked(connection->getToken()); + const auto [_, touchedWindowState, displayId] = + findTouchStateWindowAndDisplayLocked(connection->getToken()); + if (touchedWindowState == nullptr) { + LOG(FATAL) << __func__ << ": Touch state is out of sync: No touched window for token"; + } + const auto& windowHandle = touchedWindowState->windowHandle; const bool wasEmpty = connection->outboundQueue.empty(); for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) { diff --git a/services/inputflinger/dispatcher/trace/InputTracer.cpp b/services/inputflinger/dispatcher/trace/InputTracer.cpp index b065729873..8a855c2035 100644 --- a/services/inputflinger/dispatcher/trace/InputTracer.cpp +++ b/services/inputflinger/dispatcher/trace/InputTracer.cpp @@ -154,19 +154,21 @@ std::optional<InputTracer::EventState>& InputTracer::getState(const EventTracker void InputTracer::threadLoop() { androidSetThreadName("InputTracer"); + std::vector<const EventState> eventsToTrace; + std::vector<const WindowDispatchArgs> dispatchEventsToTrace; + while (true) { - std::vector<const EventState> eventsToTrace; - std::vector<const WindowDispatchArgs> dispatchEventsToTrace; - { + { // acquire lock std::unique_lock lock(mLock); base::ScopedLockAssertion assumeLocked(mLock); + + // Wait until we need to process more events or exit. + mThreadWakeCondition.wait(lock, [&]() REQUIRES(mLock) { + return mThreadExit || !mTraceQueue.empty() || !mDispatchTraceQueue.empty(); + }); if (mThreadExit) { return; } - if (mTraceQueue.empty() && mDispatchTraceQueue.empty()) { - // Wait indefinitely until the thread is awoken. - mThreadWakeCondition.wait(lock); - } mTraceQueue.swap(eventsToTrace); mDispatchTraceQueue.swap(dispatchEventsToTrace); |