Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c6a88e4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Simplify code around mPreviousViewFocusParameters"

parents be5a320c 87cd22cf
Loading
Loading
Loading
Loading
+9 −47
Original line number Diff line number Diff line
@@ -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,
                            startInputReason, softInputMode, windowFlags);
            updatePreviousViewFocusParametersLocked(mCurrentEditorInfo, startInputFlags,
                            mPreviousViewFocusParameters, 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
     * <a href="https://errorprone.info/bugpattern/GuardedBy">errorprone</a> false positive warning
     * can be suppressed without granting a blanket exception to the {@link #startInputInner}
     * method.
     * <p>
     * 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}.