Encapsulate mVisibleConnection in IMMS

This is a step in a refactoring and will be superseded
by follow-up commits.

Bug: 205676419
Test: make
Change-Id: Icb98e6e5a0fd517e61e12711a0aaf0a77d52f760
This commit is contained in:
Nikolas Havrikov
2021-11-10 17:58:37 +01:00
parent 2be64fc442
commit 66763f371f

View File

@@ -351,12 +351,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
@GuardedBy("mMethodMap")
private int mMethodMapUpdateCount = 0;
// Used to bring IME service up to visible adjustment while it is being shown.
final ServiceConnection mVisibleConnection = new ServiceConnection() {
/**
* Used to bring IME service up to visible adjustment while it is being shown.
*/
private ServiceConnection getVisibleConnection() {
return mVisibleConnection;
}
private final ServiceConnection mVisibleConnection = new ServiceConnection() {
@Override public void onBindingDied(ComponentName name) {
synchronized (mMethodMap) {
if (mVisibleBound) {
mContext.unbindService(mVisibleConnection);
mContext.unbindService(getVisibleConnection());
mVisibleBound = false;
}
}
@@ -2668,7 +2674,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
@GuardedBy("mMethodMap")
void unbindCurrentMethodLocked() {
if (mVisibleBound) {
mContext.unbindService(mVisibleConnection);
mContext.unbindService(getVisibleConnection());
mVisibleBound = false;
}
@@ -3242,7 +3248,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
mInputShown = true;
if (hasConnection() && !mVisibleBound) {
bindCurrentInputMethodServiceLocked(
getCurIntent(), mVisibleConnection, IME_VISIBLE_BIND_FLAGS);
getCurIntent(), getVisibleConnection(), IME_VISIBLE_BIND_FLAGS);
mVisibleBound = true;
}
res = true;
@@ -3350,7 +3356,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
res = false;
}
if (hasConnection() && mVisibleBound) {
mContext.unbindService(mVisibleConnection);
mContext.unbindService(getVisibleConnection());
mVisibleBound = false;
}
mInputShown = false;