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

Commit 6619acb8 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix missing surface offset for stack with outset

This change restores the relative position calculation as
commit 32bcb10e (removed in commit ed6767fe).

Bug: 124532338
Test: atest TaskStackTests#testStackOutset
Test: manual - Observe there is no offset at the beginning
      of the pip enter animation. And when dragging the pip
      window to the left side and right side, the space
      between the edge of screen should be the same.

Change-Id: I05ca6aa6a3debf0a1f66a44d786fdd84348af3a4
parent 1ca52f00
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.SurfaceControl;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
import com.android.internal.policy.DockedDividerUtils;
@@ -787,6 +788,14 @@ public class TaskStack extends WindowContainer<Task> implements
        return 0;
    }

    @Override
    void getRelativeDisplayedPosition(Point outPos) {
        super.getRelativeDisplayedPosition(outPos);
        final int outset = getStackOutset();
        outPos.x -= outset;
        outPos.y -= outset;
    }

    private void updateSurfaceSize(SurfaceControl.Transaction transaction) {
        if (mSurfaceControl == null) {
            return;
@@ -807,6 +816,11 @@ public class TaskStack extends WindowContainer<Task> implements
        mLastSurfaceSize.set(width, height);
    }

    @VisibleForTesting
    Point getLastSurfaceSize() {
        return mLastSurfaceSize;
    }

    @Override
    void onDisplayChanged(DisplayContent dc) {
        if (mDisplayContent != null && mDisplayContent != dc) {
+21 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.server.wm;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
@@ -168,4 +171,22 @@ public class TaskStackTests extends WindowTestsBase {
        assertEquals(stack1PositionInParent, stack2PositionInParent + 1);
        assertTrue(task1.mOnDisplayChangedCalled);
    }

    @Test
    public void testStackOutset() {
        final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
        spyOn(stack);

        final int stackOutset = 10;
        doReturn(stackOutset).when(stack).getStackOutset();

        final Rect stackBounds = new Rect(200, 200, 800, 1000);
        // Update surface position and size by the given bounds.
        stack.setBounds(stackBounds);

        assertEquals(stackBounds.width() + 2 * stackOutset, stack.getLastSurfaceSize().x);
        assertEquals(stackBounds.height() + 2 * stackOutset, stack.getLastSurfaceSize().y);
        assertEquals(stackBounds.left - stackOutset, stack.getLastSurfacePosition().x);
        assertEquals(stackBounds.top - stackOutset, stack.getLastSurfacePosition().y);
    }
}