Loading services/inputflinger/dispatcher/InputDispatcher.cpp +22 −22 Original line number Original line Diff line number Diff line Loading @@ -1111,7 +1111,7 @@ void InputDispatcher::dispatchEventLocked(nsecs_t currentTime, EventEntry* event sp<Connection> connection = sp<Connection> connection = getConnectionLocked(inputTarget.inputChannel->getConnectionToken()); getConnectionLocked(inputTarget.inputChannel->getConnectionToken()); if (connection != nullptr) { if (connection != nullptr) { prepareDispatchCycleLocked(currentTime, connection, eventEntry, &inputTarget); prepareDispatchCycleLocked(currentTime, connection, eventEntry, inputTarget); } else { } else { if (DEBUG_FOCUS) { if (DEBUG_FOCUS) { ALOGD("Dropping event delivery to target with channel '%s' because it " ALOGD("Dropping event delivery to target with channel '%s' because it " Loading Loading @@ -2045,7 +2045,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) { void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, const sp<Connection>& connection, EventEntry* eventEntry, EventEntry* eventEntry, const InputTarget* inputTarget) { const InputTarget& inputTarget) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { std::string message = std::string message = StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, sequenceNum=%" PRIu32 ")", StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, sequenceNum=%" PRIu32 ")", Loading @@ -2056,9 +2056,9 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, ALOGD("channel '%s' ~ prepareDispatchCycle - flags=0x%08x, " ALOGD("channel '%s' ~ prepareDispatchCycle - flags=0x%08x, " "xOffset=%f, yOffset=%f, globalScaleFactor=%f, " "xOffset=%f, yOffset=%f, globalScaleFactor=%f, " "windowScaleFactor=(%f, %f), pointerIds=0x%x", "windowScaleFactor=(%f, %f), pointerIds=0x%x", connection->getInputChannelName().c_str(), inputTarget->flags, inputTarget->xOffset, connection->getInputChannelName().c_str(), inputTarget.flags, inputTarget.xOffset, inputTarget->yOffset, inputTarget->globalScaleFactor, inputTarget->windowXScale, inputTarget.yOffset, inputTarget.globalScaleFactor, inputTarget.windowXScale, inputTarget->windowYScale, inputTarget->pointerIds.value); inputTarget.windowYScale, inputTarget.pointerIds.value); #endif #endif // Skip this event if the connection status is not normal. // Skip this event if the connection status is not normal. Loading @@ -2072,13 +2072,15 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, } } // Split a motion event if needed. // Split a motion event if needed. if (inputTarget->flags & InputTarget::FLAG_SPLIT) { if (inputTarget.flags & InputTarget::FLAG_SPLIT) { ALOG_ASSERT(eventEntry->type == EventEntry::Type::MOTION); LOG_ALWAYS_FATAL_IF(eventEntry->type != EventEntry::Type::MOTION, "Entry type %s should not have FLAG_SPLIT", EventEntry::typeToString(eventEntry->type)); const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry); const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry); if (inputTarget->pointerIds.count() != originalMotionEntry.pointerCount) { if (inputTarget.pointerIds.count() != originalMotionEntry.pointerCount) { MotionEntry* splitMotionEntry = MotionEntry* splitMotionEntry = splitMotionEvent(originalMotionEntry, inputTarget->pointerIds); splitMotionEvent(originalMotionEntry, inputTarget.pointerIds); if (!splitMotionEntry) { if (!splitMotionEntry) { return; // split event was dropped return; // split event was dropped } } Loading @@ -2100,7 +2102,7 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, const sp<Connection>& connection, EventEntry* eventEntry, EventEntry* eventEntry, const InputTarget* inputTarget) { const InputTarget& inputTarget) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { std::string message = std::string message = StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, sequenceNum=%" PRIu32 StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, sequenceNum=%" PRIu32 Loading Loading @@ -2133,7 +2135,7 @@ void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connection, void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, EventEntry* eventEntry, const InputTarget* inputTarget, const InputTarget& inputTarget, int32_t dispatchMode) { int32_t dispatchMode) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { std::string message = StringPrintf("enqueueDispatchEntry(inputChannel=%s, dispatchMode=%s)", std::string message = StringPrintf("enqueueDispatchEntry(inputChannel=%s, dispatchMode=%s)", Loading @@ -2141,7 +2143,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio dispatchModeToString(dispatchMode).c_str()); dispatchModeToString(dispatchMode).c_str()); ATRACE_NAME(message.c_str()); ATRACE_NAME(message.c_str()); } } int32_t inputTargetFlags = inputTarget->flags; int32_t inputTargetFlags = inputTarget.flags; if (!(inputTargetFlags & dispatchMode)) { if (!(inputTargetFlags & dispatchMode)) { return; return; } } Loading @@ -2149,11 +2151,11 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio // This is a new event. // This is a new event. // Enqueue a new dispatch entry onto the outbound queue for this connection. // Enqueue a new dispatch entry onto the outbound queue for this connection. DispatchEntry* dispatchEntry = std::unique_ptr<DispatchEntry> dispatchEntry = new DispatchEntry(eventEntry, // increments ref std::make_unique<DispatchEntry>(eventEntry, // increments ref inputTargetFlags, inputTarget->xOffset, inputTarget->yOffset, inputTargetFlags, inputTarget.xOffset, inputTarget->globalScaleFactor, inputTarget->windowXScale, inputTarget.yOffset, inputTarget.globalScaleFactor, inputTarget->windowYScale); inputTarget.windowXScale, inputTarget.windowYScale); // Apply target flags and update the connection's input state. // Apply target flags and update the connection's input state. switch (eventEntry->type) { switch (eventEntry->type) { Loading @@ -2168,7 +2170,6 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: skipping inconsistent key event", ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: skipping inconsistent key event", connection->getInputChannelName().c_str()); connection->getInputChannelName().c_str()); #endif #endif delete dispatchEntry; return; // skip the inconsistent event return; // skip the inconsistent event } } break; break; Loading Loading @@ -2215,12 +2216,11 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio "event", "event", connection->getInputChannelName().c_str()); connection->getInputChannelName().c_str()); #endif #endif delete dispatchEntry; return; // skip the inconsistent event return; // skip the inconsistent event } } dispatchPointerDownOutsideFocus(motionEntry.source, dispatchEntry->resolvedAction, dispatchPointerDownOutsideFocus(motionEntry.source, dispatchEntry->resolvedAction, inputTarget->inputChannel->getConnectionToken()); inputTarget.inputChannel->getConnectionToken()); break; break; } } Loading @@ -2238,7 +2238,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio } } // Enqueue the dispatch entry. // Enqueue the dispatch entry. connection->outboundQueue.push_back(dispatchEntry); connection->outboundQueue.push_back(dispatchEntry.release()); traceOutboundQueueLength(connection); traceOutboundQueueLength(connection); } } Loading Loading @@ -2625,7 +2625,7 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( target.flags = InputTarget::FLAG_DISPATCH_AS_IS; target.flags = InputTarget::FLAG_DISPATCH_AS_IS; enqueueDispatchEntryLocked(connection, cancelationEventEntry, // increments ref enqueueDispatchEntryLocked(connection, cancelationEventEntry, // increments ref &target, InputTarget::FLAG_DISPATCH_AS_IS); target, InputTarget::FLAG_DISPATCH_AS_IS); cancelationEventEntry->release(); cancelationEventEntry->release(); } } Loading services/inputflinger/dispatcher/InputDispatcher.h +3 −3 Original line number Original line Diff line number Diff line Loading @@ -378,13 +378,13 @@ private: // with the mutex held makes it easier to ensure that connection invariants are maintained. // with the mutex held makes it easier to ensure that connection invariants are maintained. // If needed, the methods post commands to run later once the critical bits are done. // If needed, the methods post commands to run later once the critical bits are done. void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) EventEntry* eventEntry, const InputTarget& inputTarget) REQUIRES(mLock); REQUIRES(mLock); void enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, void enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) EventEntry* eventEntry, const InputTarget& inputTarget) REQUIRES(mLock); REQUIRES(mLock); void enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, void enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget, int32_t dispatchMode) const InputTarget& inputTarget, int32_t dispatchMode) REQUIRES(mLock); REQUIRES(mLock); void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection) void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection) REQUIRES(mLock); REQUIRES(mLock); Loading services/inputflinger/dispatcher/InputTarget.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -108,7 +108,7 @@ struct InputTarget { // The subset of pointer ids to include in motion events dispatched to this input target // The subset of pointer ids to include in motion events dispatched to this input target // if FLAG_SPLIT is set. // if FLAG_SPLIT is set. BitSet32 pointerIds{}; BitSet32 pointerIds; }; }; std::string dispatchModeToString(int32_t dispatchMode); std::string dispatchModeToString(int32_t dispatchMode); Loading Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +22 −22 Original line number Original line Diff line number Diff line Loading @@ -1111,7 +1111,7 @@ void InputDispatcher::dispatchEventLocked(nsecs_t currentTime, EventEntry* event sp<Connection> connection = sp<Connection> connection = getConnectionLocked(inputTarget.inputChannel->getConnectionToken()); getConnectionLocked(inputTarget.inputChannel->getConnectionToken()); if (connection != nullptr) { if (connection != nullptr) { prepareDispatchCycleLocked(currentTime, connection, eventEntry, &inputTarget); prepareDispatchCycleLocked(currentTime, connection, eventEntry, inputTarget); } else { } else { if (DEBUG_FOCUS) { if (DEBUG_FOCUS) { ALOGD("Dropping event delivery to target with channel '%s' because it " ALOGD("Dropping event delivery to target with channel '%s' because it " Loading Loading @@ -2045,7 +2045,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) { void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, const sp<Connection>& connection, EventEntry* eventEntry, EventEntry* eventEntry, const InputTarget* inputTarget) { const InputTarget& inputTarget) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { std::string message = std::string message = StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, sequenceNum=%" PRIu32 ")", StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, sequenceNum=%" PRIu32 ")", Loading @@ -2056,9 +2056,9 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, ALOGD("channel '%s' ~ prepareDispatchCycle - flags=0x%08x, " ALOGD("channel '%s' ~ prepareDispatchCycle - flags=0x%08x, " "xOffset=%f, yOffset=%f, globalScaleFactor=%f, " "xOffset=%f, yOffset=%f, globalScaleFactor=%f, " "windowScaleFactor=(%f, %f), pointerIds=0x%x", "windowScaleFactor=(%f, %f), pointerIds=0x%x", connection->getInputChannelName().c_str(), inputTarget->flags, inputTarget->xOffset, connection->getInputChannelName().c_str(), inputTarget.flags, inputTarget.xOffset, inputTarget->yOffset, inputTarget->globalScaleFactor, inputTarget->windowXScale, inputTarget.yOffset, inputTarget.globalScaleFactor, inputTarget.windowXScale, inputTarget->windowYScale, inputTarget->pointerIds.value); inputTarget.windowYScale, inputTarget.pointerIds.value); #endif #endif // Skip this event if the connection status is not normal. // Skip this event if the connection status is not normal. Loading @@ -2072,13 +2072,15 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, } } // Split a motion event if needed. // Split a motion event if needed. if (inputTarget->flags & InputTarget::FLAG_SPLIT) { if (inputTarget.flags & InputTarget::FLAG_SPLIT) { ALOG_ASSERT(eventEntry->type == EventEntry::Type::MOTION); LOG_ALWAYS_FATAL_IF(eventEntry->type != EventEntry::Type::MOTION, "Entry type %s should not have FLAG_SPLIT", EventEntry::typeToString(eventEntry->type)); const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry); const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry); if (inputTarget->pointerIds.count() != originalMotionEntry.pointerCount) { if (inputTarget.pointerIds.count() != originalMotionEntry.pointerCount) { MotionEntry* splitMotionEntry = MotionEntry* splitMotionEntry = splitMotionEvent(originalMotionEntry, inputTarget->pointerIds); splitMotionEvent(originalMotionEntry, inputTarget.pointerIds); if (!splitMotionEntry) { if (!splitMotionEntry) { return; // split event was dropped return; // split event was dropped } } Loading @@ -2100,7 +2102,7 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, const sp<Connection>& connection, EventEntry* eventEntry, EventEntry* eventEntry, const InputTarget* inputTarget) { const InputTarget& inputTarget) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { std::string message = std::string message = StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, sequenceNum=%" PRIu32 StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, sequenceNum=%" PRIu32 Loading Loading @@ -2133,7 +2135,7 @@ void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connection, void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, EventEntry* eventEntry, const InputTarget* inputTarget, const InputTarget& inputTarget, int32_t dispatchMode) { int32_t dispatchMode) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { std::string message = StringPrintf("enqueueDispatchEntry(inputChannel=%s, dispatchMode=%s)", std::string message = StringPrintf("enqueueDispatchEntry(inputChannel=%s, dispatchMode=%s)", Loading @@ -2141,7 +2143,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio dispatchModeToString(dispatchMode).c_str()); dispatchModeToString(dispatchMode).c_str()); ATRACE_NAME(message.c_str()); ATRACE_NAME(message.c_str()); } } int32_t inputTargetFlags = inputTarget->flags; int32_t inputTargetFlags = inputTarget.flags; if (!(inputTargetFlags & dispatchMode)) { if (!(inputTargetFlags & dispatchMode)) { return; return; } } Loading @@ -2149,11 +2151,11 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio // This is a new event. // This is a new event. // Enqueue a new dispatch entry onto the outbound queue for this connection. // Enqueue a new dispatch entry onto the outbound queue for this connection. DispatchEntry* dispatchEntry = std::unique_ptr<DispatchEntry> dispatchEntry = new DispatchEntry(eventEntry, // increments ref std::make_unique<DispatchEntry>(eventEntry, // increments ref inputTargetFlags, inputTarget->xOffset, inputTarget->yOffset, inputTargetFlags, inputTarget.xOffset, inputTarget->globalScaleFactor, inputTarget->windowXScale, inputTarget.yOffset, inputTarget.globalScaleFactor, inputTarget->windowYScale); inputTarget.windowXScale, inputTarget.windowYScale); // Apply target flags and update the connection's input state. // Apply target flags and update the connection's input state. switch (eventEntry->type) { switch (eventEntry->type) { Loading @@ -2168,7 +2170,6 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: skipping inconsistent key event", ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: skipping inconsistent key event", connection->getInputChannelName().c_str()); connection->getInputChannelName().c_str()); #endif #endif delete dispatchEntry; return; // skip the inconsistent event return; // skip the inconsistent event } } break; break; Loading Loading @@ -2215,12 +2216,11 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio "event", "event", connection->getInputChannelName().c_str()); connection->getInputChannelName().c_str()); #endif #endif delete dispatchEntry; return; // skip the inconsistent event return; // skip the inconsistent event } } dispatchPointerDownOutsideFocus(motionEntry.source, dispatchEntry->resolvedAction, dispatchPointerDownOutsideFocus(motionEntry.source, dispatchEntry->resolvedAction, inputTarget->inputChannel->getConnectionToken()); inputTarget.inputChannel->getConnectionToken()); break; break; } } Loading @@ -2238,7 +2238,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio } } // Enqueue the dispatch entry. // Enqueue the dispatch entry. connection->outboundQueue.push_back(dispatchEntry); connection->outboundQueue.push_back(dispatchEntry.release()); traceOutboundQueueLength(connection); traceOutboundQueueLength(connection); } } Loading Loading @@ -2625,7 +2625,7 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( target.flags = InputTarget::FLAG_DISPATCH_AS_IS; target.flags = InputTarget::FLAG_DISPATCH_AS_IS; enqueueDispatchEntryLocked(connection, cancelationEventEntry, // increments ref enqueueDispatchEntryLocked(connection, cancelationEventEntry, // increments ref &target, InputTarget::FLAG_DISPATCH_AS_IS); target, InputTarget::FLAG_DISPATCH_AS_IS); cancelationEventEntry->release(); cancelationEventEntry->release(); } } Loading
services/inputflinger/dispatcher/InputDispatcher.h +3 −3 Original line number Original line Diff line number Diff line Loading @@ -378,13 +378,13 @@ private: // with the mutex held makes it easier to ensure that connection invariants are maintained. // with the mutex held makes it easier to ensure that connection invariants are maintained. // If needed, the methods post commands to run later once the critical bits are done. // If needed, the methods post commands to run later once the critical bits are done. void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) EventEntry* eventEntry, const InputTarget& inputTarget) REQUIRES(mLock); REQUIRES(mLock); void enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, void enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) EventEntry* eventEntry, const InputTarget& inputTarget) REQUIRES(mLock); REQUIRES(mLock); void enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, void enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget, int32_t dispatchMode) const InputTarget& inputTarget, int32_t dispatchMode) REQUIRES(mLock); REQUIRES(mLock); void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection) void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection) REQUIRES(mLock); REQUIRES(mLock); Loading
services/inputflinger/dispatcher/InputTarget.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -108,7 +108,7 @@ struct InputTarget { // The subset of pointer ids to include in motion events dispatched to this input target // The subset of pointer ids to include in motion events dispatched to this input target // if FLAG_SPLIT is set. // if FLAG_SPLIT is set. BitSet32 pointerIds{}; BitSet32 pointerIds; }; }; std::string dispatchModeToString(int32_t dispatchMode); std::string dispatchModeToString(int32_t dispatchMode); Loading