From 6746452ebaceac45ce3b8aa49bb616adb81541d7 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 28 Jan 2019 00:50:09 -0800 Subject: Simplify IMMS#startInputOrWindowGainedFocusInternal() part 5/5 This is a series of CLs to reduce the average indentation level of InputMethodManagerService#startInputOrWindowGainedFocusInternal(). This CL does several format clean-ups and fixes several lint errors. This is a mechanical refactoring. There should be no behavior change. Bug: 34886274 Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: Icd5b7da96e1ec11b329e2d1a4a885796510e23f9 --- .../inputmethod/InputMethodManagerService.java | 53 ++++++++++------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 6062f0f7c481..b50433eacc38 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2799,26 +2799,26 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @SoftInputModeFlags int softInputMode, int windowFlags, EditorInfo attribute, IInputContext inputContext, @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion, @UserIdInt int userId) { - InputBindResult res = null; - final int windowDisplayId = - mWindowManagerInternal.getDisplayIdForWindow(windowToken); - if (DEBUG) Slog.v(TAG, "startInputOrWindowGainedFocusInternalLocked: reason=" - + InputMethodDebug.startInputReasonToString(startInputReason) - + " client=" + client.asBinder() - + " inputContext=" + inputContext - + " missingMethods=" - + InputConnectionInspector.getMissingMethodFlagsAsString(missingMethods) - + " attribute=" + attribute - + " startInputFlags=" - + InputMethodDebug.startInputFlagsToString(startInputFlags) - + " softInputMode=" + InputMethodDebug.softInputModeToString(softInputMode) - + " windowFlags=#" + Integer.toHexString(windowFlags) - + " unverifiedTargetSdkVersion=" + unverifiedTargetSdkVersion); - - ClientState cs = mClients.get(client.asBinder()); + if (DEBUG) { + Slog.v(TAG, "startInputOrWindowGainedFocusInternalLocked: reason=" + + InputMethodDebug.startInputReasonToString(startInputReason) + + " client=" + client.asBinder() + + " inputContext=" + inputContext + + " missingMethods=" + + InputConnectionInspector.getMissingMethodFlagsAsString(missingMethods) + + " attribute=" + attribute + + " startInputFlags=" + + InputMethodDebug.startInputFlagsToString(startInputFlags) + + " softInputMode=" + InputMethodDebug.softInputModeToString(softInputMode) + + " windowFlags=#" + Integer.toHexString(windowFlags) + + " unverifiedTargetSdkVersion=" + unverifiedTargetSdkVersion); + } + + final int windowDisplayId = mWindowManagerInternal.getDisplayIdForWindow(windowToken); + + final ClientState cs = mClients.get(client.asBinder()); if (cs == null) { - throw new IllegalArgumentException("unknown client " - + client.asBinder()); + throw new IllegalArgumentException("unknown client " + client.asBinder()); } if (cs.selfReportedDisplayId != windowDisplayId) { Slog.e(TAG, "startInputOrWindowGainedFocusInternal: display ID mismatch." @@ -2857,8 +2857,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Master feature flag that overrides other conditions and forces IME preRendering. if (DEBUG) { Slog.v(TAG, "IME PreRendering MASTER flag: " - + DebugFlags.FLAG_PRE_RENDER_IME_VIEWS.value() - + ", LowRam: " + mIsLowRam); + + DebugFlags.FLAG_PRE_RENDER_IME_VIEWS.value() + ", LowRam: " + mIsLowRam); } // pre-rendering not supported on low-ram devices. cs.shouldPreRenderIme = DebugFlags.FLAG_PRE_RENDER_IME_VIEWS.value() && !mIsLowRam; @@ -2892,8 +2891,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub == LayoutParams.SOFT_INPUT_ADJUST_RESIZE || mRes.getConfiguration().isLayoutSizeAtLeast( Configuration.SCREENLAYOUT_SIZE_LARGE); - final boolean isTextEditor = - (startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0; + final boolean isTextEditor = (startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0; // We want to start input before showing the IME, but after closing // it. We want to do this after closing it to help the IME disappear @@ -2901,6 +2899,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // new focused input, even if its window wants to hide the IME). boolean didStart = false; + InputBindResult res = null; switch (softInputMode & LayoutParams.SOFT_INPUT_MASK_STATE) { case LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED: if (!isTextEditor || !doAutoShow) { @@ -2957,9 +2956,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (InputMethodUtils.isSoftInputModeStateVisibleAllowed( unverifiedTargetSdkVersion, startInputFlags)) { if (attribute != null) { - res = startInputUncheckedLocked(cs, inputContext, - missingMethods, attribute, startInputFlags, - startInputReason); + res = startInputUncheckedLocked(cs, inputContext, missingMethods, + attribute, startInputFlags, startInputReason); didStart = true; } showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null); @@ -2992,8 +2990,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (attribute != null) { if (!DebugFlags.FLAG_OPTIMIZE_START_INPUT.value() || (startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0) { - res = startInputUncheckedLocked(cs, inputContext, missingMethods, - attribute, + res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute, startInputFlags, startInputReason); } else { res = InputBindResult.NO_EDITOR; -- cgit v1.2.3-59-g8ed1b