From bc7b5260431f0b34998a86a0da3227734b84388f Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 17 Nov 2015 17:38:41 -0800 Subject: [PATCH] Factor out IMMS#resetCurrentMethodAndClient(). As a preparation to fix Bug 25373872, this CL does a mechanical code clean-ups in InputMethodManagerService. As a follow up of I6c3186050592526fc95c5b27f18e2155acff5ebc, this CL introduces IMMS#resetCurrentMethodAndClient() to make it clear when we are resetting both IMMS->IME and IMMS->Apps connections. This is literally mechanical. No behavior change is intended. Bug: 25373872 Change-Id: Ia4161854d9da71783fd028fcb79407e4b9463aee --- .../server/InputMethodManagerService.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index ab1d775e3c32d..d404a42762d8f 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -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,10 +1516,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mCurId = null; clearCurMethodLocked(); + } - if (resetCurrentMethodAndClient) { - unbindCurrentClientLocked(); - } + void resetCurrentMethodAndClient() { + mCurMethodId = null; + unbindCurrentMethodLocked(false); + unbindCurrentClientLocked(); } void requestClientSessionLocked(ClientState cs) { @@ -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.