Check that the window which wants to force hide is visible before setting the flag forceHiding to true. If we do layout the surfaces
again this flag gets set no matter what since the keyguard window is always present in the list of tokens and this hides the window which would
have become visible since the keyguard just got dismissed.
This causes unnecessary focus changes due to changes in visibility of current window.

This will resolve issues related to current focus and time outs when dispatching key events.
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 6418901..94667eb 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -9653,7 +9653,8 @@
                             WindowState w = (WindowState)mWindows.get(i);
                             if (w.mSurface != null) {
                                 final WindowManager.LayoutParams attrs = w.mAttrs;
-                                if (mPolicy.doesForceHide(w, attrs)) {
+                                if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) {
+                                    if (DEBUG_FOCUS) Log.i(TAG, "win=" + w + " force hides other windows");
                                     forceHiding = true;
                                 } else if (mPolicy.canBeForceHidden(w, attrs)) {
                                     if (!w.mAnimating) {