From e65a1c4fde39d025957a29962ebdcbac92f72223 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 28 Feb 2017 16:52:59 -0800 Subject: [PATCH 1/2] Don't limited pinned tasks to content area. During the pinned animation from fullscreen we layout the window for as if it were fullscreen. However this logic determines that we then overlap the content area and unhelpfully tries to adjust us. Test: Manual. Change-Id: I1cbeb47731062f95c631e8cbd1f0601085d1762f --- .../java/com/android/server/wm/WindowState.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 945a349a28fd0..b9466d2d43d05 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -844,20 +844,24 @@ class WindowState extends WindowContainer implements WindowManagerP // Make sure the content and visible frames are inside of the // final window frame. if (windowsAreFloating && !mFrame.isEmpty()) { + // For pinned workspace the frame isn't limited in any particular + // way since SystemUI controls the bounds. For freeform however + // we want to keep things inside the content frame. + final Rect limitFrame = task.inPinnedWorkspace() ? mFrame : mContentFrame; // Keep the frame out of the blocked system area, limit it in size to the content area // and make sure that there is always a minimum visible so that the user can drag it // into a usable area.. - final int height = Math.min(mFrame.height(), mContentFrame.height()); - final int width = Math.min(mContentFrame.width(), mFrame.width()); + final int height = Math.min(mFrame.height(), limitFrame.height()); + final int width = Math.min(limitFrame.width(), mFrame.width()); final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics(); final int minVisibleHeight = Math.min(height, WindowManagerService.dipToPixel( MINIMUM_VISIBLE_HEIGHT_IN_DP, displayMetrics)); final int minVisibleWidth = Math.min(width, WindowManagerService.dipToPixel( MINIMUM_VISIBLE_WIDTH_IN_DP, displayMetrics)); - final int top = Math.max(mContentFrame.top, - Math.min(mFrame.top, mContentFrame.bottom - minVisibleHeight)); - final int left = Math.max(mContentFrame.left + minVisibleWidth - width, - Math.min(mFrame.left, mContentFrame.right - minVisibleWidth)); + final int top = Math.max(limitFrame.top, + Math.min(mFrame.top, limitFrame.bottom - minVisibleHeight)); + final int left = Math.max(limitFrame.left + minVisibleWidth - width, + Math.min(mFrame.left, limitFrame.right - minVisibleWidth)); mFrame.set(left, top, left + width, top + height); mContentFrame.set(mFrame); mVisibleFrame.set(mContentFrame); From db2f6e6edf864d17e53d48e62c4b4d04529e4081 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 1 Mar 2017 20:17:58 -0800 Subject: [PATCH 2/2] Don't destroy preserved surfaces when cleaning up on resume. We clean up surfaces from apps which were stopping (mDestroying=true) but not stopped when we resume, as described in commit 45e6d2d. The removal of preserved surfaces was added earlier in eb66557 for a use case where an app is stopped without an animation pass. It seems the clean up of preserved surfaces on resume may be more coincidental than intentional, so let's try disabling it! This fixes flicker at the end of the PiP animation when we use preserved surfaces for switching in to fullscreen. Bug: 35396882 Test: Move PiP to fullscreen. No flickers? Change-Id: I0df55b11774c826027b0982fca7a28f4d8322d1d --- .../com/android/server/wm/WindowState.java | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index b9466d2d43d05..d3519fa2ba483 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2721,29 +2721,32 @@ class WindowState extends WindowContainer implements WindowManagerP destroyedSomething |= c.destroySurface(cleanupOnResume, appStopped); } - if (appStopped || mWindowRemovalAllowed || cleanupOnResume) { - - mWinAnimator.destroyPreservedSurfaceLocked(); - - if (mDestroying) { - if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + this - + " destroySurfaces: appStopped=" + appStopped - + " win.mWindowRemovalAllowed=" + mWindowRemovalAllowed - + " win.mRemoveOnExit=" + mRemoveOnExit); - - if (!cleanupOnResume || mRemoveOnExit) { - destroyOrSaveSurface(); - } - if (mRemoveOnExit) { - removeImmediately(); - } - if (cleanupOnResume) { - requestUpdateWallpaperIfNeeded(); - } - mDestroying = false; - destroyedSomething = true; - } + if (!(appStopped || mWindowRemovalAllowed || cleanupOnResume)) { + return destroyedSomething; } + + if (appStopped || mWindowRemovalAllowed) { + mWinAnimator.destroyPreservedSurfaceLocked(); + } + + if (mDestroying) { + if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + this + + " destroySurfaces: appStopped=" + appStopped + + " win.mWindowRemovalAllowed=" + mWindowRemovalAllowed + + " win.mRemoveOnExit=" + mRemoveOnExit); + if (!cleanupOnResume || mRemoveOnExit) { + destroyOrSaveSurface(); + } + if (mRemoveOnExit) { + removeImmediately(); + } + if (cleanupOnResume) { + requestUpdateWallpaperIfNeeded(); + } + mDestroying = false; + destroyedSomething = true; + } + return destroyedSomething; } @@ -4401,7 +4404,8 @@ class WindowState extends WindowContainer implements WindowManagerP // will keep their surface and its size may change over time. if (mHasSurface && !isChildWindow()) { mWinAnimator.preserveSurfaceLocked(); - result |= RELAYOUT_RES_FIRST_TIME; + result |= RELAYOUT_RES_SURFACE_CHANGED | + RELAYOUT_RES_FIRST_TIME; } } final boolean freeformResizing = isDragResizing()