Merge "Force to notify ContentCapture event even view is not laid out" into sc-dev

This commit is contained in:
Ahaan Ugale
2021-05-27 00:35:19 +00:00
committed by Android (Google) Code Review

View File

@@ -9828,30 +9828,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (mContext.getContentCaptureOptions() == null) return; if (mContext.getContentCaptureOptions() == null) return;
if (appeared) { if (appeared) {
if (!isLaidOut() || getVisibility() != VISIBLE // The appeared event stops sending to AiAi.
|| (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) { // 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) { if (DEBUG_CONTENT_CAPTURE) {
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'appeared' on " + this + ": laid=" Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'appeared' on " + this + ": laid="
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser() + isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE) + ", visible=" + (getVisibility() == VISIBLE)
+ ": alreadyNotifiedAppeared=" + ((mPrivateFlags4 + ": alreadyNotifiedAppeared=" + getNotifiedContentCaptureAppeared()
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) + ", alreadyNotifiedDisappeared="
+ ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4 + getNotifiedContentCaptureDisappeared());
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
} }
return; return;
} }
} else { } else {
if ((mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) == 0 if (!getNotifiedContentCaptureAppeared() || getNotifiedContentCaptureDisappeared()) {
|| (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0) {
if (DEBUG_CONTENT_CAPTURE) { if (DEBUG_CONTENT_CAPTURE) {
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'disappeared' on " + this + ": laid=" Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'disappeared' on " + this + ": laid="
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser() + isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE) + ", visible=" + (getVisibility() == VISIBLE)
+ ": alreadyNotifiedAppeared=" + ((mPrivateFlags4 + ": alreadyNotifiedAppeared=" + getNotifiedContentCaptureAppeared()
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) + ", alreadyNotifiedDisappeared="
+ ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4 + getNotifiedContentCaptureDisappeared());
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
} }
return; return;
} }
@@ -9899,6 +9906,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. * Sets the (optional) {@link ContentCaptureSession} associated with this view.
* *