Loading services/inputflinger/dispatcher/Connection.cpp +0 −11 Original line number Original line Diff line number Diff line Loading @@ -23,21 +23,10 @@ namespace android::inputdispatcher { Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, const IdGenerator& idGenerator) const IdGenerator& idGenerator) : status(Status::NORMAL), : status(Status::NORMAL), inputChannel(inputChannel), monitor(monitor), monitor(monitor), inputPublisher(inputChannel), inputPublisher(inputChannel), inputState(idGenerator) {} inputState(idGenerator) {} const std::string Connection::getWindowName() const { if (inputChannel != nullptr) { return inputChannel->getName(); } if (monitor) { return "monitor"; } return "?"; } sp<IBinder> Connection::getToken() const { sp<IBinder> Connection::getToken() const { return inputPublisher.getChannel()->getConnectionToken(); return inputPublisher.getChannel()->getConnectionToken(); }; }; Loading services/inputflinger/dispatcher/Connection.h +3 −4 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,6 @@ public: }; }; Status status; Status status; std::shared_ptr<InputChannel> inputChannel; // never null bool monitor; bool monitor; InputPublisher inputPublisher; InputPublisher inputPublisher; InputState inputState; InputState inputState; Loading @@ -62,11 +61,11 @@ public: Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, const IdGenerator& idGenerator); const IdGenerator& idGenerator); inline const std::string getInputChannelName() const { return inputChannel->getName(); } inline const std::string getInputChannelName() const { return inputPublisher.getChannel()->getName(); } sp<IBinder> getToken() const; sp<IBinder> getToken() const; const std::string getWindowName() const; }; }; } // namespace android::inputdispatcher } // namespace android::inputdispatcher services/inputflinger/dispatcher/InputDispatcher.cpp +15 −14 Original line number Original line Diff line number Diff line Loading @@ -2084,7 +2084,7 @@ void InputDispatcher::cancelEventsForAnrLocked(const std::shared_ptr<Connection> // sending new pointers to the connection when it blocked, but focused events will continue to // sending new pointers to the connection when it blocked, but focused events will continue to // pile up. // pile up. ALOGW("Canceling events for %s because it is unresponsive", ALOGW("Canceling events for %s because it is unresponsive", connection->inputChannel->getName().c_str()); connection->getInputChannelName().c_str()); if (connection->status == Connection::Status::NORMAL) { if (connection->status == Connection::Status::NORMAL) { CancelationOptions options(CancelationOptions::Mode::CANCEL_ALL_EVENTS, CancelationOptions options(CancelationOptions::Mode::CANCEL_ALL_EVENTS, "application not responding"); "application not responding"); Loading Loading @@ -2271,7 +2271,7 @@ std::vector<Monitor> InputDispatcher::selectResponsiveMonitorsLocked( std::shared_ptr<Connection> connection = monitor.connection; std::shared_ptr<Connection> connection = monitor.connection; if (!connection->responsive) { if (!connection->responsive) { ALOGW("Unresponsive monitor %s will not get the new gesture", ALOGW("Unresponsive monitor %s will not get the new gesture", connection->inputChannel->getName().c_str()); connection->getInputChannelName().c_str()); return false; return false; } } return true; return true; Loading Loading @@ -3586,7 +3586,7 @@ void InputDispatcher::processInteractionsLocked(const EventEntry& entry, std::string targetList; std::string targetList; for (const std::shared_ptr<Connection>& connection : newConnections) { for (const std::shared_ptr<Connection>& connection : newConnections) { targetList += connection->getWindowName() + ", "; targetList += connection->getInputChannelName() + ", "; } } std::string message = "Interaction with: " + targetList; std::string message = "Interaction with: " + targetList; if (targetList.empty()) { if (targetList.empty()) { Loading Loading @@ -5803,11 +5803,10 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) const { if (!mConnectionsByToken.empty()) { if (!mConnectionsByToken.empty()) { dump += INDENT "Connections:\n"; dump += INDENT "Connections:\n"; for (const auto& [token, connection] : mConnectionsByToken) { for (const auto& [token, connection] : mConnectionsByToken) { dump += StringPrintf(INDENT2 "%i: channelName='%s', windowName='%s', " dump += StringPrintf(INDENT2 "%i: channelName='%s', " "status=%s, monitor=%s, responsive=%s\n", "status=%s, monitor=%s, responsive=%s\n", connection->inputChannel->getFd(), connection->inputPublisher.getChannel()->getFd(), connection->getInputChannelName().c_str(), connection->getInputChannelName().c_str(), connection->getWindowName().c_str(), ftl::enum_string(connection->status).c_str(), ftl::enum_string(connection->status).c_str(), toString(connection->monitor), toString(connection->responsive)); toString(connection->monitor), toString(connection->responsive)); Loading Loading @@ -5986,7 +5985,7 @@ status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connection removeMonitorChannelLocked(connectionToken); removeMonitorChannelLocked(connectionToken); } } mLooper->removeFd(connection->inputChannel->getFd()); mLooper->removeFd(connection->inputPublisher.getChannel()->getFd()); nsecs_t currentTime = now(); nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); abortBrokenDispatchCycleLocked(currentTime, connection, notify); Loading Loading @@ -6180,7 +6179,7 @@ void InputDispatcher::doDispatchCycleFinishedCommand(nsecs_t finishTime, const nsecs_t eventDuration = finishTime - dispatchEntry.deliveryTime; const nsecs_t eventDuration = finishTime - dispatchEntry.deliveryTime; if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) { if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) { ALOGI("%s spent %" PRId64 "ms processing %s", connection->getWindowName().c_str(), ALOGI("%s spent %" PRId64 "ms processing %s", connection->getInputChannelName().c_str(), ns2ms(eventDuration), dispatchEntry.eventEntry->getDescription().c_str()); ns2ms(eventDuration), dispatchEntry.eventEntry->getDescription().c_str()); } } if (shouldReportFinishedEvent(dispatchEntry, *connection)) { if (shouldReportFinishedEvent(dispatchEntry, *connection)) { Loading Loading @@ -6251,7 +6250,7 @@ void InputDispatcher::onAnrLocked(const std::shared_ptr<Connection>& connection) // is already healthy again. Don't raise ANR in this situation // is already healthy again. Don't raise ANR in this situation if (connection->waitQueue.empty()) { if (connection->waitQueue.empty()) { ALOGI("Not raising ANR because the connection %s has recovered", ALOGI("Not raising ANR because the connection %s has recovered", connection->inputChannel->getName().c_str()); connection->getInputChannelName().c_str()); return; return; } } /** /** Loading @@ -6266,7 +6265,7 @@ void InputDispatcher::onAnrLocked(const std::shared_ptr<Connection>& connection) const nsecs_t currentWait = now() - oldestEntry.deliveryTime; const nsecs_t currentWait = now() - oldestEntry.deliveryTime; std::string reason = std::string reason = android::base::StringPrintf("%s is not responding. Waited %" PRId64 "ms for %s", android::base::StringPrintf("%s is not responding. Waited %" PRId64 "ms for %s", connection->inputChannel->getName().c_str(), connection->getInputChannelName().c_str(), ns2ms(currentWait), ns2ms(currentWait), oldestEntry.eventEntry->getDescription().c_str()); oldestEntry.eventEntry->getDescription().c_str()); sp<IBinder> connectionToken = connection->getToken(); sp<IBinder> connectionToken = connection->getToken(); Loading Loading @@ -6371,12 +6370,12 @@ void InputDispatcher::processConnectionUnresponsiveLocked(const Connection& conn const sp<IBinder>& connectionToken = connection.getToken(); const sp<IBinder>& connectionToken = connection.getToken(); std::optional<gui::Pid> pid; std::optional<gui::Pid> pid; if (connection.monitor) { if (connection.monitor) { ALOGW("Monitor %s is unresponsive: %s", connection.inputChannel->getName().c_str(), ALOGW("Monitor %s is unresponsive: %s", connection.getInputChannelName().c_str(), reason.c_str()); reason.c_str()); pid = findMonitorPidByTokenLocked(connectionToken); pid = findMonitorPidByTokenLocked(connectionToken); } else { } else { // The connection is a window // The connection is a window ALOGW("Window %s is unresponsive: %s", connection.inputChannel->getName().c_str(), ALOGW("Window %s is unresponsive: %s", connection.getInputChannelName().c_str(), reason.c_str()); reason.c_str()); const sp<WindowInfoHandle> handle = getWindowHandleLocked(connectionToken); const sp<WindowInfoHandle> handle = getWindowHandleLocked(connectionToken); if (handle != nullptr) { if (handle != nullptr) { Loading Loading @@ -6595,7 +6594,8 @@ void InputDispatcher::traceInboundQueueLengthLocked() { void InputDispatcher::traceOutboundQueueLength(const Connection& connection) { void InputDispatcher::traceOutboundQueueLength(const Connection& connection) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { char counterName[40]; char counterName[40]; snprintf(counterName, sizeof(counterName), "oq:%s", connection.getWindowName().c_str()); snprintf(counterName, sizeof(counterName), "oq:%s", connection.getInputChannelName().c_str()); ATRACE_INT(counterName, connection.outboundQueue.size()); ATRACE_INT(counterName, connection.outboundQueue.size()); } } } } Loading @@ -6603,7 +6603,8 @@ void InputDispatcher::traceOutboundQueueLength(const Connection& connection) { void InputDispatcher::traceWaitQueueLength(const Connection& connection) { void InputDispatcher::traceWaitQueueLength(const Connection& connection) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { char counterName[40]; char counterName[40]; snprintf(counterName, sizeof(counterName), "wq:%s", connection.getWindowName().c_str()); snprintf(counterName, sizeof(counterName), "wq:%s", connection.getInputChannelName().c_str()); ATRACE_INT(counterName, connection.waitQueue.size()); ATRACE_INT(counterName, connection.waitQueue.size()); } } } } Loading Loading
services/inputflinger/dispatcher/Connection.cpp +0 −11 Original line number Original line Diff line number Diff line Loading @@ -23,21 +23,10 @@ namespace android::inputdispatcher { Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, const IdGenerator& idGenerator) const IdGenerator& idGenerator) : status(Status::NORMAL), : status(Status::NORMAL), inputChannel(inputChannel), monitor(monitor), monitor(monitor), inputPublisher(inputChannel), inputPublisher(inputChannel), inputState(idGenerator) {} inputState(idGenerator) {} const std::string Connection::getWindowName() const { if (inputChannel != nullptr) { return inputChannel->getName(); } if (monitor) { return "monitor"; } return "?"; } sp<IBinder> Connection::getToken() const { sp<IBinder> Connection::getToken() const { return inputPublisher.getChannel()->getConnectionToken(); return inputPublisher.getChannel()->getConnectionToken(); }; }; Loading
services/inputflinger/dispatcher/Connection.h +3 −4 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,6 @@ public: }; }; Status status; Status status; std::shared_ptr<InputChannel> inputChannel; // never null bool monitor; bool monitor; InputPublisher inputPublisher; InputPublisher inputPublisher; InputState inputState; InputState inputState; Loading @@ -62,11 +61,11 @@ public: Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, const IdGenerator& idGenerator); const IdGenerator& idGenerator); inline const std::string getInputChannelName() const { return inputChannel->getName(); } inline const std::string getInputChannelName() const { return inputPublisher.getChannel()->getName(); } sp<IBinder> getToken() const; sp<IBinder> getToken() const; const std::string getWindowName() const; }; }; } // namespace android::inputdispatcher } // namespace android::inputdispatcher
services/inputflinger/dispatcher/InputDispatcher.cpp +15 −14 Original line number Original line Diff line number Diff line Loading @@ -2084,7 +2084,7 @@ void InputDispatcher::cancelEventsForAnrLocked(const std::shared_ptr<Connection> // sending new pointers to the connection when it blocked, but focused events will continue to // sending new pointers to the connection when it blocked, but focused events will continue to // pile up. // pile up. ALOGW("Canceling events for %s because it is unresponsive", ALOGW("Canceling events for %s because it is unresponsive", connection->inputChannel->getName().c_str()); connection->getInputChannelName().c_str()); if (connection->status == Connection::Status::NORMAL) { if (connection->status == Connection::Status::NORMAL) { CancelationOptions options(CancelationOptions::Mode::CANCEL_ALL_EVENTS, CancelationOptions options(CancelationOptions::Mode::CANCEL_ALL_EVENTS, "application not responding"); "application not responding"); Loading Loading @@ -2271,7 +2271,7 @@ std::vector<Monitor> InputDispatcher::selectResponsiveMonitorsLocked( std::shared_ptr<Connection> connection = monitor.connection; std::shared_ptr<Connection> connection = monitor.connection; if (!connection->responsive) { if (!connection->responsive) { ALOGW("Unresponsive monitor %s will not get the new gesture", ALOGW("Unresponsive monitor %s will not get the new gesture", connection->inputChannel->getName().c_str()); connection->getInputChannelName().c_str()); return false; return false; } } return true; return true; Loading Loading @@ -3586,7 +3586,7 @@ void InputDispatcher::processInteractionsLocked(const EventEntry& entry, std::string targetList; std::string targetList; for (const std::shared_ptr<Connection>& connection : newConnections) { for (const std::shared_ptr<Connection>& connection : newConnections) { targetList += connection->getWindowName() + ", "; targetList += connection->getInputChannelName() + ", "; } } std::string message = "Interaction with: " + targetList; std::string message = "Interaction with: " + targetList; if (targetList.empty()) { if (targetList.empty()) { Loading Loading @@ -5803,11 +5803,10 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) const { if (!mConnectionsByToken.empty()) { if (!mConnectionsByToken.empty()) { dump += INDENT "Connections:\n"; dump += INDENT "Connections:\n"; for (const auto& [token, connection] : mConnectionsByToken) { for (const auto& [token, connection] : mConnectionsByToken) { dump += StringPrintf(INDENT2 "%i: channelName='%s', windowName='%s', " dump += StringPrintf(INDENT2 "%i: channelName='%s', " "status=%s, monitor=%s, responsive=%s\n", "status=%s, monitor=%s, responsive=%s\n", connection->inputChannel->getFd(), connection->inputPublisher.getChannel()->getFd(), connection->getInputChannelName().c_str(), connection->getInputChannelName().c_str(), connection->getWindowName().c_str(), ftl::enum_string(connection->status).c_str(), ftl::enum_string(connection->status).c_str(), toString(connection->monitor), toString(connection->responsive)); toString(connection->monitor), toString(connection->responsive)); Loading Loading @@ -5986,7 +5985,7 @@ status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connection removeMonitorChannelLocked(connectionToken); removeMonitorChannelLocked(connectionToken); } } mLooper->removeFd(connection->inputChannel->getFd()); mLooper->removeFd(connection->inputPublisher.getChannel()->getFd()); nsecs_t currentTime = now(); nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); abortBrokenDispatchCycleLocked(currentTime, connection, notify); Loading Loading @@ -6180,7 +6179,7 @@ void InputDispatcher::doDispatchCycleFinishedCommand(nsecs_t finishTime, const nsecs_t eventDuration = finishTime - dispatchEntry.deliveryTime; const nsecs_t eventDuration = finishTime - dispatchEntry.deliveryTime; if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) { if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) { ALOGI("%s spent %" PRId64 "ms processing %s", connection->getWindowName().c_str(), ALOGI("%s spent %" PRId64 "ms processing %s", connection->getInputChannelName().c_str(), ns2ms(eventDuration), dispatchEntry.eventEntry->getDescription().c_str()); ns2ms(eventDuration), dispatchEntry.eventEntry->getDescription().c_str()); } } if (shouldReportFinishedEvent(dispatchEntry, *connection)) { if (shouldReportFinishedEvent(dispatchEntry, *connection)) { Loading Loading @@ -6251,7 +6250,7 @@ void InputDispatcher::onAnrLocked(const std::shared_ptr<Connection>& connection) // is already healthy again. Don't raise ANR in this situation // is already healthy again. Don't raise ANR in this situation if (connection->waitQueue.empty()) { if (connection->waitQueue.empty()) { ALOGI("Not raising ANR because the connection %s has recovered", ALOGI("Not raising ANR because the connection %s has recovered", connection->inputChannel->getName().c_str()); connection->getInputChannelName().c_str()); return; return; } } /** /** Loading @@ -6266,7 +6265,7 @@ void InputDispatcher::onAnrLocked(const std::shared_ptr<Connection>& connection) const nsecs_t currentWait = now() - oldestEntry.deliveryTime; const nsecs_t currentWait = now() - oldestEntry.deliveryTime; std::string reason = std::string reason = android::base::StringPrintf("%s is not responding. Waited %" PRId64 "ms for %s", android::base::StringPrintf("%s is not responding. Waited %" PRId64 "ms for %s", connection->inputChannel->getName().c_str(), connection->getInputChannelName().c_str(), ns2ms(currentWait), ns2ms(currentWait), oldestEntry.eventEntry->getDescription().c_str()); oldestEntry.eventEntry->getDescription().c_str()); sp<IBinder> connectionToken = connection->getToken(); sp<IBinder> connectionToken = connection->getToken(); Loading Loading @@ -6371,12 +6370,12 @@ void InputDispatcher::processConnectionUnresponsiveLocked(const Connection& conn const sp<IBinder>& connectionToken = connection.getToken(); const sp<IBinder>& connectionToken = connection.getToken(); std::optional<gui::Pid> pid; std::optional<gui::Pid> pid; if (connection.monitor) { if (connection.monitor) { ALOGW("Monitor %s is unresponsive: %s", connection.inputChannel->getName().c_str(), ALOGW("Monitor %s is unresponsive: %s", connection.getInputChannelName().c_str(), reason.c_str()); reason.c_str()); pid = findMonitorPidByTokenLocked(connectionToken); pid = findMonitorPidByTokenLocked(connectionToken); } else { } else { // The connection is a window // The connection is a window ALOGW("Window %s is unresponsive: %s", connection.inputChannel->getName().c_str(), ALOGW("Window %s is unresponsive: %s", connection.getInputChannelName().c_str(), reason.c_str()); reason.c_str()); const sp<WindowInfoHandle> handle = getWindowHandleLocked(connectionToken); const sp<WindowInfoHandle> handle = getWindowHandleLocked(connectionToken); if (handle != nullptr) { if (handle != nullptr) { Loading Loading @@ -6595,7 +6594,8 @@ void InputDispatcher::traceInboundQueueLengthLocked() { void InputDispatcher::traceOutboundQueueLength(const Connection& connection) { void InputDispatcher::traceOutboundQueueLength(const Connection& connection) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { char counterName[40]; char counterName[40]; snprintf(counterName, sizeof(counterName), "oq:%s", connection.getWindowName().c_str()); snprintf(counterName, sizeof(counterName), "oq:%s", connection.getInputChannelName().c_str()); ATRACE_INT(counterName, connection.outboundQueue.size()); ATRACE_INT(counterName, connection.outboundQueue.size()); } } } } Loading @@ -6603,7 +6603,8 @@ void InputDispatcher::traceOutboundQueueLength(const Connection& connection) { void InputDispatcher::traceWaitQueueLength(const Connection& connection) { void InputDispatcher::traceWaitQueueLength(const Connection& connection) { if (ATRACE_ENABLED()) { if (ATRACE_ENABLED()) { char counterName[40]; char counterName[40]; snprintf(counterName, sizeof(counterName), "wq:%s", connection.getWindowName().c_str()); snprintf(counterName, sizeof(counterName), "wq:%s", connection.getInputChannelName().c_str()); ATRACE_INT(counterName, connection.waitQueue.size()); ATRACE_INT(counterName, connection.waitQueue.size()); } } } } Loading