RecentsAnimation.java revision 3e2980ed3251ec5f8ca85d7ce23f44daf717dd82
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; 213e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chungimport static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; 223e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chungimport static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; 23e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; 24e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION; 25584d652a1dba2b09975a1555c71ed339374faac7Winson Chungimport static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER; 26e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static android.view.WindowManager.TRANSIT_NONE; 27e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS; 283e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chungimport static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; 293e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chungimport static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION; 303e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chungimport static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_TOP; 31e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 32e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.app.ActivityOptions; 33e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.content.ComponentName; 34e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.content.Intent; 35ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chungimport android.os.RemoteException; 36584d652a1dba2b09975a1555c71ed339374faac7Winson Chungimport android.os.Trace; 37ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chungimport android.util.Slog; 38e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport android.view.IRecentsAnimationRunner; 396a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chungimport com.android.server.wm.RecentsAnimationController; 40e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport com.android.server.wm.RecentsAnimationController.RecentsAnimationCallbacks; 41e2d721781fc024cbd9a14929741e5b476242291fWinson Chungimport com.android.server.wm.WindowManagerService; 42e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 43e2d721781fc024cbd9a14929741e5b476242291fWinson Chung/** 44e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * Manages the recents animation, including the reordering of the stacks for the transition and 45e2d721781fc024cbd9a14929741e5b476242291fWinson Chung * cleanup. See {@link com.android.server.wm.RecentsAnimationController}. 46e2d721781fc024cbd9a14929741e5b476242291fWinson Chung */ 47e2d721781fc024cbd9a14929741e5b476242291fWinson Chungclass RecentsAnimation implements RecentsAnimationCallbacks { 48e2d721781fc024cbd9a14929741e5b476242291fWinson Chung private static final String TAG = RecentsAnimation.class.getSimpleName(); 49e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 50e2d721781fc024cbd9a14929741e5b476242291fWinson Chung private final ActivityManagerService mService; 51e2d721781fc024cbd9a14929741e5b476242291fWinson Chung private final ActivityStackSupervisor mStackSupervisor; 52e2d721781fc024cbd9a14929741e5b476242291fWinson Chung private final ActivityStartController mActivityStartController; 53e2d721781fc024cbd9a14929741e5b476242291fWinson Chung private final WindowManagerService mWindowManager; 54e2d721781fc024cbd9a14929741e5b476242291fWinson Chung private final UserController mUserController; 553e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung private final ActivityDisplay mDefaultDisplay; 56bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi private final int mCallingPid; 57e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 583e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung private int mTargetActivityType; 593e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung 603e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // The stack to restore the target stack behind when the animation is finished 613e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung private ActivityStack mRestoreTargetBehindStack; 62e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 63e2d721781fc024cbd9a14929741e5b476242291fWinson Chung RecentsAnimation(ActivityManagerService am, ActivityStackSupervisor stackSupervisor, 64e2d721781fc024cbd9a14929741e5b476242291fWinson Chung ActivityStartController activityStartController, WindowManagerService wm, 65bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi UserController userController, int callingPid) { 66e2d721781fc024cbd9a14929741e5b476242291fWinson Chung mService = am; 67e2d721781fc024cbd9a14929741e5b476242291fWinson Chung mStackSupervisor = stackSupervisor; 683e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mDefaultDisplay = stackSupervisor.getDefaultDisplay(); 69e2d721781fc024cbd9a14929741e5b476242291fWinson Chung mActivityStartController = activityStartController; 70e2d721781fc024cbd9a14929741e5b476242291fWinson Chung mWindowManager = wm; 71e2d721781fc024cbd9a14929741e5b476242291fWinson Chung mUserController = userController; 72bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi mCallingPid = callingPid; 73e2d721781fc024cbd9a14929741e5b476242291fWinson Chung } 74e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 75e2d721781fc024cbd9a14929741e5b476242291fWinson Chung void startRecentsActivity(Intent intent, IRecentsAnimationRunner recentsAnimationRunner, 76e2d721781fc024cbd9a14929741e5b476242291fWinson Chung ComponentName recentsComponent, int recentsUid) { 77584d652a1dba2b09975a1555c71ed339374faac7Winson Chung Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "RecentsAnimation#startRecentsActivity"); 78ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung 79ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung if (!mWindowManager.canStartRecentsAnimation()) { 80ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung notifyAnimationCancelBeforeStart(recentsAnimationRunner); 81ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung return; 82ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } 83ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung 843e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // If the activity is associated with the recents stack, then try and get that first 853e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mTargetActivityType = intent.getComponent() != null 863e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung && recentsComponent.equals(intent.getComponent()) 873e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung ? ACTIVITY_TYPE_RECENTS 883e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung : ACTIVITY_TYPE_HOME; 893e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung final ActivityStack targetStack = mDefaultDisplay.getStack(WINDOWING_MODE_UNDEFINED, 903e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mTargetActivityType); 913e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung ActivityRecord targetActivity = targetStack != null 923e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung ? targetStack.getTopActivity() 933e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung : null; 943e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung final boolean hasExistingActivity = targetActivity != null; 953e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (hasExistingActivity) { 963e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung final ActivityDisplay display = targetActivity.getDisplay(); 973e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mRestoreTargetBehindStack = display.getStackAbove(targetStack); 983e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (mRestoreTargetBehindStack == null) { 99ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung notifyAnimationCancelBeforeStart(recentsAnimationRunner); 100ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung return; 101ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } 102ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } 103ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung 1043e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Send launch hint if we are actually launching the target. If it's already visible 1053e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // (shouldn't happen in general) we don't need to send it. 1063e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (targetActivity == null || !targetActivity.visible) { 107ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi mStackSupervisor.sendPowerHintForLaunchStartIfNeeded(true /* forceSend */, 1083e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung targetActivity); 109ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi } 110ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi 11154cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunching(); 11254cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi 113bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi mService.setRunningRemoteAnimation(mCallingPid, true); 114bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi 1151e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.deferSurfaceLayout(); 1161e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung try { 117ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung final ActivityDisplay display; 1183e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (hasExistingActivity) { 1193e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Move the recents activity into place for the animation if it is not top most 1203e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung display = targetActivity.getDisplay(); 1213e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung display.moveStackBehindBottomMostVisibleStack(targetStack); 122ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } else { 1233e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // No recents activity 1243e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung ActivityOptions options = ActivityOptions.makeBasic(); 1253e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung options.setLaunchActivityType(mTargetActivityType); 1263e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung options.setAvoidMoveToFront(); 1271e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_NO_ANIMATION); 1281e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung 1291e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mActivityStartController 1303e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung .obtainStarter(intent, "startRecentsActivity_noTargetActivity") 1311e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung .setCallingUid(recentsUid) 1321e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung .setCallingPackage(recentsComponent.getPackageName()) 1333e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung .setActivityOptions(SafeActivityOptions.fromBundle(options.toBundle())) 1341e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung .setMayWait(mUserController.getCurrentUserId()) 1351e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung .execute(); 1361e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.prepareAppTransition(TRANSIT_NONE, false); 137e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 1383e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung targetActivity = mDefaultDisplay.getStack(WINDOWING_MODE_UNDEFINED, 1393e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mTargetActivityType).getTopActivity(); 1403e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung display = targetActivity.getDisplay(); 141ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung 1421e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // TODO: Maybe wait for app to draw in this particular case? 1431e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung } 144e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 1453e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Mark the target activity as launch-behind to bump its visibility for the 1461e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // duration of the gesture that is driven by the recents component 1473e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung targetActivity.mLaunchTaskBehind = true; 148e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 1491e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // Fetch all the surface controls and pass them to the client to get the animation 1501e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // started 1513e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mWindowManager.cancelRecentsAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); 1523e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mWindowManager.initializeRecentsAnimation(mTargetActivityType, recentsAnimationRunner, 1533e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung this, display.mDisplayId, mStackSupervisor.mRecentTasks.getRecentTaskIds()); 154e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 1551e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // If we updated the launch-behind state, update the visibility of the activities after 1561e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // we fetch the visible tasks to be controlled by the animation 1571e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS); 15854cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi 15954cff64ec6ef818e270eb39a74d6a58068553d66Jorim Jaggi mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunched(START_TASK_TO_FRONT, 1603e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung targetActivity); 1611e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung } finally { 1621e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.continueSurfaceLayout(); 163584d652a1dba2b09975a1555c71ed339374faac7Winson Chung Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); 1641e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung } 165e2d721781fc024cbd9a14929741e5b476242291fWinson Chung } 166e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 167e2d721781fc024cbd9a14929741e5b476242291fWinson Chung @Override 1686a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung public void onAnimationFinished(@RecentsAnimationController.ReorderMode int reorderMode) { 169e2d721781fc024cbd9a14929741e5b476242291fWinson Chung synchronized (mService) { 170e2d721781fc024cbd9a14929741e5b476242291fWinson Chung if (mWindowManager.getRecentsAnimationController() == null) return; 171e2d721781fc024cbd9a14929741e5b476242291fWinson Chung 1723e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Just to be sure end the launch hint in case the target activity was never launched. 1733e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // However, if we're keeping the activity and making it visible, we can leave it on. 1743e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (reorderMode != REORDER_KEEP_IN_PLACE) { 175ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi mStackSupervisor.sendPowerHintForLaunchEndIfNeeded(); 176ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi } 177ac96052733c4c07f68f81c203fa05a05940c0f31Jorim Jaggi 178bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi mService.setRunningRemoteAnimation(mCallingPid, false); 179bc2aabe84568c6b1a54c1b1467a539781488c8caJorim Jaggi 180e2d721781fc024cbd9a14929741e5b476242291fWinson Chung mWindowManager.inSurfaceTransaction(() -> { 181584d652a1dba2b09975a1555c71ed339374faac7Winson Chung Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, 182584d652a1dba2b09975a1555c71ed339374faac7Winson Chung "RecentsAnimation#onAnimationFinished_inSurfaceTransaction"); 1831e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.deferSurfaceLayout(); 1841e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung try { 1856a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung mWindowManager.cleanupRecentsAnimation(reorderMode); 1861e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung 1873e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung final ActivityStack targetStack = mDefaultDisplay.getStack( 1883e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung WINDOWING_MODE_UNDEFINED, mTargetActivityType); 1893e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung final ActivityRecord targetActivity = targetStack.getTopActivity(); 1903e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (targetActivity == null) { 1911e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung return; 1921e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung } 1931e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung 1941e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // Restore the launched-behind state 1953e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung targetActivity.mLaunchTaskBehind = false; 1963e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung 1973e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung if (reorderMode == REORDER_MOVE_TO_TOP) { 1983e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Bring the target stack to the front 1993e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung mStackSupervisor.mNoAnimActivities.add(targetActivity); 2003e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung targetStack.moveToFront("RecentsAnimation.onAnimationFinished()"); 2013e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung } else if (reorderMode == REORDER_MOVE_TO_ORIGINAL_POSITION){ 2023e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Restore the target stack to its previous position 2033e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung final ActivityDisplay display = targetActivity.getDisplay(); 2043e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung display.moveStackBehindStack(targetStack, mRestoreTargetBehindStack); 2056a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung } else { 2063e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // Keep target stack in place, nothing changes, so ignore the transition 2073e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // logic below 2086a38fca2d81e5d5bc0343c57e4db3629c3a9a619Winson Chung return; 2091e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung } 2101e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung 2111e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.prepareAppTransition(TRANSIT_NONE, false); 2121e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, false); 2131e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mStackSupervisor.resumeFocusedStackTopActivityLocked(); 2141e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung 2151e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // No reason to wait for the pausing activity in this case, as the hiding of 2161e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung // surfaces needs to be done immediately. 2171e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.executeAppTransition(); 218f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung 219f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung // After reordering the stacks, reset the minimized state. At this point, either 2203e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // the target activity is now top-most and we will stay minimized (if in 2213e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // split-screen), or we will have returned to the app, and the minimized state 2223e2980ed3251ec5f8ca85d7ce23f44daf717dd82Winson Chung // should be reset 223f557c3b56547de332b1f116f316b3a81dabd230dWinson Chung mWindowManager.checkSplitScreenMinimizedChanged(true /* animate */); 2241e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung } finally { 2251e6d4a9e001f910de9396f4056eb74fdf9b8257cWinson Chung mWindowManager.continueSurfaceLayout(); 226584d652a1dba2b09975a1555c71ed339374faac7Winson Chung Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); 227e2d721781fc024cbd9a14929741e5b476242291fWinson Chung } 228e2d721781fc024cbd9a14929741e5b476242291fWinson Chung }); 229e2d721781fc024cbd9a14929741e5b476242291fWinson Chung } 230e2d721781fc024cbd9a14929741e5b476242291fWinson Chung } 231ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung 232ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung /** 233ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung * Called only when the animation should be canceled prior to starting. 234ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung */ 235ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung private void notifyAnimationCancelBeforeStart(IRecentsAnimationRunner recentsAnimationRunner) { 236ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung try { 237ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung recentsAnimationRunner.onAnimationCanceled(); 238ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } catch (RemoteException e) { 239ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung Slog.e(TAG, "Failed to cancel recents animation before start", e); 240ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } 241ddf62975798eff2a68422d075441a4bfcf1cd6b4Winson Chung } 242e2d721781fc024cbd9a14929741e5b476242291fWinson Chung} 243