RecentsAnimation.java revision ac96052733c4c07f68f81c203fa05a05940c0f31
1e2d721781fc024cbd9a14929741e5b476242291fWinson Chung/*
2e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * Copyright (C) 2018 The Android Open Source Project
3e2d721781fc024cbd9a14929741e5b476242291fWinson Chung *
4e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * Licensed under the Apache License, Version 2.0 (the "License");
5e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * you may not use this file except in compliance with the License.
6e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * You may obtain a copy of the License at
7e2d721781fc024cbd9a14929741e5b476242291fWinson Chung *
8e2d721781fc024cbd9a14929741e5b476242291fWinson Chung *      http://www.apache.org/licenses/LICENSE-2.0
9e2d721781fc024cbd9a14929741e5b476242291fWinson Chung *
10e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * Unless required by applicable law or agreed to in writing, software
11e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * distributed under the License is distributed on an "AS IS" BASIS,
12e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * See the License for the specific language governing permissions and
14e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * limitations under the License.
15e2d721781fc024cbd9a14929741e5b476242291fWinson Chung */
16e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
17e2d721781fc024cbd9a14929741e5b476242291fWinson Chungpackage com.android.server.am;
18e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
1954cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggiimport static android.app.ActivityManager.START_TASK_TO_FRONT;
20e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
21e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
22e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
23584d652a1dba2b09975a1555c71ed339374faac7Winson Chungimport static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
24e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.view.WindowManager.TRANSIT_NONE;
25e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
26ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggiimport static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_HOME_IN_PLACE;
276a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chungimport static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_HOME_TO_ORIGINAL_POSITION;
286a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chungimport static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_HOME_TO_TOP;
29e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
30e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.app.ActivityOptions;
31e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.content.ComponentName;
32e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.content.Intent;
33e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.os.Handler;
34ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chungimport android.os.RemoteException;
35584d652a1dba2b09975a1555c71ed339374faac7Winson Chungimport android.os.Trace;
36ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chungimport android.util.Slog;
37e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.view.IRecentsAnimationRunner;
386a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chungimport com.android.server.wm.RecentsAnimationController;
39e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport com.android.server.wm.RecentsAnimationController.RecentsAnimationCallbacks;
40e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport com.android.server.wm.WindowManagerService;
41e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
42e2d721781fc024cbd9a14929741e5b476242291fWinson Chung/**
43e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * Manages the recents animation, including the reordering of the stacks for the transition and
44e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * cleanup. See {@link com.android.server.wm.RecentsAnimationController}.
45e2d721781fc024cbd9a14929741e5b476242291fWinson Chung */
46e2d721781fc024cbd9a14929741e5b476242291fWinson Chungclass RecentsAnimation implements RecentsAnimationCallbacks {
47e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private static final String TAG = RecentsAnimation.class.getSimpleName();
48e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
49e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private final ActivityManagerService mService;
50e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private final ActivityStackSupervisor mStackSupervisor;
51e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private final ActivityStartController mActivityStartController;
52e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private final WindowManagerService mWindowManager;
53e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private final UserController mUserController;
54bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi    private final int mCallingPid;
55e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
56e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    // The stack to restore the home stack behind when the animation is finished
57e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    private ActivityStack mRestoreHomeBehindStack;
58e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
59e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    RecentsAnimation(ActivityManagerService am, ActivityStackSupervisor stackSupervisor,
60e2d721781fc024cbd9a14929741e5b476242291fWinson Chung            ActivityStartController activityStartController, WindowManagerService wm,
61bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi            UserController userController, int callingPid) {
62e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        mService = am;
63e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        mStackSupervisor = stackSupervisor;
64e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        mActivityStartController = activityStartController;
65e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        mWindowManager = wm;
66e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        mUserController = userController;
67bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi        mCallingPid = callingPid;
68e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    }
69e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
70e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    void startRecentsActivity(Intent intent, IRecentsAnimationRunner recentsAnimationRunner,
71e2d721781fc024cbd9a14929741e5b476242291fWinson Chung            ComponentName recentsComponent, int recentsUid) {
72584d652a1dba2b09975a1555c71ed339374faac7Winson Chung        Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "RecentsAnimation#startRecentsActivity");
73ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung
74ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        if (!mWindowManager.canStartRecentsAnimation()) {
75ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            notifyAnimationCancelBeforeStart(recentsAnimationRunner);
76ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            return;
77ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        }
78ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung
79ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        // If the existing home activity is already on top, then cancel
80ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        ActivityRecord homeActivity = mStackSupervisor.getHomeActivity();
81ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        final boolean hasExistingHomeActivity = homeActivity != null;
82ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        if (hasExistingHomeActivity) {
83ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            final ActivityDisplay display = homeActivity.getDisplay();
84ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            mRestoreHomeBehindStack = display.getStackAboveHome();
85ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            if (mRestoreHomeBehindStack == null) {
86ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                notifyAnimationCancelBeforeStart(recentsAnimationRunner);
87ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                return;
88ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            }
89ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        }
90ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung
91ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi        // Send launch hint if we are actually launching home. If it's already visible (shouldn't
92ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi        // happen in general) we don't need to send it.
93ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi        if (homeActivity == null || !homeActivity.visible) {
94ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi            mStackSupervisor.sendPowerHintForLaunchStartIfNeeded(true /* forceSend */,
95ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi                    homeActivity);
96ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi        }
97ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi
9854cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi        mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunching();
9954cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi
100bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi        mService.setRunningRemoteAnimation(mCallingPid, true);
101bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi
1021e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung        mWindowManager.deferSurfaceLayout();
1031e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung        try {
104ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            final ActivityDisplay display;
105ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            if (hasExistingHomeActivity) {
106ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                // Move the home activity into place for the animation if it is not already top most
107ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                display = homeActivity.getDisplay();
108ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                display.moveHomeStackBehindBottomMostVisibleStack();
109ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            } else {
1101e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                // No home activity
1111e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                final ActivityOptions opts = ActivityOptions.makeBasic();
1121e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                opts.setLaunchActivityType(ACTIVITY_TYPE_HOME);
1131e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                opts.setAvoidMoveToFront();
1141e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_NO_ANIMATION);
1151e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung
1161e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                mActivityStartController
1171e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        .obtainStarter(intent, "startRecentsActivity_noHomeActivity")
1181e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        .setCallingUid(recentsUid)
1191e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        .setCallingPackage(recentsComponent.getPackageName())
1201e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        .setActivityOptions(SafeActivityOptions.fromBundle(opts.toBundle()))
1211e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        .setMayWait(mUserController.getCurrentUserId())
1221e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        .execute();
1231e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
124e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
125ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                homeActivity = mStackSupervisor.getHomeActivity();
126ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung                display = homeActivity.getDisplay();
127ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung
1281e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                // TODO: Maybe wait for app to draw in this particular case?
1291e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            }
130e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
1311e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            // Mark the home activity as launch-behind to bump its visibility for the
1321e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            // duration of the gesture that is driven by the recents component
1331e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            homeActivity.mLaunchTaskBehind = true;
134e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
1351e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            // Fetch all the surface controls and pass them to the client to get the animation
1361e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            // started
1376a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung            mWindowManager.cancelRecentsAnimation(REORDER_MOVE_HOME_TO_ORIGINAL_POSITION);
1381e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            mWindowManager.initializeRecentsAnimation(recentsAnimationRunner, this,
139593e9567fdc2a7b5c7e06c12c9af4b32f4216d85Vadim Tryshev                    display.mDisplayId, mStackSupervisor.mRecentTasks.getRecentTaskIds());
140e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
1411e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            // If we updated the launch-behind state, update the visibility of the activities after
1421e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            // we fetch the visible tasks to be controlled by the animation
1431e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS);
14454cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi
14554cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi            mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunched(START_TASK_TO_FRONT,
14654cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi                    homeActivity);
1471e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung        } finally {
1481e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung            mWindowManager.continueSurfaceLayout();
149584d652a1dba2b09975a1555c71ed339374faac7Winson Chung            Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
1501e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung        }
151e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    }
152e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
153e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    @Override
1546a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung    public void onAnimationFinished(@RecentsAnimationController.ReorderMode int reorderMode) {
155e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        synchronized (mService) {
156e2d721781fc024cbd9a14929741e5b476242291fWinson Chung            if (mWindowManager.getRecentsAnimationController() == null) return;
157e2d721781fc024cbd9a14929741e5b476242291fWinson Chung
158ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi            // Just to be sure end the launch hint in case home was never launched. However, if
159ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi            // we're keeping home and making it visible, we can leave it on.
160ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi            if (reorderMode != REORDER_KEEP_HOME_IN_PLACE) {
161ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi                mStackSupervisor.sendPowerHintForLaunchEndIfNeeded();
162ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi            }
163ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi
164bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi            mService.setRunningRemoteAnimation(mCallingPid, false);
165bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi
166e2d721781fc024cbd9a14929741e5b476242291fWinson Chung            mWindowManager.inSurfaceTransaction(() -> {
167584d652a1dba2b09975a1555c71ed339374faac7Winson Chung                Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER,
168584d652a1dba2b09975a1555c71ed339374faac7Winson Chung                        "RecentsAnimation#onAnimationFinished_inSurfaceTransaction");
1691e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                mWindowManager.deferSurfaceLayout();
1701e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                try {
1716a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                    mWindowManager.cleanupRecentsAnimation(reorderMode);
1721e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung
1731e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    final ActivityRecord homeActivity = mStackSupervisor.getHomeActivity();
1741e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    if (homeActivity == null) {
1751e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        return;
1761e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    }
1771e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung
1781e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    // Restore the launched-behind state
1791e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    homeActivity.mLaunchTaskBehind = false;
1801e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung
1816a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                    if (reorderMode == REORDER_MOVE_HOME_TO_TOP) {
1821e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        // Bring the home stack to the front
1831e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        final ActivityStack homeStack = homeActivity.getStack();
184fa9ed96f1e9970e8867daa0b76175006c082b890Jorim Jaggi                        mStackSupervisor.mNoAnimActivities.add(homeActivity);
1851e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        homeStack.moveToFront("RecentsAnimation.onAnimationFinished()");
1866a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                    } else if (reorderMode == REORDER_MOVE_HOME_TO_ORIGINAL_POSITION){
1871e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        // Restore the home stack to its previous position
1881e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        final ActivityDisplay display = homeActivity.getDisplay();
1891e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                        display.moveHomeStackBehindStack(mRestoreHomeBehindStack);
1906a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                    } else {
1916a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                        // Keep home stack in place, nothing changes, so ignore the transition logic
1926a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                        // below
1936a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung                        return;
1941e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    }
1951e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung
1961e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
1971e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, false);
1981e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    mStackSupervisor.resumeFocusedStackTopActivityLocked();
1991e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung
2001e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    // No reason to wait for the pausing activity in this case, as the hiding of
2011e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    // surfaces needs to be done immediately.
2021e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    mWindowManager.executeAppTransition();
203f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung
204f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung                    // After reordering the stacks, reset the minimized state. At this point, either
205f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung                    // home is now top-most and we will stay minimized (if in split-screen), or we
206f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung                    // will have returned to the app, and the minimized state should be reset
207f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung                    mWindowManager.checkSplitScreenMinimizedChanged(true /* animate */);
2081e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                } finally {
2091e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung                    mWindowManager.continueSurfaceLayout();
210584d652a1dba2b09975a1555c71ed339374faac7Winson Chung                    Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
211e2d721781fc024cbd9a14929741e5b476242291fWinson Chung                }
212e2d721781fc024cbd9a14929741e5b476242291fWinson Chung            });
213e2d721781fc024cbd9a14929741e5b476242291fWinson Chung        }
214e2d721781fc024cbd9a14929741e5b476242291fWinson Chung    }
215ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung
216ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung    /**
217ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung     * Called only when the animation should be canceled prior to starting.
218ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung     */
219ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung    private void notifyAnimationCancelBeforeStart(IRecentsAnimationRunner recentsAnimationRunner) {
220ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        try {
221ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            recentsAnimationRunner.onAnimationCanceled();
222ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        } catch (RemoteException e) {
223ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung            Slog.e(TAG, "Failed to cancel recents animation before start", e);
224ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung        }
225ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung    }
226e2d721781fc024cbd9a14929741e5b476242291fWinson Chung}
227