Set windowInfo.displayId to be the layerStack
Instead of using the displayId sent from WMS, it's better to use the
layerStack since it more accurately represents where the layer is
presented. Previously, the only case where WMS needed to set a displayId
different from layerStack was when using portal displays, which is no
longer supported.
This also fixes the case with cloned layers. If a cloned layer was
placed on a different display than the main layer, the WindowInfo for
the clone would end up having the same display as the main window since
the properties were directly copied over. With this fix, the cloned
layer's WindowInfo will get the correct layerStack that represents where
it's actually rendered.
Test: MediaProjection capture with mirror
Bug: 195280234
Change-Id: Id1794798a543260c9868ccdc1be3cdb574b73dd5
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 7523362..698b3f1 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2305,10 +2305,7 @@
WindowInfo info = mDrawingState.inputInfo;
info.id = sequence;
-
- if (info.displayId == ADISPLAY_ID_NONE) {
- info.displayId = getLayerStack();
- }
+ info.displayId = getLayerStack();
// Transform that goes from "logical(rotated)" display to physical/unrotated display.
// This is for when inputflinger operates in physical display-space.