diff options
author | Yohei Yukawa <yukawa@google.com> | 2014-05-22 12:49:00 +0900 |
---|---|---|
committer | Yohei Yukawa <yukawa@google.com> | 2014-05-22 18:18:02 +0900 |
commit | 5a647b69be8ac8d40c33ed9abe63e41514699e5b (patch) | |
tree | ced03f8b88fb4d59d2a176f859cea1cb53f9e95b /services | |
parent | 69b43b496472132c4eaee0f9007d453c6f6a49b2 (diff) | |
download | frameworks_base-5a647b69be8ac8d40c33ed9abe63e41514699e5b.zip frameworks_base-5a647b69be8ac8d40c33ed9abe63e41514699e5b.tar.gz frameworks_base-5a647b69be8ac8d40c33ed9abe63e41514699e5b.tar.bz2 |
Remove unnecessary internal lock
Previously, InputMethodSubtypeSwitchingController has relied on
its own internal lock for #getNextInputMethod and
class has to be invalidated whenever
InputMethodManagerService#mMethodMap is updated, any method of
InputMethodSubtypeSwitchingController should be called under
the global lock of InputMethodManagerService#mMethodMap.
As a consequence, we can conclude that
InputMethodSubtypeSwitchingController does not need its own
internal lock.
This CL also adds additional synchronization blocks into
the constructor of InputMethodManagerService to address the
existing inconsistency that methods with *Locked suffix are
called without the lock actually.
BUG: 7043015
Change-Id: I9d4d3d7232c984432185c10c13fb726a6158cac8
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/InputMethodManagerService.java | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 2d270e7..fb69c86 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -692,8 +692,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mRes, context.getContentResolver(), mMethodMap, mMethodList, userId); updateCurrentProfileIds(); mFileManager = new InputMethodFileManager(mMethodMap, userId); - mSwitchingController = new InputMethodSubtypeSwitchingController(mSettings); - mSwitchingController.resetCircularListLocked(context); + synchronized (mMethodMap) { + mSwitchingController = InputMethodSubtypeSwitchingController.createInstanceLocked( + mSettings, context); + } // Just checking if defaultImiId is empty or not final String defaultImiId = mSettings.getSelectedInputMethod(); @@ -702,17 +704,23 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } mImeSelectedOnBoot = !TextUtils.isEmpty(defaultImiId); - buildInputMethodListLocked(mMethodList, mMethodMap, - !mImeSelectedOnBoot /* resetDefaultEnabledIme */); + synchronized (mMethodMap) { + buildInputMethodListLocked(mMethodList, mMethodMap, + !mImeSelectedOnBoot /* resetDefaultEnabledIme */); + } mSettings.enableAllIMEsIfThereIsNoEnabledIME(); if (!mImeSelectedOnBoot) { Slog.w(TAG, "No IME selected. Choose the most applicable IME."); - resetDefaultImeLocked(context); + synchronized (mMethodMap) { + resetDefaultImeLocked(context); + } } mSettingsObserver = new SettingsObserver(mHandler); - updateFromSettingsLocked(true); + synchronized (mMethodMap) { + updateFromSettingsLocked(true); + } // IMMS wants to receive Intent.ACTION_LOCALE_CHANGED in order to update the current IME // according to the new system locale. @@ -2174,7 +2182,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return false; } synchronized (mMethodMap) { - final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethod( + final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked( onlyCurrentIme, mMethodMap.get(mCurMethodId), mCurrentSubtype); if (nextSubtype == null) { return false; @@ -2190,7 +2198,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return false; } synchronized (mMethodMap) { - final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethod( + final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked( false /* onlyCurrentIme */, mMethodMap.get(mCurMethodId), mCurrentSubtype); if (nextSubtype == null) { return false; @@ -2273,9 +2281,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (DEBUG) { Slog.d(TAG, "Got the notification of commitText"); } - final InputMethodInfo imi = mMethodMap.get(mCurMethodId); - if (imi != null) { - mSwitchingController.onCommitText(imi, mCurrentSubtype); + synchronized (mMethodMap) { + final InputMethodInfo imi = mMethodMap.get(mCurMethodId); + if (imi != null) { + mSwitchingController.onCommitTextLocked(imi, mCurrentSubtype); + } } } @@ -2698,7 +2708,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub hideInputMethodMenuLocked(); final List<ImeSubtypeListItem> imList = - mSwitchingController.getSortedInputMethodAndSubtypeList( + mSwitchingController.getSortedInputMethodAndSubtypeListLocked( showSubtypes, mInputShown, isScreenLocked); if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { |