Fix issue with where display is removed while creating it in AM and WM

It is possible to a display to be removed while we are in the ctor of
ActivityDisplay in AM, but before we can get the Display object in the
ctor of DisplayWindowController in WM. This causes us to throw an
exception becuase the caller is trying to add a display we can't find in
display manager. Unfortunately there isn't a good way to handle this race.
To work around it we will now pass the Display object from AM to WM to use
and depend on the fact that AM will remove the display shortly after.

Change-Id: Ie3f9d86bad67f5a023e3e7dfce5219b98c796864
Fixes: 72893961
Test: go/wm-smoke
diff --git a/services/core/java/com/android/server/wm/DisplayWindowController.java b/services/core/java/com/android/server/wm/DisplayWindowController.java
index e3e4a46..ba8ec69 100644
--- a/services/core/java/com/android/server/wm/DisplayWindowController.java
+++ b/services/core/java/com/android/server/wm/DisplayWindowController.java
@@ -34,25 +34,21 @@
 
     private final int mDisplayId;
 
-    public DisplayWindowController(int displayId, WindowContainerListener listener) {
+    public DisplayWindowController(Display display, WindowContainerListener listener) {
         super(listener, WindowManagerService.getInstance());
-        mDisplayId = displayId;
+        mDisplayId = display.getDisplayId();
 
         synchronized (mWindowMap) {
-            final Display display = mService.mDisplayManager.getDisplay(displayId);
-            if (display != null) {
-                final long callingIdentity = Binder.clearCallingIdentity();
-                try {
-                    mRoot.createDisplayContent(display, this /* controller */);
-                } finally {
-                    Binder.restoreCallingIdentity(callingIdentity);
-                }
+            final long callingIdentity = Binder.clearCallingIdentity();
+            try {
+                mRoot.createDisplayContent(display, this /* controller */);
+            } finally {
+                Binder.restoreCallingIdentity(callingIdentity);
             }
 
             if (mContainer == null) {
-                throw new IllegalArgumentException("Trying to add displayId=" + displayId
-                        + " display=" + display
-                        + " dc=" + mRoot.getDisplayContent(displayId));
+                throw new IllegalArgumentException("Trying to add display=" + display
+                        + " dc=" + mRoot.getDisplayContent(mDisplayId));
             }
         }
     }