From cecf424d3ad031f7353bc228e970211b443d91c5 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 21 Feb 2018 18:46:53 +0100 Subject: [PATCH] Fix task animations Sometimes apps are using trampoline activities in the current task, and then open a new task from that trampoline activity, which means that the first transition was ACTIVITY_OPEN and that's what we take at end. To fix this, we let task animations always override activity animations. Test: go/wm-smoke Test: Open a Docs document from Drive. Open a Chrome link from Maps. Fixes: 72710883 Change-Id: I72b6901fdc21514ffca4a47e433d66ea9d3cdb32 --- .../java/com/android/server/wm/AppTransition.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java index 0d36145c8661..f0ca2ef1747b 100644 --- a/services/core/java/com/android/server/wm/AppTransition.java +++ b/services/core/java/com/android/server/wm/AppTransition.java @@ -29,6 +29,7 @@ import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE; import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; import static android.view.WindowManager.TRANSIT_NONE; import static android.view.WindowManager.TRANSIT_TASK_CLOSE; +import static android.view.WindowManager.TRANSIT_TASK_IN_PLACE; import static android.view.WindowManager.TRANSIT_TASK_OPEN; import static android.view.WindowManager.TRANSIT_TASK_OPEN_BEHIND; import static android.view.WindowManager.TRANSIT_TASK_TO_BACK; @@ -2138,6 +2139,10 @@ public class AppTransition implements Dump { && isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) { // Opening a new activity always supersedes a close for the anim. setAppTransition(transit, flags); + } else if (isTaskTransit(transit) && isActivityTransit(mNextAppTransition)) { + // Task animations always supersede activity animations, because if we have both, it + // usually means that activity transition were just trampoline activities. + setAppTransition(transit, flags); } } boolean prepared = prepare(); @@ -2162,6 +2167,21 @@ public class AppTransition implements Dump { || transit == TRANSIT_KEYGUARD_UNOCCLUDE; } + private static boolean isTaskTransit(int transit) { + return transit == TRANSIT_TASK_OPEN + || transit == TRANSIT_TASK_CLOSE + || transit == TRANSIT_TASK_OPEN_BEHIND + || transit == TRANSIT_TASK_TO_BACK + || transit == TRANSIT_TASK_TO_FRONT + || transit == TRANSIT_TASK_IN_PLACE; + } + + private static boolean isActivityTransit(int transit) { + return transit == TRANSIT_ACTIVITY_OPEN + || transit == TRANSIT_ACTIVITY_CLOSE + || transit == TRANSIT_ACTIVITY_RELAUNCH; + } + /** * @return whether the transition should show the thumbnail being scaled down. */ -- 2.11.0