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

Commit 5c232e49 authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Move binding current method to controller

Bug: 205676419
Test: make
Change-Id: I53855a72869a608891f55ca99101f0be9b65efde
parent 285c6dea
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.IBinder;
import android.os.Process;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.Slog;
import android.view.inputmethod.InputMethodInfo;
@@ -341,4 +342,15 @@ final class InputMethodBindingController {
        mCurId = null;
        mService.clearCurMethodLocked();
    }

    @GuardedBy("mMethodMap")
    boolean bindCurrentInputMethodServiceLocked(ServiceConnection conn, int flags) {
        if (mCurIntent == null || conn == null) {
            Slog.e(TAG, "--- bind failed: service = " + mCurIntent + ", conn = " + conn);
            return false;
        }
        return mContext.bindServiceAsUser(mCurIntent, conn, flags,
                new UserHandle(mSettings.getCurrentUserId()));
    }

}
+4 −14
Original line number Diff line number Diff line
@@ -1984,17 +1984,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        return true;
    }

    @GuardedBy("mMethodMap")
    private boolean bindCurrentInputMethodServiceLocked(ServiceConnection conn, int flags) {
        Intent service = getCurIntent();
        if (service == null || conn == null) {
            Slog.e(TAG, "--- bind failed: service = " + service + ", conn = " + conn);
            return false;
        }
        return mContext.bindServiceAsUser(service, conn, flags,
                new UserHandle(mSettings.getCurrentUserId()));
    }

    @Override
    public List<InputMethodInfo> getInputMethodList(@UserIdInt int userId) {
        if (UserHandle.getCallingUserId() != userId) {
@@ -2511,7 +2500,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        Intent intent = createImeBindingIntent(info.getComponent());
        setCurIntent(intent);

        if (bindCurrentInputMethodServiceLocked(intent, getMainConnection(),
        if (mBindingController.bindCurrentInputMethodServiceLocked(intent, getMainConnection(),
                mImeConnectionBindFlags)) {
            addFreshWindowTokenLocked(displayIdToShowIme, info.getId());
            return new InputBindResult(
@@ -3211,7 +3200,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    showInputToken));
            mInputShown = true;
            if (hasConnection() && !isVisibleBound()) {
                bindCurrentInputMethodServiceLocked(getVisibleConnection(), IME_VISIBLE_BIND_FLAGS);
                mBindingController.bindCurrentInputMethodServiceLocked(getVisibleConnection(),
                        IME_VISIBLE_BIND_FLAGS);
                setVisibleBound(true);
            }
            res = true;
@@ -3227,7 +3217,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                Slog.w(TAG, "Force disconnect/connect to the IME in showCurrentInputLocked()");
                ServiceConnection connection = getMainConnection();
                mContext.unbindService(connection);
                bindCurrentInputMethodServiceLocked(connection,
                mBindingController.bindCurrentInputMethodServiceLocked(connection,
                        mImeConnectionBindFlags);
            } else {
                if (DEBUG) {