Loading services/input/InputDispatcher.cpp +15 −6 Original line number Original line Diff line number Diff line Loading @@ -224,10 +224,16 @@ void InputDispatcher::dispatchOnce() { AutoMutex _l(mLock); AutoMutex _l(mLock); mDispatcherIsAliveCondition.broadcast(); mDispatcherIsAliveCondition.broadcast(); // Run a dispatch loop if there are no pending commands. // The dispatch loop might enqueue commands to run afterwards. if (!haveCommandsLocked()) { dispatchOnceInnerLocked(&nextWakeupTime); dispatchOnceInnerLocked(&nextWakeupTime); } // Run all pending commands if there are any. // If any commands were run then force the next poll to wake up immediately. if (runCommandsLockedInterruptible()) { if (runCommandsLockedInterruptible()) { nextWakeupTime = LONG_LONG_MIN; // force next poll to wake up immediately nextWakeupTime = LONG_LONG_MIN; } } } // release lock } // release lock Loading Loading @@ -562,6 +568,10 @@ bool InputDispatcher::isStaleEventLocked(nsecs_t currentTime, EventEntry* entry) return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT; return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT; } } bool InputDispatcher::haveCommandsLocked() const { return !mCommandQueue.isEmpty(); } bool InputDispatcher::runCommandsLockedInterruptible() { bool InputDispatcher::runCommandsLockedInterruptible() { if (mCommandQueue.isEmpty()) { if (mCommandQueue.isEmpty()) { return false; return false; Loading Loading @@ -3247,9 +3257,10 @@ status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChan } } mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this); mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this); runCommandsLockedInterruptible(); } // release lock } // release lock // Wake the looper because some connections have changed. mLooper->wake(); return OK; return OK; } } Loading Loading @@ -3294,8 +3305,6 @@ status_t InputDispatcher::unregisterInputChannelLocked(const sp<InputChannel>& i nsecs_t currentTime = now(); nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); abortBrokenDispatchCycleLocked(currentTime, connection, notify); runCommandsLockedInterruptible(); connection->status = Connection::STATUS_ZOMBIE; connection->status = Connection::STATUS_ZOMBIE; return OK; return OK; } } Loading services/input/InputDispatcher.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -899,6 +899,7 @@ private: KeyEntry* synthesizeKeyRepeatLocked(nsecs_t currentTime); KeyEntry* synthesizeKeyRepeatLocked(nsecs_t currentTime); // Deferred command processing. // Deferred command processing. bool haveCommandsLocked() const; bool runCommandsLockedInterruptible(); bool runCommandsLockedInterruptible(); CommandEntry* postCommandLocked(Command command); CommandEntry* postCommandLocked(Command command); Loading Loading
services/input/InputDispatcher.cpp +15 −6 Original line number Original line Diff line number Diff line Loading @@ -224,10 +224,16 @@ void InputDispatcher::dispatchOnce() { AutoMutex _l(mLock); AutoMutex _l(mLock); mDispatcherIsAliveCondition.broadcast(); mDispatcherIsAliveCondition.broadcast(); // Run a dispatch loop if there are no pending commands. // The dispatch loop might enqueue commands to run afterwards. if (!haveCommandsLocked()) { dispatchOnceInnerLocked(&nextWakeupTime); dispatchOnceInnerLocked(&nextWakeupTime); } // Run all pending commands if there are any. // If any commands were run then force the next poll to wake up immediately. if (runCommandsLockedInterruptible()) { if (runCommandsLockedInterruptible()) { nextWakeupTime = LONG_LONG_MIN; // force next poll to wake up immediately nextWakeupTime = LONG_LONG_MIN; } } } // release lock } // release lock Loading Loading @@ -562,6 +568,10 @@ bool InputDispatcher::isStaleEventLocked(nsecs_t currentTime, EventEntry* entry) return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT; return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT; } } bool InputDispatcher::haveCommandsLocked() const { return !mCommandQueue.isEmpty(); } bool InputDispatcher::runCommandsLockedInterruptible() { bool InputDispatcher::runCommandsLockedInterruptible() { if (mCommandQueue.isEmpty()) { if (mCommandQueue.isEmpty()) { return false; return false; Loading Loading @@ -3247,9 +3257,10 @@ status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChan } } mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this); mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this); runCommandsLockedInterruptible(); } // release lock } // release lock // Wake the looper because some connections have changed. mLooper->wake(); return OK; return OK; } } Loading Loading @@ -3294,8 +3305,6 @@ status_t InputDispatcher::unregisterInputChannelLocked(const sp<InputChannel>& i nsecs_t currentTime = now(); nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); abortBrokenDispatchCycleLocked(currentTime, connection, notify); runCommandsLockedInterruptible(); connection->status = Connection::STATUS_ZOMBIE; connection->status = Connection::STATUS_ZOMBIE; return OK; return OK; } } Loading
services/input/InputDispatcher.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -899,6 +899,7 @@ private: KeyEntry* synthesizeKeyRepeatLocked(nsecs_t currentTime); KeyEntry* synthesizeKeyRepeatLocked(nsecs_t currentTime); // Deferred command processing. // Deferred command processing. bool haveCommandsLocked() const; bool runCommandsLockedInterruptible(); bool runCommandsLockedInterruptible(); CommandEntry* postCommandLocked(Command command); CommandEntry* postCommandLocked(Command command); Loading