From 2f731c5585391e94dc80cbf19ce3fea1b088d322 Mon Sep 17 00:00:00 2001 From: Tarandeep Singh Date: Mon, 5 Feb 2018 13:55:06 -0800 Subject: [PATCH] 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 --- .../internal/view/InputBindResult.java | 10 ++++++++++ .../server/InputMethodManagerService.java | 19 +++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/core/java/com/android/internal/view/InputBindResult.java b/core/java/com/android/internal/view/InputBindResult.java index 74dbaba320434..f05bd32ba2cd0 100644 --- a/core/java/com/android/internal/view/InputBindResult.java +++ b/core/java/com/android/internal/view/InputBindResult.java @@ -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}. */ diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 2f425859fec4c..93f7f1d12922d 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -2970,12 +2970,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub break; } - if (!didStart && attribute != null) { - if (!DebugFlags.FLAG_OPTIMIZE_START_INPUT.value() - || (controlFlags - & InputMethodManager.CONTROL_WINDOW_IS_TEXT_EDITOR) != 0) { - res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute, - controlFlags, startInputReason); + 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, + controlFlags, startInputReason); + } else { + res = InputBindResult.NO_EDITOR; + } + } else { + res = InputBindResult.NULL_EDITOR_INFO; } } }