Fix possible NPE caused while monkey test
Bug: 7269036 Change-Id: I9054b33ad3c8996cac3ee5f0e9c01ba8ceea4971main
parent
15281adbc1
commit
d445b56ce1
|
@ -390,7 +390,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getManualCapsMode() {
|
public int getManualCapsMode() {
|
||||||
switch (getKeyboard().mId.mElementId) {
|
final Keyboard keyboard = getKeyboard();
|
||||||
|
if (keyboard == null) {
|
||||||
|
return WordComposer.CAPS_MODE_OFF;
|
||||||
|
}
|
||||||
|
switch (keyboard.mId.mElementId) {
|
||||||
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
|
||||||
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
|
case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
|
||||||
return WordComposer.CAPS_MODE_MANUAL_SHIFT_LOCKED;
|
return WordComposer.CAPS_MODE_MANUAL_SHIFT_LOCKED;
|
||||||
|
|
|
@ -1910,6 +1910,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
}
|
}
|
||||||
|
|
||||||
private SuggestedWords getSuggestedWords(final int sessionId) {
|
private SuggestedWords getSuggestedWords(final int sessionId) {
|
||||||
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||||
|
if (keyboard == null) {
|
||||||
|
return SuggestedWords.EMPTY;
|
||||||
|
}
|
||||||
final String typedWord = mWordComposer.getTypedWord();
|
final String typedWord = mWordComposer.getTypedWord();
|
||||||
// Get the word on which we should search the bigrams. If we are composing a word, it's
|
// Get the word on which we should search the bigrams. If we are composing a word, it's
|
||||||
// whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
|
// whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
|
||||||
|
@ -1919,8 +1923,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
mConnection.getNthPreviousWord(mCurrentSettings.mWordSeparators,
|
mConnection.getNthPreviousWord(mCurrentSettings.mWordSeparators,
|
||||||
mWordComposer.isComposingWord() ? 2 : 1);
|
mWordComposer.isComposingWord() ? 2 : 1);
|
||||||
final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer,
|
final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer,
|
||||||
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(),
|
prevWord, keyboard.getProximityInfo(), mCurrentSettings.mCorrectionEnabled,
|
||||||
mCurrentSettings.mCorrectionEnabled, sessionId);
|
sessionId);
|
||||||
return maybeRetrieveOlderSuggestions(typedWord, suggestedWords);
|
return maybeRetrieveOlderSuggestions(typedWord, suggestedWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,14 +177,16 @@ public final class WordComposer {
|
||||||
* Internal method to retrieve reasonable proximity info for a character.
|
* Internal method to retrieve reasonable proximity info for a character.
|
||||||
*/
|
*/
|
||||||
private void addKeyInfo(final int codePoint, final Keyboard keyboard) {
|
private void addKeyInfo(final int codePoint, final Keyboard keyboard) {
|
||||||
final Key key = keyboard.getKey(codePoint);
|
final int x, y;
|
||||||
if (key != null) {
|
final Key key;
|
||||||
final int x = key.mX + key.mWidth / 2;
|
if (keyboard != null && (key = keyboard.getKey(codePoint)) != null) {
|
||||||
final int y = key.mY + key.mHeight / 2;
|
x = key.mX + key.mWidth / 2;
|
||||||
add(codePoint, x, y);
|
y = key.mY + key.mHeight / 2;
|
||||||
return;
|
} else {
|
||||||
|
x = Constants.NOT_A_COORDINATE;
|
||||||
|
y = Constants.NOT_A_COORDINATE;
|
||||||
}
|
}
|
||||||
add(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
add(codePoint, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,7 +197,7 @@ public final class WordComposer {
|
||||||
reset();
|
reset();
|
||||||
final int length = word.length();
|
final int length = word.length();
|
||||||
for (int i = 0; i < length; i = Character.offsetByCodePoints(word, i, 1)) {
|
for (int i = 0; i < length; i = Character.offsetByCodePoints(word, i, 1)) {
|
||||||
int codePoint = Character.codePointAt(word, i);
|
final int codePoint = Character.codePointAt(word, i);
|
||||||
addKeyInfo(codePoint, keyboard);
|
addKeyInfo(codePoint, keyboard);
|
||||||
}
|
}
|
||||||
mIsResumed = true;
|
mIsResumed = true;
|
||||||
|
|
Loading…
Reference in New Issue