From 9e4ca44e28ff23d56be186943adec9721e76d1dc Mon Sep 17 00:00:00 2001 From: Feng Cao Date: Sun, 2 Jun 2019 11:05:16 -0700 Subject: [PATCH] Only send text update for TextView after VIEW_ADDED is notified Test: atest CtsContentCaptureServiceTestCases (sanity check) Fixes: 134309443 Change-Id: Ia94194576db0a1679bbb2a9b76c84a871b965435 --- core/java/android/view/View.java | 6 ++++++ core/java/android/widget/TextView.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 063f02422d29f..fd4dafc81f368 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -9510,6 +9510,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPrivateFlags4 &= ~PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED; } + /** @hide */ + protected boolean getNotifiedContentCaptureAppeared() { + return (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0; + } + + /** * Sets the (optional) {@link ContentCaptureSession} associated with this view. * diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index ac144b202bd5b..0918c5fdefa88 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -10586,7 +10586,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // notifyAppeared was not sent. // ContentCapture - if (isLaidOut() && isImportantForContentCapture()) { + if (isLaidOut() && isImportantForContentCapture() && getNotifiedContentCaptureAppeared()) { final ContentCaptureManager cm = mContext.getSystemService(ContentCaptureManager.class); if (cm != null && cm.isContentCaptureEnabled()) { final ContentCaptureSession session = getContentCaptureSession();