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

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

Extract unbinding visible IME connection

Bug: 205676419
Test: make
Change-Id: I436095d4f2858c67aeed6296c9f70e253798f4b6
parent 713036b6
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -269,8 +269,7 @@ final class InputMethodBindingController {
        @Override public void onBindingDied(ComponentName name) {
        @Override public void onBindingDied(ComponentName name) {
            synchronized (mMethodMap) {
            synchronized (mMethodMap) {
                if (mVisibleBound) {
                if (mVisibleBound) {
                    mContext.unbindService(mVisibleConnection);
                    unbindVisibleConnectionLocked();
                    mVisibleBound = false;
                }
                }
            }
            }
        }
        }
@@ -368,8 +367,7 @@ final class InputMethodBindingController {
    @GuardedBy("mMethodMap")
    @GuardedBy("mMethodMap")
    void unbindCurrentMethodLocked() {
    void unbindCurrentMethodLocked() {
        if (mVisibleBound) {
        if (mVisibleBound) {
            mContext.unbindService(mVisibleConnection);
            unbindVisibleConnectionLocked();
            mVisibleBound = false;
        }
        }


        if (mHasConnection) {
        if (mHasConnection) {
@@ -385,6 +383,13 @@ final class InputMethodBindingController {
        mService.clearCurMethodLocked();
        mService.clearCurMethodLocked();
    }
    }



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

    @GuardedBy("mMethodMap")
    @GuardedBy("mMethodMap")
    private boolean bindCurrentInputMethodServiceLocked(ServiceConnection conn, int flags) {
    private boolean bindCurrentInputMethodServiceLocked(ServiceConnection conn, int flags) {
        if (mCurIntent == null || conn == null) {
        if (mCurIntent == null || conn == null) {
+3 −14
Original line number Original line Diff line number Diff line
@@ -313,23 +313,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private int mMethodMapUpdateCount = 0;
    private int mMethodMapUpdateCount = 0;


    /**
    /**
     * Indicates whether {@link #getVisibleConnection} is currently in use.
     * Indicates whether {@link InputMethodBindingController#getVisibleConnection} is currently
     * in use.
     */
     */
    private boolean isVisibleBound() {
    private boolean isVisibleBound() {
        return mBindingController.isVisibleBound();
        return mBindingController.isVisibleBound();
    }
    }


    private void setVisibleBound(boolean visibleBound) {
        mBindingController.setVisibleBound(visibleBound);
    }

    /**
     * Used to bring IME service up to visible adjustment while it is being shown.
     */
    private ServiceConnection getVisibleConnection() {
        return mBindingController.getVisibleConnection();
    }

    /**
    /**
     * Used to bind the IME while it is not currently being shown.
     * Used to bind the IME while it is not currently being shown.
     */
     */
@@ -3254,8 +3244,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            res = false;
            res = false;
        }
        }
        if (hasConnection() && isVisibleBound()) {
        if (hasConnection() && isVisibleBound()) {
            mContext.unbindService(getVisibleConnection());
            mBindingController.unbindVisibleConnectionLocked();
            setVisibleBound(false);
        }
        }
        mInputShown = false;
        mInputShown = false;
        mShowRequested = false;
        mShowRequested = false;