summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TYM Tsai <tymtsai@google.com> 2021-05-22 00:36:02 +0800
committer TYM Tsai <tymtsai@google.com> 2021-05-27 00:52:50 +0800
commit1d0ad768721b0005cbd5925cb4715e8f029f534c (patch)
tree8e662df672d9f13f4977b6c5a347a916f8116975
parent86d3f3deaea4af79b77ecc7e2fbdcc6d10954279 (diff)
Force to notify ContentCapture event even view is not laid out
Some recycled views cached its layout and a relayout is unnecessary. In this case, system still needs to notify content capture the view appeared. Bug: 177687849 Test: atest CtsContentCaptureServiceTestCases Test: atest ContentCapturePerfTests Change-Id: I480436c4fc3508b9eed485421a1cc778d55d5dde
-rw-r--r--core/java/android/view/View.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index acc0fc178d6e..e5f15618b0f1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -9817,30 +9817,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (mContext.getContentCaptureOptions() == null) return;
if (appeared) {
- if (!isLaidOut() || getVisibility() != VISIBLE
- || (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) {
+ // The appeared event stops sending to AiAi.
+ // 1. The view is hidden.
+ // 2. The same event was sent.
+ // 3. The view is not laid out, and it will be laid out in the future.
+ // Some recycled views cached its layout and a relayout is unnecessary. In this case,
+ // system still needs to notify content capture the view appeared. When a view is
+ // recycled, it will set the flag PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED.
+ final boolean isRecycledWithoutRelayout = getNotifiedContentCaptureDisappeared()
+ && getVisibility() == VISIBLE
+ && !isLayoutRequested();
+ if (getVisibility() != VISIBLE || getNotifiedContentCaptureAppeared()
+ || !(isLaidOut() || isRecycledWithoutRelayout)) {
if (DEBUG_CONTENT_CAPTURE) {
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'appeared' on " + this + ": laid="
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE)
- + ": alreadyNotifiedAppeared=" + ((mPrivateFlags4
- & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0)
- + ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4
- & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
+ + ": alreadyNotifiedAppeared=" + getNotifiedContentCaptureAppeared()
+ + ", alreadyNotifiedDisappeared="
+ + getNotifiedContentCaptureDisappeared());
}
return;
}
} else {
- if ((mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) == 0
- || (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0) {
+ if (!getNotifiedContentCaptureAppeared() || getNotifiedContentCaptureDisappeared()) {
if (DEBUG_CONTENT_CAPTURE) {
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'disappeared' on " + this + ": laid="
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE)
- + ": alreadyNotifiedAppeared=" + ((mPrivateFlags4
- & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0)
- + ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4
- & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
+ + ": alreadyNotifiedAppeared=" + getNotifiedContentCaptureAppeared()
+ + ", alreadyNotifiedDisappeared="
+ + getNotifiedContentCaptureDisappeared());
}
return;
}
@@ -9888,6 +9895,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
+ private boolean getNotifiedContentCaptureDisappeared() {
+ return (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0;
+ }
+
/**
* Sets the (optional) {@link ContentCaptureSession} associated with this view.
*