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

Commit 4f17c97d authored by Winson Chung's avatar Winson Chung
Browse files

Defer nav handle action until after the recents transition is complete



Bug: 303078360
Test: Force delay in finishing recents transition and verify with bug steps
Change-Id: I2021cc291204261de56ef9c912d8b5935059c7fb
Signed-off-by: default avatarWinson Chung <winsonc@google.com>
parent 528356e7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -126,4 +126,14 @@ public interface InputConsumer {
        }
        return name.toString();
    }

    /**
     * Returns an input consumer of the given class type, or null if none is found.
     */
    default <T extends InputConsumer> T getInputConsumerOfClass(Class<T> c) {
        if (getClass().equals(c)) {
            return c.cast(this);
        }
        return null;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ public class RecentsAnimationCallbacks implements
                    /* extras= */ 0,
                    /* gestureEvent= */ ON_START_RECENTS_ANIMATION);
            notifyAnimationCanceled();
            animationController.finish(false /* toHome */, false /* sendUserLeaveHint */);
            animationController.finish(false /* toHome */, false /* sendUserLeaveHint */,
                    null /* finishCb */);
            return;
        }

+11 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITION
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.FINISH_RECENTS_ANIMATION;

import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import android.view.IRecentsAnimationController;
@@ -32,6 +33,7 @@ import android.window.PictureInPictureSurfaceTransaction;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;

import com.android.internal.os.IResultReceiver;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.RunnableList;
import com.android.quickstep.util.ActiveGestureErrorDetector;
@@ -172,12 +174,19 @@ public class RecentsAnimationController {
        mFinishTargetIsLauncher = toRecents;
        mOnFinishedListener.accept(this);
        Runnable finishCb = () -> {
            mController.finish(toRecents, sendUserLeaveHint);
            mController.finish(toRecents, sendUserLeaveHint, new IResultReceiver.Stub() {
                @Override
                public void send(int i, Bundle bundle) throws RemoteException {
                    ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation-callback");
                    MAIN_EXECUTOR.execute(() -> {
                        mPendingFinishCallbacks.executeAllAndDestroy();
                    });
                }
            });
            InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
            InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
            InteractionJankMonitorWrapper.end(
                    InteractionJankMonitorWrapper.CUJ_APP_SWIPE_TO_RECENTS);
            MAIN_EXECUTOR.execute(mPendingFinishCallbacks::executeAllAndDestroy);
        };
        if (forceFinish) {
            finishCb.run();
+6 −4
Original line number Diff line number Diff line
@@ -119,7 +119,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
            }
        }
        // But force-finish it anyways
        finishRunningRecentsAnimation(false /* toHome */, true /* forceFinish */);
        finishRunningRecentsAnimation(false /* toHome */, true /* forceFinish */,
                null /* forceFinishCb */);

        if (mCallbacks != null) {
            // If mCallbacks still != null, that means we are getting this startRecentsAnimation()
@@ -325,19 +326,20 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
     * Finishes the running recents animation.
     */
    public void finishRunningRecentsAnimation(boolean toHome) {
        finishRunningRecentsAnimation(toHome, false /* forceFinish */);
        finishRunningRecentsAnimation(toHome, false /* forceFinish */, null /* forceFinishCb */);
    }

    /**
     * Finishes the running recents animation.
     * @param forceFinish will synchronously finish the controller
     */
    public void finishRunningRecentsAnimation(boolean toHome, boolean forceFinish) {
    public void finishRunningRecentsAnimation(boolean toHome, boolean forceFinish,
            Runnable forceFinishCb) {
        if (mController != null) {
            ActiveGestureLog.INSTANCE.addLog(
                    /* event= */ "finishRunningRecentsAnimation", toHome);
            if (forceFinish) {
                mController.finishController(toHome, null, false /* sendUserLeaveHint */,
                mController.finishController(toHome, forceFinishCb, false /* sendUserLeaveHint */,
                        true /* forceFinish */);
            } else {
                Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), toHome
+8 −0
Original line number Diff line number Diff line
@@ -48,6 +48,14 @@ public abstract class DelegateInputConsumer implements InputConsumer {
     */
    protected abstract String getDelegatorName();

    @Override
    public <T extends InputConsumer> T getInputConsumerOfClass(Class<T> c) {
        if (getClass().equals(c)) {
            return c.cast(this);
        }
        return mDelegate.getInputConsumerOfClass(c);
    }

    protected void setActive(MotionEvent ev) {
        ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(getDelegatorName())
                .append(" became active"));
Loading