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

Commit a441b924 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Removed cancelRecentsAnimationSynchronously() call path (48/n)

No longer needed since we are now under a unified lock.

Bug: 80414790
Test: Existing test pass
Change-Id: I5aad974053d85330653b99ebc410f8cbda076348
parent 92b9365f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2797,7 +2797,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        try {
            synchronized (mGlobalLock) {
                // Cancel the recents animation synchronously (do not hold the WM lock)
                mWindowManager.cancelRecentsAnimationSynchronously(restoreHomeStackPosition
                mWindowManager.cancelRecentsAnimation(restoreHomeStackPosition
                        ? REORDER_MOVE_TO_ORIGINAL_POSITION
                        : REORDER_KEEP_IN_PLACE, "cancelRecentsAnimation/uid=" + callingUid);
            }
+4 −9
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
            // Fetch all the surface controls and pass them to the client to get the animation
            // started. Cancel any existing recents animation running synchronously (do not hold the
            // WM lock)
            mWindowManager.cancelRecentsAnimationSynchronously(REORDER_MOVE_TO_ORIGINAL_POSITION,
            mWindowManager.cancelRecentsAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION,
                    "startRecentsActivity");
            mWindowManager.initializeRecentsAnimation(mTargetActivityType, recentsAnimationRunner,
                    this, mDefaultDisplay.mDisplayId,
@@ -396,12 +396,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks,

    @Override
    public void onAnimationFinished(@RecentsAnimationController.ReorderMode int reorderMode,
            boolean runSychronously, boolean sendUserLeaveHint) {
        if (runSychronously) {
            boolean sendUserLeaveHint) {
        finishAnimation(reorderMode, sendUserLeaveHint);
        } else {
            mService.mH.post(() -> finishAnimation(reorderMode, sendUserLeaveHint));
        }
    }

    @Override
@@ -435,8 +431,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
        } else {
            // Just cancel directly to unleash from launcher when the next launching task is the
            // current top task.
            mWindowManager.cancelRecentsAnimationSynchronously(REORDER_KEEP_IN_PLACE,
                    "stackOrderChanged");
            mWindowManager.cancelRecentsAnimation(REORDER_KEEP_IN_PLACE, "stackOrderChanged");
        }
    }

+11 −24
Original line number Diff line number Diff line
@@ -168,8 +168,7 @@ public class RecentsAnimationController implements DeathRecipient {

    public interface RecentsAnimationCallbacks {
        /** Callback when recents animation is finished. */
        void onAnimationFinished(@ReorderMode int reorderMode, boolean runSychronously,
                boolean sendUserLeaveHint);
        void onAnimationFinished(@ReorderMode int reorderMode, boolean sendUserLeaveHint);
    }

    private final IRecentsAnimationController mController =
@@ -221,8 +220,7 @@ public class RecentsAnimationController implements DeathRecipient {
                // prior to calling the callback
                mCallbacks.onAnimationFinished(moveHomeToTop
                        ? REORDER_MOVE_TO_TOP
                        : REORDER_MOVE_TO_ORIGINAL_POSITION,
                        true /* runSynchronously */, sendUserLeaveHint);
                        : REORDER_MOVE_TO_ORIGINAL_POSITION, sendUserLeaveHint);
                mDisplayContent.mBoundsAnimationController.setAnimationType(FADE_IN);
            } finally {
                Binder.restoreCallingIdentity(token);
@@ -498,21 +496,15 @@ public class RecentsAnimationController implements DeathRecipient {
    }

    void cancelAnimation(@ReorderMode int reorderMode, String reason) {
        cancelAnimation(reorderMode, false /* runSynchronously */, false /*screenshot */, reason);
    }

    void cancelAnimationSynchronously(@ReorderMode int reorderMode, String reason) {
        cancelAnimation(reorderMode, true /* runSynchronously */, false /* screenshot */, reason);
        cancelAnimation(reorderMode, false /*screenshot */, reason);
    }

    void cancelAnimationWithScreenshot(boolean screenshot) {
        cancelAnimation(REORDER_KEEP_IN_PLACE, true /* sync */, screenshot, "stackOrderChanged");
        cancelAnimation(REORDER_KEEP_IN_PLACE, screenshot, "stackOrderChanged");
    }

    private void cancelAnimation(@ReorderMode int reorderMode, boolean runSynchronously,
            boolean screenshot, String reason) {
        if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "cancelAnimation(): reason=" + reason
                + " runSynchronously=" + runSynchronously);
    private void cancelAnimation(@ReorderMode int reorderMode, boolean screenshot, String reason) {
        if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "cancelAnimation(): reason=" + reason);
        synchronized (mService.getWindowManagerLock()) {
            if (mCanceled) {
                // We've already canceled the animation
@@ -525,16 +517,14 @@ public class RecentsAnimationController implements DeathRecipient {
                // Screen shot previous task when next task starts transition and notify the runner.
                // We will actually finish the animation once the runner calls cleanUpScreenshot().
                final Task task = mPendingAnimations.get(0).mTask;
                final TaskSnapshot taskSnapshot = screenshotRecentTask(task, reorderMode,
                        runSynchronously);
                final TaskSnapshot taskSnapshot = screenshotRecentTask(task, reorderMode);
                try {
                    mRunner.onAnimationCanceled(taskSnapshot);
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to cancel recents animation", e);
                }
                if (taskSnapshot == null) {
                    mCallbacks.onAnimationFinished(reorderMode, runSynchronously,
                            false /* sendUserLeaveHint */);
                    mCallbacks.onAnimationFinished(reorderMode, false /* sendUserLeaveHint */);
                }
            } else {
                // Otherwise, notify the runner and clean up the animation immediately
@@ -545,8 +535,7 @@ public class RecentsAnimationController implements DeathRecipient {
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to cancel recents animation", e);
                }
                mCallbacks.onAnimationFinished(reorderMode, runSynchronously,
                        false /* sendUserLeaveHint */);
                mCallbacks.onAnimationFinished(reorderMode, false /* sendUserLeaveHint */);
            }
        }
    }
@@ -592,8 +581,7 @@ public class RecentsAnimationController implements DeathRecipient {
        return mRequestDeferCancelUntilNextTransition && mCancelDeferredWithScreenshot;
    }

    TaskSnapshot screenshotRecentTask(Task task, @ReorderMode int reorderMode,
            boolean runSynchronously) {
    TaskSnapshot screenshotRecentTask(Task task, @ReorderMode int reorderMode) {
        final TaskSnapshotController snapshotController = mService.mTaskSnapshotController;
        final ArraySet<Task> tasks = Sets.newArraySet(task);
        snapshotController.snapshotTasks(tasks);
@@ -613,8 +601,7 @@ public class RecentsAnimationController implements DeathRecipient {
                    if (DEBUG_RECENTS_ANIMATIONS) {
                        Slog.d(TAG, "mRecentScreenshotAnimator finish");
                    }
                    mCallbacks.onAnimationFinished(reorderMode, runSynchronously,
                            false /* sendUserLeaveHint */);
                    mCallbacks.onAnimationFinished(reorderMode, false /* sendUserLeaveHint */);
                }, mService);
        mRecentScreenshotAnimator.transferAnimation(task.mSurfaceAnimator);
        return taskSnapshot;
+20 −31
Original line number Diff line number Diff line
@@ -2607,32 +2607,24 @@ public class WindowManagerService extends IWindowManager.Stub
     * @return Whether the next recents animation can continue to start. Called from
     *         {@link RecentsAnimation#startRecentsActivity}.
     */
    public boolean canStartRecentsAnimation() {
        synchronized (mGlobalLock) {
    boolean canStartRecentsAnimation() {
        // TODO(multi-display): currently only default display support recent activity
        if (getDefaultDisplayContentLocked().mAppTransition.isTransitionSet()) {
            return false;
        }
        return true;
    }
    }

    /**
     * Cancels any running recents animation. The caller should NOT hold the WM lock while calling
     * this method, as it will call back into AM and may cause a deadlock. Any locking will be done
     * in the animation controller itself.
     */
    public void cancelRecentsAnimationSynchronously(
    void cancelRecentsAnimation(
            @RecentsAnimationController.ReorderMode int reorderMode, String reason) {
        if (mRecentsAnimationController != null) {
            // This call will call through to cleanupAnimation() below after the animation is
            // canceled
            mRecentsAnimationController.cancelAnimationSynchronously(reorderMode, reason);
            mRecentsAnimationController.cancelAnimation(reorderMode, reason);
        }
    }

    public void cleanupRecentsAnimation(@RecentsAnimationController.ReorderMode int reorderMode) {
        synchronized (mGlobalLock) {
    void cleanupRecentsAnimation(@RecentsAnimationController.ReorderMode int reorderMode) {
        if (mRecentsAnimationController != null) {
            final RecentsAnimationController controller = mRecentsAnimationController;
            mRecentsAnimationController = null;
@@ -2641,10 +2633,8 @@ public class WindowManagerService extends IWindowManager.Stub
            getDefaultDisplayContentLocked().mAppTransition.updateBooster();
        }
    }
    }

    public void setAppFullscreen(IBinder token, boolean toOpaque) {
        synchronized (mGlobalLock) {
    void setAppFullscreen(IBinder token, boolean toOpaque) {
        final AppWindowToken atoken = mRoot.getAppWindowToken(token);
        if (atoken != null) {
            atoken.setFillsParent(toOpaque);
@@ -2652,7 +2642,6 @@ public class WindowManagerService extends IWindowManager.Stub
            mWindowPlacerLocked.requestTraversal();
        }
    }
    }

    public void setWindowOpaque(IBinder token, boolean isOpaque) {
        synchronized (mGlobalLock) {
+2 −2
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {

        // Simulate the app transition finishing
        mController.mAppTransitionListener.onAppTransitionStartingLocked(0, 0, 0, 0);
        verify(mAnimationCallbacks).onAnimationFinished(REORDER_KEEP_IN_PLACE, true, false);
        verify(mAnimationCallbacks).onAnimationFinished(REORDER_KEEP_IN_PLACE, false);
    }

    @Test
@@ -208,7 +208,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
        spyOn(mController.mRecentScreenshotAnimator.mAnimatable);
        mController.mRecentScreenshotAnimator.cancelAnimation();
        verify(mController.mRecentScreenshotAnimator.mAnimatable).onAnimationLeashLost(any());
        verify(mAnimationCallbacks).onAnimationFinished(REORDER_KEEP_IN_PLACE, true, false);
        verify(mAnimationCallbacks).onAnimationFinished(REORDER_KEEP_IN_PLACE, false);
    }

    @Test
Loading