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

Commit f0a5c56d authored by Josh Yang's avatar Josh Yang
Browse files

Fix several bugs in back animation handoff.

1. Always start animation after preparation.
2. Reset handoff handler to null when handoff is not available.

Flag: com.android.systemui.shared.return_animation_framework_library
Flag: com.android.systemui.shared.return_animation_framework_long_lived
Bug: 382137941
Test: manual test with test app
Change-Id: I81e98b8a49c7851e5b14e4983e88b43c2f7a59d0
parent e196412f
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -731,6 +731,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            callback.onBackStarted(backEvent);
            if (mBackTransitionHandler.canHandOffAnimation()) {
                callback.setHandoffHandler(mHandoffHandler);
            } else {
                callback.setHandoffHandler(null);
            }
            mOnBackStartDispatched = true;
        } catch (RemoteException e) {
@@ -1273,14 +1275,6 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                @NonNull SurfaceControl.Transaction st,
                @NonNull SurfaceControl.Transaction ft,
                @NonNull Transitions.TransitionFinishCallback finishCallback) {
            final boolean isPrepareTransition =
                    info.getType() == WindowManager.TRANSIT_PREPARE_BACK_NAVIGATION;
            if (isPrepareTransition) {
                if (checkTakeoverFlags()) {
                    mTakeoverHandler = mTransitions.getHandlerForTakeover(transition, info);
                }
                kickStartAnimation();
            }
            // Both mShellExecutor and Transitions#mMainExecutor are ShellMainThread, so we don't
            // need to post to ShellExecutor when called.
            if (info.getType() == WindowManager.TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION) {
@@ -1308,7 +1302,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                    // animation never start, consume directly
                    applyAndFinish(st, ft, finishCallback);
                    return true;
                } else if (mClosePrepareTransition == null && isPrepareTransition) {
                } else if (mClosePrepareTransition == null
                        && info.getType() == WindowManager.TRANSIT_PREPARE_BACK_NAVIGATION) {
                    // Gesture animation was cancelled before prepare transition ready, create
                    // the close prepare transition
                    createClosePrepareTransition();
@@ -1316,6 +1311,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            }

            if (handlePrepareTransition(info, st, ft, finishCallback)) {
                if (checkTakeoverFlags()) {
                    mTakeoverHandler = mTransitions.getHandlerForTakeover(transition, info);
                }
                kickStartAnimation();
                return true;
            }
            return handleCloseTransition(info, st, ft, finishCallback);
+4 −2
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -634,7 +636,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
        releaseBackGesture();
        mShellExecutor.flushAll();

        verify(mAppCallback).setHandoffHandler(any());
        verify(mAppCallback).setHandoffHandler(notNull());
    }

    @Test
@@ -654,7 +656,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
        releaseBackGesture();
        mShellExecutor.flushAll();

        verify(mAppCallback, never()).setHandoffHandler(any());
        verify(mAppCallback).setHandoffHandler(isNull());
    }

    @Test