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

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

[DO NOT MERGE] DisplayImeController: fix out-of-sync IME visibility

This change is based on CL[1] in rvc-qpr-dev code base.

Note: This cherry-picked change isn't completely same as master one,
it add a method "getImeRequestedVisibility" in InsetsControlTarget
since "getRequestedVisibility" didn't exist in rvc-qpr currently.

Fixes an issue where the DisplayImeController would disagree with
the InputMethodManagerService about the visibility of the IME.

Currently, the Insets component is supposed to execute the
visibility as dictated by IMMS; however, when the DisplayImeController
became the control target, previously it would just apply the IME
visibility that was last requested of it - regardless of the
changes to it that may have happened while it was not the control
target.

Eventually, IME visibility should be driven by the requested IME
inset visibility of the focused window, instead of the separate
dispatch we have now from IMMS.

[1]:I1f140af6bcccbcbe6efb2fde9a789ac4c7bd127f

Bug: 167780081
Test: atest ImeInsetsSourceProviderTest
Change-Id: I3962f3aa26d9325d7d8a4611f13a637d46337fef
parent 0d094ad3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -203,6 +203,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                    return;
                }

                mImeShowing = insetsState.getSourceOrDefaultVisibility(InsetsState.ITYPE_IME);

                final InsetsSource newSource = insetsState.getSource(InsetsState.ITYPE_IME);
                final Rect newFrame = newSource.getFrame();
                final Rect oldFrame = mInsetsState.getSource(InsetsState.ITYPE_IME).getFrame();
+5 −0
Original line number Diff line number Diff line
@@ -5877,6 +5877,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                Slog.w(TAG, "Failed to deliver showInsets", e);
            }
        }

        @Override
        public boolean getImeRequestedVisibility(@InternalInsetsType int type) {
            return getInsetsStateController().getImeSourceProvider().isImeShowing();
        }
    }

    /**
+23 −3
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
    private InsetsControlTarget mImeTargetFromIme;
    private Runnable mShowImeRunner;
    private boolean mIsImeLayoutDrawn;
    private boolean mImeShowing;

    ImeInsetsSourceProvider(InsetsSource source,
            InsetsStateController stateController, DisplayContent displayContent) {
@@ -74,6 +75,7 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {

                ProtoLog.i(WM_DEBUG_IME, "call showInsets(ime) on %s",
                        target.getWindow() != null ? target.getWindow().getName() : "");
                setImeShowing(true);
                target.showInsets(WindowInsets.Type.ime(), true /* fromIme */);
                if (target != mImeTargetFromIme && mImeTargetFromIme != null) {
                    ProtoLog.w(WM_DEBUG_IME,
@@ -147,11 +149,29 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
    @Override
    public void dump(PrintWriter pw, String prefix) {
        super.dump(pw, prefix);
        if (mImeTargetFromIme != null) {
        pw.print(prefix);
        pw.print("mImeShowing=");
        pw.print(mImeShowing);
        if (mImeTargetFromIme != null) {
            pw.print(" showImePostLayout pending for mImeTargetFromIme=");
            pw.print(mImeTargetFromIme);
        }
        pw.println();
    }

    /**
     * Sets whether the IME is currently supposed to be showing according to
     * InputMethodManagerService.
     */
    public void setImeShowing(boolean imeShowing) {
        mImeShowing = imeShowing;
    }

    /**
     * Returns whether the IME is currently supposed to be showing according to
     * InputMethodManagerService.
     */
    public boolean isImeShowing() {
        return mImeShowing;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,13 @@ interface InsetsControlTarget {
        return null;
    }

    /**
     * @return The requested visibility of this target.
     */
    default boolean getImeRequestedVisibility(@InsetsState.InternalInsetsType int type) {
        return InsetsState.getDefaultVisibility(type);
    }

    /**
     * @return The requested {@link InsetsState} of this target.
     */
+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ class InsetsSourceProvider {
        }
        mAdapter = new ControlAdapter();
        if (getSource().getType() == ITYPE_IME) {
            setClientVisible(InsetsState.getDefaultVisibility(mSource.getType()));
            setClientVisible(target.getImeRequestedVisibility(mSource.getType()));
        }
        final Transaction t = mDisplayContent.getPendingTransaction();
        mWin.startAnimation(t, mAdapter, !mClientVisible /* hidden */,
Loading