From 6e29c8d40a3103fefb1dc683e1daafd3b0b06f1f Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Mon, 12 Sep 2022 20:12:31 +0800 Subject: [PATCH] Use legacy layer name for screenshot shell display rotation Just to avoid divergence of flicker test which assumes there will be a "RotationLayer" when running display rotation animation. Also make the condition to calculate luma more accurate. Bug: 242056267 Test: setprop persist.wm.debug.shell_transit_blast 0; setprop persist.wm.debug.shell_transit 1; reboot atest FlickerTests:ChangeAppRotationTest Change-Id: Icedc18192249fbba27a6429e66d0e81c42cefc22 --- .../core/java/com/android/server/wm/Transition.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 0e1a6ded8515c..6650f43c15ae1 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -2155,8 +2155,12 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe Slog.w(TAG, "Failed to capture screenshot for " + wc); return false; } + final boolean isDisplayRotation = wc.asDisplayContent() != null + && wc.asDisplayContent().isRotationChanging(); + // Some tests may check the name "RotationLayer" to detect display rotation. + final String name = isDisplayRotation ? "RotationLayer" : "transition snapshot: " + wc; SurfaceControl snapshotSurface = wc.makeAnimationLeash() - .setName("transition snapshot: " + wc.toString()) + .setName(name) .setOpaque(true) .setParent(wc.getSurfaceControl()) .setSecure(screenshotBuffer.containsSecureLayers()) @@ -2166,9 +2170,8 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe mFrozen.add(wc); final ChangeInfo changeInfo = Objects.requireNonNull(mChanges.get(wc)); changeInfo.mSnapshot = snapshotSurface; - if (wc.asDisplayContent() != null) { - // This isn't cheap, so only do it for rotations: assume display-level is rotate - // since most of the time it is. + if (isDisplayRotation) { + // This isn't cheap, so only do it for display rotations. changeInfo.mSnapshotLuma = RotationAnimationUtils.getMedianBorderLuma( screenshotBuffer.getHardwareBuffer(), screenshotBuffer.getColorSpace()); }