Skip to content

Commit

Permalink
Merge pull request #11481 from keymanapp/fix/android/null-string-startup
Browse files Browse the repository at this point in the history
fix(android/app): Verify extracted text is not null
  • Loading branch information
darcywong00 authored May 20, 2024
2 parents ec76ece + 9e0207a commit 3d29143
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ExtractedText icText = ic.getExtractedText(new ExtractedTextRequest(), 0);
if (icText != null) {
/*
We do sometimes receive null `icText.text`, even though
getExtractedText() docs does not list this as a possible
return value, so we test for that as well (#11479)
*/
if (icText != null && icText.text != null) {
boolean didUpdateText = KMManager.updateText(KeyboardType.KEYBOARD_TYPE_SYSTEM, icText.text.toString());
boolean didUpdateSelection = KMManager.updateSelectionRange(KeyboardType.KEYBOARD_TYPE_SYSTEM);
if (!didUpdateText || !didUpdateSelection)
Expand Down

0 comments on commit 3d29143

Please sign in to comment.