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

Commit a04859b9 authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Extract unbinding main IME connection

Bug: 205676419
Test: make
Change-Id: Ie01d68e7455bcd2d6e40b63687b948992834b51d
parent fa91d1c8
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -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() {
+1 −11
Original line number Diff line number Diff line
@@ -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) {