Never consider windows visible if appToken is hidden

This fixes a bug with trampoline activities: T1 starts T2 in
onCreate. Now T2 finished itself and in activityResult in T1
T1 starts TNoDisplay that finishes and starts T1' which starts
T2'. Since T1' didn't get the request yet to be hidden
mViewVisibility for the main window is still VISIBLE. Thus, we
note that all windows for T1' are visible and report that to
AM. Note that since visibility of T1' never changed (it was always
hidden) we also don't have an animation set so we don't block
visibility on the fact that there is an animation set.

However, AM was waiting for things to be visible before
destroying T2, and thus destroy T2 before the animation is
actually done, leading to a black hole.

We fix this by only reporting AM things to be visible if our app
token is not hidden.

Test: Above flow, ensure no black hole
Test: go/wm-smoke

Change-Id: Ifde0e9fa1f1381a5b3a1ac9c88fd209d0903e513
Fixes: 62802161
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index c4ff455..5e56f0c 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -290,7 +290,7 @@
         boolean nowGone = mReportedVisibilityResults.nowGone;
 
         boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
-        boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
+        boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting && !hidden;
         if (!nowGone) {
             // If the app is not yet gone, then it can only become visible/drawn.
             if (!nowDrawn) {