Revert "InputDispatcher: Allow all windows to be removed from a ..."

Revert submission 19396488

Reason for revert: Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/tests/view?invocationId=I83300010074249798&testResultId=TR51728160843391916, bug 240320932
Reverted Changes:
I0b50d6789:InputDispatcher: Allow all windows to be removed f...
Ibe0e4326d:Send WindowInfo even if the window isn't associate...

Bug: 240320932
Change-Id: If6c7018be45ff07e45a65bea6ab0267fa5426578
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 742ea67..4516558 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -6371,13 +6371,6 @@
 
     { // 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);
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index f8d8d13..8a2dea5 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -2370,35 +2370,6 @@
     thirdWindow->consumeMotionDown();
 }
 
-TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) {
-    std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
-    sp<FakeWindowHandle> window =
-            new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
-    window->setFocusable(true);
-
-    mDispatcher->onWindowInfosChanged({*window->getInfo()}, {});
-    setFocusedWindow(window);
-
-    window->consumeFocusEvent(true);
-
-    NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
-    NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
-    mDispatcher->notifyKey(&keyDown);
-    mDispatcher->notifyKey(&keyUp);
-
-    window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
-    window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
-
-    // All windows are removed from the display. Ensure that we can no longer dispatch to it.
-    mDispatcher->onWindowInfosChanged({}, {});
-
-    window->consumeFocusEvent(false);
-
-    mDispatcher->notifyKey(&keyDown);
-    mDispatcher->notifyKey(&keyUp);
-    window->assertNoEvents();
-}
-
 /**
  * Ensure the correct coordinate spaces are used by InputDispatcher.
  *