Removed use of WindowState.mTargetAppToken

Instead of keeping track of the ime target app token in each ime window state
for the purpose of adjusting the animation layer, we now just check if it is
a ime window and there is an ime target when we want to adjust the animation
layer.

Also correct some use of WindowTokens.windows to AppWidowToken.allAppWindows
in AppWindowToken since that contains all the windows associated with the app
token.

Bug: 30060889
Change-Id: Iba1a6076d0ed09413a0802d02c92b9b32ad50891
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index f268aa2..f4bb479 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -280,10 +280,10 @@
 
     WindowState findMainWindow() {
         WindowState candidate = null;
-        int j = windows.size();
+        int j = allAppWindows.size();
         while (j > 0) {
             j--;
-            WindowState win = windows.get(j);
+            WindowState win = allAppWindows.get(j);
             if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
                     || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
                 // In cases where there are multiple windows, we prefer the non-exiting window. This
@@ -542,7 +542,7 @@
         clearVisibleBeforeClientHidden();
 
         if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
-                "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn
+                "restoreSavedSurfaces: " + this + " allDrawn=" + allDrawn
                 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
     }
 
@@ -609,8 +609,8 @@
     }
 
     void setReplacingWindows(boolean animate) {
-        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
-                + " with replacing windows.");
+        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
+                "Marking app token " + this + " with replacing windows.");
 
         for (int i = allAppWindows.size() - 1; i >= 0; i--) {
             final WindowState w = allAppWindows.get(i);
@@ -627,7 +627,7 @@
     }
 
     void setReplacingChildren() {
-        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
+        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
                 + " with replacing child windows.");
         for (int i = allAppWindows.size() - 1; i >= 0; i--) {
             final WindowState w = allAppWindows.get(i);
@@ -638,8 +638,8 @@
     }
 
     void resetReplacingWindows() {
-        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Resetting app token " + appWindowToken
-                + " of replacing window marks.");
+        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
+                "Resetting app token " + this + " of replacing window marks.");
 
         for (int i = allAppWindows.size() - 1; i >= 0; i--) {
             final WindowState w = allAppWindows.get(i);
@@ -769,8 +769,8 @@
         if (!mFrozenMergedConfig.isEmpty()) {
             mFrozenMergedConfig.remove();
         }
-        for (int i = windows.size() - 1; i >= 0; i--) {
-            final WindowState win = windows.get(i);
+        for (int i = allAppWindows.size() - 1; i >= 0; i--) {
+            final WindowState win = allAppWindows.get(i);
             if (!win.mHasSurface) {
                 continue;
             }