Extract unbinding main IME connection

Bug: 205676419
Test: make
Change-Id: Ie01d68e7455bcd2d6e40b63687b948992834b51d
This commit is contained in:
Nikolas Havrikov
2021-11-12 11:47:14 +01:00
parent fa91d1c86c
commit a04859b9f0
2 changed files with 7 additions and 18 deletions

View File

@@ -284,11 +284,6 @@ final class InputMethodBindingController {
/**
* Used to bind the IME while it is not currently being shown.
*/
@NonNull
ServiceConnection getMainConnection() {
return mMainConnection;
}
private final ServiceConnection mMainConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
@@ -371,8 +366,7 @@ final class InputMethodBindingController {
}
if (mHasConnection) {
mContext.unbindService(mNonVisibleConnection);
mHasConnection = false;
unbindMainConnectionLocked();
}
if (mCurToken != null) {
@@ -383,6 +377,11 @@ final class InputMethodBindingController {
mService.clearCurMethodLocked();
}
@GuardedBy("mMethodMap")
void unbindMainConnectionLocked() {
mContext.unbindService(mMainConnection);
mHasConnection = false;
}
@GuardedBy("mMethodMap")
void unbindVisibleConnectionLocked() {

View File

@@ -77,7 +77,6 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
@@ -320,14 +319,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return mBindingController.isVisibleBound();
}
/**
* Used to bind the IME while it is not currently being shown.
*/
@NonNull
private ServiceConnection getMainConnection() {
return mBindingController.getMainConnection();
}
// Ongoing notification
private NotificationManager mNotificationManager;
KeyguardManager mKeyguardManager;
@@ -3149,8 +3140,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME, getSelectedMethodId(),
bindingDuration, 1);
Slog.w(TAG, "Force disconnect/connect to the IME in showCurrentInputLocked()");
ServiceConnection connection = getMainConnection();
mContext.unbindService(connection);
mBindingController.unbindMainConnectionLocked();
mBindingController.bindCurrentInputMethodServiceMainConnectionLocked();
} else {
if (DEBUG) {