summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2018-01-26 10:04:20 -0800
committer Winson Chung <winsonc@google.com> 2018-01-29 09:52:05 -0800
commit1e6d4a9e001f910de9396f4056eb74fdf9b8257c (patch)
tree893ee8dc80f58b66b037b4da84d419a9f8e0247a
parent1917ca9471b3a68f394e5aff60ae40945f114449 (diff)
Defer surface layouts during recents animation setup/cleanup
Bug: 72550644 Test: Swipe up with suitable launcher build check systrace Change-Id: Idf5ff8bd60250176a60b84b7f29604ac9882b493
-rw-r--r--services/core/java/com/android/server/am/RecentsAnimation.java149
1 files changed, 80 insertions, 69 deletions
diff --git a/services/core/java/com/android/server/am/RecentsAnimation.java b/services/core/java/com/android/server/am/RecentsAnimation.java
index f0b27a74a66b..c188ccb4d273 100644
--- a/services/core/java/com/android/server/am/RecentsAnimation.java
+++ b/services/core/java/com/android/server/am/RecentsAnimation.java
@@ -70,55 +70,61 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
void startRecentsActivity(Intent intent, IRecentsAnimationRunner recentsAnimationRunner,
ComponentName recentsComponent, int recentsUid) {
+ mWindowManager.deferSurfaceLayout();
+ try {
+ // Cancel the previous recents animation if necessary
+ mWindowManager.cancelRecentsAnimation();
- // Cancel the previous recents animation if necessary
- mWindowManager.cancelRecentsAnimation();
-
- final boolean hasExistingHomeActivity = mStackSupervisor.getHomeActivity() != null;
- if (!hasExistingHomeActivity) {
- // No home activity
- final ActivityOptions opts = ActivityOptions.makeBasic();
- opts.setLaunchActivityType(ACTIVITY_TYPE_HOME);
- opts.setAvoidMoveToFront();
- intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_NO_ANIMATION);
-
- mActivityStartController.obtainStarter(intent, "startRecentsActivity_noHomeActivity")
- .setCallingUid(recentsUid)
- .setCallingPackage(recentsComponent.getPackageName())
- .setActivityOptions(SafeActivityOptions.fromBundle(opts.toBundle()))
- .setMayWait(mUserController.getCurrentUserId())
- .execute();
- mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
-
- // TODO: Maybe wait for app to draw in this particular case?
- }
+ final boolean hasExistingHomeActivity = mStackSupervisor.getHomeActivity() != null;
+ if (!hasExistingHomeActivity) {
+ // No home activity
+ final ActivityOptions opts = ActivityOptions.makeBasic();
+ opts.setLaunchActivityType(ACTIVITY_TYPE_HOME);
+ opts.setAvoidMoveToFront();
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_NO_ANIMATION);
+
+ mActivityStartController
+ .obtainStarter(intent, "startRecentsActivity_noHomeActivity")
+ .setCallingUid(recentsUid)
+ .setCallingPackage(recentsComponent.getPackageName())
+ .setActivityOptions(SafeActivityOptions.fromBundle(opts.toBundle()))
+ .setMayWait(mUserController.getCurrentUserId())
+ .execute();
+ mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
- final ActivityRecord homeActivity = mStackSupervisor.getHomeActivity();
- final ActivityDisplay display = homeActivity.getDisplay();
+ // TODO: Maybe wait for app to draw in this particular case?
+ }
- // Save the initial position of the home activity stack to be restored to after the
- // animation completes
- mRestoreHomeBehindStack = hasExistingHomeActivity
- ? display.getStackAboveHome()
- : null;
+ final ActivityRecord homeActivity = mStackSupervisor.getHomeActivity();
+ final ActivityDisplay display = homeActivity.getDisplay();
- // Move the home activity into place for the animation
- display.moveHomeStackBehindBottomMostVisibleStack();
+ // Save the initial position of the home activity stack to be restored to after the
+ // animation completes
+ mRestoreHomeBehindStack = hasExistingHomeActivity
+ ? display.getStackAboveHome()
+ : null;
- // Mark the home activity as launch-behind to bump its visibility for the
- // duration of the gesture that is driven by the recents component
- homeActivity.mLaunchTaskBehind = true;
+ // Move the home activity into place for the animation
+ display.moveHomeStackBehindBottomMostVisibleStack();
- // Fetch all the surface controls and pass them to the client to get the animation
- // started
- mWindowManager.initializeRecentsAnimation(recentsAnimationRunner, this, display.mDisplayId);
+ // Mark the home activity as launch-behind to bump its visibility for the
+ // duration of the gesture that is driven by the recents component
+ homeActivity.mLaunchTaskBehind = true;
- // If we updated the launch-behind state, update the visibility of the activities after we
- // fetch the visible tasks to be controlled by the animation
- mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS);
+ // Fetch all the surface controls and pass them to the client to get the animation
+ // started
+ mWindowManager.initializeRecentsAnimation(recentsAnimationRunner, this,
+ display.mDisplayId);
- // Post a timeout for the animation
- mHandler.postDelayed(mCancelAnimationRunnable, RECENTS_ANIMATION_TIMEOUT);
+ // If we updated the launch-behind state, update the visibility of the activities after
+ // we fetch the visible tasks to be controlled by the animation
+ mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS);
+
+ // Post a timeout for the animation
+ mHandler.postDelayed(mCancelAnimationRunnable, RECENTS_ANIMATION_TIMEOUT);
+ } finally {
+ mWindowManager.continueSurfaceLayout();
+ }
}
@Override
@@ -128,35 +134,40 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
if (mWindowManager.getRecentsAnimationController() == null) return;
mWindowManager.inSurfaceTransaction(() -> {
- mWindowManager.cleanupRecentsAnimation();
-
- // Move the home stack to the front
- final ActivityRecord homeActivity = mStackSupervisor.getHomeActivity();
- if (homeActivity == null) {
- return;
+ mWindowManager.deferSurfaceLayout();
+ try {
+ mWindowManager.cleanupRecentsAnimation();
+
+ // Move the home stack to the front
+ final ActivityRecord homeActivity = mStackSupervisor.getHomeActivity();
+ if (homeActivity == null) {
+ return;
+ }
+
+ // Restore the launched-behind state
+ homeActivity.mLaunchTaskBehind = false;
+
+ if (moveHomeToTop) {
+ // Bring the home stack to the front
+ final ActivityStack homeStack = homeActivity.getStack();
+ homeStack.mNoAnimActivities.add(homeActivity);
+ homeStack.moveToFront("RecentsAnimation.onAnimationFinished()");
+ } else {
+ // Restore the home stack to its previous position
+ final ActivityDisplay display = homeActivity.getDisplay();
+ display.moveHomeStackBehindStack(mRestoreHomeBehindStack);
+ }
+
+ mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
+ mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, false);
+ mStackSupervisor.resumeFocusedStackTopActivityLocked();
+
+ // No reason to wait for the pausing activity in this case, as the hiding of
+ // surfaces needs to be done immediately.
+ mWindowManager.executeAppTransition();
+ } finally {
+ mWindowManager.continueSurfaceLayout();
}
-
- // Restore the launched-behind state
- homeActivity.mLaunchTaskBehind = false;
-
- if (moveHomeToTop) {
- // Bring the home stack to the front
- final ActivityStack homeStack = homeActivity.getStack();
- homeStack.mNoAnimActivities.add(homeActivity);
- homeStack.moveToFront("RecentsAnimation.onAnimationFinished()");
- } else {
- // Restore the home stack to its previous position
- final ActivityDisplay display = homeActivity.getDisplay();
- display.moveHomeStackBehindStack(mRestoreHomeBehindStack);
- }
-
- mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
- mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, false);
- mStackSupervisor.resumeFocusedStackTopActivityLocked();
-
- // No reason to wait for the pausing activity in this case, as the hiding of
- // surfaces needs to be done immediately.
- mWindowManager.executeAppTransition();
});
}
}