Reland: Send WindowInfo even if the window isn't associated with a DisplayDevice
Previously reverted for b/240320932. Fixed broken test.
The previous behavior was the following: If a window was in a layerStack
for which there were no DisplayDevices that mapped to it, there was no
WindowInfo sent for it.
When a display is turned OFF, it is mapped to an invalid layer stack.
So when the primary display is turned OFF, there is no WindowInfo sent
for any windows on layerStack 0 as there are no DisplayDevices that now
map to it. In this model, no window can receive input when the display
is OFF.
In this CL, we change the behavior so that WindowInfos are sent even if
there are no DisplayDevices that map to its layerStack -- except that
in this case, we do not let the window receive touches, as we do not
have a valid transform associated with it.
Bug: 239788987
Test: See bug for repro steps
Test: Observe logs at runtime
Test: atest libgui_tests
Change-Id: Ib7e343685a0e3a87769883bdd5e24ac0e6d5e83f
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index c6cdeb7..2637f59 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -1184,18 +1184,23 @@
std::vector<sp<IGraphicBufferProducer>> mProducers;
};
-TEST_F(MultiDisplayTests, drop_input_if_layer_on_invalid_display) {
+TEST_F(MultiDisplayTests, drop_touch_if_layer_on_invalid_display) {
ui::LayerStack layerStack = ui::LayerStack::fromValue(42);
// Do not create a display associated with the LayerStack.
std::unique_ptr<InputSurface> surface = makeSurface(100, 100);
surface->doTransaction([&](auto &t, auto &sc) { t.setLayerStack(sc, layerStack); });
surface->showAt(100, 100);
+ // Touches should be dropped if the layer is on an invalid display.
injectTapOnDisplay(101, 101, layerStack.id);
- surface->requestFocus(layerStack.id);
- injectKeyOnDisplay(AKEYCODE_V, layerStack.id);
-
EXPECT_EQ(surface->consumeEvent(100), nullptr);
+
+ // However, we still let the window be focused and receive keys.
+ surface->requestFocus(layerStack.id);
+ surface->assertFocusChange(true);
+
+ injectKeyOnDisplay(AKEYCODE_V, layerStack.id);
+ surface->expectKey(AKEYCODE_V);
}
TEST_F(MultiDisplayTests, virtual_display_receives_input) {