Move binding current method to controller

Bug: 205676419
Test: make
Change-Id: I53855a72869a608891f55ca99101f0be9b65efde
This commit is contained in:
Nikolas Havrikov
2021-11-11 18:15:23 +01:00
parent 285c6dea7b
commit 5c232e4970
2 changed files with 16 additions and 14 deletions

View File

@@ -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()));
}
}

View File

@@ -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) {