OSDN Git Service

Fixed constant window switching on lock screen with Swype KB.
authorWale Ogunwale <ogunwale@google.com>
Fri, 7 Nov 2014 20:13:02 +0000 (12:13 -0800)
committerWale Ogunwale <ogunwale@google.com>
Wed, 12 Nov 2014 16:42:09 +0000 (08:42 -0800)
We allow TYPE_INPUT_METHOD windows to show on the lock screen.
These windows can attached other types of windows (For this
case the Swype KB was attaching a PopupWinow which will be
of TYPE_APPLICATION). This causes the popup window app token
to be added to the list of apps to be hidden on the lock
screen, thereby preventing the lock screen from been hidden,
which then causes a layout cycle(s). Now, we remove app
tokens for non-app windows from the hidden list in case it
was added by any attached widow they migth have.

Also, when we are updating window animations, set the
hideWhenLocked flag for windows that are IME tragets so
they don't go through unneeded cycles of having their
visibility policy set to hide/show/hide/show/...

Bug: 18021493
Change-Id: I3680256d41793f62def42fda00e26db1dcc990cc

core/java/android/view/WindowManagerPolicy.java
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
services/core/java/com/android/server/wm/WindowAnimator.java
services/core/java/com/android/server/wm/WindowManagerService.java

index b8e94ee..94f3e7a 100644 (file)
@@ -901,12 +901,13 @@ public interface WindowManagerPolicy {
 
     /**
      * Called following layout of all window to apply policy to each window.
-     * 
+     *
      * @param win The window being positioned.
-     * @param attrs The LayoutParams of the window. 
+     * @param attrs The LayoutParams of the window.
+     * @param attached For sub-windows, the window it is attached to. Otherwise null.
      */
     public void applyPostLayoutPolicyLw(WindowState win,
-            WindowManager.LayoutParams attrs);
+            WindowManager.LayoutParams attrs, WindowState attached);
 
     /**
      * Called following layout of all windows and after policy has been applied
index 24de9a8..b670584 100644 (file)
@@ -3985,7 +3985,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
 
     /** {@inheritDoc} */
     @Override
-    public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs) {
+    public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs,
+            WindowState attached) {
+
         if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
                 + win.isVisibleOrBehindKeyguardLw());
         final int fl = PolicyControl.getWindowFlags(win, attrs);
@@ -4024,8 +4026,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
             final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0;
             final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0;
             final boolean secureKeyguard = isKeyguardSecure();
-            if (appWindow) {
-                final IApplicationToken appToken = win.getAppToken();
+            final IApplicationToken appToken = win.getAppToken();
+
+            // For app windows that are not attached, we decide if all windows in the app they
+            // represent should be hidden or if we should hide the lockscreen. For attached app
+            // windows we defer the decision to the window it is attached to.
+            if (appWindow && attached == null) {
                 if (showWhenLocked) {
                     // Remove any previous windows with the same appToken.
                     mAppsToBeHidden.remove(appToken);
index a90cc95..5deb1cd 100644 (file)
@@ -333,7 +333,7 @@ public class WindowAnimator {
                             + " hidden=" + win.mRootToken.hidden
                             + " anim=" + win.mWinAnimator.mAnimation);
                 } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
-                    final boolean hideWhenLocked = !((win.mIsImWindow && showImeOverKeyguard) ||
+                    final boolean hideWhenLocked = !((win.mIsImWindow || imeTarget == win) && showImeOverKeyguard) ||
                             (appShowWhenLocked != null && (appShowWhenLocked == win.mAppToken ||
                                     // Show error dialogs over apps that dismiss keyguard.
                                     (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0)));
index 1e492a5..eb418ed 100644 (file)
@@ -9687,7 +9687,7 @@ public class WindowManagerService extends IWindowManager.Stub
                         for (i = windows.size() - 1; i >= 0; i--) {
                             WindowState w = windows.get(i);
                             if (w.mHasSurface) {
-                                mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs);
+                                mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs, w.mAttachedWindow);
                             }
                         }
                         displayContent.pendingLayoutChanges |= mPolicy.finishPostLayoutPolicyLw();