Reland: InputDispatcher: Allow all windows to be removed from a display
Previoulsy reverted for b/240320932. No changes.
Previously, if there were no windows reported on a displayId by the
OnWindowInfosChangedListener, InputDispatcher did not remove the
existing windows from that displayId.
Here, we fix the bug so that when OnWindowInfosChangedListener reports
no windows on a display, the windows are removed from the displayId in
dispatcher.
Bug: 239788987
Test: atest inputflinger_tests
Change-Id: I444cf8c510997742e268d51c358ed78fa48a43f9
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index bd55216..9265fd3 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -6363,6 +6363,13 @@
{ // acquire lock
std::scoped_lock _l(mLock);
+
+ // Ensure that we have an entry created for all existing displays so that if a displayId has
+ // no windows, we can tell that the windows were removed from the display.
+ for (const auto& [displayId, _] : mWindowHandlesByDisplay) {
+ handlesPerDisplay[displayId];
+ }
+
mDisplayInfos.clear();
for (const auto& displayInfo : displayInfos) {
mDisplayInfos.emplace(displayInfo.displayId, displayInfo);