am cfbb7fbd: Fix: Read lock is wrongly used for gutSuggestions.

* commit 'cfbb7fbd48125909ed61e58500e56b06afc12709':
  Fix: Read lock is wrongly used for gutSuggestions.
main
Keisuke Kuroynagi 2013-07-09 01:54:44 -07:00 committed by Android Git Automerger
commit 551091ef39
1 changed files with 3 additions and 2 deletions

View File

@ -196,7 +196,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
final String prevWord, final ProximityInfo proximityInfo, final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords) { final boolean blockOffensiveWords) {
asyncReloadDictionaryIfRequired(); asyncReloadDictionaryIfRequired();
if (mLocalDictionaryController.readLock().tryLock()) { // Write lock because getSuggestions in native updates session status.
if (mLocalDictionaryController.writeLock().tryLock()) {
try { try {
final ArrayList<SuggestedWordInfo> inMemDictSuggestion = final ArrayList<SuggestedWordInfo> inMemDictSuggestion =
mDictionaryWriter.getSuggestions(composer, prevWord, proximityInfo, mDictionaryWriter.getSuggestions(composer, prevWord, proximityInfo,
@ -217,7 +218,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
return inMemDictSuggestion; return inMemDictSuggestion;
} }
} finally { } finally {
mLocalDictionaryController.readLock().unlock(); mLocalDictionaryController.writeLock().unlock();
} }
} }
return null; return null;