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

Commit 55b543e1 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Do some actions eagerly for IInputMethod#startInput()

This CL moves some operations from DO_START_INPUT handler to
IInputMethod#startInput() binder callback, which should be safe
because calling EditorInfo#makeCompatible() and instantiating
RemoteInputConnection are both OK to be done eagerly.

There should be no developer observable behavior change in this CL.

Bug: 234882948
Test: presubmit
Change-Id: I69e8bc5515d09824ed19e68f585590447e130a38
parent 29173f1d
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -195,18 +195,13 @@ class IInputMethodWrapper extends IInputMethod.Stub
            case DO_START_INPUT: {
                final SomeArgs args = (SomeArgs) msg.obj;
                final IBinder startInputToken = (IBinder) args.arg1;
                final IRemoteInputConnection remoteIc = (IRemoteInputConnection) args.arg2;
                final InputConnection ic = (InputConnection) args.arg2;
                final EditorInfo info = (EditorInfo) args.arg3;
                final ImeOnBackInvokedDispatcher imeDispatcher =
                        (ImeOnBackInvokedDispatcher) args.arg4;
                final CancellationGroup cancellationGroup = (CancellationGroup) args.arg5;
                final boolean restarting = args.argi1 == 1;
                @InputMethodNavButtonFlags
                final int navButtonFlags = args.argi2;
                final InputConnection ic = remoteIc != null
                        ? new RemoteInputConnection(mTarget, remoteIc, cancellationGroup)
                        : null;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.dispatchStartInputWithToken(ic, info, restarting, startInputToken,
                        navButtonFlags, imeDispatcher);
                args.recycle();
@@ -358,14 +353,19 @@ class IInputMethodWrapper extends IInputMethod.Stub
            Log.e(TAG, "startInput must be called after bindInput.");
            mCancellationGroup = new CancellationGroup();
        }

        editorInfo.makeCompatible(mTargetSdkVersion);

        final InputConnection ic = inputConnection == null ? null
                : new RemoteInputConnection(mTarget, inputConnection, mCancellationGroup);

        final SomeArgs args = SomeArgs.obtain();
        args.arg1 = startInputToken;
        args.arg2 = inputConnection;
        args.arg2 = ic;
        args.arg3 = editorInfo;
        args.argi1 = restarting ? 1 : 0;
        args.argi2 = navButtonFlags;
        args.arg4 = imeDispatcher;
        args.arg5 = mCancellationGroup;
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_START_INPUT, args));
    }