From a9625d3beef7d1d41c51fa7c02268866e6636f5f Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 17 Oct 2022 12:11:58 -0700 Subject: [PATCH] Simplify MSG_SET_ACTIVE handler This is mechanical refactoring. There must be no behavior change. Bug: 234882948 Test: presubmit Change-Id: I410fc54cd941eda13f25acd1aedf8778956091f3 --- .../view/inputmethod/InputMethodManager.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index be501055681bf..7840d4cacc255 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1116,14 +1116,19 @@ public final class InputMethodManager { // Check focus again in case that "onWindowFocus" is called before // handling this message. final View servedView = getServedViewLocked(); - if (servedView != null && canStartInput(servedView)) { - if (mCurRootView != null && mCurRootView.getImeFocusController() - .checkFocus(mRestartOnNextWindowFocus, false)) { - final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS - : StartInputReason.DEACTIVATED_BY_IMMS; - startInputOnWindowFocusGainInternal(reason, null, 0, 0, 0); - } + if (servedView == null || !canStartInput(servedView)) { + return; } + if (mCurRootView == null) { + return; + } + if (!mCurRootView.getImeFocusController().checkFocus( + mRestartOnNextWindowFocus, false)) { + return; + } + final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS + : StartInputReason.DEACTIVATED_BY_IMMS; + startInputOnWindowFocusGainInternal(reason, null, 0, 0, 0); } return; }