From 9bdd2e6151aa7a70bb4a12e91e7f68959b6334cb Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 21 Feb 2018 11:02:20 -0800 Subject: [PATCH] Handle window surface insets Bug: 69413152 Test: PixelCopy CTS tests Change-Id: Ie26c38e462fbc6c19669d33efaec5251f40f75bd --- graphics/java/android/view/PixelCopy.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/graphics/java/android/view/PixelCopy.java b/graphics/java/android/view/PixelCopy.java index a14609f3e924e..2797a4daa9253 100644 --- a/graphics/java/android/view/PixelCopy.java +++ b/graphics/java/android/view/PixelCopy.java @@ -263,8 +263,16 @@ public final class PixelCopy { "Only able to copy windows with decor views"); } Surface surface = null; - if (source.peekDecorView().getViewRootImpl() != null) { - surface = source.peekDecorView().getViewRootImpl().mSurface; + final ViewRootImpl root = source.peekDecorView().getViewRootImpl(); + if (root != null) { + surface = root.mSurface; + final Rect surfaceInsets = root.mWindowAttributes.surfaceInsets; + if (srcRect == null) { + srcRect = new Rect(surfaceInsets.left, surfaceInsets.top, + root.mWidth + surfaceInsets.left, root.mHeight + surfaceInsets.top); + } else { + srcRect.offset(surfaceInsets.left, surfaceInsets.top); + } } if (surface == null || !surface.isValid()) { throw new IllegalArgumentException(