File tree Expand file tree Collapse file tree
services/inputflinger/dispatcher Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4192,7 +4192,12 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked(
41924192 connection->getInputChannelName ().c_str (), downEvents.size ());
41934193 }
41944194
4195- sp<WindowInfoHandle> windowHandle = getWindowHandleLocked (connection->getToken ());
4195+ const auto [_, touchedWindowState, displayId] =
4196+ findTouchStateWindowAndDisplayLocked (connection->getToken ());
4197+ if (touchedWindowState == nullptr ) {
4198+ LOG (FATAL) << __func__ << " : Touch state is out of sync: No touched window for token" ;
4199+ }
4200+ const auto & windowHandle = touchedWindowState->windowHandle ;
41964201
41974202 const bool wasEmpty = connection->outboundQueue .empty ();
41984203 for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) {
Original file line number Diff line number Diff line change @@ -154,19 +154,21 @@ std::optional<InputTracer::EventState>& InputTracer::getState(const EventTracker
154154void InputTracer::threadLoop () {
155155 androidSetThreadName (" InputTracer" );
156156
157+ std::vector<const EventState> eventsToTrace;
158+ std::vector<const WindowDispatchArgs> dispatchEventsToTrace;
159+
157160 while (true ) {
158- std::vector<const EventState> eventsToTrace;
159- std::vector<const WindowDispatchArgs> dispatchEventsToTrace;
160- {
161+ { // acquire lock
161162 std::unique_lock lock (mLock );
162163 base::ScopedLockAssertion assumeLocked (mLock );
164+
165+ // Wait until we need to process more events or exit.
166+ mThreadWakeCondition .wait (lock, [&]() REQUIRES (mLock ) {
167+ return mThreadExit || !mTraceQueue .empty () || !mDispatchTraceQueue .empty ();
168+ });
163169 if (mThreadExit ) {
164170 return ;
165171 }
166- if (mTraceQueue .empty () && mDispatchTraceQueue .empty ()) {
167- // Wait indefinitely until the thread is awoken.
168- mThreadWakeCondition .wait (lock);
169- }
170172
171173 mTraceQueue .swap (eventsToTrace);
172174 mDispatchTraceQueue .swap (dispatchEventsToTrace);
You can’t perform that action at this time.
0 commit comments