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

Commit 815e0363 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Add callback when finishing a recents transition" into main

parents b28b648f 435cf666
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,8 @@ import android.graphics.GraphicBuffer;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.TaskSnapshot;
import android.window.TaskSnapshot;


import com.android.internal.os.IResultReceiver;

/**
/**
 * Passed to the {@link IRecentsAnimationRunner} in order for the runner to control to let the
 * Passed to the {@link IRecentsAnimationRunner} in order for the runner to control to let the
 * runner control certain aspects of the recents animation, and to notify window manager when the
 * runner control certain aspects of the recents animation, and to notify window manager when the
@@ -58,7 +60,7 @@ interface IRecentsAnimationController {
     *                          top resumed app, false otherwise.
     *                          top resumed app, false otherwise.
     */
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    void finish(boolean moveHomeToTop, boolean sendUserLeaveHint);
    void finish(boolean moveHomeToTop, boolean sendUserLeaveHint, in IResultReceiver finishCb);


    /**
    /**
     * Called by the handler to indicate that the recents animation input consumer should be
     * Called by the handler to indicate that the recents animation input consumer should be
+19 −6
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
import android.window.WindowContainerTransaction;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
@@ -279,7 +280,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            mDeathHandler = () -> {
            mDeathHandler = () -> {
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                        "[%d] RecentsController.DeathRecipient: binder died", mInstanceId);
                        "[%d] RecentsController.DeathRecipient: binder died", mInstanceId);
                finish(mWillFinishToHome, false /* leaveHint */);
                finish(mWillFinishToHome, false /* leaveHint */, null /* finishCb */);
            };
            };
            try {
            try {
                mListener.asBinder().linkToDeath(mDeathHandler, 0 /* flags */);
                mListener.asBinder().linkToDeath(mDeathHandler, 0 /* flags */);
@@ -313,7 +314,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                }
                }
            }
            }
            if (mFinishCB != null) {
            if (mFinishCB != null) {
                finishInner(toHome, false /* userLeave */);
                finishInner(toHome, false /* userLeave */, null /* finishCb */);
            } else {
            } else {
                cleanUp();
                cleanUp();
            }
            }
@@ -670,7 +671,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                // now and let it do its animation (since recents is going to be occluded).
                // now and let it do its animation (since recents is going to be occluded).
                sendCancelWithSnapshots();
                sendCancelWithSnapshots();
                mExecutor.executeDelayed(
                mExecutor.executeDelayed(
                        () -> finishInner(true /* toHome */, false /* userLeaveHint */), 0);
                        () -> finishInner(true /* toHome */, false /* userLeaveHint */,
                                null /* finishCb */), 0);
                return;
                return;
            }
            }
            if (recentsOpening != null) {
            if (recentsOpening != null) {
@@ -899,11 +901,12 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {


        @Override
        @Override
        @SuppressLint("NewApi")
        @SuppressLint("NewApi")
        public void finish(boolean toHome, boolean sendUserLeaveHint) {
        public void finish(boolean toHome, boolean sendUserLeaveHint, IResultReceiver finishCb) {
            mExecutor.execute(() -> finishInner(toHome, sendUserLeaveHint));
            mExecutor.execute(() -> finishInner(toHome, sendUserLeaveHint, finishCb));
        }
        }


        private void finishInner(boolean toHome, boolean sendUserLeaveHint) {
        private void finishInner(boolean toHome, boolean sendUserLeaveHint,
                IResultReceiver runnerFinishCb) {
            if (mFinishCB == null) {
            if (mFinishCB == null) {
                Slog.e(TAG, "Duplicate call to finish");
                Slog.e(TAG, "Duplicate call to finish");
                return;
                return;
@@ -993,6 +996,16 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            }
            }
            cleanUp();
            cleanUp();
            finishCB.onTransitionFinished(wct.isEmpty() ? null : wct);
            finishCB.onTransitionFinished(wct.isEmpty() ? null : wct);
            if (runnerFinishCb != null) {
                try {
                    ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                            "[%d] RecentsController.finishInner: calling finish callback",
                            mInstanceId);
                    runnerFinishCb.send(0, null);
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to report transition finished", e);
                }
            }
        }
        }


        @Override
        @Override
+8 −2
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.SurfaceControl;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.TaskSnapshot;
import android.window.TaskSnapshot;


import com.android.internal.os.IResultReceiver;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.recents.model.ThumbnailData;


public class RecentsAnimationControllerCompat {
public class RecentsAnimationControllerCompat {
@@ -89,11 +90,16 @@ public class RecentsAnimationControllerCompat {
     * @param sendUserLeaveHint determines whether userLeaveHint will be set true to the previous
     * @param sendUserLeaveHint determines whether userLeaveHint will be set true to the previous
     *                          app.
     *                          app.
     */
     */
    public void finish(boolean toHome, boolean sendUserLeaveHint) {
    public void finish(boolean toHome, boolean sendUserLeaveHint, IResultReceiver finishCb) {
        try {
        try {
            mAnimationController.finish(toHome, sendUserLeaveHint);
            mAnimationController.finish(toHome, sendUserLeaveHint, finishCb);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to finish recents animation", e);
            Log.e(TAG, "Failed to finish recents animation", e);
            try {
                finishCb.send(0, null);
            } catch (Exception ex) {
                // Local call, can ignore
            }
        }
        }
    }
    }


+10 −1
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ import android.window.PictureInPictureSurfaceTransaction;
import android.window.TaskSnapshot;
import android.window.TaskSnapshot;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.protolog.common.ProtoLog;
import com.android.server.LocalServices;
import com.android.server.LocalServices;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.inputmethod.InputMethodManagerInternal;
@@ -244,7 +245,8 @@ public class RecentsAnimationController implements DeathRecipient {
        }
        }


        @Override
        @Override
        public void finish(boolean moveHomeToTop, boolean sendUserLeaveHint) {
        public void finish(boolean moveHomeToTop, boolean sendUserLeaveHint,
                IResultReceiver finishCb) {
            ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS,
            ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS,
                    "finish(%b): mCanceled=%b", moveHomeToTop, mCanceled);
                    "finish(%b): mCanceled=%b", moveHomeToTop, mCanceled);
            final long token = Binder.clearCallingIdentity();
            final long token = Binder.clearCallingIdentity();
@@ -257,6 +259,13 @@ public class RecentsAnimationController implements DeathRecipient {
            } finally {
            } finally {
                Binder.restoreCallingIdentity(token);
                Binder.restoreCallingIdentity(token);
            }
            }
            if (finishCb != null) {
                try {
                    finishCb.send(0, new Bundle());
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to report animation finished", e);
                }
            }
        }
        }


        @Override
        @Override