From 82c1786e2c19201d02e014afc6458296b4f29e79 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 21 Feb 2018 17:50:18 +0100 Subject: [PATCH] Add ability to show wallpaper during animation In the new task switch animations, we'd like to show the wallpaper behind. For that, we add the ability to show the wallpaper for any animation via Animation.showWallpaper as an XML attribute. If the window of an app is animating, and the animation requests the wallpaper, it can also be a wallpaper. One remaning issue here is that we don't wait for the wallpaper to be drawn when waiting for the transition. However, usually this isn't an issue because the wallpaper is drawn in any case. To fix this we'd need to load the animation already and then make it a target before the animation starts, which is a bit involved /quirky. Test: Open/close task, observe wallpaper behind Test: go/wm-smoke Bug: 72396815 Change-Id: I676273a4e6627f8b5e0a1366fcd80a7c92018123 --- .../android/view/animation/Animation.java | 29 ++++++++++++++++++- core/res/res/anim/task_close_enter.xml | 3 +- core/res/res/anim/task_close_exit.xml | 3 +- core/res/res/anim/task_open_enter.xml | 3 +- .../task_open_enter_cross_profile_apps.xml | 3 +- core/res/res/anim/task_open_exit.xml | 3 +- core/res/res/values/attrs.xml | 3 ++ .../android/server/wm/AnimationAdapter.java | 6 ++++ .../com/android/server/wm/AppWindowToken.java | 3 ++ .../server/wm/LocalAnimationAdapter.java | 12 ++++++++ .../server/wm/RecentsAnimationController.java | 5 ++++ .../server/wm/RemoteAnimationController.java | 5 ++++ .../server/wm/RootWindowContainer.java | 7 +++-- .../server/wm/WallpaperController.java | 5 +++- .../server/wm/WindowAnimationSpec.java | 5 ++++ 15 files changed, 86 insertions(+), 9 deletions(-) diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java index 474db128fcc3f..64686dd977a2a 100644 --- a/core/java/android/view/animation/Animation.java +++ b/core/java/android/view/animation/Animation.java @@ -206,6 +206,8 @@ public abstract class Animation implements Cloneable { */ private boolean mDetachWallpaper = false; + private boolean mShowWallpaper; + private boolean mMore = true; private boolean mOneMoreTime = true; @@ -253,7 +255,10 @@ public abstract class Animation implements Cloneable { setBackgroundColor(a.getInt(com.android.internal.R.styleable.Animation_background, 0)); - setDetachWallpaper(a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false)); + setDetachWallpaper( + a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false)); + setShowWallpaper( + a.getBoolean(com.android.internal.R.styleable.Animation_showWallpaper, false)); final int resID = a.getResourceId(com.android.internal.R.styleable.Animation_interpolator, 0); @@ -660,6 +665,18 @@ public abstract class Animation implements Cloneable { mDetachWallpaper = detachWallpaper; } + /** + * If this animation is run as a window animation, this will make the wallpaper visible behind + * the animation. + * + * @param showWallpaper Whether the wallpaper should be shown during the animation. + * @attr ref android.R.styleable#Animation_detachWallpaper + * @hide + */ + public void setShowWallpaper(boolean showWallpaper) { + mShowWallpaper = showWallpaper; + } + /** * Gets the acceleration curve type for this animation. * @@ -774,6 +791,16 @@ public abstract class Animation implements Cloneable { return mDetachWallpaper; } + /** + * @return If run as a window animation, returns whether the wallpaper will be shown behind + * during the animation. + * @attr ref android.R.styleable#Animation_showWallpaper + * @hide + */ + public boolean getShowWallpaper() { + return mShowWallpaper; + } + /** *

Indicates whether or not this animation will affect the transformation * matrix. For instance, a fade animation will not affect the matrix whereas diff --git a/core/res/res/anim/task_close_enter.xml b/core/res/res/anim/task_close_enter.xml index 81d1300038e39..c298b8090a01c 100644 --- a/core/res/res/anim/task_close_enter.xml +++ b/core/res/res/anim/task_close_enter.xml @@ -17,7 +17,8 @@ --> + android:zAdjustment="top" + android:showWallpaper="true"> + android:shareInterpolator="false" + android:showWallpaper="true"> + android:zAdjustment="top" + android:showWallpaper="true"> + android:zAdjustment="top" + android:showWallpaper="true"> + android:shareInterpolator="false" + android:showWallpaper="true"> + + diff --git a/services/core/java/com/android/server/wm/AnimationAdapter.java b/services/core/java/com/android/server/wm/AnimationAdapter.java index ed4543ef82feb..64f77a2cc4ce7 100644 --- a/services/core/java/com/android/server/wm/AnimationAdapter.java +++ b/services/core/java/com/android/server/wm/AnimationAdapter.java @@ -38,6 +38,12 @@ interface AnimationAdapter { */ boolean getDetachWallpaper(); + /** + * @return Whether we should show the wallpaper during the animation. + * @see Animation#getShowWallpaper() + */ + boolean getShowWallpaper(); + /** * @return The background color behind the animation. */ diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 8155656cd5f4f..20bcd2d8194b1 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -1668,6 +1668,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } if (adapter != null) { startAnimation(getPendingTransaction(), adapter, !isVisible()); + if (adapter.getShowWallpaper()) { + mDisplayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; + } } } else { cancelAnimation(); diff --git a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java index 2173fa3a283d1..1b41cb84516d6 100644 --- a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java +++ b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java @@ -42,6 +42,11 @@ class LocalAnimationAdapter implements AnimationAdapter { return mSpec.getDetachWallpaper(); } + @Override + public boolean getShowWallpaper() { + return mSpec.getShowWallpaper(); + } + @Override public int getBackgroundColor() { return mSpec.getBackgroundColor(); @@ -81,6 +86,13 @@ class LocalAnimationAdapter implements AnimationAdapter { return false; } + /** + * @see AnimationAdapter#getShowWallpaper + */ + default boolean getShowWallpaper() { + return false; + } + /** * @see AnimationAdapter#getBackgroundColor */ diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 78dd580259a03..31b5c698dc5e9 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -367,6 +367,11 @@ public class RecentsAnimationController { return false; } + @Override + public boolean getShowWallpaper() { + return false; + } + @Override public int getBackgroundColor() { return 0; diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java index 35fc99fe46122..ed6e606b0c755 100644 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java @@ -220,6 +220,11 @@ class RemoteAnimationController { return false; } + @Override + public boolean getShowWallpaper() { + return false; + } + @Override public int getBackgroundColor() { return 0; diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index a4f20b012576f..6356a3512e65c 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -606,8 +606,11 @@ class RootWindowContainer extends WindowContainer { // If we are ready to perform an app transition, check through all of the app tokens to be // shown and see if they are ready to go. if (mService.mAppTransition.isReady()) { - defaultDisplay.pendingLayoutChanges |= - surfacePlacer.handleAppTransitionReadyLocked(); + // This needs to be split into two expressions, as handleAppTransitionReadyLocked may + // modify dc.pendingLayoutChanges, which would get lost when writing + // defaultDisplay.pendingLayoutChanges |= handleAppTransitionReadyLocked() + final int layoutChanges = surfacePlacer.handleAppTransitionReadyLocked(); + defaultDisplay.pendingLayoutChanges |= layoutChanges; if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("after handleAppTransitionReadyLocked", defaultDisplay.pendingLayoutChanges); diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index f2ad6fb7a8880..a7d51f175ab55 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -151,7 +151,10 @@ class WallpaperController { final RecentsAnimationController recentsAnimationController = mService.getRecentsAnimationController(); - final boolean hasWallpaper = (w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0; + final boolean animationWallpaper = w.mAppToken != null && w.mAppToken.getAnimation() != null + && w.mAppToken.getAnimation().getShowWallpaper(); + final boolean hasWallpaper = (w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0 + || animationWallpaper; final boolean isRecentsTransitionTarget = (recentsAnimationController != null && recentsAnimationController.isWallpaperVisible(w)); if (isRecentsTransitionTarget) { diff --git a/services/core/java/com/android/server/wm/WindowAnimationSpec.java b/services/core/java/com/android/server/wm/WindowAnimationSpec.java index 0863ee9eebb37..43fa3d56914e1 100644 --- a/services/core/java/com/android/server/wm/WindowAnimationSpec.java +++ b/services/core/java/com/android/server/wm/WindowAnimationSpec.java @@ -68,6 +68,11 @@ public class WindowAnimationSpec implements AnimationSpec { return mAnimation.getDetachWallpaper(); } + @Override + public boolean getShowWallpaper() { + return mAnimation.getShowWallpaper(); + } + @Override public int getBackgroundColor() { return mAnimation.getBackgroundColor(); -- GitLab