Use new insets apis for determining the stable/system insets

- The old calls appear to account for the display cutout now which causes
  the landscape/seascape comparison to fail

Bug: 157878422
Test: atest TaskSnapshotControllerTest
Test: TaskSnapshotSurfaceTest
Test: DecorViewTest
Test: Open an app with displaycutout layout shortEdge or always, and
      rotate to landscape in non-gestural mode, and ensure that the
      divider and background are drawn in the right place
Change-Id: Ib51964a76e25f902858aad4e8aeb810dfca2edc0
Merged-In: Ib51964a76e25f902858aad4e8aeb810dfca2edc0
This commit is contained in:
Winson Chung
2020-06-04 11:57:58 -07:00
parent 8202b399da
commit 05b5f976d7
5 changed files with 84 additions and 103 deletions

View File

@@ -16,6 +16,7 @@
package com.android.internal.policy;
import android.graphics.Insets;
import android.graphics.RecordingCanvas;
import android.graphics.Rect;
import android.graphics.RenderNode;
@@ -69,16 +70,14 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
private ColorDrawable mNavigationBarColor;
private boolean mOldFullscreen;
private boolean mFullscreen;
private final Rect mOldSystemInsets = new Rect();
private final Rect mOldStableInsets = new Rect();
private final Rect mSystemInsets = new Rect();
private final Rect mStableInsets = new Rect();
private final Rect mOldSystemBarInsets = new Rect();
private final Rect mSystemBarInsets = new Rect();
private final Rect mTmpRect = new Rect();
public BackdropFrameRenderer(DecorView decorView, ThreadedRenderer renderer, Rect initialBounds,
Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable,
Drawable userCaptionBackgroundDrawable, int statusBarColor, int navigationBarColor,
boolean fullscreen, Rect systemInsets, Rect stableInsets) {
boolean fullscreen, Insets systemBarInsets) {
setName("ResizeFrame");
mRenderer = renderer;
@@ -95,10 +94,8 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
mTargetRect.set(initialBounds);
mFullscreen = fullscreen;
mOldFullscreen = fullscreen;
mSystemInsets.set(systemInsets);
mStableInsets.set(stableInsets);
mOldSystemInsets.set(systemInsets);
mOldStableInsets.set(stableInsets);
mSystemBarInsets.set(systemBarInsets.toRect());
mOldSystemBarInsets.set(systemBarInsets.toRect());
// Kick off our draw thread.
start();
@@ -154,16 +151,13 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
*
* @param newTargetBounds The new target bounds.
* @param fullscreen Whether the window is currently drawing in fullscreen.
* @param systemInsets The current visible system insets for the window.
* @param stableInsets The stable insets for the window.
* @param systemBarInsets The current visible system insets for the window.
*/
public void setTargetRect(Rect newTargetBounds, boolean fullscreen, Rect systemInsets,
Rect stableInsets) {
public void setTargetRect(Rect newTargetBounds, boolean fullscreen, Rect systemBarInsets) {
synchronized (this) {
mFullscreen = fullscreen;
mTargetRect.set(newTargetBounds);
mSystemInsets.set(systemInsets);
mStableInsets.set(stableInsets);
mSystemBarInsets.set(systemBarInsets);
// Notify of a bounds change.
pingRenderLocked(false /* drawImmediate */);
}
@@ -247,14 +241,12 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
mNewTargetRect.set(mTargetRect);
if (!mNewTargetRect.equals(mOldTargetRect)
|| mOldFullscreen != mFullscreen
|| !mStableInsets.equals(mOldStableInsets)
|| !mSystemInsets.equals(mOldSystemInsets)
|| !mSystemBarInsets.equals(mOldSystemBarInsets)
|| mReportNextDraw) {
mOldFullscreen = mFullscreen;
mOldTargetRect.set(mNewTargetRect);
mOldSystemInsets.set(mSystemInsets);
mOldStableInsets.set(mStableInsets);
redrawLocked(mNewTargetRect, mFullscreen, mSystemInsets, mStableInsets);
mOldSystemBarInsets.set(mSystemBarInsets);
redrawLocked(mNewTargetRect, mFullscreen);
}
}
@@ -304,11 +296,8 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
*
* @param newBounds The window bounds which needs to be drawn.
* @param fullscreen Whether the window is currently drawing in fullscreen.
* @param systemInsets The current visible system insets for the window.
* @param stableInsets The stable insets for the window.
*/
private void redrawLocked(Rect newBounds, boolean fullscreen, Rect systemInsets,
Rect stableInsets) {
private void redrawLocked(Rect newBounds, boolean fullscreen) {
// While a configuration change is taking place the view hierarchy might become
// inaccessible. For that case we remember the previous metrics to avoid flashes.
@@ -355,7 +344,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
}
mFrameAndBackdropNode.endRecording();
drawColorViews(left, top, width, height, fullscreen, systemInsets, stableInsets);
drawColorViews(left, top, width, height, fullscreen);
// We need to render the node explicitly
mRenderer.drawRenderNode(mFrameAndBackdropNode);
@@ -363,14 +352,13 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
reportDrawIfNeeded();
}
private void drawColorViews(int left, int top, int width, int height,
boolean fullscreen, Rect systemInsets, Rect stableInsets) {
private void drawColorViews(int left, int top, int width, int height, boolean fullscreen) {
if (mSystemBarBackgroundNode == null) {
return;
}
RecordingCanvas canvas = mSystemBarBackgroundNode.beginRecording(width, height);
mSystemBarBackgroundNode.setLeftTopRightBottom(left, top, left + width, top + height);
final int topInset = DecorView.getColorViewTopInset(mStableInsets.top, mSystemInsets.top);
final int topInset = mSystemBarInsets.top;
if (mStatusBarColor != null) {
mStatusBarColor.setBounds(0, 0, left + width, topInset);
mStatusBarColor.draw(canvas);
@@ -380,7 +368,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
// don't want the navigation bar background be moving around when resizing in docked mode.
// However, we need it for the transitions into/out of docked mode.
if (mNavigationBarColor != null && fullscreen) {
DecorView.getNavigationBarRect(width, height, stableInsets, systemInsets, mTmpRect, 1f);
DecorView.getNavigationBarRect(width, height, mSystemBarInsets, mTmpRect, 1f);
mNavigationBarColor.setBounds(mTmpRect);
mNavigationBarColor.draw(canvas);
}

View File

@@ -1050,22 +1050,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
return false;
}
public static int getColorViewTopInset(int stableTop, int systemTop) {
return Math.min(stableTop, systemTop);
}
public static int getColorViewBottomInset(int stableBottom, int systemBottom) {
return Math.min(stableBottom, systemBottom);
}
public static int getColorViewRightInset(int stableRight, int systemRight) {
return Math.min(stableRight, systemRight);
}
public static int getColorViewLeftInset(int stableLeft, int systemLeft) {
return Math.min(stableLeft, systemLeft);
}
public static boolean isNavBarToRightEdge(int bottomInset, int rightInset) {
return bottomInset == 0 && rightInset > 0;
}
@@ -1079,14 +1063,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
: isNavBarToLeftEdge(bottomInset, leftInset) ? leftInset : bottomInset;
}
public static void getNavigationBarRect(int canvasWidth, int canvasHeight, Rect stableInsets,
Rect contentInsets, Rect outRect, float scale) {
final int bottomInset =
(int) (getColorViewBottomInset(stableInsets.bottom, contentInsets.bottom) * scale);
final int leftInset =
(int) (getColorViewLeftInset(stableInsets.left, contentInsets.left) * scale);
final int rightInset =
(int) (getColorViewLeftInset(stableInsets.right, contentInsets.right) * scale);
public static void getNavigationBarRect(int canvasWidth, int canvasHeight, Rect systemBarInsets,
Rect outRect, float scale) {
final int bottomInset = (int) (systemBarInsets.bottom * scale);
final int leftInset = (int) (systemBarInsets.left * scale);
final int rightInset = (int) (systemBarInsets.right * scale);
final int size = getNavBarSize(bottomInset, rightInset, leftInset);
if (isNavBarToRightEdge(bottomInset, rightInset)) {
outRect.set(canvasWidth - size, 0, canvasWidth, canvasHeight);
@@ -1113,31 +1094,30 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
mLastWindowFlags = attrs.flags;
if (insets != null) {
mLastTopInset = getColorViewTopInset(insets.getStableInsetTop(),
insets.getSystemWindowInsetTop());
mLastBottomInset = getColorViewBottomInset(insets.getStableInsetBottom(),
insets.getSystemWindowInsetBottom());
mLastRightInset = getColorViewRightInset(insets.getStableInsetRight(),
insets.getSystemWindowInsetRight());
mLastLeftInset = getColorViewRightInset(insets.getStableInsetLeft(),
insets.getSystemWindowInsetLeft());
final Insets systemBarInsets = insets.getInsets(WindowInsets.Type.systemBars());
final Insets stableBarInsets = insets.getInsetsIgnoringVisibility(
WindowInsets.Type.systemBars());
mLastTopInset = systemBarInsets.top;
mLastBottomInset = systemBarInsets.bottom;
mLastRightInset = systemBarInsets.right;
mLastLeftInset = systemBarInsets.left;
// Don't animate if the presence of stable insets has changed, because that
// indicates that the window was either just added and received them for the
// first time, or the window size or position has changed.
boolean hasTopStableInset = insets.getStableInsetTop() != 0;
boolean hasTopStableInset = stableBarInsets.top != 0;
disallowAnimate |= (hasTopStableInset != mLastHasTopStableInset);
mLastHasTopStableInset = hasTopStableInset;
boolean hasBottomStableInset = insets.getStableInsetBottom() != 0;
boolean hasBottomStableInset = stableBarInsets.bottom != 0;
disallowAnimate |= (hasBottomStableInset != mLastHasBottomStableInset);
mLastHasBottomStableInset = hasBottomStableInset;
boolean hasRightStableInset = insets.getStableInsetRight() != 0;
boolean hasRightStableInset = stableBarInsets.right != 0;
disallowAnimate |= (hasRightStableInset != mLastHasRightStableInset);
mLastHasRightStableInset = hasRightStableInset;
boolean hasLeftStableInset = insets.getStableInsetLeft() != 0;
boolean hasLeftStableInset = stableBarInsets.left != 0;
disallowAnimate |= (hasLeftStableInset != mLastHasLeftStableInset);
mLastHasLeftStableInset = hasLeftStableInset;
@@ -2296,7 +2276,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
public void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets,
Rect stableInsets) {
if (mBackdropFrameRenderer != null) {
mBackdropFrameRenderer.setTargetRect(newBounds, fullscreen, systemInsets, stableInsets);
mBackdropFrameRenderer.setTargetRect(newBounds, fullscreen, systemInsets);
}
}
@@ -2314,11 +2294,12 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
final ThreadedRenderer renderer = getThreadedRenderer();
if (renderer != null) {
loadBackgroundDrawablesIfNeeded();
WindowInsets rootInsets = getRootWindowInsets();
mBackdropFrameRenderer = new BackdropFrameRenderer(this, renderer,
initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState),
getCurrentColor(mNavigationColorViewState), fullscreen, systemInsets,
stableInsets);
getCurrentColor(mNavigationColorViewState), fullscreen,
rootInsets.getInsets(WindowInsets.Type.systemBars()));
// Get rid of the shadow while we are resizing. Shadow drawing takes considerable time.
// If we want to get the shadow shown while resizing, we would need to elevate a new

View File

@@ -28,6 +28,7 @@ import android.app.ActivityManager.TaskSnapshot;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.GraphicBuffer;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.RecordingCanvas;
@@ -37,8 +38,11 @@ import android.os.Environment;
import android.os.Handler;
import android.util.ArraySet;
import android.util.Slog;
import android.view.InsetsSource;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.ThreadedRenderer;
import android.view.WindowInsets;
import android.view.WindowManager.LayoutParams;
import com.android.internal.annotations.VisibleForTesting;
@@ -475,9 +479,12 @@ class TaskSnapshotController {
final int color = ColorUtils.setAlphaComponent(
task.getTaskDescription().getBackgroundColor(), 255);
final LayoutParams attrs = mainWindow.getAttrs();
final InsetsPolicy insetsPolicy = mainWindow.getDisplayContent().getInsetsPolicy();
final InsetsState insetsState = insetsPolicy.getInsetsForDispatch(mainWindow);
final Rect systemBarInsets = getSystemBarInsets(mainWindow.getFrameLw(), insetsState);
final SystemBarBackgroundPainter decorPainter = new SystemBarBackgroundPainter(attrs.flags,
attrs.privateFlags, attrs.systemUiVisibility, task.getTaskDescription(),
mHighResTaskSnapshotScale, mainWindow.getRequestedInsetsState());
mHighResTaskSnapshotScale, insetsState);
final int taskWidth = task.getBounds().width();
final int taskHeight = task.getBounds().height();
final int width = (int) (taskWidth * mHighResTaskSnapshotScale);
@@ -488,7 +495,7 @@ class TaskSnapshotController {
node.setClipToBounds(false);
final RecordingCanvas c = node.start(width, height);
c.drawColor(color);
decorPainter.setInsets(mainWindow.getContentInsets(), mainWindow.getStableInsets());
decorPainter.setInsets(systemBarInsets);
decorPainter.drawDecors(c, null /* statusBarExcludeFrame */);
node.end(c);
final Bitmap hwBitmap = ThreadedRenderer.createHardwareBitmap(node, width, height);
@@ -593,6 +600,13 @@ class TaskSnapshotController {
return 0;
}
static Rect getSystemBarInsets(Rect frame, InsetsState state) {
return state.calculateInsets(frame, null /* ignoringVisibilityState */,
false /* isScreenRound */, false /* alwaysConsumeSystemBars */,
null /* displayCutout */, 0 /* legacySoftInputMode */, 0 /* legacySystemUiFlags */,
null /* typeSideMap */).getInsets(WindowInsets.Type.systemBars()).toRect();
}
void dump(PrintWriter pw, String prefix) {
pw.println(prefix + "mHighResTaskSnapshotScale=" + mHighResTaskSnapshotScale);
mCache.dump(pw, prefix);

View File

@@ -39,10 +39,9 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static com.android.internal.policy.DecorView.NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES;
import static com.android.internal.policy.DecorView.STATUS_BAR_COLOR_VIEW_ATTRIBUTES;
import static com.android.internal.policy.DecorView.getColorViewLeftInset;
import static com.android.internal.policy.DecorView.getColorViewTopInset;
import static com.android.internal.policy.DecorView.getNavigationBarRect;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_STARTING_WINDOW;
import static com.android.server.wm.TaskSnapshotController.getSystemBarInsets;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -131,9 +130,8 @@ class TaskSnapshotSurface implements StartingSurface {
private final IWindowSession mSession;
private final WindowManagerService mService;
private final Rect mTaskBounds;
private final Rect mStableInsets = new Rect();
private final Rect mContentInsets = new Rect();
private final Rect mFrame = new Rect();
private final Rect mSystemBarInsets = new Rect();
private TaskSnapshot mSnapshot;
private final RectF mTmpSnapshotSize = new RectF();
private final RectF mTmpDstFrame = new RectF();
@@ -174,6 +172,7 @@ class TaskSnapshotSurface implements StartingSurface {
final int windowFlags;
final int windowPrivateFlags;
final int currentOrientation;
final InsetsState insetsState;
synchronized (service.mGlobalLock) {
final WindowState mainWindow = activity.findMainWindow();
final Task task = activity.getTask();
@@ -241,6 +240,10 @@ class TaskSnapshotSurface implements StartingSurface {
taskBounds = new Rect();
task.getBounds(taskBounds);
currentOrientation = topFullscreenOpaqueWindow.getConfiguration().orientation;
final InsetsPolicy insetsPolicy = topFullscreenOpaqueWindow.getDisplayContent()
.getInsetsPolicy();
insetsState = insetsPolicy.getInsetsForDispatch(topFullscreenOpaqueWindow);
}
try {
final int res = session.addToDisplay(window, window.mSeq, layoutParams,
@@ -255,8 +258,7 @@ class TaskSnapshotSurface implements StartingSurface {
}
final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
windowFlags, windowPrivateFlags, taskBounds,
currentOrientation, topFullscreenOpaqueWindow.getRequestedInsetsState());
windowFlags, windowPrivateFlags, taskBounds, currentOrientation, insetsState);
window.setOuter(snapshotSurface);
try {
session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,
@@ -266,7 +268,9 @@ class TaskSnapshotSurface implements StartingSurface {
} catch (RemoteException e) {
// Local call.
}
snapshotSurface.setFrames(tmpFrame, tmpContentInsets, tmpStableInsets);
final Rect systemBarInsets = getSystemBarInsets(tmpFrame, insetsState);
snapshotSurface.setFrames(tmpFrame, systemBarInsets);
snapshotSurface.drawSnapshot();
return snapshotSurface;
}
@@ -315,13 +319,12 @@ class TaskSnapshotSurface implements StartingSurface {
}
@VisibleForTesting
void setFrames(Rect frame, Rect contentInsets, Rect stableInsets) {
void setFrames(Rect frame, Rect systemBarInsets) {
mFrame.set(frame);
mContentInsets.set(contentInsets);
mStableInsets.set(stableInsets);
mSystemBarInsets.set(systemBarInsets);
mSizeMismatch = (mFrame.width() != mSnapshot.getSnapshot().getWidth()
|| mFrame.height() != mSnapshot.getSnapshot().getHeight());
mSystemBarBackgroundPainter.setInsets(contentInsets, stableInsets);
mSystemBarBackgroundPainter.setInsets(systemBarInsets);
}
private void drawSnapshot() {
@@ -453,9 +456,7 @@ class TaskSnapshotSurface implements StartingSurface {
);
// However, we also need to make space for the navigation bar on the left side.
final int colorViewLeftInset = getColorViewLeftInset(mStableInsets.left,
mContentInsets.left);
frame.offset(colorViewLeftInset, 0);
frame.offset(mSystemBarInsets.left, 0);
return frame;
}
@@ -540,8 +541,6 @@ class TaskSnapshotSurface implements StartingSurface {
*/
static class SystemBarBackgroundPainter {
private final Rect mContentInsets = new Rect();
private final Rect mStableInsets = new Rect();
private final Paint mStatusBarPaint = new Paint();
private final Paint mNavigationBarPaint = new Paint();
private final int mStatusBarColor;
@@ -551,6 +550,7 @@ class TaskSnapshotSurface implements StartingSurface {
private final int mSysUiVis;
private final float mScale;
private final InsetsState mInsetsState;
private final Rect mSystemBarInsets = new Rect();
SystemBarBackgroundPainter(int windowFlags, int windowPrivateFlags, int sysUiVis,
TaskDescription taskDescription, float scale, InsetsState insetsState) {
@@ -576,9 +576,8 @@ class TaskSnapshotSurface implements StartingSurface {
mInsetsState = insetsState;
}
void setInsets(Rect contentInsets, Rect stableInsets) {
mContentInsets.set(contentInsets);
mStableInsets.set(stableInsets);
void setInsets(Rect systemBarInsets) {
mSystemBarInsets.set(systemBarInsets);
}
int getStatusBarColorViewHeight() {
@@ -589,7 +588,7 @@ class TaskSnapshotSurface implements StartingSurface {
mSysUiVis, mStatusBarColor, mWindowFlags, forceBarBackground)
: STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
mInsetsState, mStatusBarColor, mWindowFlags, forceBarBackground)) {
return (int) (getColorViewTopInset(mStableInsets.top, mContentInsets.top) * mScale);
return (int) (mSystemBarInsets.top * mScale);
} else {
return 0;
}
@@ -615,8 +614,7 @@ class TaskSnapshotSurface implements StartingSurface {
int statusBarHeight) {
if (statusBarHeight > 0 && Color.alpha(mStatusBarColor) != 0
&& (alreadyDrawnFrame == null || c.getWidth() > alreadyDrawnFrame.right)) {
final int rightInset = (int) (DecorView.getColorViewRightInset(mStableInsets.right,
mContentInsets.right) * mScale);
final int rightInset = (int) (mSystemBarInsets.right * mScale);
final int left = alreadyDrawnFrame != null ? alreadyDrawnFrame.right : 0;
c.drawRect(left, 0, c.getWidth() - rightInset, statusBarHeight, mStatusBarPaint);
}
@@ -625,8 +623,8 @@ class TaskSnapshotSurface implements StartingSurface {
@VisibleForTesting
void drawNavigationBarBackground(Canvas c) {
final Rect navigationBarRect = new Rect();
getNavigationBarRect(c.getWidth(), c.getHeight(), mStableInsets, mContentInsets,
navigationBarRect, mScale);
getNavigationBarRect(c.getWidth(), c.getHeight(), mSystemBarInsets, navigationBarRect,
mScale);
final boolean visible = isNavigationBarColorViewVisible();
if (visible && Color.alpha(mNavigationBarColor) != 0 && !navigationBarRect.isEmpty()) {
c.drawRect(navigationBarRect, mNavigationBarPaint);

View File

@@ -190,7 +190,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
public void testCalculateSnapshotFrame() {
setupSurface(100, 100);
final Rect insets = new Rect(0, 10, 0, 10);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
assertEquals(new Rect(0, 0, 100, 80),
mSurface.calculateSnapshotFrame(new Rect(0, 10, 100, 90)));
}
@@ -199,7 +199,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
public void testCalculateSnapshotFrame_navBarLeft() {
setupSurface(100, 100);
final Rect insets = new Rect(10, 10, 0, 0);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
assertEquals(new Rect(10, 0, 100, 90),
mSurface.calculateSnapshotFrame(new Rect(10, 10, 100, 100)));
}
@@ -208,7 +208,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
public void testCalculateSnapshotFrame_waterfall() {
setupSurface(100, 100, new Rect(5, 10, 5, 10), 0, 0, new Rect(0, 0, 100, 100));
final Rect insets = new Rect(0, 10, 0, 10);
mSurface.setFrames(new Rect(5, 0, 95, 100), insets, insets);
mSurface.setFrames(new Rect(5, 0, 95, 100), insets);
assertEquals(new Rect(0, 0, 90, 90),
mSurface.calculateSnapshotFrame(new Rect(5, 0, 95, 90)));
}
@@ -217,7 +217,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
public void testDrawStatusBarBackground() {
setupSurface(100, 100);
final Rect insets = new Rect(0, 10, 10, 0);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
final Canvas mockCanvas = mock(Canvas.class);
when(mockCanvas.getWidth()).thenReturn(100);
when(mockCanvas.getHeight()).thenReturn(100);
@@ -230,7 +230,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
public void testDrawStatusBarBackground_nullFrame() {
setupSurface(100, 100);
final Rect insets = new Rect(0, 10, 10, 0);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
final Canvas mockCanvas = mock(Canvas.class);
when(mockCanvas.getWidth()).thenReturn(100);
when(mockCanvas.getHeight()).thenReturn(100);
@@ -243,7 +243,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
public void testDrawStatusBarBackground_nope() {
setupSurface(100, 100);
final Rect insets = new Rect(0, 10, 10, 0);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
final Canvas mockCanvas = mock(Canvas.class);
when(mockCanvas.getWidth()).thenReturn(100);
when(mockCanvas.getHeight()).thenReturn(100);
@@ -257,7 +257,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
final Rect insets = new Rect(0, 10, 0, 10);
setupSurface(100, 100, insets, 0, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
new Rect(0, 0, 100, 100));
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
final Canvas mockCanvas = mock(Canvas.class);
when(mockCanvas.getWidth()).thenReturn(100);
when(mockCanvas.getHeight()).thenReturn(100);
@@ -270,7 +270,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
final Rect insets = new Rect(10, 10, 0, 0);
setupSurface(100, 100, insets, 0, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
new Rect(0, 0, 100, 100));
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
final Canvas mockCanvas = mock(Canvas.class);
when(mockCanvas.getWidth()).thenReturn(100);
when(mockCanvas.getHeight()).thenReturn(100);
@@ -283,7 +283,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
final Rect insets = new Rect(0, 10, 10, 0);
setupSurface(100, 100, insets, 0, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
new Rect(0, 0, 100, 100));
mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
mSurface.setFrames(new Rect(0, 0, 100, 100), insets);
final Canvas mockCanvas = mock(Canvas.class);
when(mockCanvas.getWidth()).thenReturn(100);
when(mockCanvas.getHeight()).thenReturn(100);