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

Commit e525c014 authored by Wilson Wu's avatar Wilson Wu
Browse files

Fix IME be dismissed abruptly

CL[1] used to fix some IME animation issue.
And simplified the check focused view logic.

But when window focus changed, the focused view
may still be null. So ImeFocusdController use the
DecorView to start an new Input and hide keyboard.

Use the focused view after focus change callbacks
when we call onPostWindowFocus as before.

[1]: Ib140801f1ce03b5566e756914f96dacba3ad8892

Bug: 186331446
Test: Manual test with the bug steps
Test: atest FocusHandlingTest#testRequestFocusOnWindowFocusChanged
Change-Id: I2f8fde0b6575db17955ff8b8804b61378f9d6dad
parent 9b60ca5d
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -3370,9 +3370,9 @@ public final class ViewRootImpl implements ViewParent,
        }
        // TODO (b/131181940): Make sure this doesn't leak Activity with mActivityConfigCallback
        // config changes.
        final View focusedView = mView != null ? mView.findFocus() : null;
        if (hasWindowFocus) {
            mInsetsController.onWindowFocusGained(focusedView != null /* hasViewFocused */);
            mInsetsController.onWindowFocusGained(
                    getFocusedViewOrNull() != null /* hasViewFocused */);
        } else {
            mInsetsController.onWindowFocusLost();
        }
@@ -3421,7 +3421,8 @@ public final class ViewRootImpl implements ViewParent,

            // Note: must be done after the focus change callbacks,
            // so all of the view state is set up correctly.
            mImeFocusController.onPostWindowFocus(focusedView, hasWindowFocus, mWindowAttributes);
            mImeFocusController.onPostWindowFocus(
                    getFocusedViewOrNull(), hasWindowFocus, mWindowAttributes);

            if (hasWindowFocus) {
                // Clear the forward bit.  We can just do this directly, since
@@ -6390,6 +6391,11 @@ public final class ViewRootImpl implements ViewParent,
        mView.dispatchTooltipHoverEvent(event);
    }

    @Nullable
    private View getFocusedViewOrNull() {
        return mView != null ? mView.findFocus() : null;
    }

    /**
     * Performs synthesis of new input events from unhandled input events.
     */