diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index b5bbc75373919..6c4933e07b900 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -785,12 +785,14 @@ public final class SurfaceControl implements Parcelable { private final HardwareBuffer mHardwareBuffer; private final ColorSpace mColorSpace; private final boolean mContainsSecureLayers; + private final boolean mContainsHdrLayers; public ScreenshotHardwareBuffer(HardwareBuffer hardwareBuffer, ColorSpace colorSpace, - boolean containsSecureLayers) { + boolean containsSecureLayers, boolean containsHdrLayers) { mHardwareBuffer = hardwareBuffer; mColorSpace = colorSpace; mContainsSecureLayers = containsSecureLayers; + mContainsHdrLayers = containsHdrLayers; } /** @@ -798,13 +800,15 @@ public final class SurfaceControl implements Parcelable { * @param hardwareBuffer The existing HardwareBuffer object * @param namedColorSpace Integer value of a named color space {@link ColorSpace.Named} * @param containsSecureLayers Indicates whether this graphic buffer contains captured - * contents - * of secure layers, in which case the screenshot should not be persisted. + * contents of secure layers, in which case the screenshot + * should not be persisted. + * @param containsHdrLayers Indicates whether this graphic buffer contains HDR content. */ private static ScreenshotHardwareBuffer createFromNative(HardwareBuffer hardwareBuffer, - int namedColorSpace, boolean containsSecureLayers) { + int namedColorSpace, boolean containsSecureLayers, boolean containsHdrLayers) { ColorSpace colorSpace = ColorSpace.get(ColorSpace.Named.values()[namedColorSpace]); - return new ScreenshotHardwareBuffer(hardwareBuffer, colorSpace, containsSecureLayers); + return new ScreenshotHardwareBuffer( + hardwareBuffer, colorSpace, containsSecureLayers, containsHdrLayers); } public ColorSpace getColorSpace() { @@ -818,6 +822,14 @@ public final class SurfaceControl implements Parcelable { public boolean containsSecureLayers() { return mContainsSecureLayers; } + /** + * Returns whether the screenshot contains at least one HDR layer. + * This information may be useful for informing the display whether this screenshot + * is allowed to be dimmed to SDR white. + */ + public boolean containsHdrLayers() { + return mContainsHdrLayers; + } /** * Copy content of ScreenshotHardwareBuffer into a hardware bitmap and return it. diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 51a708b76801e..c769da57eecc4 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -322,7 +322,8 @@ public: env->CallStaticObjectMethod(gScreenshotHardwareBufferClassInfo.clazz, gScreenshotHardwareBufferClassInfo.builder, jhardwareBuffer, namedColorSpace, - captureResults.capturedSecureLayers); + captureResults.capturedSecureLayers, + captureResults.capturedHdrLayers); env->CallVoidMethod(screenCaptureListenerObject, gScreenCaptureListenerClassInfo.onScreenCaptureComplete, screenshotHardwareBuffer); @@ -2399,7 +2400,7 @@ int register_android_view_SurfaceControl(JNIEnv* env) MakeGlobalRefOrDie(env, screenshotGraphicsBufferClazz); gScreenshotHardwareBufferClassInfo.builder = GetStaticMethodIDOrDie(env, screenshotGraphicsBufferClazz, "createFromNative", - "(Landroid/hardware/HardwareBuffer;IZ)Landroid/view/" + "(Landroid/hardware/HardwareBuffer;IZZ)Landroid/view/" "SurfaceControl$ScreenshotHardwareBuffer;"); jclass displayedContentSampleClazz = FindClassOrDie(env, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index a2b35fc9211ae..a089585a5a004 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -454,8 +454,11 @@ public class BubbleExpandedView extends LinearLayout { p.beginRecording(mOverflowView.getWidth(), mOverflowView.getHeight())); p.endRecording(); Bitmap snapshot = Bitmap.createBitmap(p); - return new SurfaceControl.ScreenshotHardwareBuffer(snapshot.getHardwareBuffer(), - snapshot.getColorSpace(), false /* containsSecureLayers */); + return new SurfaceControl.ScreenshotHardwareBuffer( + snapshot.getHardwareBuffer(), + snapshot.getColorSpace(), + false /* containsSecureLayers */, + false /* containsHdrLayers */); } if (mTaskView == null || mTaskView.getSurfaceControl() == null) { return null; diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java index 65ae3fcb4c900..b4029d185b9f9 100644 --- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java +++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java @@ -219,7 +219,7 @@ class ScreenRotationAnimation { // If hdr layers are on-screen, e.g. picture-in-picture mode, the screenshot of // rotation animation is an sdr image containing tone-mapping hdr content, then // disable dimming effect to get avoid of hdr content being dimmed during animation. - t.setDimmingEnabled(mScreenshotLayer, false); + t.setDimmingEnabled(mScreenshotLayer, !screenshotBuffer.containsHdrLayers()); t.setLayer(mBackColorSurface, -1); t.setColor(mBackColorSurface, new float[]{mStartLuma, mStartLuma, mStartLuma}); t.setAlpha(mBackColorSurface, 1);