From 4ccfc30a80d6b63cc938ce3578b19773ca00a2ea Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 20 Apr 2016 20:37:45 -0700 Subject: [PATCH] Animation fixes when task is not resumed - Make sure to add the activity to mWaitingVisibleActivities to not destroy the activity before the app transition has started. - Defer layouts in startActivityUnchecked so when clearing the current activities in the current stack, we don't execute the app transition yet. We need to wait until the new activities are added as well. Bug: 28026847 Change-Id: I252cf139e06197ea34329d1466f1f6162f3e7a30 --- .../core/java/com/android/server/am/ActivityStack.java | 4 +++- .../core/java/com/android/server/am/ActivityStarter.java | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index b043311b2d5ef..61f2af089e087 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -3431,8 +3431,10 @@ final class ActivityStack { mWindowManager.prepareAppTransition(transit, false); mWindowManager.setAppVisibility(r.appToken, false); mWindowManager.executeAppTransition(); + mStackSupervisor.mWaitingVisibleActivities.add(r); } - return finishCurrentActivityLocked(r, FINISH_AFTER_PAUSE, oomAdj) == null; + return finishCurrentActivityLocked(r, + r.visible ? FINISH_AFTER_VISIBLE : FINISH_AFTER_PAUSE, oomAdj) == null; } else { if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Finish waiting for pause of: " + r); } diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 4d24a8b7dc97f..6622b34c11066 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -527,8 +527,13 @@ class ActivityStarter { doPendingActivityLaunchesLocked(false); - err = startActivityUnchecked( - r, sourceRecord, voiceSession, voiceInteractor, startFlags, true, options, inTask); + try { + mService.mWindowManager.deferSurfaceLayout(); + err = startActivityUnchecked(r, sourceRecord, voiceSession, voiceInteractor, startFlags, + true, options, inTask); + } finally { + mService.mWindowManager.continueSurfaceLayout(); + } postStartActivityUncheckedProcessing(r, err, stack.mStackId); return err; }