Handle keyguard dismiss flags correctly

When FLAG_SHOW_WHEN_LOCKED was set over an unsecure lockscreen the
behavior was incorrect. In such cases the lockscreen was not being
dismissed with or without FLAG_DISMISS_KEYGUARD. This change causes
the lockscreen to be dismissed when FLAG_SHOW_WHEN_LOCKED is set
over an insecure logckscreen.

Fixes bug 18563298.

Change-Id: Iba0d096a59789bf41332e109f1bd3e70834bbb83
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index ca0d481..8b53a62 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -4055,12 +4055,12 @@
                     mAppsToBeHidden.remove(appToken);
                     mAppsThatDismissKeyguard.remove(appToken);
                     if (mAppsToBeHidden.isEmpty()) {
-                        if (mKeyguardSecureIncludingHidden) {
+                        if (dismissKeyguard && !mKeyguardSecure) {
+                            mAppsThatDismissKeyguard.add(appToken);
+                        } else {
                             mWinShowWhenLocked = win;
                             mHideLockScreen = true;
                             mForceStatusBarFromKeyguard = false;
-                        } else if (dismissKeyguard && !mKeyguardSecure) {
-                            mAppsThatDismissKeyguard.add(appToken);
                         }
                     }
                 } else if (dismissKeyguard) {