Fixed flicker on activity transition in docked stack.

- If the app token isn't hidden then it is considered visible
and there is no need to check its children windows to see if
they are visible. The WindowState.isVisible() might say it isn't
visible due to hiddenRequested even though it is visible on-screen
since the app token isn't hidden.
- Comment out check for hiddenRequested flag when determining if a
window state is visible. The window can still be visible on screen
when the flag is true. We would like the isVisible() method to
return an answer closer to if the window is truly visible
(can't be an exact answer without checking the surface state), so
comment out the check for now so we can test to see what problem it
causes.
If it doesn't cause any issues, then we can remove just before we lock
down the current release (O) and also consolidate this method with
If it does cause problems, then we can look if there are other ways
to solve the problems. If there isn't then we uncomment and document why.

Bug: 31630397
Test: Manual testing and existing tests pass.
Change-Id: I230cf0ef5cf1012fb90d93857dd5feb2a330493b
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index 3dfcfe7..508cf24 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -368,11 +368,9 @@
 
     @Override
     boolean isVisible() {
-        if (hidden) {
-            // TODO: Should this be checking hiddenRequested instead of hidden?
-            return false;
-        }
-        return super.isVisible();
+        // If the app token isn't hidden then it is considered visible and there is no need to check
+        // its children windows to see if they are visible.
+        return !hidden;
     }
 
     @Override
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index cf360ba..aa4d7be 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1302,7 +1302,22 @@
 
     @Override
     boolean isVisible() {
-        if ((mAppToken == null || !mAppToken.hiddenRequested) && isVisibleUnchecked()) {
+        // TODO: The check for hiddenRequested is commented out below, because the window can still
+        // be visible on screen when the flag is true. We would like the isVisible() method to
+        // return an answer closer to if the window is truly visible (can't be an exact answer
+        // without checking the surface state), so comment out the check for now so we can test to
+        // see what problem it causes.
+        // If it doesn't cause any issues, then we can remove just before we lock down the current
+        // release (O) and also consolidate this method with #isVisibleUnchecked() and possibly
+        // other methods like isVisibleNow().
+        // If it does cause problems, then we can look if there are other ways to solve the problem.
+        // If there isn't then uncomment and document here why it is needed.
+        if (/*(mAppToken == null || !mAppToken.hiddenRequested) && */isVisibleUnchecked()
+            // TODO: The window isn't considered visible when the token is hidden, however
+            // uncommenting the check below breaks the visual transition from an app to the launcher
+            // if the home buttons is pressed. Need to investigate an fix that issue before
+            // uncommenting.
+            /* && !mToken.hidden*/) {
             // Is this window visible?  It is not visible if there is no surface, or we are in the
             // process of running an exit animation that will remove the surface, or its app token
             // has been hidden.