From 7e4c90e5441e344a1e2b58f46f5785db8409d609 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 15 Feb 2017 19:52:38 -0800 Subject: [PATCH] Pinned stack animation: Fix inset logic. When animating to the fullscreen size, we need to immediately report insets as if we were fullscreen so that the app will draw its content in the appropriate aspect ratio depending on whether or not it plans to paint behind the insets. Two things were preventing this, first the pinned stack is skipped for temp task inset calculation, and second we were passing null as the temp inset bounds. Bug: 35396882 Test: Move skeleton pinned app to fullscreen. Verify no aspect jump at end. Change-Id: I670fe9423fbde45d55b95801c6dcbad97b0280d1 --- .../android/server/am/ActivityStackSupervisor.java | 13 ++++++++++++- .../server/wm/BoundsAnimationController.java | 4 ++-- services/core/java/com/android/server/wm/Task.java | 9 ++++++++- .../core/java/com/android/server/wm/TaskStack.java | 8 +++++++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 95734a4ed7822..0662a5ab1b6ee 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -2394,7 +2394,18 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D mWindowManager.deferSurfaceLayout(); try { ActivityRecord r = stack.topRunningActivityLocked(); - stack.resize(pinnedBounds, tempPinnedTaskBounds, null); + Rect insetBounds = null; + if (tempPinnedTaskBounds != null) { + // We always use 0,0 as the position for the inset rect because + // if we are getting insets at all in the pinned stack it must mean + // we are headed for fullscreen. + insetBounds = tempRect; + insetBounds.top = 0; + insetBounds.left = 0; + insetBounds.right = tempPinnedTaskBounds.width(); + insetBounds.bottom = tempPinnedTaskBounds.height(); + } + stack.resize(pinnedBounds, tempPinnedTaskBounds, insetBounds); stack.ensureVisibleActivitiesConfigurationLocked(r, false); } finally { mWindowManager.continueSurfaceLayout(); diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java index cf5cecdaf797c..01bd86d4f3265 100644 --- a/services/core/java/com/android/server/wm/BoundsAnimationController.java +++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java @@ -176,7 +176,7 @@ public class BoundsAnimationController { // we trigger any size changes, so it can swap surfaces // in to appropriate modes, or do as it wishes otherwise. if (!mReplacement) { - mTarget.onAnimationStart(); + mTarget.onAnimationStart(mMoveToFullScreen); } // Immediately update the task bounds if they have to become larger, but preserve @@ -263,7 +263,7 @@ public class BoundsAnimationController { */ boolean setPinnedStackSize(Rect bounds, Rect taskBounds); - void onAnimationStart(); + void onAnimationStart(boolean toFullscreen); /** * Callback for the target to inform it that the animation has ended, so it can do some diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index ab9a378e7a5bc..da5fcf301c983 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -592,8 +592,15 @@ class Task extends WindowContainer implements DimLayer.DimLayerU return mStack != null && mStack.mStackId == PINNED_STACK_ID; } + /** + * When we are in a floating stack (Freeform, Pinned, ...) we calculate + * insets differently. However if we are animating to the fullscreen stack + * we need to begin calculating insets as if we were fullscreen, otherwise + * we will have a jump at the end. + */ boolean isFloating() { - return StackId.tasksAreFloating(mStack.mStackId); + return StackId.tasksAreFloating(mStack.mStackId) + && !mStack.isBoundsAnimatingToFullscreen(); } WindowState getTopVisibleAppMainWindow() { diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index d81db1663f6f2..bd0ec23c580fa 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -125,6 +125,7 @@ public class TaskStack extends WindowContainer implements DimLayer.DimLaye // perfectly fit the region it would have been cropped to. We may also avoid certain logic we // would otherwise apply while resizing, while resizing in the bounds animating mode. private boolean mBoundsAnimating = false; + private boolean mBoundsAnimatingToFullscreen = false; private Rect mBoundsAnimationTarget = new Rect(); // Temporary storage for the new bounds that should be used after the configuration change. @@ -1443,9 +1444,10 @@ public class TaskStack extends WindowContainer implements DimLayer.DimLaye } @Override // AnimatesBounds - public void onAnimationStart() { + public void onAnimationStart(boolean toFullscreen) { synchronized (mService.mWindowMap) { mBoundsAnimating = true; + mBoundsAnimatingToFullscreen = toFullscreen; } } @@ -1491,6 +1493,10 @@ public class TaskStack extends WindowContainer implements DimLayer.DimLaye return mBoundsAnimating; } + public boolean isBoundsAnimatingToFullscreen() { + return mBoundsAnimating && mBoundsAnimatingToFullscreen; + } + /** Returns true if a removal action is still being deferred. */ boolean checkCompleteDeferredRemoval() { if (isAnimating()) {