Loading services/inputflinger/dispatcher/InputDispatcher.cpp +15 −15 Original line number Diff line number Diff line Loading @@ -518,7 +518,7 @@ nsecs_t InputDispatcher::processAnrsLocked() { connection->responsive = false; // Stop waking up for this unresponsive connection mAnrTracker.eraseToken(connection->inputChannel->getConnectionToken()); onAnrLocked(connection); onAnrLocked(*connection); return LONG_LONG_MIN; } Loading Loading @@ -4542,12 +4542,12 @@ void InputDispatcher::onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus postCommandLocked(std::move(commandEntry)); } void InputDispatcher::onAnrLocked(const sp<Connection>& connection) { void InputDispatcher::onAnrLocked(const Connection& connection) { // Since we are allowing the policy to extend the timeout, maybe the waitQueue // 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", connection->inputChannel->getName().c_str()); connection.inputChannel->getName().c_str()); return; } /** Loading @@ -4558,21 +4558,21 @@ void InputDispatcher::onAnrLocked(const sp<Connection>& connection) { * processes the events linearly. So providing information about the oldest entry seems to be * most useful. */ DispatchEntry* oldestEntry = *connection->waitQueue.begin(); DispatchEntry* oldestEntry = *connection.waitQueue.begin(); const nsecs_t currentWait = now() - oldestEntry->deliveryTime; std::string reason = android::base::StringPrintf("%s is not responding. Waited %" PRId64 "ms for %s", connection->inputChannel->getName().c_str(), connection.inputChannel->getName().c_str(), ns2ms(currentWait), oldestEntry->eventEntry->getDescription().c_str()); updateLastAnrStateLocked(getWindowHandleLocked(connection->inputChannel->getConnectionToken()), updateLastAnrStateLocked(getWindowHandleLocked(connection.inputChannel->getConnectionToken()), reason); std::unique_ptr<CommandEntry> commandEntry = std::make_unique<CommandEntry>(&InputDispatcher::doNotifyAnrLockedInterruptible); commandEntry->inputApplicationHandle = nullptr; commandEntry->inputChannel = connection->inputChannel; commandEntry->inputChannel = connection.inputChannel; commandEntry->reason = std::move(reason); postCommandLocked(std::move(commandEntry)); } Loading Loading @@ -4672,15 +4672,15 @@ void InputDispatcher::doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) void InputDispatcher::extendAnrTimeoutsLocked(const sp<InputApplicationHandle>& application, const sp<IBinder>& connectionToken, nsecs_t timeoutExtension) { sp<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { if (mNoFocusedWindowTimeoutTime.has_value() && application != nullptr) { // Maybe ANR happened because there's no focused window? if (connectionToken == nullptr && application != nullptr) { // The ANR happened because there's no focused window mNoFocusedWindowTimeoutTime = now() + timeoutExtension; mAwaitedFocusedApplication = application; } else { // It's also possible that the connection already disappeared. No action necessary. } sp<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { // It's possible that the connection already disappeared. No action necessary. return; } Loading services/inputflinger/dispatcher/InputDispatcher.h +1 −1 Original line number Diff line number Diff line Loading @@ -489,7 +489,7 @@ private: REQUIRES(mLock); void onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus, const sp<InputWindowHandle>& newFocus) REQUIRES(mLock); void onAnrLocked(const sp<Connection>& connection) REQUIRES(mLock); void onAnrLocked(const Connection& connection) REQUIRES(mLock); void onAnrLocked(const sp<InputApplicationHandle>& application) REQUIRES(mLock); void updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason) REQUIRES(mLock); Loading services/inputflinger/tests/InputDispatcher_test.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ public: const std::chrono::duration waited = std::chrono::steady_clock::now() - start; if (mAnrApplications.empty() || mAnrWindowTokens.empty()) { ADD_FAILURE() << "Did not receive ANR callback"; return {}; } // Ensure that the ANR didn't get raised too early. We can't be too strict here because // the dispatcher started counting before this function was called Loading Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +15 −15 Original line number Diff line number Diff line Loading @@ -518,7 +518,7 @@ nsecs_t InputDispatcher::processAnrsLocked() { connection->responsive = false; // Stop waking up for this unresponsive connection mAnrTracker.eraseToken(connection->inputChannel->getConnectionToken()); onAnrLocked(connection); onAnrLocked(*connection); return LONG_LONG_MIN; } Loading Loading @@ -4542,12 +4542,12 @@ void InputDispatcher::onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus postCommandLocked(std::move(commandEntry)); } void InputDispatcher::onAnrLocked(const sp<Connection>& connection) { void InputDispatcher::onAnrLocked(const Connection& connection) { // Since we are allowing the policy to extend the timeout, maybe the waitQueue // 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", connection->inputChannel->getName().c_str()); connection.inputChannel->getName().c_str()); return; } /** Loading @@ -4558,21 +4558,21 @@ void InputDispatcher::onAnrLocked(const sp<Connection>& connection) { * processes the events linearly. So providing information about the oldest entry seems to be * most useful. */ DispatchEntry* oldestEntry = *connection->waitQueue.begin(); DispatchEntry* oldestEntry = *connection.waitQueue.begin(); const nsecs_t currentWait = now() - oldestEntry->deliveryTime; std::string reason = android::base::StringPrintf("%s is not responding. Waited %" PRId64 "ms for %s", connection->inputChannel->getName().c_str(), connection.inputChannel->getName().c_str(), ns2ms(currentWait), oldestEntry->eventEntry->getDescription().c_str()); updateLastAnrStateLocked(getWindowHandleLocked(connection->inputChannel->getConnectionToken()), updateLastAnrStateLocked(getWindowHandleLocked(connection.inputChannel->getConnectionToken()), reason); std::unique_ptr<CommandEntry> commandEntry = std::make_unique<CommandEntry>(&InputDispatcher::doNotifyAnrLockedInterruptible); commandEntry->inputApplicationHandle = nullptr; commandEntry->inputChannel = connection->inputChannel; commandEntry->inputChannel = connection.inputChannel; commandEntry->reason = std::move(reason); postCommandLocked(std::move(commandEntry)); } Loading Loading @@ -4672,15 +4672,15 @@ void InputDispatcher::doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) void InputDispatcher::extendAnrTimeoutsLocked(const sp<InputApplicationHandle>& application, const sp<IBinder>& connectionToken, nsecs_t timeoutExtension) { sp<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { if (mNoFocusedWindowTimeoutTime.has_value() && application != nullptr) { // Maybe ANR happened because there's no focused window? if (connectionToken == nullptr && application != nullptr) { // The ANR happened because there's no focused window mNoFocusedWindowTimeoutTime = now() + timeoutExtension; mAwaitedFocusedApplication = application; } else { // It's also possible that the connection already disappeared. No action necessary. } sp<Connection> connection = getConnectionLocked(connectionToken); if (connection == nullptr) { // It's possible that the connection already disappeared. No action necessary. return; } Loading
services/inputflinger/dispatcher/InputDispatcher.h +1 −1 Original line number Diff line number Diff line Loading @@ -489,7 +489,7 @@ private: REQUIRES(mLock); void onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus, const sp<InputWindowHandle>& newFocus) REQUIRES(mLock); void onAnrLocked(const sp<Connection>& connection) REQUIRES(mLock); void onAnrLocked(const Connection& connection) REQUIRES(mLock); void onAnrLocked(const sp<InputApplicationHandle>& application) REQUIRES(mLock); void updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason) REQUIRES(mLock); Loading
services/inputflinger/tests/InputDispatcher_test.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ public: const std::chrono::duration waited = std::chrono::steady_clock::now() - start; if (mAnrApplications.empty() || mAnrWindowTokens.empty()) { ADD_FAILURE() << "Did not receive ANR callback"; return {}; } // Ensure that the ANR didn't get raised too early. We can't be too strict here because // the dispatcher started counting before this function was called Loading