Fixed issue with ordering of non-app token windows

We tried to fix this issue in I83357975c87c704af9d0702c939ca99984462365
but the fix introduced other problems. So, we are going to have sys-ui
create a separate binder for object for each type of window it adds.
Long term we want to allow one binder object to map to multiple window
tokens on the same display in window manager.

Change-Id: Iee53b8bf95b87f79ab7a1b574a54111c678f7413
Fixes: 33567674
Fixes: 33538278
Test: bit FrameworksServicesTests:com.android.server.wm.DisplayContentTests
diff --git a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
index 0e20c4e..01808cb 100644
--- a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
@@ -83,7 +83,7 @@
     }
 
     @Test
-    public void testForAllWindows_WithImeTarget() throws Exception {
+    public void testForAllWindows_WithAppImeTarget() throws Exception {
         final WindowState imeAppTarget =
                 createWindow(null, TYPE_BASE_APPLICATION, sDisplayContent, "imeAppTarget");
 
@@ -126,6 +126,44 @@
     }
 
     @Test
+    public void testForAllWindows_WithStatusBarImeTarget() throws Exception {
+
+        sWm.mInputMethodTarget = sStatusBarWindow;
+
+        final ArrayList<WindowState> windows = new ArrayList();
+
+        // Test forward traversal.
+        sDisplayContent.forAllWindows(w -> {windows.add(w);}, false /* traverseTopToBottom */);
+
+        assertEquals(sWallpaperWindow, windows.get(0));
+        assertEquals(sChildAppWindowBelow, windows.get(1));
+        assertEquals(sAppWindow, windows.get(2));
+        assertEquals(sChildAppWindowAbove, windows.get(3));
+        assertEquals(sDockedDividerWindow, windows.get(4));
+        assertEquals(sStatusBarWindow, windows.get(5));
+        assertEquals(sImeWindow, windows.get(6));
+        assertEquals(sImeDialogWindow, windows.get(7));
+        assertEquals(sNavBarWindow, windows.get(8));
+
+        // Test backward traversal.
+        windows.clear();
+        sDisplayContent.forAllWindows(w -> {windows.add(w);}, true /* traverseTopToBottom */);
+
+        assertEquals(sWallpaperWindow, windows.get(8));
+        assertEquals(sChildAppWindowBelow, windows.get(7));
+        assertEquals(sAppWindow, windows.get(6));
+        assertEquals(sChildAppWindowAbove, windows.get(5));
+        assertEquals(sDockedDividerWindow, windows.get(4));
+        assertEquals(sStatusBarWindow, windows.get(3));
+        assertEquals(sImeWindow, windows.get(2));
+        assertEquals(sImeDialogWindow, windows.get(1));
+        assertEquals(sNavBarWindow, windows.get(0));
+
+        // Clean-up
+        sWm.mInputMethodTarget = null;
+    }
+
+    @Test
     public void testForAllWindows_WithInBetweenWindowToken() throws Exception {
         // This window is set-up to be z-ordered between some windows that go in the same token like
         // the nav bar and status bar.