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

Commit 2f731c55 authored by Tarandeep Singh's avatar Tarandeep Singh
Browse files

Add new InputBindResult.ResultCode for no editor

Added a new ResultCode.ERROR_NO_EDITOR for case when there is
no focused editor in the current window. This change should've been included
in Ibf9dab3d9c138b5f04e053d41ee4fd248c78e4da

Bug: 37617707
Fixes: 72913821
Test: Manually check logcats for an activity window:
1. with editor focused
2. with edtior available but not focused (e.g. SearchView)
3. with no editor.
Verified that in all cases, InputBindResult isn't null.

Change-Id: I681b8a452dc7104ca294d5388219cea9ab41e160
parent ee714474
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -139,6 +139,10 @@ public final class InputBindResult implements Parcelable {
         * @see com.android.server.wm.WindowManagerService#inputMethodClientHasFocus(IInputMethodClient)
         */
        int ERROR_NOT_IME_TARGET_WINDOW = 11;
        /**
         * Indicates that focused view in the current window is not an editor.
         */
        int ERROR_NO_EDITOR = 12;
    }

    @ResultCode
@@ -258,6 +262,8 @@ public final class InputBindResult implements Parcelable {
                return "ERROR_NULL";
            case ResultCode.ERROR_NO_IME:
                return "ERROR_NO_IME";
            case ResultCode.ERROR_NO_EDITOR:
                return "ERROR_NO_EDITOR";
            case ResultCode.ERROR_INVALID_PACKAGE_NAME:
                return "ERROR_INVALID_PACKAGE_NAME";
            case ResultCode.ERROR_SYSTEM_NOT_READY:
@@ -287,6 +293,10 @@ public final class InputBindResult implements Parcelable {
     * Predefined error object for {@link ResultCode#NO_IME}.
     */
    public static final InputBindResult NO_IME = error(ResultCode.ERROR_NO_IME);
    /**
     * Predefined error object for {@link ResultCode#NO_EDITOR}.
     */
    public static final InputBindResult NO_EDITOR = error(ResultCode.ERROR_NO_EDITOR);
    /**
     * Predefined error object for {@link ResultCode#ERROR_INVALID_PACKAGE_NAME}.
     */
+13 −6
Original line number Diff line number Diff line
@@ -2970,12 +2970,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                        break;
                }

                if (!didStart && attribute != null) {
                if (!didStart) {
                    if (attribute != null) {
                        if (!DebugFlags.FLAG_OPTIMIZE_START_INPUT.value()
                                || (controlFlags
                                & InputMethodManager.CONTROL_WINDOW_IS_TEXT_EDITOR) != 0) {
                        res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute,
                            res = startInputUncheckedLocked(cs, inputContext, missingMethods,
                                    attribute,
                                    controlFlags, startInputReason);
                        } else {
                            res = InputBindResult.NO_EDITOR;
                        }
                    } else {
                        res = InputBindResult.NULL_EDITOR_INFO;
                    }
                }
            }