Fixed some test failure and log warnings.

- Make DisplayContent.attachStack and moveStack use the same code
path for adding child stack so they both account for the presence
of pinnded stack.
- Don't call DC.attachStack on a stack that is already on the
display. Use DC.removeStack instead to just make sure it is at the
right z-order on the display.
- Use WindowContainer.getName() when for exception messages to have
a more concise print-out for the error.
- Only try to remove a task from a stack when positioning if the task
is contained in the stack.
- Throw an exception if we try to remove a task that isn't contained
in a stack.
- Skip checking of exiting or waiting for replacement when rebuilding
window list for app tokens that are exiting.
- Properly display and intent output from WC.dumpChildrenNames().
- Have DisplayContent WindowContainer type always return true for
fillsParent() and isVisible() as displays always fill their parent
and always visible for now.

Bug: 31624623
Test: Failing test passes.
Change-Id: I8a84770feb1fd278716755cdec2900fddb9940de
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 8de267c..21b6ae5 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -232,8 +232,10 @@
 
             stack = dc.getStackById(stackId);
             if (stack != null) {
-                // It's already attached to the display...clear mDeferRemoval!
+                // It's already attached to the display...clear mDeferRemoval and move stack to
+                // appropriate z-order on display as needed.
                 stack.mDeferRemoval = false;
+                dc.moveStack(stack, onTop);
                 attachedToDisplay = true;
             } else {
                 stack = new TaskStack(mService, stackId);
@@ -245,14 +247,16 @@
                         .notifyDockedStackExistsChanged(true);
             }
         }
+
         if (!attachedToDisplay) {
             stack.attachDisplayContent(dc);
+            dc.attachStack(stack, onTop);
         }
-        dc.attachStack(stack, onTop);
+
         if (stack.getRawFullscreen()) {
             return null;
         }
-        Rect bounds = new Rect();
+        final Rect bounds = new Rect();
         stack.getRawBounds(bounds);
         return bounds;
     }
@@ -1425,4 +1429,9 @@
             }
         }
     }
+
+    @Override
+    String getName() {
+        return "ROOT";
+    }
 }