diff options
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 1cdcd2015f03..0e7de48cc7da 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -2463,22 +2463,22 @@ public final class InputMethodManager { public boolean hideSoftInputFromView(@NonNull View view, @HideFlags int flags) { final boolean isFocusedAndWindowFocused = view.hasWindowFocus() && view.isFocused(); synchronized (mH) { - if (!isFocusedAndWindowFocused && !hasServedByInputMethodLocked(view)) { + final boolean hasServedByInputMethod = hasServedByInputMethodLocked(view); + if (!isFocusedAndWindowFocused && !hasServedByInputMethod) { // Fail early if the view is not focused and not served // to avoid logging many erroneous calls. return false; } - } - final int reason = SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW; - final var statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE, - ImeTracker.ORIGIN_CLIENT, reason, ImeTracker.isFromUser(view)); - ImeTracker.forLatency().onRequestHide(statsToken, - ImeTracker.ORIGIN_CLIENT, reason, ActivityThread::currentApplication); - ImeTracing.getInstance().triggerClientDump("InputMethodManager#hideSoftInputFromView", - this, null /* icProto */); - synchronized (mH) { - if (!hasServedByInputMethodLocked(view)) { + final int reason = SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW; + final var statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE, + ImeTracker.ORIGIN_CLIENT, reason, ImeTracker.isFromUser(view)); + ImeTracker.forLatency().onRequestHide(statsToken, + ImeTracker.ORIGIN_CLIENT, reason, ActivityThread::currentApplication); + ImeTracing.getInstance().triggerClientDump("InputMethodManager#hideSoftInputFromView", + this, null /* icProto */); + + if (!hasServedByInputMethod) { ImeTracker.forLogging().onFailed(statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED); ImeTracker.forLatency().onShowFailed(statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED, ActivityThread::currentApplication); |