Loading services/inputflinger/dispatcher/InputDispatcher.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -548,6 +548,7 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic mAppSwitchSawKeyDown(false), mAppSwitchDueTime(LONG_LONG_MAX), mNextUnblockedEvent(nullptr), mMonitorDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT), mDispatchEnabled(false), mDispatchFrozen(false), mInputFilterEnabled(false), Loading Loading @@ -707,8 +708,13 @@ nsecs_t InputDispatcher::processAnrsLocked() { return LONG_LONG_MIN; } std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(const sp<IBinder>& token) { sp<WindowInfoHandle> window = getWindowHandleLocked(token); std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked( const sp<Connection>& connection) { if (connection->monitor) { return mMonitorDispatchingTimeout; } const sp<WindowInfoHandle> window = getWindowHandleLocked(connection->inputChannel->getConnectionToken()); if (window != nullptr) { return window->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT); } Loading Loading @@ -3205,8 +3211,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, while (connection->status == Connection::Status::NORMAL && !connection->outboundQueue.empty()) { DispatchEntry* dispatchEntry = connection->outboundQueue.front(); dispatchEntry->deliveryTime = currentTime; const std::chrono::nanoseconds timeout = getDispatchingTimeoutLocked(connection->inputChannel->getConnectionToken()); const std::chrono::nanoseconds timeout = getDispatchingTimeoutLocked(connection); dispatchEntry->timeoutTime = currentTime + timeout.count(); // Publish the event. Loading Loading @@ -6400,4 +6405,9 @@ void InputDispatcher::cancelCurrentTouch() { mLooper->wake(); } void InputDispatcher::setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout) { std::scoped_lock _l(mLock); mMonitorDispatchingTimeout = timeout; } } // namespace android::inputdispatcher services/inputflinger/dispatcher/InputDispatcher.h +8 −1 Original line number Diff line number Diff line Loading @@ -148,6 +148,9 @@ public: void cancelCurrentTouch() override; // Public to allow tests to verify that a Monitor can get ANR. void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout); private: enum class DropReason { NOT_DROPPED, Loading Loading @@ -324,8 +327,12 @@ private: bool runCommandsLockedInterruptable() REQUIRES(mLock); void postCommandLocked(Command&& command) REQUIRES(mLock); // The dispatching timeout to use for Monitors. std::chrono::nanoseconds mMonitorDispatchingTimeout GUARDED_BY(mLock); nsecs_t processAnrsLocked() REQUIRES(mLock); std::chrono::nanoseconds getDispatchingTimeoutLocked(const sp<IBinder>& token) REQUIRES(mLock); std::chrono::nanoseconds getDispatchingTimeoutLocked(const sp<Connection>& connection) REQUIRES(mLock); // Input filter processing. bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock); Loading services/inputflinger/tests/InputDispatcher_test.cpp +242 −172 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -548,6 +548,7 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic mAppSwitchSawKeyDown(false), mAppSwitchDueTime(LONG_LONG_MAX), mNextUnblockedEvent(nullptr), mMonitorDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT), mDispatchEnabled(false), mDispatchFrozen(false), mInputFilterEnabled(false), Loading Loading @@ -707,8 +708,13 @@ nsecs_t InputDispatcher::processAnrsLocked() { return LONG_LONG_MIN; } std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(const sp<IBinder>& token) { sp<WindowInfoHandle> window = getWindowHandleLocked(token); std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked( const sp<Connection>& connection) { if (connection->monitor) { return mMonitorDispatchingTimeout; } const sp<WindowInfoHandle> window = getWindowHandleLocked(connection->inputChannel->getConnectionToken()); if (window != nullptr) { return window->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT); } Loading Loading @@ -3205,8 +3211,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, while (connection->status == Connection::Status::NORMAL && !connection->outboundQueue.empty()) { DispatchEntry* dispatchEntry = connection->outboundQueue.front(); dispatchEntry->deliveryTime = currentTime; const std::chrono::nanoseconds timeout = getDispatchingTimeoutLocked(connection->inputChannel->getConnectionToken()); const std::chrono::nanoseconds timeout = getDispatchingTimeoutLocked(connection); dispatchEntry->timeoutTime = currentTime + timeout.count(); // Publish the event. Loading Loading @@ -6400,4 +6405,9 @@ void InputDispatcher::cancelCurrentTouch() { mLooper->wake(); } void InputDispatcher::setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout) { std::scoped_lock _l(mLock); mMonitorDispatchingTimeout = timeout; } } // namespace android::inputdispatcher
services/inputflinger/dispatcher/InputDispatcher.h +8 −1 Original line number Diff line number Diff line Loading @@ -148,6 +148,9 @@ public: void cancelCurrentTouch() override; // Public to allow tests to verify that a Monitor can get ANR. void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout); private: enum class DropReason { NOT_DROPPED, Loading Loading @@ -324,8 +327,12 @@ private: bool runCommandsLockedInterruptable() REQUIRES(mLock); void postCommandLocked(Command&& command) REQUIRES(mLock); // The dispatching timeout to use for Monitors. std::chrono::nanoseconds mMonitorDispatchingTimeout GUARDED_BY(mLock); nsecs_t processAnrsLocked() REQUIRES(mLock); std::chrono::nanoseconds getDispatchingTimeoutLocked(const sp<IBinder>& token) REQUIRES(mLock); std::chrono::nanoseconds getDispatchingTimeoutLocked(const sp<Connection>& connection) REQUIRES(mLock); // Input filter processing. bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock); Loading
services/inputflinger/tests/InputDispatcher_test.cpp +242 −172 File changed.Preview size limit exceeded, changes collapsed. Show changes