diff options
author | Yohei Yukawa <yukawa@google.com> | 2015-10-12 17:08:59 -0700 |
---|---|---|
committer | Yohei Yukawa <yukawa@google.com> | 2015-10-12 17:08:59 -0700 |
commit | 739d0b0585950d6e4717132b7e4c6f7f963288ab (patch) | |
tree | ed98b689c4b887fbd8ae740a8b095385edcbbca1 /services | |
parent | 6cc3735a492abd1c17f15a46287de70e62bf116d (diff) | |
download | frameworks_base-739d0b0585950d6e4717132b7e4c6f7f963288ab.zip frameworks_base-739d0b0585950d6e4717132b7e4c6f7f963288ab.tar.gz frameworks_base-739d0b0585950d6e4717132b7e4c6f7f963288ab.tar.bz2 |
Unbind IME client when unsetting the current IME.
This follows up Ia70b870723acf647e0c27f24aff91b40d6f85543.
In certain scenarios, only IMMS#mCurMethodId is cleared with null
while IMMS#mCurClient is still pointing to the last application.
This is problematic when IMMS#mCurClient matches
SystemConfig#getFixedImeApps(), because it means that the current
IME is to be fixed to null.
With this CL, IMMS#unbindCurrentClientLocked() is always called
every time when IMMS#mCurMethodId is cleared to null. Note that
clearing IMMS#mCurMethodId to null is a kind of hard-reset, where
unbinding IME client should make much sense in terms of robust
and predictable state management.
Bug: 18056075
Change-Id: I6c3186050592526fc95c5b27f18e2155acff5ebc
(cherry picked from commit e13a20faccf6f33aa43c9c1fa4c4ec2a79b86cfb)
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/InputMethodManagerService.java | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 4e11070..6d07a57 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -40,6 +40,7 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlSerializer; +import android.annotation.Nullable; import android.app.ActivityManagerNative; import android.app.AppGlobals; import android.app.AlertDialog; @@ -286,8 +287,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub boolean mSystemReady; /** - * Id of the currently selected input method. + * Id obtained with {@link InputMethodInfo#getId()} for the currently selected input method. + * method. This is to be synchronized with the secure settings keyed with + * {@link Settings.Secure#DEFAULT_INPUT_METHOD}. + * + * <p>This can be transiently {@code null} when the system is re-initializing input method + * settings, e.g., the system locale is just changed.</p> + * + * <p>Note that {@link #mCurId} is used to track which IME is being connected to + * {@link InputMethodManagerService}.</p> + * + * @see #mCurId */ + @Nullable String mCurMethodId; /** @@ -317,9 +329,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub EditorInfo mCurAttribute; /** - * The input method ID of the input method service that we are currently + * Id obtained with {@link InputMethodInfo#getId()} for the input method that we are currently * connected to or in the process of connecting to. + * + * <p>This can be {@code null} when no input method is connected.</p> + * + * @see #mCurMethodId */ + @Nullable String mCurId; /** @@ -967,7 +984,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub || (newLocale != null && !newLocale.equals(mLastSystemLocale))) { if (!updateOnlyWhenLocaleChanged) { hideCurrentInputLocked(0, null); - mCurMethodId = null; unbindCurrentMethodLocked(true, false); } if (DEBUG) { @@ -1523,7 +1539,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub channel.dispose(); } - void unbindCurrentMethodLocked(boolean reportToClient, boolean savePosition) { + void unbindCurrentMethodLocked(boolean resetCurrentMethodAndClient, boolean savePosition) { + if (resetCurrentMethodAndClient) { + mCurMethodId = null; + } + if (mVisibleBound) { mContext.unbindService(mVisibleConnection); mVisibleBound = false; @@ -1550,9 +1570,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mCurId = null; clearCurMethodLocked(); - if (reportToClient && mCurClient != null) { - executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( - MSG_UNBIND_METHOD, mCurSeq, mCurClient.client)); + if (resetCurrentMethodAndClient) { + unbindCurrentClientLocked(); } } @@ -1903,13 +1922,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); } catch (IllegalArgumentException e) { Slog.w(TAG, "Unknown input method from prefs: " + id, e); - mCurMethodId = null; unbindCurrentMethodLocked(true, false); } mShortcutInputMethodsAndSubtypes.clear(); } else { // There is no longer an input method set, so stop any current one. - mCurMethodId = null; unbindCurrentMethodLocked(true, false); } // Here is not the perfect place to reset the switching controller. Ideally |