Fix input infos are inconsistent between WMS and InputFlinger (2/2)
In single focus system, the top focused display may change to the new
one when receive a key event. And we would expect the focus could be
changed before the event enqueued into inbound queue.
This patch refactor 'setInputWindows' to prevent early callback and
wakeup in first display, and make sure 'syncInputWindow' could wait
until all input windows from all displays updated.
Bug: 150250453
Test: atest libinput_tests inputflinger_tests
Test: atest --rerun-until-failure 100 WindowFocusTests#testMovingDisplayToTopByKeyEvent
Change-Id: I38f53d83738c4fbf570ea3b99e46341a5f9a4c0f
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 4aa47f8..cbba7e1 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -109,8 +109,8 @@
virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override;
virtual void setInputWindows(
- const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId,
- const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override;
+ const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
+ handlesPerDisplay) override;
virtual void setFocusedApplication(
int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override;
virtual void setFocusedDisplay(int32_t displayId) override;
@@ -278,6 +278,8 @@
std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay
GUARDED_BY(mLock);
+ void setInputWindowsLocked(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
+ int32_t displayId) REQUIRES(mLock);
// Get window handles by display, return an empty vector if not found.
std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const
REQUIRES(mLock);