Merge "Ignore onStartInput when WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
70ad33113f
@@ -19,6 +19,9 @@ package android.view.inputmethod;
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
|
||||
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
|
||||
|
||||
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR;
|
||||
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR;
|
||||
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
@@ -622,8 +625,11 @@ public final class InputMethodManager {
|
||||
Log.v(TAG, "Reporting focus gain, without startInput"
|
||||
+ ", nextFocusIsServedView=" + nextFocusIsServedView);
|
||||
}
|
||||
final int startInputReason =
|
||||
nextFocusIsServedView ? WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
|
||||
: WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR;
|
||||
mService.startInputOrWindowGainedFocus(
|
||||
StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY, mClient,
|
||||
startInputReason, mClient,
|
||||
focusedView.getWindowToken(), startInputFlags, softInputMode,
|
||||
windowFlags,
|
||||
nextFocusIsServedView ? mCurrentTextBoxAttribute : null,
|
||||
|
||||
@@ -46,8 +46,10 @@ public final class InputMethodDebug {
|
||||
return "UNSPECIFIED";
|
||||
case StartInputReason.WINDOW_FOCUS_GAIN:
|
||||
return "WINDOW_FOCUS_GAIN";
|
||||
case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY:
|
||||
return "WINDOW_FOCUS_GAIN_REPORT_ONLY";
|
||||
case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR:
|
||||
return "WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR";
|
||||
case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR:
|
||||
return "WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR";
|
||||
case StartInputReason.APP_CALLED_RESTART_INPUT_API:
|
||||
return "APP_CALLED_RESTART_INPUT_API";
|
||||
case StartInputReason.CHECK_FOCUS:
|
||||
|
||||
@@ -30,7 +30,8 @@ import java.lang.annotation.Retention;
|
||||
@IntDef(value = {
|
||||
StartInputReason.UNSPECIFIED,
|
||||
StartInputReason.WINDOW_FOCUS_GAIN,
|
||||
StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY,
|
||||
StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR,
|
||||
StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR,
|
||||
StartInputReason.APP_CALLED_RESTART_INPUT_API,
|
||||
StartInputReason.CHECK_FOCUS,
|
||||
StartInputReason.BOUND_TO_IMMS,
|
||||
@@ -49,45 +50,50 @@ public @interface StartInputReason {
|
||||
*/
|
||||
int WINDOW_FOCUS_GAIN = 1;
|
||||
/**
|
||||
* {@link android.view.Window} gained focus but there is no {@link android.view.View} that is
|
||||
* eligible to have IME focus, or the focused view is same as current served view and its
|
||||
* input connection remains. {@link android.view.inputmethod.InputMethodManager} just reports
|
||||
* this window focus change event to sync IME input target for system.
|
||||
* {@link android.view.Window} gained focus and the focused view is same as current served
|
||||
* view and its input connection remains. {@link android.view.inputmethod.InputMethodManager}
|
||||
* just reports this window focus change event to sync IME input target for system.
|
||||
*/
|
||||
int WINDOW_FOCUS_GAIN_REPORT_ONLY = 2;
|
||||
int WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR = 2;
|
||||
/**
|
||||
* {@link android.view.Window} gained focus but there is no {@link android.view.View} that is
|
||||
* eligible to have IME focus. {@link android.view.inputmethod.InputMethodManager} just reports
|
||||
* this window focus change event for logging.
|
||||
*/
|
||||
int WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR = 3;
|
||||
/**
|
||||
* {@link android.view.inputmethod.InputMethodManager#restartInput(android.view.View)} is
|
||||
* either explicitly called by the application or indirectly called by some Framework class
|
||||
* (e.g. {@link android.widget.EditText}).
|
||||
*/
|
||||
int APP_CALLED_RESTART_INPUT_API = 3;
|
||||
int APP_CALLED_RESTART_INPUT_API = 4;
|
||||
/**
|
||||
* {@link android.view.View} requested a new connection because of view focus change.
|
||||
*/
|
||||
int CHECK_FOCUS = 4;
|
||||
int CHECK_FOCUS = 5;
|
||||
/**
|
||||
* {@link android.view.inputmethod.InputMethodManager} is responding to
|
||||
* {@link com.android.internal.view.IInputMethodClient#onBindMethod}.
|
||||
*/
|
||||
int BOUND_TO_IMMS = 5;
|
||||
int BOUND_TO_IMMS = 6;
|
||||
/**
|
||||
* {@link android.view.inputmethod.InputMethodManager} is responding to
|
||||
* {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}.
|
||||
*/
|
||||
int UNBOUND_FROM_IMMS = 6;
|
||||
int UNBOUND_FROM_IMMS = 7;
|
||||
/**
|
||||
* {@link android.view.inputmethod.InputMethodManager} is responding to
|
||||
* {@link com.android.internal.view.IInputMethodClient#setActive}.
|
||||
*/
|
||||
int ACTIVATED_BY_IMMS = 7;
|
||||
int ACTIVATED_BY_IMMS = 8;
|
||||
/**
|
||||
* {@link android.view.inputmethod.InputMethodManager} is responding to
|
||||
* {@link com.android.internal.view.IInputMethodClient#setActive}.
|
||||
*/
|
||||
int DEACTIVATED_BY_IMMS = 8;
|
||||
int DEACTIVATED_BY_IMMS = 9;
|
||||
/**
|
||||
* {@link com.android.server.inputmethod.InputMethodManagerService} is responding to
|
||||
* {@link com.android.internal.view.IInputSessionCallback#sessionCreated}.
|
||||
*/
|
||||
int SESSION_CREATED_BY_IME = 9;
|
||||
int SESSION_CREATED_BY_IME = 10;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.server.inputmethod;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
|
||||
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -710,6 +712,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
*/
|
||||
int mImeWindowVis;
|
||||
|
||||
/**
|
||||
* Checks if the client needs to start input.
|
||||
*/
|
||||
private boolean mCurClientNeedStartInput = false;
|
||||
|
||||
private AlertDialog.Builder mDialogBuilder;
|
||||
private AlertDialog mSwitchingDialog;
|
||||
private IBinder mSwitchingDialogToken = new Binder();
|
||||
@@ -3425,10 +3432,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client
|
||||
+ " attribute=" + attribute + ", token = " + windowToken);
|
||||
}
|
||||
if (attribute != null) {
|
||||
// Needs to start input when the same window focus gain but not with the same editor,
|
||||
// or when the current client needs to start input (e.g. when focusing the same
|
||||
// window after device turned screen on).
|
||||
if (attribute != null && (startInputReason != WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
|
||||
|| mCurClientNeedStartInput)) {
|
||||
if (mIsInteractive) {
|
||||
mCurClientNeedStartInput = false;
|
||||
}
|
||||
return startInputUncheckedLocked(cs, inputContext, missingMethods,
|
||||
attribute, startInputFlags, startInputReason);
|
||||
}
|
||||
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_REPORT_WINDOW_FOCUS_ONLY,
|
||||
null, null, null, -1, null);
|
||||
@@ -4381,6 +4396,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
private void handleSetInteractive(final boolean interactive) {
|
||||
synchronized (mMethodMap) {
|
||||
mIsInteractive = interactive;
|
||||
if (!interactive) {
|
||||
mCurClientNeedStartInput = true;
|
||||
}
|
||||
updateSystemUiLocked(interactive ? mImeWindowVis : 0, mBackDisposition);
|
||||
|
||||
// Inform the current client of the change in active status
|
||||
|
||||
Reference in New Issue
Block a user