Override all open/close animation for organized app

We want to keep the animation consistent when using activity embedding,
so override the transition animation for activity/task open/close as
well.

Bug: 196173550
Test: manually with settings app
Change-Id: I2f22c8dc8ea22fe549f716ca683833debf7d0f02
This commit is contained in:
Chris Li
2021-11-11 13:00:56 +08:00
parent b5827095ca
commit f738fadd09
5 changed files with 47 additions and 26 deletions

View File

@@ -16,9 +16,13 @@
package androidx.window.extensions.embedding;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import android.util.Log;
import android.view.RemoteAnimationAdapter;
@@ -45,8 +49,12 @@ class TaskFragmentAnimationController {
final RemoteAnimationDefinition definition = new RemoteAnimationDefinition();
final RemoteAnimationAdapter animationAdapter =
new RemoteAnimationAdapter(mRemoteRunner, 0, 0, true /* changeNeedsSnapshot */);
definition.addRemoteAnimation(TRANSIT_OLD_ACTIVITY_OPEN, animationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_OPEN, animationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_TASK_OPEN, animationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_ACTIVITY_CLOSE, animationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_CLOSE, animationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_TASK_CLOSE, animationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_CHANGE, animationAdapter);
mOrganizer.registerRemoteAnimations(definition);
}

View File

@@ -17,9 +17,13 @@
package androidx.window.extensions.embedding;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import android.animation.Animator;
import android.animation.ValueAnimator;
@@ -155,9 +159,13 @@ class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub {
@WindowManager.TransitionOldType int transit,
@NonNull RemoteAnimationTarget[] targets) {
switch (transit) {
case TRANSIT_OLD_ACTIVITY_OPEN:
case TRANSIT_OLD_TASK_FRAGMENT_OPEN:
case TRANSIT_OLD_TASK_OPEN:
return createOpenAnimationAdapters(targets);
case TRANSIT_OLD_ACTIVITY_CLOSE:
case TRANSIT_OLD_TASK_FRAGMENT_CLOSE:
case TRANSIT_OLD_TASK_CLOSE:
return createCloseAnimationAdapters(targets);
case TRANSIT_OLD_TASK_FRAGMENT_CHANGE:
return createChangeAnimationAdapters(targets);

View File

@@ -65,7 +65,10 @@ import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_S
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_SPLASH_SCREEN;
import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_WINDOWS_DRAWN;
import static com.android.server.wm.AppTransition.isNormalTransit;
import static com.android.server.wm.NonAppWindowAnimationAdapter.shouldAttachNavBarToApp;
import static com.android.server.wm.NonAppWindowAnimationAdapter.shouldStartNonAppWindowAnimationsForKeyguardExit;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.WallpaperAnimationAdapter.shouldStartWallpaperAnimation;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -529,18 +532,9 @@ public class AppTransitionController {
// Having {@code transit} of those types doesn't mean it will contain non-app windows, but
// non-app windows will only be included with those transition types. And we don't currently
// have any use case of those for TaskFragment transition.
// @see NonAppWindowAnimationAdapter#startNonAppWindowAnimations
if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
|| transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER
|| transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
|| transit == TRANSIT_OLD_WALLPAPER_CLOSE) {
return true;
}
// Check if the wallpaper is going to participate in the transition. We don't want to have
// the client to animate the wallpaper windows.
// @see WallpaperAnimationAdapter#startWallpaperAnimations
return mDisplayContent.mWallpaperController.isWallpaperVisible();
return shouldStartNonAppWindowAnimationsForKeyguardExit(transit)
|| shouldAttachNavBarToApp(mService, mDisplayContent, transit)
|| shouldStartWallpaperAnimation(mDisplayContent);
}
/**

View File

@@ -69,25 +69,32 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
long durationHint, long statusBarTransitionDelay,
ArrayList<NonAppWindowAnimationAdapter> adaptersOut) {
final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>();
if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
|| transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER) {
if (shouldStartNonAppWindowAnimationsForKeyguardExit(transit)) {
startNonAppWindowAnimationsForKeyguardExit(
service, durationHint, statusBarTransitionDelay, targets, adaptersOut);
} else if (transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
|| transit == TRANSIT_OLD_WALLPAPER_CLOSE) {
final boolean shouldAttachNavBarToApp =
displayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition()
&& service.getRecentsAnimationController() == null
&& displayContent.getFadeRotationAnimationController() == null;
if (shouldAttachNavBarToApp) {
startNavigationBarWindowAnimation(
displayContent, durationHint, statusBarTransitionDelay, targets,
adaptersOut);
}
} else if (shouldAttachNavBarToApp(service, displayContent, transit)) {
startNavigationBarWindowAnimation(
displayContent, durationHint, statusBarTransitionDelay, targets,
adaptersOut);
}
return targets.toArray(new RemoteAnimationTarget[targets.size()]);
}
static boolean shouldStartNonAppWindowAnimationsForKeyguardExit(
@WindowManager.TransitionOldType int transit) {
return transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
|| transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
}
static boolean shouldAttachNavBarToApp(WindowManagerService service,
DisplayContent displayContent, @WindowManager.TransitionOldType int transit) {
return (transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
|| transit == TRANSIT_OLD_WALLPAPER_CLOSE)
&& displayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition()
&& service.getRecentsAnimationController() == null
&& displayContent.getFadeRotationAnimationController() == null;
}
/**
* Creates and starts remote animations for all the visible non app windows.
*

View File

@@ -69,7 +69,7 @@ class WallpaperAnimationAdapter implements AnimationAdapter {
long durationHint, long statusBarTransitionDelay,
Consumer<WallpaperAnimationAdapter> animationCanceledRunnable,
ArrayList<WallpaperAnimationAdapter> adaptersOut) {
if (!displayContent.mWallpaperController.isWallpaperVisible()) {
if (!shouldStartWallpaperAnimation(displayContent)) {
ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS,
"\tWallpaper of display=%s is not visible", displayContent);
return new RemoteAnimationTarget[0];
@@ -87,6 +87,10 @@ class WallpaperAnimationAdapter implements AnimationAdapter {
return targets.toArray(new RemoteAnimationTarget[targets.size()]);
}
static boolean shouldStartWallpaperAnimation(DisplayContent displayContent) {
return displayContent.mWallpaperController.isWallpaperVisible();
}
/**
* Create a remote animation target for this animation adapter.
*/