Optimize InputConnection.getCursorCapsMode calling
Bug: 6464226 Change-Id: I30c1b01be5e1719ded5f7f8a7e24a38e9bbc3637
This commit is contained in:
parent
67b2c58404
commit
03ca17c841
1 changed files with 18 additions and 6 deletions
|
@ -1026,13 +1026,25 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getCurrentAutoCapsState() {
|
public boolean getCurrentAutoCapsState() {
|
||||||
|
if (!mSettingsValues.mAutoCap) return false;
|
||||||
|
|
||||||
|
final EditorInfo ei = getCurrentInputEditorInfo();
|
||||||
|
if (ei == null) return false;
|
||||||
|
|
||||||
|
final int inputType = ei.inputType;
|
||||||
|
if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) return true;
|
||||||
|
|
||||||
|
final boolean noNeedToCheckCapsMode = (inputType & (InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||||
|
| InputType.TYPE_TEXT_FLAG_CAP_WORDS)) == 0;
|
||||||
|
if (noNeedToCheckCapsMode) return false;
|
||||||
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
EditorInfo ei = getCurrentInputEditorInfo();
|
if (ic == null) return false;
|
||||||
if (mSettingsValues.mAutoCap && ic != null && ei != null
|
// TODO: This blocking IPC call is heavy. Consider doing this without using IPC calls.
|
||||||
&& ei.inputType != InputType.TYPE_NULL) {
|
// Note: getCursorCapsMode() returns the current capitalization mode that is any
|
||||||
return ic.getCursorCapsMode(ei.inputType) != 0;
|
// combination of CAP_MODE_CHARACTERS, CAP_MODE_WORDS, and CAP_MODE_SENTENCES. 0 means none
|
||||||
}
|
// of them.
|
||||||
return false;
|
return ic.getCursorCapsMode(inputType) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ic" may be null
|
// "ic" may be null
|
||||||
|
|
Loading…
Reference in a new issue