From 87cd22cf897476fc3891d7d479eb3f6022311e02 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Thu, 25 Aug 2022 21:01:13 +0900 Subject: [PATCH] Simplify code around mPreviousViewFocusParameters This is a follow up CL to our previous CL [1], which introduced ViewFocusParameterInfo. This CL mechanically simplifies that CL without changing any semantics. There should be no observable behavior change. [1]: I0331462624351d17399c733cffa84a132f118ab7 cb0a7808349a1b48dcdfffb84c477d624c866ff2 Bug: 219819349 Bug: 243778447 Test: presubmit Change-Id: Iee99cd184503ca8720efb3c43a78cf3ba46f94ad --- .../view/inputmethod/InputMethodManager.java | 56 +++---------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 6049613f41e7f..21b39a8e42ca0 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -471,6 +471,11 @@ public final class InputMethodManager { * to the input connection. */ private EditorInfo mCurrentEditorInfo; + + @GuardedBy("mH") + @Nullable + private ViewFocusParameterInfo mPreviousViewFocusParameters; + /** * The InputConnection that was last retrieved from the served view. */ @@ -660,26 +665,6 @@ public final class InputMethodManager { private final class DelegateImpl implements ImeFocusController.InputMethodManagerDelegate { - @GuardedBy("mH") - @Nullable - private ViewFocusParameterInfo mPreviousViewFocusParameters; - - @GuardedBy("mH") - private void updatePreviousViewFocusParametersLocked( - @Nullable EditorInfo currentEditorInfo, - @StartInputFlags int startInputFlags, - @StartInputReason int startInputReason, - @SoftInputModeFlags int softInputMode, - int windowFlags) { - mPreviousViewFocusParameters = new ViewFocusParameterInfo(currentEditorInfo, - startInputFlags, startInputReason, softInputMode, windowFlags); - } - - @GuardedBy("mH") - private void clearStateLocked() { - mPreviousViewFocusParameters = null; - } - /** * Used by {@link ImeFocusController} to start input connection. */ @@ -1729,7 +1714,7 @@ public final class InputMethodManager { @GuardedBy("mH") private void clearConnectionLocked() { mCurrentEditorInfo = null; - mDelegate.clearStateLocked(); + mPreviousViewFocusParameters = null; if (mServedInputConnection != null) { mServedInputConnection.deactivate(); mServedInputConnection = null; @@ -2424,10 +2409,10 @@ public final class InputMethodManager { && previouslyServedConnection == null && ic == null && isSwitchingBetweenEquivalentNonEditableViews( - mDelegate.mPreviousViewFocusParameters, startInputFlags, + mPreviousViewFocusParameters, startInputFlags, startInputReason, softInputMode, windowFlags); - updatePreviousViewFocusParametersLocked(mCurrentEditorInfo, startInputFlags, - startInputReason, softInputMode, windowFlags); + mPreviousViewFocusParameters = new ViewFocusParameterInfo(mCurrentEditorInfo, + startInputFlags, startInputReason, softInputMode, windowFlags); if (canSkip) { if (DEBUG) { Log.d(TAG, "Not calling IMMS due to switching between non-editable views."); @@ -2498,29 +2483,6 @@ public final class InputMethodManager { return true; } - /** - * This method exists only so that the - * errorprone false positive warning - * can be suppressed without granting a blanket exception to the {@link #startInputInner} - * method. - *

- * The warning in question implies that the access to the - * {@link DelegateImpl#updatePreviousViewFocusParametersLocked} method should be guarded by - * {@code InputMethodManager.this.mH}, but instead {@code mDelegate.mH} is held in the caller. - * In this case errorprone fails to realize that it is the same object. - */ - @GuardedBy("mH") - @SuppressWarnings("GuardedBy") - private void updatePreviousViewFocusParametersLocked( - @Nullable EditorInfo currentEditorInfo, - @StartInputFlags int startInputFlags, - @StartInputReason int startInputReason, - @SoftInputModeFlags int softInputMode, - int windowFlags) { - mDelegate.updatePreviousViewFocusParametersLocked(currentEditorInfo, startInputFlags, - startInputReason, softInputMode, windowFlags); - } - /** * @return {@code true} when we are switching focus between two non-editable views * so that we can avoid calling {@link IInputMethodManager#startInputOrWindowGainedFocus}.