Fixes to clean up icon launching during animations.

Several problems were causing animations to jump to the end when
launching an app while a previous app was animating away.

- Keep the two app token lists in tighter synch. These were separated
when we hoped to completely separate layout form animation. This is
not as critical a goal any more.

- Use new test criteria for starting and stopping animations.

Bug 7885350 fixed.

Change-Id: Ib679117f627d0957cda17cc6ffca2bc2cdd6ecdd
diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java
index 275c9bf..adad09d 100644
--- a/services/java/com/android/server/wm/AppWindowToken.java
+++ b/services/java/com/android/server/wm/AppWindowToken.java
@@ -223,6 +223,22 @@
         return null;
     }
 
+    boolean isVisible() {
+        final int N = allAppWindows.size();
+        // TODO: Consider using allDrawn instead of a single window.
+        for (int i=0; i<N; i++) {
+            WindowState win = allAppWindows.get(i);
+            if (!win.mAppFreezing
+                    && (win.mViewVisibility == View.VISIBLE ||
+                        (win.mWinAnimator.isAnimating() &&
+                                !service.mAppTransition.isTransitionSet()))
+                    && !win.mDestroying && win.isDrawnLw()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Override
     void dump(PrintWriter pw, String prefix) {
         super.dump(pw, prefix);