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

Commit 05c25f8a authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Unify windowGainedFocus() and startInput().

This is a safe refactoring that changes nothing.

In order to improve the keyboard dismissal lags [1][2], we have used
IMMS#windowGainedFocus() as a combined event to do startInput() in
certain situations.

To make the intent of those CLs clear, this CL renames
IMMS#windowGainedFocus() to IMMS#startInputOrWindowGainedFocus().  Note
that these are @hide internal IPC protocols.  Hence this change is never
observable to application developers.

 [1] I8494cbd6e19e2ab6db03f2463d9906680dda058b
     a82ba54b
 [2] Icb58bef75ef4bf9979f3e2ba88cea20db2e2c3fb
     7663d80f

Bug: 25373872
Change-Id: I56934f18e30d90fcdf77bcbb0c35a92a5feb1b82
parent 9cea80cd
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -1245,15 +1245,9 @@ public final class InputMethodManager {
                if (DEBUG) Log.v(TAG, "START INPUT: " + view + " ic="
                        + ic + " tba=" + tba + " controlFlags=#"
                        + Integer.toHexString(controlFlags));
                InputBindResult res;
                if (windowGainingFocus != null) {
                    res = mService.windowGainedFocus(startInputReason, mClient, windowGainingFocus,
                            controlFlags, softInputMode, windowFlags,
                            tba, servedContext);
                } else {
                    res = mService.startInput(startInputReason, mClient,
                            servedContext, tba, controlFlags);
                }
                final InputBindResult res = mService.startInputOrWindowGainedFocus(
                        startInputReason, mClient, windowGainingFocus, controlFlags, softInputMode,
                        windowFlags, tba, servedContext);
                if (DEBUG) Log.v(TAG, "Starting input: Bind result=" + res);
                if (res != null) {
                    if (res.id != null) {
@@ -1477,7 +1471,7 @@ public final class InputMethodManager {
        synchronized (mH) {
            try {
                if (DEBUG) Log.v(TAG, "Reporting focus gain, without startInput");
                mService.windowGainedFocus(
                mService.startInputOrWindowGainedFocus(
                        InputMethodClient.START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY, mClient,
                        rootView.getWindowToken(), controlFlags, softInputMode, windowFlags, null,
                        null);
+3 −6
Original line number Diff line number Diff line
@@ -46,17 +46,14 @@ interface IInputMethodManager {
            in IInputContext inputContext, int uid, int pid);
    void removeClient(in IInputMethodClient client);

    InputBindResult startInput(/* @InputMethodClient.StartInputReason */ int startInputReason,
            in IInputMethodClient client, IInputContext inputContext, in EditorInfo attribute,
            int controlFlags);
    void finishInput(in IInputMethodClient client);
    boolean showSoftInput(in IInputMethodClient client, int flags,
            in ResultReceiver resultReceiver);
    boolean hideSoftInput(in IInputMethodClient client, int flags,
            in ResultReceiver resultReceiver);
    // Report that a window has gained focus.  If 'attribute' is non-null,
    // this will also do a startInput.
    InputBindResult windowGainedFocus(
    // If windowToken is null, this just does startInput().  Otherwise this reports that a window
    // has gained focus, and if 'attribute' is non-null then also does startInput.
    InputBindResult startInputOrWindowGainedFocus(
            /* @InputMethodClient.StartInputReason */ int startInputReason,
            in IInputMethodClient client, in IBinder windowToken, int controlFlags,
            int softInputMode, int windowFlags, in EditorInfo attribute,
+14 −3
Original line number Diff line number Diff line
@@ -1458,8 +1458,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        return null;
    }

    @Override
    public InputBindResult startInput(
    private InputBindResult startInput(
            /* @InputMethodClient.StartInputReason */ final int startInputReason,
            IInputMethodClient client, IInputContext inputContext, EditorInfo attribute,
            int controlFlags) {
@@ -2197,7 +2196,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    }

    @Override
    public InputBindResult windowGainedFocus(
    public InputBindResult startInputOrWindowGainedFocus(
            /* @InputMethodClient.StartInputReason */ final int startInputReason,
            IInputMethodClient client, IBinder windowToken, int controlFlags, int softInputMode,
            int windowFlags, EditorInfo attribute, IInputContext inputContext) {
        if (windowToken != null) {
            return windowGainedFocus(startInputReason, client, windowToken, controlFlags,
                    softInputMode, windowFlags, attribute, inputContext);
        } else {
            return startInput(startInputReason, client, inputContext, attribute, controlFlags);
        }
    }

    private InputBindResult windowGainedFocus(
            /* @InputMethodClient.StartInputReason */ final int startInputReason,
            IInputMethodClient client, IBinder windowToken, int controlFlags, int softInputMode,
            int windowFlags, EditorInfo attribute, IInputContext inputContext) {