Loading core/java/android/view/inputmethod/ImeTracker.java +1 −0 Original line number Diff line number Diff line Loading @@ -782,6 +782,7 @@ public interface ImeTracker { private boolean shouldMonitorLatency(@SoftInputShowHideReason int reason) { return reason == SoftInputShowHideReason.SHOW_SOFT_INPUT || reason == SoftInputShowHideReason.HIDE_SOFT_INPUT || reason == SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW || reason == SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API || reason == SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API || reason == SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME Loading core/java/android/view/inputmethod/InputMethodManager.java +34 −0 Original line number Diff line number Diff line Loading @@ -2279,6 +2279,40 @@ public final class InputMethodManager { } } /** * Synonym for {@link #hideSoftInputFromWindow(IBinder, int)} but takes a {@link View} as a * parameter to be a counterpart of {@link #showSoftInput(View, int)}. * * @param view {@link View} to be used to conditionally issue hide request when and only when * this {@link View} is serving as an IME target. * @hide */ public boolean hideSoftInputFromView(@NonNull View view, @HideFlags int flags) { final var reason = SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW; final ImeTracker.Token statsToken = ImeTracker.forLogging().onRequestHide( null /* component */, Process.myUid(), ImeTracker.ORIGIN_CLIENT_HIDE_SOFT_INPUT, reason); ImeTracker.forLatency().onRequestHide(statsToken, ImeTracker.ORIGIN_CLIENT_HIDE_SOFT_INPUT, reason, ActivityThread::currentApplication); ImeTracing.getInstance().triggerClientDump("InputMethodManager#hideSoftInputFromView", this, null /* icProto */); synchronized (mH) { if (!hasServedByInputMethodLocked(view)) { ImeTracker.forLogging().onFailed(statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED); ImeTracker.forLatency().onShowFailed( statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED, ActivityThread::currentApplication); Log.w(TAG, "Ignoring hideSoftInputFromView() as view=" + view + " is not served."); return false; } ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED); return IInputMethodManagerGlobalInvoker.hideSoftInput(mClient, view.getWindowToken(), statsToken, flags, null, reason); } } /** * Start stylus handwriting session. * Loading core/java/android/widget/DatePickerSpinnerDelegate.java +6 −6 Original line number Diff line number Diff line Loading @@ -640,15 +640,15 @@ class DatePickerSpinnerDelegate extends AbstractDatePickerDelegate { // value and having the IME up makes no sense. InputMethodManager inputMethodManager = mContext.getSystemService(InputMethodManager.class); if (inputMethodManager != null) { if (inputMethodManager.isActive(mYearSpinnerInput)) { if (mYearSpinnerInput.hasFocus()) { inputMethodManager.hideSoftInputFromView(mYearSpinnerInput, 0); mYearSpinnerInput.clearFocus(); inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0); } else if (inputMethodManager.isActive(mMonthSpinnerInput)) { } else if (mMonthSpinnerInput.hasFocus()) { inputMethodManager.hideSoftInputFromView(mMonthSpinnerInput, 0); mMonthSpinnerInput.clearFocus(); inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0); } else if (inputMethodManager.isActive(mDaySpinnerInput)) { } else if (mDaySpinnerInput.hasFocus()) { inputMethodManager.hideSoftInputFromView(mDaySpinnerInput, 0); mDaySpinnerInput.clearFocus(); inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0); } } } Loading core/java/android/widget/NumberPicker.java +2 −2 Original line number Diff line number Diff line Loading @@ -1328,8 +1328,8 @@ public class NumberPicker extends LinearLayout { private void hideSoftInput() { InputMethodManager inputMethodManager = getContext().getSystemService(InputMethodManager.class); if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) { inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0); if (inputMethodManager != null) { inputMethodManager.hideSoftInputFromView(mInputText, 0); } if (mHasSelectorWheel) { mInputText.setVisibility(View.INVISIBLE); Loading core/java/android/widget/TextView.java +6 −6 Original line number Diff line number Diff line Loading @@ -2447,8 +2447,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (!enabled) { // Hide the soft input if the currently active TextView is disabled InputMethodManager imm = getInputMethodManager(); if (imm != null && imm.isActive(this)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); if (imm != null) { imm.hideSoftInputFromView(this, 0); } } Loading Loading @@ -8058,8 +8058,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else if (actionCode == EditorInfo.IME_ACTION_DONE) { InputMethodManager imm = getInputMethodManager(); if (imm != null && imm.isActive(this)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); if (imm != null) { imm.hideSoftInputFromView(this, 0); } return; } Loading Loading @@ -9722,8 +9722,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // No target for next focus, but make sure the IME // if this came from it. InputMethodManager imm = getInputMethodManager(); if (imm != null && imm.isActive(this)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); if (imm != null) { imm.hideSoftInputFromView(this, 0); } } } Loading Loading
core/java/android/view/inputmethod/ImeTracker.java +1 −0 Original line number Diff line number Diff line Loading @@ -782,6 +782,7 @@ public interface ImeTracker { private boolean shouldMonitorLatency(@SoftInputShowHideReason int reason) { return reason == SoftInputShowHideReason.SHOW_SOFT_INPUT || reason == SoftInputShowHideReason.HIDE_SOFT_INPUT || reason == SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW || reason == SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API || reason == SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API || reason == SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME Loading
core/java/android/view/inputmethod/InputMethodManager.java +34 −0 Original line number Diff line number Diff line Loading @@ -2279,6 +2279,40 @@ public final class InputMethodManager { } } /** * Synonym for {@link #hideSoftInputFromWindow(IBinder, int)} but takes a {@link View} as a * parameter to be a counterpart of {@link #showSoftInput(View, int)}. * * @param view {@link View} to be used to conditionally issue hide request when and only when * this {@link View} is serving as an IME target. * @hide */ public boolean hideSoftInputFromView(@NonNull View view, @HideFlags int flags) { final var reason = SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW; final ImeTracker.Token statsToken = ImeTracker.forLogging().onRequestHide( null /* component */, Process.myUid(), ImeTracker.ORIGIN_CLIENT_HIDE_SOFT_INPUT, reason); ImeTracker.forLatency().onRequestHide(statsToken, ImeTracker.ORIGIN_CLIENT_HIDE_SOFT_INPUT, reason, ActivityThread::currentApplication); ImeTracing.getInstance().triggerClientDump("InputMethodManager#hideSoftInputFromView", this, null /* icProto */); synchronized (mH) { if (!hasServedByInputMethodLocked(view)) { ImeTracker.forLogging().onFailed(statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED); ImeTracker.forLatency().onShowFailed( statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED, ActivityThread::currentApplication); Log.w(TAG, "Ignoring hideSoftInputFromView() as view=" + view + " is not served."); return false; } ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_VIEW_SERVED); return IInputMethodManagerGlobalInvoker.hideSoftInput(mClient, view.getWindowToken(), statsToken, flags, null, reason); } } /** * Start stylus handwriting session. * Loading
core/java/android/widget/DatePickerSpinnerDelegate.java +6 −6 Original line number Diff line number Diff line Loading @@ -640,15 +640,15 @@ class DatePickerSpinnerDelegate extends AbstractDatePickerDelegate { // value and having the IME up makes no sense. InputMethodManager inputMethodManager = mContext.getSystemService(InputMethodManager.class); if (inputMethodManager != null) { if (inputMethodManager.isActive(mYearSpinnerInput)) { if (mYearSpinnerInput.hasFocus()) { inputMethodManager.hideSoftInputFromView(mYearSpinnerInput, 0); mYearSpinnerInput.clearFocus(); inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0); } else if (inputMethodManager.isActive(mMonthSpinnerInput)) { } else if (mMonthSpinnerInput.hasFocus()) { inputMethodManager.hideSoftInputFromView(mMonthSpinnerInput, 0); mMonthSpinnerInput.clearFocus(); inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0); } else if (inputMethodManager.isActive(mDaySpinnerInput)) { } else if (mDaySpinnerInput.hasFocus()) { inputMethodManager.hideSoftInputFromView(mDaySpinnerInput, 0); mDaySpinnerInput.clearFocus(); inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0); } } } Loading
core/java/android/widget/NumberPicker.java +2 −2 Original line number Diff line number Diff line Loading @@ -1328,8 +1328,8 @@ public class NumberPicker extends LinearLayout { private void hideSoftInput() { InputMethodManager inputMethodManager = getContext().getSystemService(InputMethodManager.class); if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) { inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0); if (inputMethodManager != null) { inputMethodManager.hideSoftInputFromView(mInputText, 0); } if (mHasSelectorWheel) { mInputText.setVisibility(View.INVISIBLE); Loading
core/java/android/widget/TextView.java +6 −6 Original line number Diff line number Diff line Loading @@ -2447,8 +2447,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (!enabled) { // Hide the soft input if the currently active TextView is disabled InputMethodManager imm = getInputMethodManager(); if (imm != null && imm.isActive(this)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); if (imm != null) { imm.hideSoftInputFromView(this, 0); } } Loading Loading @@ -8058,8 +8058,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else if (actionCode == EditorInfo.IME_ACTION_DONE) { InputMethodManager imm = getInputMethodManager(); if (imm != null && imm.isActive(this)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); if (imm != null) { imm.hideSoftInputFromView(this, 0); } return; } Loading Loading @@ -9722,8 +9722,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // No target for next focus, but make sure the IME // if this came from it. InputMethodManager imm = getInputMethodManager(); if (imm != null && imm.isActive(this)) { imm.hideSoftInputFromWindow(getWindowToken(), 0); if (imm != null) { imm.hideSoftInputFromView(this, 0); } } } Loading