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

Commit 1a9b9425 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use task position for transition in freeform mode"

parents e976a132 a118b3a3
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import android.view.WindowManager.LayoutParams;
import android.view.animation.Animation;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ToBooleanFunction;
import com.android.server.input.InputApplicationHandle;
import com.android.server.policy.WindowManagerPolicy.StartingSurface;
@@ -1741,6 +1742,30 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        return boundsLayer;
    }

    /** Get position and crop region of animation. */
    @VisibleForTesting
    void getAnimationBounds(Point outPosition, Rect outBounds) {
        outPosition.set(0, 0);
        outBounds.setEmpty();

        final TaskStack stack = getStack();
        final Task task = getTask();
        if (task != null && task.inFreeformWindowingMode()) {
            task.getRelativePosition(outPosition);
        } else if (stack != null) {
            stack.getRelativePosition(outPosition);
        }

        // Always use stack bounds in order to have the ability to animate outside the task region.
        // It also needs to be consistent when {@link #mNeedsAnimationBoundsLayer} is set that crops
        // according to the bounds.
        if (stack != null) {
            stack.getBounds(outBounds);
        }
        // We have the relative position so the local position can be removed from bounds.
        outBounds.offsetTo(0, 0);
    }

    boolean applyAnimationLocked(WindowManager.LayoutParams lp, int transit, boolean enter,
            boolean isVoiceInteraction) {

@@ -1759,14 +1784,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "AWT#applyAnimationLocked");
        if (okToAnimate()) {
            final AnimationAdapter adapter;
            final TaskStack stack = getStack();
            mTmpPoint.set(0, 0);
            mTmpRect.setEmpty();
            if (stack != null) {
                stack.getRelativePosition(mTmpPoint);
                stack.getBounds(mTmpRect);
                mTmpRect.offsetTo(0, 0);
            }
            getAnimationBounds(mTmpPoint, mTmpRect);

            // Delaying animation start isn't compatible with remote animations at all.
            if (mService.mAppTransition.getRemoteAnimationController() != null
+31 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.wm;

import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
@@ -33,10 +35,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

import android.graphics.Point;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.view.Surface;
import android.view.WindowManager;
@@ -255,4 +259,30 @@ public class AppWindowTokenTests extends WindowTestsBase {
        closingWindow.removeIfPossible();
        assertTrue(closingWindow.mRemoved);
    }

    @Test
    public void testTransitionAnimationPositionAndBounds() {
        final Rect stackBounds = new Rect(
                0/* left */, 0 /* top */, 1000 /* right */, 1000 /* bottom */);
        final Rect taskBounds = new Rect(
                100/* left */, 200 /* top */, 600 /* right */, 600 /* bottom */);
        mStack.setBounds(stackBounds);
        mTask.setBounds(taskBounds);

        mTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
        assertTransitionAnimationPositionAndBounds(taskBounds.left, taskBounds.top, stackBounds);

        mTask.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
        assertTransitionAnimationPositionAndBounds(stackBounds.left, stackBounds.top, stackBounds);
    }

    private void assertTransitionAnimationPositionAndBounds(int expectedX, int expectedY,
            Rect expectedBounds) {
        final Point outPosition = new Point();
        final Rect outBounds = new Rect();
        mToken.getAnimationBounds(outPosition, outBounds);
        assertEquals(expectedX, outPosition.x);
        assertEquals(expectedY, outPosition.y);
        assertEquals(expectedBounds, outBounds);
    }
}