diff options
| author | 2025-02-11 15:47:37 +0000 | |
|---|---|---|
| committer | 2025-02-12 08:23:35 -0800 | |
| commit | fbed16bfa7b50cb85cecd1ae8868aa6d3c58ea4e (patch) | |
| tree | 2ba6d5c5a9bbdbfdb62a5154cc2ddfef2c7ae239 /services/inputflinger | |
| parent | adcbb982c1d4bba8dca2e8613dd1461404ab993c (diff) | |
Use ALWAYS_FATAL if touchState is out of sync
Converting an existing LOG(FATAL) to LOG_ALWAYS_FATAL. This methods is
always called with tokens that hvae been added to touchstate. So in this
CL we
1. Rename the method accordingly.
2. Add a LOG_ALWAYS_FATAL for cases this expectation is not met.
This is a followup from ag/31432556.
Test: atest inputflinger_tests
Bug: 245989146
Flag: EXEMPT TEST_ONLY
Change-Id: I18daa7a0086495b3a64df5286f94406d9c2c9ccb
Diffstat (limited to 'services/inputflinger')
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 15 | ||||
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.h | 6 |
2 files changed, 8 insertions, 13 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 4c8147df2c..9efe74de6c 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -4235,13 +4235,8 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( << "channel '" << connection->getInputChannelName() << "' ~ Synthesized " << downEvents.size() << " down events to ensure consistent event stream."; - auto touchedWindowHandleAndDisplay = - mTouchStates.findTouchedWindowHandleAndDisplay(connection->getToken()); - if (!touchedWindowHandleAndDisplay.has_value()) { - LOG(FATAL) << __func__ << ": Touch state is out of sync: No touched window for token"; - } - - const auto [windowHandle, displayId] = touchedWindowHandleAndDisplay.value(); + const auto [windowHandle, displayId] = + mTouchStates.findExistingTouchedWindowHandleAndDisplay(connection->getToken()); const bool wasEmpty = connection->outboundQueue.empty(); for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) { @@ -7397,8 +7392,8 @@ bool InputDispatcher::DispatcherTouchState::isPointerInWindow(const sp<android:: return false; } -std::optional<std::tuple<const sp<gui::WindowInfoHandle>&, ui::LogicalDisplayId>> -InputDispatcher::DispatcherTouchState::findTouchedWindowHandleAndDisplay( +std::tuple<const sp<gui::WindowInfoHandle>&, ui::LogicalDisplayId> +InputDispatcher::DispatcherTouchState::findExistingTouchedWindowHandleAndDisplay( const sp<android::IBinder>& token) const { for (const auto& [displayId, state] : mTouchStatesByDisplay) { for (const TouchedWindow& w : state.windows) { @@ -7407,7 +7402,7 @@ InputDispatcher::DispatcherTouchState::findTouchedWindowHandleAndDisplay( } } } - return std::nullopt; + LOG_ALWAYS_FATAL("%s : Touch state is out of sync: No touched window for token", __func__); } void InputDispatcher::DispatcherTouchState::forAllTouchedWindows( diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h index e76bd8970f..db7ebfd4e3 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.h +++ b/services/inputflinger/dispatcher/InputDispatcher.h @@ -396,9 +396,9 @@ private: bool isPointerInWindow(const sp<android::IBinder>& token, ui::LogicalDisplayId displayId, DeviceId deviceId, int32_t pointerId) const; - // Find touched windowHandle and display by token. - std::optional<std::tuple<const sp<gui::WindowInfoHandle>&, ui::LogicalDisplayId>> - findTouchedWindowHandleAndDisplay(const sp<IBinder>& token) const; + // Find an existing touched windowHandle and display by token. + std::tuple<const sp<gui::WindowInfoHandle>&, ui::LogicalDisplayId> + findExistingTouchedWindowHandleAndDisplay(const sp<IBinder>& token) const; void forAllTouchedWindows(std::function<void(const sp<gui::WindowInfoHandle>&)> f) const; |