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

Commit 85d9fed1 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Factor out IMMS#resetCurrentMethodAndClient()."

parents 0ba005fc bc7b5260
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -935,7 +935,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                || (newLocale != null && !newLocale.equals(mLastSystemLocale))) {
            if (!updateOnlyWhenLocaleChanged) {
                hideCurrentInputLocked(0, null);
                unbindCurrentMethodLocked(true, false);
                resetCurrentMethodAndClient();
            }
            if (DEBUG) {
                Slog.i(TAG, "Locale has been changed to " + newLocale);
@@ -1395,7 +1395,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
        }

        unbindCurrentMethodLocked(false, true);
        unbindCurrentMethodLocked(true);

        mCurIntent = new Intent(InputMethod.SERVICE_INTERFACE);
        mCurIntent.setComponent(info.getComponent());
@@ -1453,7 +1453,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mCurMethod = IInputMethod.Stub.asInterface(service);
                if (mCurToken == null) {
                    Slog.w(TAG, "Service connected without a token!");
                    unbindCurrentMethodLocked(false, false);
                    unbindCurrentMethodLocked(false);
                    return;
                }
                if (DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken);
@@ -1490,11 +1490,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        channel.dispose();
    }

    void unbindCurrentMethodLocked(boolean resetCurrentMethodAndClient, boolean savePosition) {
        if (resetCurrentMethodAndClient) {
            mCurMethodId = null;
        }

    void unbindCurrentMethodLocked(boolean savePosition) {
        if (mVisibleBound) {
            mContext.unbindService(mVisibleConnection);
            mVisibleBound = false;
@@ -1520,11 +1516,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

        mCurId = null;
        clearCurMethodLocked();
    }

        if (resetCurrentMethodAndClient) {
    void resetCurrentMethodAndClient() {
        mCurMethodId = null;
        unbindCurrentMethodLocked(false);
        unbindCurrentClientLocked();
    }
    }

    void requestClientSessionLocked(ClientState cs) {
        if (!cs.sessionRequested) {
@@ -1876,12 +1874,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id));
            } catch (IllegalArgumentException e) {
                Slog.w(TAG, "Unknown input method from prefs: " + id, e);
                unbindCurrentMethodLocked(true, false);
                resetCurrentMethodAndClient();
            }
            mShortcutInputMethodsAndSubtypes.clear();
        } else {
            // There is no longer an input method set, so stop any current one.
            unbindCurrentMethodLocked(true, false);
            resetCurrentMethodAndClient();
        }
        // Here is not the perfect place to reset the switching controller. Ideally
        // mSwitchingController and mSettings should be able to share the same state.