Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3de7998a authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge changes I3bedc2c2,Ic56a6f2c into main

* changes:
  InputDispatcher: Ensure pointer down is generated for touched window
  InputTracer: Use explicit thread wake conditions
parents c5fc7d48 feca057f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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) {
+9 −7
Original line number Diff line number Diff line
@@ -154,19 +154,21 @@ std::optional<InputTracer::EventState>& InputTracer::getState(const EventTracker
void InputTracer::threadLoop() {
    androidSetThreadName("InputTracer");

    while (true) {
    std::vector<const EventState> eventsToTrace;
    std::vector<const WindowDispatchArgs> dispatchEventsToTrace;
        {

    while (true) {
        { // 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);