Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 417b70c1 authored by wilsonshih's avatar wilsonshih
Browse files

Use target activity as recents animation target directly.

When recents activity just finished and someone requests to
startRecentsAnimation, although we will launch recents activity, but
the window is not ready when RecentsAnimationController#initialize.
Without set mTargetActivityRecord, we cannot ensure when to skip to set
mLaunchTaskBehind to false in WMS#onAppTransitionFinishedLocked.
We can set the target activity to RecentsAnimationController directly
after AppWindowToken merged into ActivityRecord now.

Fix: 142351430
Test: manually run StartLauncherViaGestureTests
Test: atest WmTests:RecentsAnimationTest
Test: atest WmTests:RecentsAnimationControllerTest

Change-Id: Ib60fb82deb14406ddc60e5897d2baa3d1d2dac75
parent 9d95d01d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2084,7 +2084,6 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        final TaskRecord task = r.getTaskRecord();
        final ActivityStack stack = task.getStack();

        r.mLaunchTaskBehind = false;
        mRecentTasks.add(task);
        mService.getTaskChangeNotificationController().notifyTaskStackChanged();
        stack.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
+1 −1
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
                    "startRecentsActivity");
            mWindowManager.initializeRecentsAnimation(mTargetActivityType, recentsAnimationRunner,
                    this, mDefaultDisplay.mDisplayId,
                    mStackSupervisor.mRecentTasks.getRecentTaskIds());
                    mStackSupervisor.mRecentTasks.getRecentTaskIds(), targetActivity);

            // 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
+8 −11
Original line number Diff line number Diff line
@@ -358,7 +358,8 @@ public class RecentsAnimationController implements DeathRecipient {
     * because it may call cancelAnimation() which needs to properly clean up the controller
     * in the window manager.
     */
    public void initialize(int targetActivityType, SparseBooleanArray recentTaskIds) {
    public void initialize(int targetActivityType, SparseBooleanArray recentTaskIds,
            ActivityRecord targetActivity) {
        mTargetActivityType = targetActivityType;
        mDisplayContent.mAppTransition.registerListenerLocked(mAppTransitionListener);

@@ -400,17 +401,13 @@ public class RecentsAnimationController implements DeathRecipient {
        }

        // Adjust the wallpaper visibility for the showing target activity
        final ActivityRecord recentsComponentActivity =
                targetStack.getTopChild().getTopFullscreenActivity();
        if (recentsComponentActivity != null) {
        ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS,
                    "setHomeApp(%s)", recentsComponentActivity.getName());
            mTargetActivityRecord = recentsComponentActivity;
            if (recentsComponentActivity.windowsCanBeWallpaperTarget()) {
                "setHomeApp(%s)", targetActivity.getName());
        mTargetActivityRecord = targetActivity;
        if (targetActivity.windowsCanBeWallpaperTarget()) {
            mDisplayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
            mDisplayContent.setLayoutNeeded();
        }
        }

        // Save the minimized home height
        final TaskStack dockedStack = mDisplayContent.getSplitScreenPrimaryStackIgnoringVisibility();
+2 −2
Original line number Diff line number Diff line
@@ -2652,11 +2652,11 @@ public class WindowManagerService extends IWindowManager.Stub
    void initializeRecentsAnimation(int targetActivityType,
            IRecentsAnimationRunner recentsAnimationRunner,
            RecentsAnimationController.RecentsAnimationCallbacks callbacks, int displayId,
            SparseBooleanArray recentTaskIds) {
            SparseBooleanArray recentTaskIds, ActivityRecord targetActivity) {
        mRecentsAnimationController = new RecentsAnimationController(this, recentsAnimationRunner,
                callbacks, displayId);
        mRoot.getDisplayContent(displayId).mAppTransition.updateBooster();
        mRecentsAnimationController.initialize(targetActivityType, recentTaskIds);
        mRecentsAnimationController.initialize(targetActivityType, recentTaskIds, targetActivity);
    }

    @VisibleForTesting
+4 −4
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
        hiddenActivity.setHidden(true);
        mDisplayContent.getConfiguration().windowConfiguration.setRotation(
                mDisplayContent.getRotation());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);

        // Ensure that we are animating the target activity as well
        assertTrue(mController.isAnimatingTask(homeActivity.getTask()));
@@ -181,7 +181,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {

        mDisplayContent.getConfiguration().windowConfiguration.setRotation(
                mDisplayContent.getRotation());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeAppWindow);
        mController.startAnimation();

        // Ensure that we are animating the app and wallpaper target
@@ -210,7 +210,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {

        mDisplayContent.getConfiguration().windowConfiguration.setRotation(
                mDisplayContent.getRotation());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
        mController.startAnimation();

        // Cancel the animation and ensure the controller is still running
@@ -242,7 +242,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
        doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible();

        // Start and finish the animation
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray());
        mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
        mController.startAnimation();
        // Reset at this point since we may remove adapters that couldn't be created
        reset(mController);
Loading