Clean up InputMethodBindingController a bit

This CL does several minor clean-ups for InputMethodBindingController.

 - Removed an unused field mRes.
 - Added a missing @GuardedBy("ImfLock.class") annotation.
 - Inlined bindCurrentInputMethodServiceVisibleConnection().

There must be no observable behavior change.

Bug: 234882948
Test: presubmit
Change-Id: Idc7371dd15f53c39ea508633bce9a30e56c773cb
This commit is contained in:
Yohei Yukawa
2022-10-06 08:52:37 -07:00
parent fdba7f4091
commit be0ad5c9b6

View File

@@ -26,7 +26,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManagerInternal;
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.os.Binder;
import android.os.IBinder;
@@ -65,7 +64,6 @@ final class InputMethodBindingController {
@NonNull private final InputMethodUtils.InputMethodSettings mSettings;
@NonNull private final PackageManagerInternal mPackageManagerInternal;
@NonNull private final WindowManagerInternal mWindowManagerInternal;
@NonNull private final Resources mRes;
@GuardedBy("ImfLock.class") private long mLastBindTime;
@GuardedBy("ImfLock.class") private boolean mHasConnection;
@@ -77,7 +75,7 @@ final class InputMethodBindingController {
@GuardedBy("ImfLock.class") @Nullable private IBinder mCurToken;
@GuardedBy("ImfLock.class") private int mCurSeq;
@GuardedBy("ImfLock.class") private boolean mVisibleBound;
private boolean mSupportsStylusHw;
@GuardedBy("ImfLock.class") private boolean mSupportsStylusHw;
/**
* Binding flags for establishing connection to the {@link InputMethodService}.
@@ -105,7 +103,6 @@ final class InputMethodBindingController {
mSettings = mService.mSettings;
mPackageManagerInternal = mService.mPackageManagerInternal;
mWindowManagerInternal = mService.mWindowManagerInternal;
mRes = mService.mRes;
}
/**
@@ -459,13 +456,6 @@ final class InputMethodBindingController {
new UserHandle(mSettings.getCurrentUserId()));
}
@GuardedBy("ImfLock.class")
private boolean bindCurrentInputMethodServiceVisibleConnection() {
mVisibleBound = bindCurrentInputMethodService(mVisibleConnection,
IME_VISIBLE_BIND_FLAGS);
return mVisibleBound;
}
@GuardedBy("ImfLock.class")
private boolean bindCurrentInputMethodServiceMainConnection() {
mHasConnection = bindCurrentInputMethodService(mMainConnection, IME_CONNECTION_BIND_FLAGS);
@@ -483,7 +473,8 @@ final class InputMethodBindingController {
if (mCurMethod != null) {
if (DEBUG) Slog.d(TAG, "setCurrentMethodVisible: mCurToken=" + mCurToken);
if (mHasConnection && !mVisibleBound) {
bindCurrentInputMethodServiceVisibleConnection();
mVisibleBound = bindCurrentInputMethodService(mVisibleConnection,
IME_VISIBLE_BIND_FLAGS);
}
return;
}