Always tell Keyguard about occluded state

If there was a window with FLAG_DISMISS_KEYGUARD first, when the
device was unlocked, mWinDismissingKeyguard was set to that window.

Now, a window with FLAG_SHOW_WHEN_LOCKED came on top, so we set the
Keyguard as occluded, but we didn't reset the window that is
dismissing Keyguard.

After that, the old window with FLAG_DISMISS_KEYGUARD was the focused
window again. However, since we didn't reset mWinDismissingKeyguard,
we ended up with DISMISS_KEYGUARD_CONTINUE, and lockscreen was not
occluded anymore. However, we never really told Keyguard about it
because DISMISS_KEYGUARD_CONTINUE was set instead of
DISMISS_KEYGUARD_START.

The first fix of this bug is to always tell Keyguard about the
current occluded state. The second fix is to reset
mWinDismissingKeyguard in case a window SHOW_WHEN_LOCKED comes on top.

Bug: 20102975
Change-Id: I7c778df09a1e393b9eeaf51fd2013012cb40fea9
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 7d14d47..38ed20d 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -4387,21 +4387,21 @@
                 }
             } else if (mHideLockScreen) {
                 mKeyguardHidden = true;
+                mWinDismissingKeyguard = null;
                 if (setKeyguardOccludedLw(true)) {
                     changes |= FINISH_LAYOUT_REDO_LAYOUT
                             | FINISH_LAYOUT_REDO_CONFIG
                             | FINISH_LAYOUT_REDO_WALLPAPER;
                 }
             } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) {
-                // This is the case of keyguard isSecure() and not mHideLockScreen.
+                mKeyguardHidden = false;
+                if (setKeyguardOccludedLw(false)) {
+                    changes |= FINISH_LAYOUT_REDO_LAYOUT
+                            | FINISH_LAYOUT_REDO_CONFIG
+                            | FINISH_LAYOUT_REDO_WALLPAPER;
+                }
                 if (mDismissKeyguard == DISMISS_KEYGUARD_START) {
                     // Only launch the next keyguard unlock window once per window.
-                    mKeyguardHidden = false;
-                    if (setKeyguardOccludedLw(false)) {
-                        changes |= FINISH_LAYOUT_REDO_LAYOUT
-                                | FINISH_LAYOUT_REDO_CONFIG
-                                | FINISH_LAYOUT_REDO_WALLPAPER;
-                    }
                     mHandler.post(new Runnable() {
                         @Override
                         public void run() {