Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39631823 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14683430

Change-Id: I2f7a064416c1f82de756084cc87758f2de77432c
parents 74c85198 75d63c11
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -9828,30 +9828,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;
            }
@@ -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.
     *