summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/InputMethodManagerService.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2010-11-23 06:06:29 +0900
committersatok <satok@google.com>2010-11-23 06:20:23 +0900
commit3ef8b29fa03fe3ae1c57fd891a12afa46128fff8 (patch)
tree2d409aed72e43b021666ac82138120ef4c6a4026 /services/java/com/android/server/InputMethodManagerService.java
parent804043193a46a79a8616fd7696fb781edb80b519 (diff)
Synchronize getCurrentInputMethodSubtype
Change-Id: I8bcedb39baba10e7035d5c1c11f41f74943874d1
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java38
1 files changed, 21 insertions, 17 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 84bc10079414..e14345b9ea7c 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1912,7 +1912,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
// If there are no selected subtypes, tries finding the most applicable one according to the
// current system locale
- private int findApplicableSubtype(String id) {
+ private int findApplicableSubtypeLocked(String id) {
InputMethodInfo imi = mMethodMap.get(id);
if (imi == null) {
return NOT_A_SUBTYPE_ID;
@@ -1954,24 +1954,28 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
* @return Return the current subtype of this input method.
*/
public InputMethodSubtype getCurrentInputMethodSubtype() {
- boolean subtypeIsSelected = false;
- try {
- subtypeIsSelected = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE) != NOT_A_SUBTYPE_ID;
- } catch (SettingNotFoundException e) {
- }
- if (!subtypeIsSelected || mCurrentSubtype == null) {
- String lastInputMethodId = Settings.Secure.getString(mContext
- .getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
- int subtypeId = getSelectedInputMethodSubtypeId(lastInputMethodId);
- if (subtypeId == NOT_A_SUBTYPE_ID) {
- subtypeId = findApplicableSubtype(lastInputMethodId);
- }
- if (subtypeId != NOT_A_SUBTYPE_ID) {
- mCurrentSubtype = mMethodMap.get(lastInputMethodId).getSubtypes().get(subtypeId);
+ synchronized (mMethodMap) {
+ boolean subtypeIsSelected = false;
+ try {
+ subtypeIsSelected = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE) != NOT_A_SUBTYPE_ID;
+ } catch (SettingNotFoundException e) {
+ }
+ if (!subtypeIsSelected || mCurrentSubtype == null) {
+ String lastInputMethodId =
+ Settings.Secure.getString(mContext.getContentResolver(),
+ Settings.Secure.DEFAULT_INPUT_METHOD);
+ int subtypeId = getSelectedInputMethodSubtypeId(lastInputMethodId);
+ if (subtypeId == NOT_A_SUBTYPE_ID) {
+ subtypeId = findApplicableSubtypeLocked(lastInputMethodId);
+ }
+ if (subtypeId != NOT_A_SUBTYPE_ID) {
+ mCurrentSubtype =
+ mMethodMap.get(lastInputMethodId).getSubtypes().get(subtypeId);
+ }
}
+ return mCurrentSubtype;
}
- return mCurrentSubtype;
}
public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {