summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2017-04-13 16:39:36 -0700
committer Winson Chung <winsonc@google.com> 2017-04-13 18:07:55 -0700
commit40a5f935acea488086ea1b6df7d5d09e74ea518f (patch)
tree9cc286df0140902e4c375f58817b94b476e30167
parent19953caad316a6afc6446bb268bdc062a3f5ab90 (diff)
Fixing animating bounds regression.
- Prior to ag/1954388, we used getAnimatingBounds() to get the final target bounds if animating or the current otherwise, but since we needed the target bounds to calculate the window scale even after the animation completes, the clearing of mBoundsAnimationTarget was removed. This inadvertently broke the check in getAnimatingBounds() from ever returning the current bounds (as it's never empty)! This CL fixes the issue, and renames the related methods to better reflect what they are doing going forward. This caused a regression when calculating and notifying SysUI of the movement bounds, which was never the current bounds, but the default bounds. Leading the IME change to trigger the PIP to move down. Bug: 37242422 Test: android.server.cts.ActivityManagerPinnedStackTests Test: Source hint rect animation still works Change-Id: I532b0928ebfeaf95e9754a0254306af6fbb35833
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java3
-rw-r--r--services/core/java/com/android/server/am/PinnedActivityStack.java5
-rw-r--r--services/core/java/com/android/server/wm/PinnedStackController.java2
-rw-r--r--services/core/java/com/android/server/wm/PinnedStackWindowController.java8
-rw-r--r--services/core/java/com/android/server/wm/Task.java3
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java46
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java4
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java2
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java4
9 files changed, 40 insertions, 37 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index e78ee0e4f115..fe0857151561 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -71,7 +71,6 @@ import static android.os.Process.THREAD_GROUP_TOP_APP;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import static android.os.Process.THREAD_PRIORITY_FOREGROUND;
import static android.os.Process.getFreeMemory;
-import static android.os.Process.getThreadPriority;
import static android.os.Process.getTotalMemory;
import static android.os.Process.isThreadInProcess;
import static android.os.Process.killProcess;
@@ -7895,7 +7894,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// if it is not already expanding to fullscreen. Otherwise, the arguments will
// be used the next time the activity enters PiP
final PinnedActivityStack stack = r.getStack();
- if (!stack.isBoundsAnimatingToFullscreen()) {
+ if (!stack.isAnimatingBoundsToFullscreen()) {
stack.setPictureInPictureAspectRatio(
r.pictureInPictureArgs.getAspectRatio());
stack.setPictureInPictureActions(r.pictureInPictureArgs.getActions());
diff --git a/services/core/java/com/android/server/am/PinnedActivityStack.java b/services/core/java/com/android/server/am/PinnedActivityStack.java
index 924e4af95401..cd9c42c7c643 100644
--- a/services/core/java/com/android/server/am/PinnedActivityStack.java
+++ b/services/core/java/com/android/server/am/PinnedActivityStack.java
@@ -22,7 +22,6 @@ import android.graphics.Rect;
import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
import com.android.server.wm.PinnedStackWindowController;
import com.android.server.wm.PinnedStackWindowListener;
-import com.android.server.wm.StackWindowController;
import java.util.ArrayList;
import java.util.List;
@@ -57,8 +56,8 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController>
getWindowContainerController().setPictureInPictureActions(actions);
}
- boolean isBoundsAnimatingToFullscreen() {
- return getWindowContainerController().isBoundsAnimatingToFullscreen();
+ boolean isAnimatingBoundsToFullscreen() {
+ return getWindowContainerController().isAnimatingBoundsToFullscreen();
}
@Override
diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java
index 255a3895b198..fb660e7f33bf 100644
--- a/services/core/java/com/android/server/wm/PinnedStackController.java
+++ b/services/core/java/com/android/server/wm/PinnedStackController.java
@@ -380,7 +380,7 @@ class PinnedStackController {
final Rect animatingBounds = mTmpAnimatingBoundsRect;
final TaskStack pinnedStack = mDisplayContent.getStackById(PINNED_STACK_ID);
if (pinnedStack != null) {
- pinnedStack.getAnimatingBounds(animatingBounds);
+ pinnedStack.getAnimationOrCurrentBounds(animatingBounds);
} else {
animatingBounds.set(normalBounds);
}
diff --git a/services/core/java/com/android/server/wm/PinnedStackWindowController.java b/services/core/java/com/android/server/wm/PinnedStackWindowController.java
index ac50ca65586f..135832e619a4 100644
--- a/services/core/java/com/android/server/wm/PinnedStackWindowController.java
+++ b/services/core/java/com/android/server/wm/PinnedStackWindowController.java
@@ -63,7 +63,7 @@ public class PinnedStackWindowController extends StackWindowController {
final Rect originalBounds = new Rect();
mContainer.getBounds(originalBounds);
- mContainer.setAnimatingBounds(sourceBounds, toBounds);
+ mContainer.setAnimationFinalBounds(sourceBounds, toBounds);
UiThread.getHandler().post(() -> {
if (mContainer == null) {
return;
@@ -87,7 +87,7 @@ public class PinnedStackWindowController extends StackWindowController {
final Rect toBounds = mService.getPictureInPictureBounds(displayId, aspectRatio,
true /* useExistingStackBounds */);
final Rect targetBounds = new Rect();
- mContainer.getAnimatingBounds(targetBounds);
+ mContainer.getAnimationOrCurrentBounds(targetBounds);
final PinnedStackController pinnedStackController =
mContainer.getDisplayContent().getPinnedStackController();
@@ -118,8 +118,8 @@ public class PinnedStackWindowController extends StackWindowController {
/**
* @return whether the bounds are currently animating to fullscreen.
*/
- public boolean isBoundsAnimatingToFullscreen() {
- return mContainer.isBoundsAnimatingToFullscreen();
+ public boolean isAnimatingBoundsToFullscreen() {
+ return mContainer.isAnimatingBoundsToFullscreen();
}
public boolean pinnedStackResizeAllowed() {
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index b816d8199aa6..5c46ca9aa443 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -595,8 +595,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
* we will have a jump at the end.
*/
boolean isFloating() {
- return StackId.tasksAreFloating(mStack.mStackId)
- && !mStack.isBoundsAnimatingToFullscreen();
+ return StackId.tasksAreFloating(mStack.mStackId) && !mStack.isAnimatingBoundsToFullscreen();
}
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 7d38fd2bf1a7..d7c41d335b72 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -126,6 +126,9 @@ public class TaskStack extends WindowContainer<Task> 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;
+ // Set when an animation has been requested but has not yet started from the UI thread. This is
+ // cleared when the animation actually starts.
+ private boolean mBoundsAnimatingRequested = false;
private boolean mBoundsAnimatingToFullscreen = false;
private boolean mCancelCurrentBoundsAnimation = false;
private Rect mBoundsAnimationTarget = new Rect();
@@ -316,10 +319,11 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
}
/**
- * Sets the bounds animation target bounds. This can't currently be done in onAnimationStart()
- * since that is started on the UiThread.
+ * Sets the bounds animation target bounds ahead of an animation. This can't currently be done
+ * in onAnimationStart() since that is started on the UiThread.
*/
- void setAnimatingBounds(Rect sourceBounds, Rect destBounds) {
+ void setAnimationFinalBounds(Rect sourceBounds, Rect destBounds) {
+ mBoundsAnimatingRequested = true;
if (sourceBounds != null) {
mBoundsAnimationSourceBounds.set(sourceBounds);
} else {
@@ -333,23 +337,26 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
}
/**
- * @return the source bounds for the bounds animation.
+ * @return the final bounds for the bounds animation.
*/
- void getAnimatingSourceBounds(Rect outBounds) {
- if (!mBoundsAnimationSourceBounds.isEmpty()) {
- outBounds.set(mBoundsAnimationSourceBounds);
- return;
- }
- outBounds.setEmpty();
+ void getFinalAnimationBounds(Rect outBounds) {
+ outBounds.set(mBoundsAnimationTarget);
+ }
+
+ /**
+ * @return the final source bounds for the bounds animation.
+ */
+ void getFinalAnimationSourceBounds(Rect outBounds) {
+ outBounds.set(mBoundsAnimationSourceBounds);
}
/**
- * @return the bounds that the task stack is currently being animated towards, or the current
- * stack bounds if there is no animation in progress.
+ * @return the final animation bounds if the task stack is currently being animated, or the
+ * current stack bounds otherwise.
*/
- void getAnimatingBounds(Rect outBounds) {
- if (!mBoundsAnimationTarget.isEmpty()) {
- outBounds.set(mBoundsAnimationTarget);
+ void getAnimationOrCurrentBounds(Rect outBounds) {
+ if ((mBoundsAnimatingRequested || mBoundsAnimating) && !mBoundsAnimationTarget.isEmpty()) {
+ getFinalAnimationBounds(outBounds);
return;
}
getBounds(outBounds);
@@ -396,7 +403,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
}
if (mStackId == PINNED_STACK_ID) {
- getAnimatingBounds(mTmpRect2);
+ getAnimationOrCurrentBounds(mTmpRect2);
boolean updated = mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged(
mTmpRect2, mTmpRect3);
if (updated) {
@@ -694,7 +701,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
dockedOnTopOrLeft);
} else if (mStackId == PINNED_STACK_ID) {
// Update the bounds based on any changes to the display info
- getAnimatingBounds(mTmpRect2);
+ getAnimationOrCurrentBounds(mTmpRect2);
boolean updated = mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged(
mTmpRect2, mTmpRect3);
if (updated) {
@@ -1467,6 +1474,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
@Override // AnimatesBounds
public void onAnimationStart(boolean toFullscreen) {
synchronized (mService.mWindowMap) {
+ mBoundsAnimatingRequested = false;
mBoundsAnimating = true;
mBoundsAnimatingToFullscreen = toFullscreen;
mCancelCurrentBoundsAnimation = false;
@@ -1523,11 +1531,11 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
return mBoundsAnimating;
}
- public boolean getBoundsAnimating() {
+ public boolean isAnimatingBounds() {
return mBoundsAnimating;
}
- public boolean isBoundsAnimatingToFullscreen() {
+ public boolean isAnimatingBoundsToFullscreen() {
return mBoundsAnimating && mBoundsAnimatingToFullscreen;
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index b6a7f9c52c1b..0049585f5c52 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -31,7 +31,6 @@ import static android.os.Process.SHELL_UID;
import static android.os.Process.SYSTEM_UID;
import static android.os.Process.THREAD_PRIORITY_DISPLAY;
import static android.os.Process.myPid;
-import static android.os.Process.myTid;
import static android.os.UserHandle.USER_NULL;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.DOCKED_INVALID;
@@ -148,7 +147,6 @@ import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
import android.os.PowerManagerInternal;
import android.os.PowerSaveState;
-import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
@@ -2782,7 +2780,7 @@ public class WindowManagerService extends IWindowManager.Stub
// If the stack exists, then use its final bounds to calculate the new aspect ratio
// bounds.
stackBounds = new Rect();
- stack.getAnimatingBounds(stackBounds);
+ stack.getAnimationOrCurrentBounds(stackBounds);
} else {
// Otherwise, just calculate the aspect ratio bounds from the default bounds
stackBounds = pinnedStackController.getDefaultBounds();
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 979af7e35614..0b96f3fbc1fc 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1090,7 +1090,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
// notify the client of frame changes in this case. Not only is it a lot of churn, but
// the frame may not correspond to the surface size or the onscreen area at various
// phases in the animation, and the client will become sad and confused.
- if (task != null && task.mStack.getBoundsAnimating()) {
+ if (task != null && task.mStack.isAnimatingBounds()) {
return;
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index ae17d086611d..fa353367c6e4 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1360,11 +1360,11 @@ class WindowStateAnimator {
int posX = mTmpSize.left;
int posY = mTmpSize.top;
task.mStack.getDimBounds(mTmpStackBounds);
- task.mStack.getAnimatingSourceBounds(mTmpSourceBounds);
+ task.mStack.getFinalAnimationSourceBounds(mTmpSourceBounds);
if (!mTmpSourceBounds.isEmpty()) {
// Get the final target stack bounds, if we are not animating, this is just the
// current stack bounds
- task.mStack.getAnimatingBounds(mTmpAnimatingBounds);
+ task.mStack.getFinalAnimationBounds(mTmpAnimatingBounds);
// Calculate the current progress and interpolate the difference between the target
// and source bounds