Fix IME Keyguard exit animation

Keyguard exit animation was always applied no matter whether the
current window is shown or not. Because Keyguard exit starts with
alpha=0, this lead to a flicker with the IME window as a frame
later IME was applied its dismissal animation, which reverts it to
alpha=1 at the beginning.

Fix this by only applying exit animation if window is currently
hidden only by policy. Requires readding the old visibility method
*cough cough cough*

Ideally we would apply non-app window policy visibility/animation
at the same place...but today is not the day! (to minimize risk)

Test: Set password, unlock phone
Test: Don't set password, unlock to activity with IME up
Change-Id: I46110c80da4438223282903fd4defeba2c3f0550
Fixes: 36200726
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index c59065f..257f285 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -2494,7 +2494,8 @@
     void startKeyguardExitOnNonAppWindows(boolean onWallpaper, boolean goingToShade) {
         final WindowManagerPolicy policy = mService.mPolicy;
         forAllWindows(w -> {
-            if (w.mAppToken == null && policy.canBeHiddenByKeyguardLw(w)) {
+            if (w.mAppToken == null && policy.canBeHiddenByKeyguardLw(w)
+                    && w.wouldBeVisibleIfPolicyIgnored() && !w.isVisible()) {
                 w.mWinAnimator.setAnimation(
                         policy.createHiddenByKeyguardExit(onWallpaper, goingToShade));
             }