Loading services/inputflinger/dispatcher/InputDispatcher.cpp +16 −18 Original line number Diff line number Diff line Loading @@ -998,7 +998,7 @@ InputDispatcher::~InputDispatcher() { while (!mConnectionsByToken.empty()) { std::shared_ptr<Connection> connection = mConnectionsByToken.begin()->second; removeInputChannelLocked(connection->getToken(), /*notify=*/false); removeInputChannelLocked(connection, /*notify=*/false); } } Loading Loading @@ -3929,7 +3929,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, "event to it, status=%s(%d)", connection->getInputChannelName().c_str(), statusToString(status).c_str(), status); abortBrokenDispatchCycleLocked(currentTime, connection, /*notify=*/true); abortBrokenDispatchCycleLocked(connection, /*notify=*/true); } else { // Pipe is full and we are waiting for the app to finish process some events // before sending more events to it. Loading @@ -3944,7 +3944,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, "status=%s(%d)", connection->getInputChannelName().c_str(), statusToString(status).c_str(), status); abortBrokenDispatchCycleLocked(currentTime, connection, /*notify=*/true); abortBrokenDispatchCycleLocked(connection, /*notify=*/true); } return; } Loading Loading @@ -4019,8 +4019,7 @@ void InputDispatcher::finishDispatchCycleLocked(nsecs_t currentTime, postCommandLocked(std::move(command)); } void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime, const std::shared_ptr<Connection>& connection, void InputDispatcher::abortBrokenDispatchCycleLocked(const std::shared_ptr<Connection>& connection, bool notify) { if (DEBUG_DISPATCH_CYCLE) { LOG(INFO) << "channel '" << connection->getInputChannelName() << "'~ " << __func__ Loading Loading @@ -4136,7 +4135,7 @@ int InputDispatcher::handleReceiveCallback(int events, sp<IBinder> connectionTok } // Remove the channel. removeInputChannelLocked(connection->getToken(), notify); removeInputChannelLocked(connection, notify); return 0; // remove the callback } Loading Loading @@ -6313,8 +6312,14 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor( status_t InputDispatcher::removeInputChannel(const sp<IBinder>& connectionToken) { { // acquire lock std::scoped_lock _l(mLock); std::shared_ptr<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { // Connection can be removed via socket hang up or an explicit call to // 'removeInputChannel' return BAD_VALUE; } status_t status = removeInputChannelLocked(connectionToken, /*notify=*/false); status_t status = removeInputChannelLocked(connection, /*notify=*/false); if (status) { return status; } Loading @@ -6326,25 +6331,18 @@ status_t InputDispatcher::removeInputChannel(const sp<IBinder>& connectionToken) return OK; } status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connectionToken, status_t InputDispatcher::removeInputChannelLocked(const std::shared_ptr<Connection>& connection, bool notify) { std::shared_ptr<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { // Connection can be removed via socket hang up or an explicit call to 'removeInputChannel' return BAD_VALUE; } LOG_ALWAYS_FATAL_IF(connection == nullptr); abortBrokenDispatchCycleLocked(connection, notify); removeConnectionLocked(connection); if (connection->monitor) { removeMonitorChannelLocked(connectionToken); removeMonitorChannelLocked(connection->getToken()); } mLooper->removeFd(connection->inputPublisher.getChannel().getFd()); nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); connection->status = Connection::Status::ZOMBIE; return OK; } Loading services/inputflinger/dispatcher/InputDispatcher.h +2 −3 Original line number Diff line number Diff line Loading @@ -649,8 +649,7 @@ private: void finishDispatchCycleLocked(nsecs_t currentTime, const std::shared_ptr<Connection>& connection, uint32_t seq, bool handled, nsecs_t consumeTime) REQUIRES(mLock); void abortBrokenDispatchCycleLocked(nsecs_t currentTime, const std::shared_ptr<Connection>& connection, bool notify) void abortBrokenDispatchCycleLocked(const std::shared_ptr<Connection>& connection, bool notify) REQUIRES(mLock); void drainDispatchQueue(std::deque<std::unique_ptr<DispatchEntry>>& queue); void releaseDispatchEntry(std::unique_ptr<DispatchEntry> dispatchEntry); Loading Loading @@ -696,7 +695,7 @@ private: // Registration. void removeMonitorChannelLocked(const sp<IBinder>& connectionToken) REQUIRES(mLock); status_t removeInputChannelLocked(const sp<IBinder>& connectionToken, bool notify) status_t removeInputChannelLocked(const std::shared_ptr<Connection>& connection, bool notify) REQUIRES(mLock); // Interesting events that we might like to log or tell the framework about. Loading Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +16 −18 Original line number Diff line number Diff line Loading @@ -998,7 +998,7 @@ InputDispatcher::~InputDispatcher() { while (!mConnectionsByToken.empty()) { std::shared_ptr<Connection> connection = mConnectionsByToken.begin()->second; removeInputChannelLocked(connection->getToken(), /*notify=*/false); removeInputChannelLocked(connection, /*notify=*/false); } } Loading Loading @@ -3929,7 +3929,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, "event to it, status=%s(%d)", connection->getInputChannelName().c_str(), statusToString(status).c_str(), status); abortBrokenDispatchCycleLocked(currentTime, connection, /*notify=*/true); abortBrokenDispatchCycleLocked(connection, /*notify=*/true); } else { // Pipe is full and we are waiting for the app to finish process some events // before sending more events to it. Loading @@ -3944,7 +3944,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, "status=%s(%d)", connection->getInputChannelName().c_str(), statusToString(status).c_str(), status); abortBrokenDispatchCycleLocked(currentTime, connection, /*notify=*/true); abortBrokenDispatchCycleLocked(connection, /*notify=*/true); } return; } Loading Loading @@ -4019,8 +4019,7 @@ void InputDispatcher::finishDispatchCycleLocked(nsecs_t currentTime, postCommandLocked(std::move(command)); } void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime, const std::shared_ptr<Connection>& connection, void InputDispatcher::abortBrokenDispatchCycleLocked(const std::shared_ptr<Connection>& connection, bool notify) { if (DEBUG_DISPATCH_CYCLE) { LOG(INFO) << "channel '" << connection->getInputChannelName() << "'~ " << __func__ Loading Loading @@ -4136,7 +4135,7 @@ int InputDispatcher::handleReceiveCallback(int events, sp<IBinder> connectionTok } // Remove the channel. removeInputChannelLocked(connection->getToken(), notify); removeInputChannelLocked(connection, notify); return 0; // remove the callback } Loading Loading @@ -6313,8 +6312,14 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor( status_t InputDispatcher::removeInputChannel(const sp<IBinder>& connectionToken) { { // acquire lock std::scoped_lock _l(mLock); std::shared_ptr<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { // Connection can be removed via socket hang up or an explicit call to // 'removeInputChannel' return BAD_VALUE; } status_t status = removeInputChannelLocked(connectionToken, /*notify=*/false); status_t status = removeInputChannelLocked(connection, /*notify=*/false); if (status) { return status; } Loading @@ -6326,25 +6331,18 @@ status_t InputDispatcher::removeInputChannel(const sp<IBinder>& connectionToken) return OK; } status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connectionToken, status_t InputDispatcher::removeInputChannelLocked(const std::shared_ptr<Connection>& connection, bool notify) { std::shared_ptr<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { // Connection can be removed via socket hang up or an explicit call to 'removeInputChannel' return BAD_VALUE; } LOG_ALWAYS_FATAL_IF(connection == nullptr); abortBrokenDispatchCycleLocked(connection, notify); removeConnectionLocked(connection); if (connection->monitor) { removeMonitorChannelLocked(connectionToken); removeMonitorChannelLocked(connection->getToken()); } mLooper->removeFd(connection->inputPublisher.getChannel().getFd()); nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); connection->status = Connection::Status::ZOMBIE; return OK; } Loading
services/inputflinger/dispatcher/InputDispatcher.h +2 −3 Original line number Diff line number Diff line Loading @@ -649,8 +649,7 @@ private: void finishDispatchCycleLocked(nsecs_t currentTime, const std::shared_ptr<Connection>& connection, uint32_t seq, bool handled, nsecs_t consumeTime) REQUIRES(mLock); void abortBrokenDispatchCycleLocked(nsecs_t currentTime, const std::shared_ptr<Connection>& connection, bool notify) void abortBrokenDispatchCycleLocked(const std::shared_ptr<Connection>& connection, bool notify) REQUIRES(mLock); void drainDispatchQueue(std::deque<std::unique_ptr<DispatchEntry>>& queue); void releaseDispatchEntry(std::unique_ptr<DispatchEntry> dispatchEntry); Loading Loading @@ -696,7 +695,7 @@ private: // Registration. void removeMonitorChannelLocked(const sp<IBinder>& connectionToken) REQUIRES(mLock); status_t removeInputChannelLocked(const sp<IBinder>& connectionToken, bool notify) status_t removeInputChannelLocked(const std::shared_ptr<Connection>& connection, bool notify) REQUIRES(mLock); // Interesting events that we might like to log or tell the framework about. Loading