Handle window surface insets

Bug: 69413152
Test: PixelCopy CTS tests
Change-Id: Ie26c38e462fbc6c19669d33efaec5251f40f75bd
This commit is contained in:
John Reck
2018-02-21 11:02:20 -08:00
parent 2ebb021231
commit 9bdd2e6151

View File

@@ -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(