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

Commit 90dd5cc3 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by android-build-merger
Browse files

Fixed issue with drag resize state when animating pinned stack.

am: ce14452a

* commit 'ce14452a':
  Fixed issue with drag resize state when animating pinned stack.
parents f981ef57 ce14452a
Loading
Loading
Loading
Loading
+38 −16
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.util.ArrayMap;
@@ -41,8 +40,9 @@ import android.view.animation.LinearInterpolator;
 */
public class BoundsAnimationController {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "BoundsAnimationController" : TAG_WM;
    private static final int DEBUG_ANIMATION_SLOW_DOWN_FACTOR = 1;

    // Only acccessed on UI thread.
    // Only accessed on UI thread.
    private ArrayMap<AnimateBoundsUser, BoundsAnimator> mRunningAnimations = new ArrayMap<>();

    private final class BoundsAnimator extends ValueAnimator
@@ -52,14 +52,22 @@ public class BoundsAnimationController {
        private final Rect mTo;
        private final Rect mTmpRect;
        private final boolean mMoveToFullScreen;

        BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to, boolean moveToFullScreen) {
        // True if this this animation was cancelled and will be replaced the another animation from
        // the same {@link #AnimateBoundsUser} target.
        private boolean mWillReplace;
        // True to true if this animation replaced a previous animation of the same
        // {@link #AnimateBoundsUser} target.
        private final boolean mReplacement;

        BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to,
                boolean moveToFullScreen, boolean replacement) {
            super();
            mTarget = target;
            mFrom = from;
            mTo = to;
            mTmpRect = new Rect();
            mMoveToFullScreen = moveToFullScreen;
            mReplacement = replacement;
            addUpdateListener(this);
            addListener(this);
        }
@@ -68,10 +76,10 @@ public class BoundsAnimationController {
        public void onAnimationUpdate(ValueAnimator animation) {
            final float value = (Float) animation.getAnimatedValue();
            final float remains = 1 - value;
            mTmpRect.left = (int) (mFrom.left * remains + mTo.left * value);
            mTmpRect.top = (int) (mFrom.top * remains + mTo.top * value);
            mTmpRect.right = (int) (mFrom.right * remains + mTo.right * value);
            mTmpRect.bottom = (int) (mFrom.bottom * remains + mTo.bottom * value);
            mTmpRect.left = (int) (mFrom.left * remains + mTo.left * value + 0.5f);
            mTmpRect.top = (int) (mFrom.top * remains + mTo.top * value + 0.5f);
            mTmpRect.right = (int) (mFrom.right * remains + mTo.right * value + 0.5f);
            mTmpRect.bottom = (int) (mFrom.bottom * remains + mTo.bottom * value + 0.5f);
            if (DEBUG_ANIM) Slog.d(TAG, "animateUpdate: mTarget=" + mTarget + ", mBounds="
                    + mTmpRect + ", from=" + mFrom + ", mTo=" + mTo + ", value=" + value
                    + ", remains=" + remains);
@@ -85,13 +93,15 @@ public class BoundsAnimationController {

        @Override
        public void onAnimationStart(Animator animation) {

            if (!mReplacement) {
                mTarget.onAnimationStart();
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
            if (mMoveToFullScreen) {
            if (mMoveToFullScreen && !mWillReplace) {
                mTarget.moveToFullscreen();
            }
        }
@@ -101,8 +111,16 @@ public class BoundsAnimationController {
            finishAnimation();
        }

        @Override
        public void cancel() {
            mWillReplace = true;
            super.cancel();
        }

        private void finishAnimation() {
            mTarget.finishBoundsAnimation();
            if (!mWillReplace) {
                mTarget.onAnimationEnd();
            }
            removeListener(this);
            removeUpdateListener(this);
            mRunningAnimations.remove(mTarget);
@@ -126,11 +144,13 @@ public class BoundsAnimationController {
         */
        boolean setSize(Rect bounds);

        void onAnimationStart();

        /**
         * Callback for the target to inform it that the animation is finished, so it can do some
         * Callback for the target to inform it that the animation has ended, so it can do some
         * necessary cleanup.
         */
        void finishBoundsAnimation();
        void onAnimationEnd();

        void moveToFullscreen();

@@ -146,13 +166,15 @@ public class BoundsAnimationController {
        }

        final BoundsAnimator existing = mRunningAnimations.get(target);
        if (existing != null) {
        final boolean replacing = existing != null;
        if (replacing) {
            existing.cancel();
        }
        BoundsAnimator animator = new BoundsAnimator(target, from, to, moveToFullscreen);
        final BoundsAnimator animator =
                new BoundsAnimator(target, from, to, moveToFullscreen, replacing);
        mRunningAnimations.put(target, animator);
        animator.setFloatValues(0f, 1f);
        animator.setDuration(DEFAULT_APP_TRANSITION_DURATION);
        animator.setDuration(DEFAULT_APP_TRANSITION_DURATION * DEBUG_ANIMATION_SLOW_DOWN_FACTOR);
        animator.setInterpolator(new LinearInterpolator());
        animator.start();
    }
+1 −1
Original line number Diff line number Diff line
@@ -540,7 +540,7 @@ class Task implements DimLayer.DimLayerUser {
    }

    boolean isDragResizing() {
        return mDragResizing;
        return mDragResizing || (mStack != null && mStack.isDragResizing());
    }

    void updateDisplayInfo(final DisplayContent displayContent) {
+17 −9
Original line number Diff line number Diff line
@@ -99,6 +99,9 @@ public class TaskStack implements DimLayer.DimLayerUser,
    boolean mDeferDetach;
    private boolean mUpdateBoundsAfterRotation = false;

    // Whether the stack and all its tasks is currently being drag-resized
    private boolean mDragResizing;

    TaskStack(WindowManagerService service, int stackId) {
        mService = service;
        mStackId = stackId;
@@ -911,6 +914,10 @@ public class TaskStack implements DimLayer.DimLayerUser,
        return false;
    }

    boolean isDragResizing() {
        return mDragResizing;
    }

    @Override  // AnimatesBounds
    public boolean setSize(Rect bounds) {
        synchronized (mService.mWindowMap) {
@@ -926,16 +933,17 @@ public class TaskStack implements DimLayer.DimLayerUser,
    }

    @Override  // AnimatesBounds
    public void finishBoundsAnimation() {
    public void onAnimationStart() {
        synchronized (mService.mWindowMap) {
            if (mTasks.isEmpty()) {
                return;
            mDragResizing = true;
        }
            final Task task = mTasks.get(mTasks.size() - 1);
            if (task != null) {
                task.setDragResizing(false);
                mService.requestTraversal();
    }

    @Override  // AnimatesBounds
    public void onAnimationEnd() {
        synchronized (mService.mWindowMap) {
            mDragResizing = false;
            mService.requestTraversal();
        }
    }

+0 −7
Original line number Diff line number Diff line
@@ -10377,13 +10377,6 @@ public class WindowManagerService extends IWindowManager.Stub
                Slog.w(TAG, "animateResizePinnedStack: stackId " + PINNED_STACK_ID + " not found.");
                return;
            }
            final ArrayList<Task> tasks = stack.getTasks();
            if (tasks.isEmpty()) {
                Slog.w(TAG, "animateResizePinnedStack: pinned stack doesn't have any tasks.");
                return;
            }
            final Task task = tasks.get(tasks.size() - 1);
            task.setDragResizing(true);
            final Rect originalBounds = new Rect();
            stack.getBounds(originalBounds);
            UiThread.getHandler().post(new Runnable() {