Treat dimming-disabled layers as HDR

Screen rotations currently capture an SDR screenshot, and rotate the
screenshot. If there is an HDR layer on screen, this causes the HDR
layer to be tone-mapped to SDR, and the screeenshot when fed back into
SurfaceFlinger has a tag that prevents the screenshot from being dimmed
so that the HDR layer can remain at the same brightness (modulo a
brightness change). But this means that the screenshot should be treated
as an HDR layer, as there is a noticeable dip and re-ramp up in
brightness.

Bug: 228197661
Test: builds, boots
Change-Id: I1d1b0dcaf230300ca34b84ea407d0817feb2c664
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 498f37c..e5e493f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2345,7 +2345,12 @@
 }
 
 bool SurfaceFlinger::isHdrLayer(Layer* layer) const {
-    if (!isHdrDataspace(layer->getDataSpace())) {
+    // Treat all layers as non-HDR if:
+    // 1. They do not have a valid HDR dataspace. Currently we treat those as PQ or HLG. and
+    // 2. The layer is allowed to be dimmed. WindowManager may disable dimming in order to
+    // keep animations invoking SDR screenshots of HDR layers seamless. Treat such tagged
+    // layers as HDR so that DisplayManagerService does not try to change the screen brightness
+    if (!isHdrDataspace(layer->getDataSpace()) && layer->isDimmingEnabled()) {
         return false;
     }
     if (mIgnoreHdrCameraLayers) {