Send cancel events to the correct display when mirroring
When a display is mirrored, such as when screen recording is enabled,
there will be clones of the input windows on the mirrored display that
are on the mirror display.
When there is a stream of input going to the channel through one of
those windows and that stream should be canceled, the generated cancel
event should be sent to the correct window on the correct display.
Bug: 299074463
Test: atest inputflinger_tests
Change-Id: I7b9eab69c9e9086750cf9fe8a10998a12c30d084
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index ee5a797..0020301 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -354,14 +354,11 @@
// Get a reference to window handles by display, return an empty vector if not found.
const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesLocked(
int32_t displayId) const REQUIRES(mLock);
- sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
- const sp<IBinder>& windowHandleToken) const REQUIRES(mLock);
ui::Transform getTransformLocked(int32_t displayId) const REQUIRES(mLock);
- // Same function as above, but faster. Since displayId is provided, this avoids the need
- // to loop through all displays.
- sp<android::gui::WindowInfoHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken,
- int displayId) const REQUIRES(mLock);
+ sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
+ const sp<IBinder>& windowHandleToken, std::optional<int32_t> displayId = {}) const
+ REQUIRES(mLock);
sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
const sp<android::gui::WindowInfoHandle>& windowHandle) const REQUIRES(mLock);
std::shared_ptr<InputChannel> getInputChannelLocked(const sp<IBinder>& windowToken) const