Plumb through display orientation separate from transform
This is exclusively used for getRaw compatibility. The input
transform can include window rotation and also, apparently,
nested view rotations as it the events get mutated by ui-toolkit.
Bug: 187686656
Test: cd frameworks/native/services/inputflinger && atest
Change-Id: I2fd7a2b2acbe422d962d0646d41c60eb48160620
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index d824649..93c86d1 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2298,6 +2298,10 @@
ui::Transform toPhysicalDisplay;
if (display) {
toPhysicalDisplay = display->getTransform();
+ // getOrientation() without masking can contain more-significant bits (eg. ROT_INVALID).
+ static constexpr uint32_t ALL_ROTATIONS_MASK =
+ ui::Transform::ROT_90 | ui::Transform::ROT_180 | ui::Transform::ROT_270;
+ info.displayOrientation = toPhysicalDisplay.getOrientation() & ALL_ROTATIONS_MASK;
info.displayWidth = display->getWidth();
info.displayHeight = display->getHeight();
}