summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/InputMethodManagerService.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2012-05-21 12:58:45 +0900
committersatok <satok@google.com>2012-05-21 18:30:14 +0900
commitd81e950265356c81276b73da68a535ffa48d72f0 (patch)
treeeec30b460669c705c17213b45176f33bdf2dbe64 /services/java/com/android/server/InputMethodManagerService.java
parent5d4d23ebdf42a90207a86fc258a44e9540f356ab (diff)
Fix the issue on the inconsistent condition of InputMethodSubtype
Bug: 6510104 Change-Id: I67790e5f59d0d05340b74eca1029c60f381061b8
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java51
1 files changed, 30 insertions, 21 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 4935d796177e..ff14568c8956 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -657,6 +657,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
buildInputMethodListLocked(mMethodList, mMethodMap);
// Reset the current ime to the proper one
resetDefaultImeLocked(mContext);
+ updateFromSettingsLocked();
mLastSystemLocale = newLocale;
}
}
@@ -1439,34 +1440,41 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
throw new IllegalArgumentException("Unknown id: " + id);
}
+ // See if we need to notify a subtype change within the same IME.
if (id.equals(mCurMethodId)) {
- InputMethodSubtype subtype = null;
- if (subtypeId >= 0 && subtypeId < info.getSubtypeCount()) {
- subtype = info.getSubtypeAt(subtypeId);
+ final int subtypeCount = info.getSubtypeCount();
+ if (subtypeCount <= 0) {
+ return;
}
- if (subtype != mCurrentSubtype) {
- synchronized (mMethodMap) {
- if (subtype != null) {
- setSelectedInputMethodAndSubtypeLocked(info, subtypeId, true);
- }
- if (mCurMethod != null) {
- try {
- refreshImeWindowVisibilityLocked();
- // If subtype is null, try to find the most applicable one from
- // getCurrentInputMethodSubtype.
- if (subtype == null) {
- subtype = getCurrentInputMethodSubtype();
- }
- mCurMethod.changeInputMethodSubtype(subtype);
- } catch (RemoteException e) {
- return;
- }
+ final InputMethodSubtype oldSubtype = mCurrentSubtype;
+ final InputMethodSubtype newSubtype;
+ if (subtypeId >= 0 && subtypeId < subtypeCount) {
+ newSubtype = info.getSubtypeAt(subtypeId);
+ } else {
+ // If subtype is null, try to find the most applicable one from
+ // getCurrentInputMethodSubtype.
+ newSubtype = getCurrentInputMethodSubtype();
+ }
+ if (newSubtype == null || oldSubtype == null) {
+ Slog.w(TAG, "Illegal subtype state: old subtype = " + oldSubtype
+ + ", new subtype = " + newSubtype);
+ return;
+ }
+ if (newSubtype != oldSubtype) {
+ setSelectedInputMethodAndSubtypeLocked(info, subtypeId, true);
+ if (mCurMethod != null) {
+ try {
+ refreshImeWindowVisibilityLocked();
+ mCurMethod.changeInputMethodSubtype(newSubtype);
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Failed to call changeInputMethodSubtype");
}
}
}
return;
}
+ // Changing to a different IME.
final long ident = Binder.clearCallingIdentity();
try {
// Set a subtype to this input method.
@@ -2653,7 +2661,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
mCurrentSubtype = subtype;
} else {
mSettings.putSelectedSubtype(NOT_A_SUBTYPE_ID);
- mCurrentSubtype = null;
+ // If the subtype is not specified, choose the most applicable one
+ mCurrentSubtype = getCurrentInputMethodSubtype();
}
}