Skip to content

Commit 3de7998

Browse files
prabirmspAndroid (Google) Code Review
authored andcommitted
Merge changes I3bedc2c2,Ic56a6f2c into main
* changes: InputDispatcher: Ensure pointer down is generated for touched window InputTracer: Use explicit thread wake conditions
2 parents c5fc7d4 + feca057 commit 3de7998

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

services/inputflinger/dispatcher/trace/InputTracer.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,21 @@ std::optional<InputTracer::EventState>& InputTracer::getState(const EventTracker
154154
void 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);

0 commit comments

Comments
 (0)