Add FULLSCREEN policies to task level

When a task is in FULLSCREEN windowing mode, it will
fill its parent subject to some policy constraints.
This is handled at the configuration resolution step
which means that FULLSCREEN now implies matchParentBounds
even if the requestedOverrideBounds is not empty.

If it has an overridden orientation (app requested), and
this orientation doesn't match it's parent, the task will
fill as much of it's parent as it can while maintaining
it's requested orientation and will be centered.

This also sets the *requested* override bounds back to
mLastNonFullscreenBounds when entering freeform mode so
that restore works properly. This happens in tandem with
the mode change. Because this is changing *requested*
bounds, callers are free to manipulate it afterwards.

Bug: 113252962
Test: go/wm-smoke, wmtests, "maximizing" and restoring a
      freeform app now properly resizes the task, added
      some TaskRecordTests. Also, tested on freeform display.
Change-Id: If0e32d4240a9331dcf18209eaf4718d7ba800c5c
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index a5ceee2..17424a5 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -3655,6 +3655,12 @@
         }
     }
 
+    /** @returns the orientation of the display when it's rotation is ROTATION_0. */
+    int getNaturalOrientation() {
+        return mBaseDisplayWidth < mBaseDisplayHeight
+                ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
+    }
+
     void performLayout(boolean initial, boolean updateInputWindows) {
         if (!isLayoutNeeded()) {
             return;