From 038f7a8b09db95a375a9eab49fa89ab8b2e40b81 Mon Sep 17 00:00:00 2001 From: Clara Bayarri Date: Mon, 4 Jun 2018 15:00:07 +0100 Subject: [PATCH] Fix repeated calls into reportExtractedText As part of adding the hint text feature in I357dd5c74b61d149cf8612d1f52c7118ec70c696 I refactored the code inside reportExtractedText to avoid nesting but lost one of the condition checks in the process. Since onDraw calls into this method on each frame, the missing check was causing calls to be made into the IME even when no content or selection changes have happened. Test: CtsWidgetTestCases:.TextViewTest Bug: 73613936 Change-Id: If56e3f1d45e64dccd052e4cff4d742f0cbecc07c --- core/java/android/widget/Editor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 10de4497c05cd..d07721a3c27a1 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -1688,6 +1688,11 @@ public class Editor { if (ims == null) { return false; } + final boolean wasContentChanged = ims.mContentChanged; + if (!wasContentChanged && !ims.mSelectionModeChanged) { + return false; + } + ims.mContentChanged = false; ims.mSelectionModeChanged = false; final ExtractedTextRequest req = ims.mExtractedTextRequest; if (req == null) { @@ -1703,7 +1708,7 @@ public class Editor { + " end=" + ims.mChangedEnd + " delta=" + ims.mChangedDelta); } - if (ims.mChangedStart < 0 && !ims.mContentChanged) { + if (ims.mChangedStart < 0 && !wasContentChanged) { ims.mChangedStart = EXTRACT_NOTHING; } if (extractTextInternal(req, ims.mChangedStart, ims.mChangedEnd,