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

Commit ba37769c authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Move unbinding current method logic to controller

Also inline accessors

Bug: 205676419
Test: make
Change-Id: I5ace23a4539c349aee767bf689d8c8b88df0a39b
parent 81fa0e6b
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ final class InputMethodBindingController {
                    updateCurrentMethodUidLocked();
                    if (mCurToken == null) {
                        Slog.w(TAG, "Service connected without a token!");
                        mService.unbindCurrentMethodLocked();
                        unbindCurrentMethodLocked();
                        Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                        return;
                    }
@@ -322,4 +322,23 @@ final class InputMethodBindingController {
        }
    };

    @GuardedBy("mMethodMap")
    void unbindCurrentMethodLocked() {
        if (mVisibleBound) {
            mContext.unbindService(mVisibleConnection);
            mVisibleBound = false;
        }

        if (mHasConnection) {
            mContext.unbindService(mNonVisibleConnection);
            mHasConnection = false;
        }

        if (mCurToken != null) {
            mService.removeCurrentTokenLocked();
        }

        mCurId = null;
        mService.clearCurMethodLocked();
    }
}
+5 −25
Original line number Diff line number Diff line
@@ -761,7 +761,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     * </dd>
     * </dl>
     * <em>Do not update this value outside of {@link #setImeWindowStatus(IBinder, int, int)} and
     * {@link #unbindCurrentMethodLocked()}.</em>
     * {@link InputMethodBindingController#unbindCurrentMethodLocked()}.</em>
     */
    int mImeWindowVis;

@@ -2506,7 +2506,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            throw new IllegalArgumentException("Unknown id: " + getSelectedMethodId());
        }

        unbindCurrentMethodLocked();
        mBindingController.unbindCurrentMethodLocked();

        Intent intent = createImeBindingIntent(info.getComponent());
        setCurIntent(intent);
@@ -2674,26 +2674,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        channel.dispose();
    }

    @GuardedBy("mMethodMap")
    void unbindCurrentMethodLocked() {
        if (isVisibleBound()) {
            mContext.unbindService(getVisibleConnection());
            setVisibleBound(false);
        }

        if (hasConnection()) {
            mContext.unbindService(getMainConnection());
            setHasConnection(false);
        }

        if (getCurToken() != null) {
            removeCurrentTokenLocked();
        }

        setCurId(null);
        clearCurMethodLocked();
    }

    @GuardedBy("mMethodMap")
    void removeCurrentTokenLocked() {
        IBinder token = getCurToken();
@@ -2714,7 +2694,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    @GuardedBy("mMethodMap")
    void resetCurrentMethodAndClientLocked(@UnbindReason int unbindClientReason) {
        setSelectedMethodId(null);
        unbindCurrentMethodLocked();
        mBindingController.unbindCurrentMethodLocked();
        unbindCurrentClientLocked(unbindClientReason);
    }

@@ -3583,7 +3563,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                        // Note that we can trust client's display ID as long as it matches
                        // to the display ID obtained from the window.
                        if (cs.selfReportedDisplayId != mCurTokenDisplayId) {
                            unbindCurrentMethodLocked();
                            mBindingController.unbindCurrentMethodLocked();
                        }
                    }
                } else if (isTextEditor && doAutoShow
@@ -5801,7 +5781,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                if (userId == mSettings.getCurrentUserId()) {
                    hideCurrentInputLocked(mCurFocusedWindow, 0, null,
                            SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND);
                    unbindCurrentMethodLocked();
                    mBindingController.unbindCurrentMethodLocked();
                    // Reset the current IME
                    resetSelectedInputMethodAndSubtypeLocked(null);
                    // Also reset the settings of the current IME