aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-07-29 13:58:52 -0700
committerTadashi G. Takaoka <takaoka@google.com>2010-07-29 14:54:21 -0700
commit35f6cd905d94a5dea3eb8b341663e84f801c66f1 (patch)
tree409942028f1891fbe2f3abac0bc906c2f575fea4 /java
parentbc305c21bf840f2a2476e8df4995c9c2191659f3 (diff)
downloadlatinime-35f6cd905d94a5dea3eb8b341663e84f801c66f1.tar.gz
latinime-35f6cd905d94a5dea3eb8b341663e84f801c66f1.tar.xz
latinime-35f6cd905d94a5dea3eb8b341663e84f801c66f1.zip
Fix possible NPE and IndexOutOfBoundsException.
Bug: 2868304 Change-Id: I2c474736fb9bb95da9e04bdeb9b9b641e7c3adda
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index e7fbd22dd..665c641c2 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -320,7 +320,8 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
};
static class KeyDebouncer {
- private Key[] mKeys;
+ private final Key[] mKeys;
+ private final int mKeyDebounceThresholdSquared;
// for move de-bouncing
private int mLastCodeX;
@@ -334,9 +335,9 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
private long mLastMoveTime;
private long mCurrentKeyTime;
- private final int mKeyDebounceThresholdSquared;
-
KeyDebouncer(Key[] keys, float hysteresisPixel) {
+ if (keys == null || hysteresisPixel < 1.0f)
+ throw new IllegalArgumentException();
mKeys = keys;
mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel);
}
@@ -379,11 +380,11 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
public boolean isMinorMoveBounce(int x, int y, int newKey, int curKey) {
if (newKey == curKey) {
return true;
- } else if (curKey == NOT_A_KEY) {
- return false;
- } else {
+ } else if (curKey >= 0 && curKey < mKeys.length) {
return getSquareDistanceToKeyEdge(x, y, mKeys[curKey])
- < mKeyDebounceThresholdSquared;
+ < mKeyDebounceThresholdSquared;
+ } else {
+ return false;
}
}