Merge "Fix Keyboard.getKey as thread safe"

main
Tadashi G. Takaoka 2012-07-04 19:58:17 -07:00 committed by Android (Google) Code Review
commit 7aeb7ef1ab
1 changed files with 13 additions and 11 deletions

View File

@ -185,6 +185,7 @@ public class Keyboard {
if (code == CODE_UNSPECIFIED) {
return null;
}
synchronized (mKeyCache) {
final int index = mKeyCache.indexOfKey(code);
if (index >= 0) {
return mKeyCache.valueAt(index);
@ -199,6 +200,7 @@ public class Keyboard {
mKeyCache.put(code, null);
return null;
}
}
public boolean hasKey(Key aKey) {
if (mKeyCache.indexOfValue(aKey) >= 0) {