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

Commit 106326a4 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Fix cancel transition finished before animation finish." into main

parents 789e5eac ea3ce958
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -1395,6 +1395,13 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                mergePendingTransitions(info);
                mergePendingTransitions(info);
            }
            }


            if (info.getType() == TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION
                    && !mCloseTransitionRequested && info.getChanges().isEmpty() && mApps != null) {
                // Wait for post animation finish
                finishCallback.onTransitionFinished(null);
                t.apply();
                return;
            }
            if (isNotGestureBackTransition(info) || shouldCancelAnimation(info)
            if (isNotGestureBackTransition(info) || shouldCancelAnimation(info)
                    || !mCloseTransitionRequested) {
                    || !mCloseTransitionRequested) {
                if (mPrepareOpenTransition != null) {
                if (mPrepareOpenTransition != null) {
@@ -1502,14 +1509,27 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                }
                }
            }
            }
            if (openingLeash != null) {
            if (openingLeash != null) {
                int rootIdx = -1;
                for (int i = info.getChanges().size() - 1; i >= 0; --i) {
                for (int i = info.getChanges().size() - 1; i >= 0; --i) {
                    final TransitionInfo.Change c = info.getChanges().get(i);
                    final TransitionInfo.Change c = info.getChanges().get(i);
                    if (c.hasFlags(FLAG_IS_WALLPAPER)) {
                        st.setAlpha(c.getLeash(), 1.0f);
                        continue;
                    }
                    if (TransitionUtil.isOpeningMode(c.getMode())) {
                    if (TransitionUtil.isOpeningMode(c.getMode())) {
                        final Point offset = c.getEndRelOffset();
                        final Point offset = c.getEndRelOffset();
                        st.setPosition(c.getLeash(), offset.x, offset.y);
                        st.setPosition(c.getLeash(), offset.x, offset.y);
                        st.reparent(c.getLeash(), openingLeash);
                        st.reparent(c.getLeash(), openingLeash);
                        st.setAlpha(c.getLeash(), 1.0f);
                        st.setAlpha(c.getLeash(), 1.0f);
                        rootIdx = TransitionUtil.rootIndexFor(c, info);
                    }
                }
                }
                // The root leash and the leash of opening target should actually in the same level,
                // but since the root leash is created after opening target, it will have higher
                // layer in surface flinger. Move the root leash to lower level, so it won't affect
                // the playing animation.
                if (rootIdx >= 0 && info.getRootCount() > 0) {
                    st.setLayer(info.getRoot(rootIdx).getLeash(), -1);
                }
                }
            }
            }
            st.apply();
            st.apply();
@@ -1553,6 +1573,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            if (openingLeash != null && closingLeash != null) {
            if (openingLeash != null && closingLeash != null) {
                for (int i = info.getChanges().size() - 1; i >= 0; --i) {
                for (int i = info.getChanges().size() - 1; i >= 0; --i) {
                    final TransitionInfo.Change c = info.getChanges().get(i);
                    final TransitionInfo.Change c = info.getChanges().get(i);
                    if (c.hasFlags(FLAG_IS_WALLPAPER)) {
                        st.setAlpha(c.getLeash(), 1.0f);
                        continue;
                    }
                    if (TransitionUtil.isOpeningMode(c.getMode())) {
                    if (TransitionUtil.isOpeningMode(c.getMode())) {
                        final Point offset = c.getEndRelOffset();
                        final Point offset = c.getEndRelOffset();
                        st.setPosition(c.getLeash(), offset.x, offset.y);
                        st.setPosition(c.getLeash(), offset.x, offset.y);