Loading core/java/com/android/internal/policy/BackdropFrameRenderer.java +17 −29 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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(); Loading Loading @@ -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 */); } Loading Loading @@ -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); } } Loading Loading @@ -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. Loading Loading @@ -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); Loading @@ -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); Loading @@ -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); } Loading core/java/com/android/internal/policy/DecorView.java +20 −39 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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); Loading @@ -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; Loading Loading @@ -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); } } Loading @@ -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 Loading services/core/java/com/android/server/wm/TaskSnapshotController.java +16 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading Loading @@ -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); Loading services/core/java/com/android/server/wm/TaskSnapshotSurface.java +22 −24 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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(); Loading Loading @@ -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, Loading @@ -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, Loading @@ -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; } Loading Loading @@ -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() { Loading Loading @@ -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; } Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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() { Loading @@ -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; } Loading @@ -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); } Loading @@ -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); Loading services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -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))); } Loading @@ -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))); } Loading @@ -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))); } Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading Loading
core/java/com/android/internal/policy/BackdropFrameRenderer.java +17 −29 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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(); Loading Loading @@ -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 */); } Loading Loading @@ -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); } } Loading Loading @@ -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. Loading Loading @@ -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); Loading @@ -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); Loading @@ -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); } Loading
core/java/com/android/internal/policy/DecorView.java +20 −39 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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); Loading @@ -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; Loading Loading @@ -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); } } Loading @@ -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 Loading
services/core/java/com/android/server/wm/TaskSnapshotController.java +16 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading Loading @@ -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); Loading
services/core/java/com/android/server/wm/TaskSnapshotSurface.java +22 −24 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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(); Loading Loading @@ -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, Loading @@ -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, Loading @@ -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; } Loading Loading @@ -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() { Loading Loading @@ -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; } Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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() { Loading @@ -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; } Loading @@ -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); } Loading @@ -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); Loading
services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -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))); } Loading @@ -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))); } Loading @@ -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))); } Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading