Merge "Refine {SHOW,HIDE}_MY_SOFT_INPUT constants" into tm-qpr-dev
This commit is contained in:
@@ -148,6 +148,7 @@ import com.android.internal.inputmethod.ImeTracing;
|
||||
import com.android.internal.inputmethod.InputMethodNavButtonFlags;
|
||||
import com.android.internal.inputmethod.InputMethodPrivilegedOperations;
|
||||
import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry;
|
||||
import com.android.internal.inputmethod.SoftInputShowHideReason;
|
||||
import com.android.internal.util.RingBuffer;
|
||||
import com.android.internal.view.IInlineSuggestionsRequestCallback;
|
||||
import com.android.internal.view.IInputContext;
|
||||
@@ -2962,9 +2963,13 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
* @param flags Provides additional operating flags.
|
||||
*/
|
||||
public void requestHideSelf(int flags) {
|
||||
requestHideSelf(flags, SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_IME);
|
||||
}
|
||||
|
||||
private void requestHideSelf(int flags, @SoftInputShowHideReason int reason) {
|
||||
ImeTracing.getInstance().triggerServiceDump("InputMethodService#requestHideSelf", mDumper,
|
||||
null /* icProto */);
|
||||
mPrivOps.hideMySoftInput(flags);
|
||||
mPrivOps.hideMySoftInput(flags, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2985,7 +2990,9 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
if (mShowInputRequested) {
|
||||
// If the soft input area is shown, back closes it and we
|
||||
// consume the back key.
|
||||
if (doIt) requestHideSelf(0);
|
||||
if (doIt) {
|
||||
requestHideSelf(0 /* flags */, SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_BACK_KEY);
|
||||
}
|
||||
return true;
|
||||
} else if (mDecorViewVisible) {
|
||||
if (mCandidatesVisibility == View.VISIBLE) {
|
||||
@@ -3136,7 +3143,8 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
private void onToggleSoftInput(int showFlags, int hideFlags) {
|
||||
if (DEBUG) Log.v(TAG, "toggleSoftInput()");
|
||||
if (isInputViewShown()) {
|
||||
requestHideSelf(hideFlags);
|
||||
requestHideSelf(
|
||||
hideFlags, SoftInputShowHideReason.HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT);
|
||||
} else {
|
||||
requestShowSelf(showFlags);
|
||||
}
|
||||
@@ -3571,7 +3579,8 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
*/
|
||||
public void onExtractingInputChanged(EditorInfo ei) {
|
||||
if (ei.inputType == InputType.TYPE_NULL) {
|
||||
requestHideSelf(InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
requestHideSelf(InputMethodManager.HIDE_NOT_ALWAYS,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2596,7 +2596,7 @@ public final class InputMethodManager {
|
||||
try {
|
||||
mService.hideSoftInput(mClient, windowToken, 0 /* flags */,
|
||||
null /* resultReceiver */,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT);
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -2989,7 +2989,8 @@ public final class InputMethodManager {
|
||||
*/
|
||||
@Deprecated
|
||||
public void hideSoftInputFromInputMethod(IBinder token, int flags) {
|
||||
InputMethodPrivilegedOperationsRegistry.get(token).hideMySoftInput(flags);
|
||||
InputMethodPrivilegedOperationsRegistry.get(token).hideMySoftInput(
|
||||
flags, SoftInputShowHideReason.HIDE_SOFT_INPUT_IMM_DEPRECATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ oneway interface IInputMethodPrivilegedOperations {
|
||||
void setInputMethod(String id, in AndroidFuture future /* T=Void */);
|
||||
void setInputMethodAndSubtype(String id, in InputMethodSubtype subtype,
|
||||
in AndroidFuture future /* T=Void */);
|
||||
void hideMySoftInput(int flags, in AndroidFuture future /* T=Void */);
|
||||
void hideMySoftInput(int flags, int reason, in AndroidFuture future /* T=Void */);
|
||||
void showMySoftInput(int flags, in AndroidFuture future /* T=Void */);
|
||||
void updateStatusIconAsync(String packageName, int iconId);
|
||||
void switchToPreviousInputMethod(in AndroidFuture future /* T=Boolean */);
|
||||
|
||||
@@ -194,12 +194,12 @@ public final class InputMethodDebug {
|
||||
return "SHOW_SOFT_INPUT";
|
||||
case SoftInputShowHideReason.ATTACH_NEW_INPUT:
|
||||
return "ATTACH_NEW_INPUT";
|
||||
case SoftInputShowHideReason.SHOW_MY_SOFT_INPUT:
|
||||
return "SHOW_MY_SOFT_INPUT";
|
||||
case SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME:
|
||||
return "SHOW_SOFT_INPUT_FROM_IME";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT:
|
||||
return "HIDE_SOFT_INPUT";
|
||||
case SoftInputShowHideReason.HIDE_MY_SOFT_INPUT:
|
||||
return "HIDE_MY_SOFT_INPUT";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_IME:
|
||||
return "HIDE_SOFT_INPUT_FROM_IME";
|
||||
case SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV:
|
||||
return "SHOW_AUTO_EDITOR_FORWARD_NAV";
|
||||
case SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV:
|
||||
@@ -242,6 +242,16 @@ public final class InputMethodDebug {
|
||||
return "SHOW_SOFT_INPUT_BY_INSETS_API";
|
||||
case SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE:
|
||||
return "HIDE_DISPLAY_IME_POLICY_HIDE";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API:
|
||||
return "HIDE_SOFT_INPUT_BY_INSETS_API";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_BACK_KEY:
|
||||
return "HIDE_SOFT_INPUT_BY_BACK_KEY";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT:
|
||||
return "HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED:
|
||||
return "HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED";
|
||||
case SoftInputShowHideReason.HIDE_SOFT_INPUT_IMM_DEPRECATION:
|
||||
return "HIDE_SOFT_INPUT_IMM_DEPRECATION";
|
||||
default:
|
||||
return "Unknown=" + reason;
|
||||
}
|
||||
|
||||
@@ -253,18 +253,19 @@ public final class InputMethodPrivilegedOperations {
|
||||
* Calls {@link IInputMethodPrivilegedOperations#hideMySoftInput(int, IVoidResultCallback)}
|
||||
*
|
||||
* @param flags additional operating flags
|
||||
* @param reason the reason to hide soft input
|
||||
* @see android.view.inputmethod.InputMethodManager#HIDE_IMPLICIT_ONLY
|
||||
* @see android.view.inputmethod.InputMethodManager#HIDE_NOT_ALWAYS
|
||||
*/
|
||||
@AnyThread
|
||||
public void hideMySoftInput(int flags) {
|
||||
public void hideMySoftInput(int flags, @SoftInputShowHideReason int reason) {
|
||||
final IInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
|
||||
if (ops == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final AndroidFuture<Void> future = new AndroidFuture<>();
|
||||
ops.hideMySoftInput(flags, future);
|
||||
ops.hideMySoftInput(flags, reason, future);
|
||||
CompletableFutureUtil.getResult(future);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -19,8 +19,11 @@ package com.android.internal.inputmethod;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.os.IBinder;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@@ -31,9 +34,9 @@ import java.lang.annotation.Retention;
|
||||
@IntDef(value = {
|
||||
SoftInputShowHideReason.SHOW_SOFT_INPUT,
|
||||
SoftInputShowHideReason.ATTACH_NEW_INPUT,
|
||||
SoftInputShowHideReason.SHOW_MY_SOFT_INPUT,
|
||||
SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT,
|
||||
SoftInputShowHideReason.HIDE_MY_SOFT_INPUT,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_IME,
|
||||
SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV,
|
||||
SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV,
|
||||
SoftInputShowHideReason.SHOW_STATE_ALWAYS_VISIBLE,
|
||||
@@ -55,7 +58,12 @@ import java.lang.annotation.Retention;
|
||||
SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT,
|
||||
SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT,
|
||||
SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API,
|
||||
SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE})
|
||||
SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_BACK_KEY,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED,
|
||||
SoftInputShowHideReason.HIDE_SOFT_INPUT_IMM_DEPRECATION})
|
||||
public @interface SoftInputShowHideReason {
|
||||
/** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */
|
||||
int SHOW_SOFT_INPUT = 0;
|
||||
@@ -63,8 +71,12 @@ public @interface SoftInputShowHideReason {
|
||||
/** Show soft input when {@code InputMethodManagerService#attachNewInputLocked} called. */
|
||||
int ATTACH_NEW_INPUT = 1;
|
||||
|
||||
/** Show soft input by {@code InputMethodManagerService#showMySoftInput}. */
|
||||
int SHOW_MY_SOFT_INPUT = 2;
|
||||
/** Show soft input by {@code InputMethodManagerService#showMySoftInput}. This is triggered when
|
||||
* the IME process try to show the keyboard.
|
||||
*
|
||||
* @see android.inputmethodservice.InputMethodService#requestShowSelf(int)
|
||||
*/
|
||||
int SHOW_SOFT_INPUT_FROM_IME = 2;
|
||||
|
||||
/**
|
||||
* Hide soft input by
|
||||
@@ -72,8 +84,11 @@ public @interface SoftInputShowHideReason {
|
||||
*/
|
||||
int HIDE_SOFT_INPUT = 3;
|
||||
|
||||
/** Hide soft input by {@code InputMethodManagerService#hideMySoftInput}. */
|
||||
int HIDE_MY_SOFT_INPUT = 4;
|
||||
/**
|
||||
* Hide soft input by
|
||||
* {@link android.inputmethodservice.InputMethodService#requestHideSelf(int)}.
|
||||
*/
|
||||
int HIDE_SOFT_INPUT_FROM_IME = 4;
|
||||
|
||||
/**
|
||||
* Show soft input when navigated forward to the window (with
|
||||
@@ -203,4 +218,32 @@ public @interface SoftInputShowHideReason {
|
||||
* See also {@code InputMethodManagerService#mImeHiddenByDisplayPolicy}.
|
||||
*/
|
||||
int HIDE_DISPLAY_IME_POLICY_HIDE = 26;
|
||||
|
||||
/**
|
||||
* Hide soft input by {@link android.view.InsetsController#hide(int)}.
|
||||
*/
|
||||
int HIDE_SOFT_INPUT_BY_INSETS_API = 27;
|
||||
|
||||
/**
|
||||
* Hide soft input by {@link android.inputmethodservice.InputMethodService#handleBack(boolean)}.
|
||||
*/
|
||||
int HIDE_SOFT_INPUT_BY_BACK_KEY = 28;
|
||||
|
||||
/**
|
||||
* Hide soft input by
|
||||
* {@link android.inputmethodservice.InputMethodService#onToggleSoftInput(int, int)}.
|
||||
*/
|
||||
int HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT = 29;
|
||||
|
||||
/**
|
||||
* Hide soft input by
|
||||
* {@link android.inputmethodservice.InputMethodService#onExtractingInputChanged(EditorInfo)})}.
|
||||
*/
|
||||
int HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED = 30;
|
||||
|
||||
/**
|
||||
* Hide soft input by the deprecated
|
||||
* {@link InputMethodManager#hideSoftInputFromInputMethod(IBinder, int)}.
|
||||
*/
|
||||
int HIDE_SOFT_INPUT_IMM_DEPRECATION = 31;
|
||||
}
|
||||
|
||||
@@ -4855,7 +4855,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
private void hideMySoftInput(@NonNull IBinder token, int flags) {
|
||||
private void hideMySoftInput(@NonNull IBinder token, int flags,
|
||||
@SoftInputShowHideReason int reason) {
|
||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.hideMySoftInput");
|
||||
synchronized (ImfLock.class) {
|
||||
if (!calledWithValidTokenLocked(token)) {
|
||||
@@ -4863,10 +4864,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
hideCurrentInputLocked(
|
||||
mLastImeTargetWindow, flags, null,
|
||||
SoftInputShowHideReason.HIDE_MY_SOFT_INPUT);
|
||||
|
||||
hideCurrentInputLocked(mLastImeTargetWindow, flags, null, reason);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
@@ -4884,7 +4882,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
showCurrentInputLocked(mLastImeTargetWindow, flags, null,
|
||||
SoftInputShowHideReason.SHOW_MY_SOFT_INPUT);
|
||||
SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
@@ -6698,11 +6696,12 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void hideMySoftInput(int flags, AndroidFuture future /* T=Void */) {
|
||||
public void hideMySoftInput(int flags, @SoftInputShowHideReason int reason,
|
||||
AndroidFuture future /* T=Void */) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final AndroidFuture<Void> typedFuture = future;
|
||||
try {
|
||||
mImms.hideMySoftInput(mToken, flags);
|
||||
mImms.hideMySoftInput(mToken, flags, reason);
|
||||
typedFuture.complete(null);
|
||||
} catch (Throwable e) {
|
||||
typedFuture.completeExceptionally(e);
|
||||
|
||||
Reference in New Issue
Block a user