diff options
| author | 2014-06-04 18:37:20 +0900 | |
|---|---|---|
| committer | 2014-06-04 18:37:20 +0900 | |
| commit | 4e02bc6f8fa64d8a8398371836e2e9abf3be3070 (patch) | |
| tree | f71f8ad53a9881543d0bb7927b6bd67f094212fb | |
| parent | 41eca132b24f2371be4fa26828803395df533beb (diff) | |
Remove redundant synchronization blocks from IMMS
This is a groundwork for the subsequent fix. It should not change
existing behavior.
BUG: 15420379
Change-Id: I6f81ec77e748a8c7c26ffa1f5faf39684b210ae4
| -rw-r--r-- | services/core/java/com/android/server/InputMethodManagerService.java | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 3a8f7676653a..9e0ff1976b2a 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -2085,8 +2085,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } synchronized (mMethodMap) { if (subtype != null) { - setInputMethodWithSubtypeId(token, id, InputMethodUtils.getSubtypeIdFromHashCode( - mMethodMap.get(id), subtype.hashCode())); + setInputMethodWithSubtypeIdLocked(token, id, + InputMethodUtils.getSubtypeIdFromHashCode(mMethodMap.get(id), + subtype.hashCode())); } else { setInputMethod(token, id); } @@ -2173,7 +2174,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub Slog.d(TAG, "Switch to: " + lastImi.getId() + ", " + lastIme.second + ", from: " + mCurMethodId + ", " + subtypeId); } - setInputMethodWithSubtypeId(token, targetLastImiId, subtypeId); + setInputMethodWithSubtypeIdLocked(token, targetLastImiId, subtypeId); return true; } else { return false; @@ -2192,7 +2193,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (nextSubtype == null) { return false; } - setInputMethodWithSubtypeId(token, nextSubtype.mImi.getId(), nextSubtype.mSubtypeId); + setInputMethodWithSubtypeIdLocked(token, nextSubtype.mImi.getId(), + nextSubtype.mSubtypeId); return true; } } @@ -2317,26 +2319,30 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private void setInputMethodWithSubtypeId(IBinder token, String id, int subtypeId) { synchronized (mMethodMap) { - if (token == null) { - if (mContext.checkCallingOrSelfPermission( - android.Manifest.permission.WRITE_SECURE_SETTINGS) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException( - "Using null token requires permission " - + android.Manifest.permission.WRITE_SECURE_SETTINGS); - } - } else if (mCurToken != token) { - Slog.w(TAG, "Ignoring setInputMethod of uid " + Binder.getCallingUid() - + " token: " + token); - return; - } + setInputMethodWithSubtypeIdLocked(token, id, subtypeId); + } + } - final long ident = Binder.clearCallingIdentity(); - try { - setInputMethodLocked(id, subtypeId); - } finally { - Binder.restoreCallingIdentity(ident); + private void setInputMethodWithSubtypeIdLocked(IBinder token, String id, int subtypeId) { + if (token == null) { + if (mContext.checkCallingOrSelfPermission( + android.Manifest.permission.WRITE_SECURE_SETTINGS) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException( + "Using null token requires permission " + + android.Manifest.permission.WRITE_SECURE_SETTINGS); } + } else if (mCurToken != token) { + Slog.w(TAG, "Ignoring setInputMethod of uid " + Binder.getCallingUid() + + " token: " + token); + return; + } + + final long ident = Binder.clearCallingIdentity(); + try { + setInputMethodLocked(id, subtypeId); + } finally { + Binder.restoreCallingIdentity(ident); } } |