Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 233164c9 authored by lumark's avatar lumark
Browse files

Fix Keyboard won't show up in some cases

Commit 970d9d2e introduced IME focus controller which
added a new method View#hasImeFocus to restrict IME focus
only when the focused window won't have either FLAG_NOT_FOCUSABLE
or FLAG_ALT_FOCUSABLE_IM flags.

Since NotificationShadeWindowController will unset both flags when
RemoteInput active (or when PasswordEntry focused on lockscreen).

But, in ImeFocusControler#onTraversal won't keep update View#hasImeFocus
state, it will affect IME focus handle correctness.

Hence, it needs to fix View#hasImeFocus state update issue.

Fix: 148489857
Fix: 148788569
Bug: 141738570
Test: manual as following steps:
Case 1:
 0) make EditTextVariations
 1) adb install -r EditTextVariations.apk
 2) adb shell am start -n com.android.inputmethod.tools.edittextvariations/.EditTextVariations
 3) Tap the 3-dot menu on the EditTextVariations
 4) Tap `Direct Reply` on the menu
 5) Open notification drawers
 6) Try to direct-reply on the notification, expect soft-keyboard should come up after step 6)

Case 2:
 1) Device set up with Pwd lockscreen security. Finish setting up the device.
 2) Once the device goes into sleep mode > Wake up the device > Swipe up locksreen.
 3) Observing that the keyboard should come up consistently.

Change-Id: I8d4fff94ba9313b773bc27fcbd019cc88580d3e9
parent e3ada502
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -253,4 +253,12 @@ public final class ImeFocusController {
    public void setNextServedView(View view) {
        mNextServedView = view;
    }

    /**
     * Indicates whether the view's window has IME focused.
     */
    @UiThread
    boolean hasImeFocus() {
        return mHasImeFocus;
    }
}
+1 −6
Original line number Diff line number Diff line
@@ -14469,7 +14469,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    public boolean hasImeFocus() {
        return mAttachInfo != null && mAttachInfo.mHasImeFocus;
        return getViewRootImpl() != null && getViewRootImpl().getImeFocusController().hasImeFocus();
    }
    /**
@@ -28722,11 +28722,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        @UnsupportedAppUsage
        boolean mHasWindowFocus;
        /**
         * Indicates whether the view's window has IME focused.
         */
        boolean mHasImeFocus;
        /**
         * The current visibility of the window.
         */
+1 −2
Original line number Diff line number Diff line
@@ -3143,8 +3143,7 @@ public final class ViewRootImpl implements ViewParent,
            }

            mAttachInfo.mHasWindowFocus = hasWindowFocus;
            mAttachInfo.mHasImeFocus = mImeFocusController.updateImeFocusable(
                    mWindowAttributes, true /* force */);
            mImeFocusController.updateImeFocusable(mWindowAttributes, true /* force */);
            mImeFocusController.onPreWindowFocus(hasWindowFocus, mWindowAttributes);

            if (mView != null) {
+5 −0
Original line number Diff line number Diff line
@@ -671,6 +671,11 @@ public final class InputMethodManager {
                mWindowFocusGainFuture = null;
            }
            synchronized (mH) {
                if (mCurRootView != null) {
                    // Reset the last served view and restart window focus state of the root view.
                    mCurRootView.getImeFocusController().setServedView(null);
                    mRestartOnNextWindowFocus = true;
                }
                mCurRootView = rootView;
            }
        }