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
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
index 2554237..b1f942e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
@@ -19,6 +19,9 @@
 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 @@
         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);
+    }
 }