From 944e668d3710f43b7068513e657920b3c729ebd8 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 29 Feb 2024 13:31:19 +0700 Subject: [PATCH] fix(android): icText null check --- .../app/src/main/java/com/keyman/engine/KMKeyboard.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java index 8a477a644b0..bdd0f4f65c4 100644 --- a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java +++ b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java @@ -168,11 +168,13 @@ protected boolean updateSelectionRange(int selStart, int selEnd) { InputConnection ic = KMManager.getInputConnection(this.keyboardType); if (ic != null) { ExtractedText icText = ic.getExtractedText(new ExtractedTextRequest(), 0); - String rawText = icText.text.toString(); - if (icText != null) { - updateText(rawText.toString()); + if (icText == null) { + return false; } + String rawText = icText.text.toString(); + updateText(rawText.toString()); + /* The values of selStart & selEnd provided by the system are in code units, not code-points. We need to account for surrogate pairs here.