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

Commit 5814cca1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add notifySessionLifecycle() to ContentCaptureSession."

parents 62db716f 34f8cc5f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53041,6 +53041,7 @@ package android.view.contentcapture {
    method @NonNull public android.view.autofill.AutofillId newAutofillId(@NonNull android.view.autofill.AutofillId, long);
    method @NonNull public final android.view.ViewStructure newViewStructure(@NonNull android.view.View);
    method @NonNull public final android.view.ViewStructure newVirtualViewStructure(@NonNull android.view.autofill.AutofillId, long);
    method public final void notifySessionLifecycle(boolean);
    method public final void notifyViewAppeared(@NonNull android.view.ViewStructure);
    method public final void notifyViewDisappeared(@NonNull android.view.autofill.AutofillId);
    method public final void notifyViewTextChanged(@NonNull android.view.autofill.AutofillId, @Nullable CharSequence);
+5 −0
Original line number Diff line number Diff line
@@ -88,6 +88,11 @@ final class ChildContentCaptureSession extends ContentCaptureSession {
        getMainCaptureSession().notifyViewTreeEvent(mId, started);
    }

    @Override
    public void internalNotifySessionLifecycle(boolean started) {
        getMainCaptureSession().notifySessionLifecycle(mId, started);
    }

    @Override
    boolean isContentCaptureEnabled() {
        return getMainCaptureSession().isContentCaptureEnabled();
+13 −0
Original line number Diff line number Diff line
@@ -438,6 +438,19 @@ public abstract class ContentCaptureSession implements AutoCloseable {
    /** @hide */
    public abstract void internalNotifyViewTreeEvent(boolean started);

    /**
     * Notifies the Content Capture Service that a session has paused/resumed.
     *
     * @param started whether session has resumed.
     */
    public final void notifySessionLifecycle(boolean started) {
        if (!isContentCaptureEnabled()) return;

        internalNotifySessionLifecycle(started);
    }

    abstract void internalNotifySessionLifecycle(boolean started);

    /**
     * Creates a {@link ViewStructure} for a "standard" view.
     *
+7 −3
Original line number Diff line number Diff line
@@ -582,6 +582,11 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        notifyViewTreeEvent(mId, started);
    }

    @Override
    public void internalNotifySessionLifecycle(boolean started) {
        notifySessionLifecycle(mId, started);
    }

    @Override
    boolean isContentCaptureEnabled() {
        return super.isContentCaptureEnabled() && mManager.isContentCaptureEnabled();
@@ -637,10 +642,9 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        sendEvent(new ContentCaptureEvent(sessionId, type), FORCE_FLUSH);
    }

    /** Public because is also used by ViewRootImpl */
    public void notifySessionLifecycle(boolean started) {
    void notifySessionLifecycle(int sessionId, boolean started) {
        final int type = started ? TYPE_SESSION_RESUMED : TYPE_SESSION_PAUSED;
        sendEvent(new ContentCaptureEvent(mId, type), FORCE_FLUSH);
        sendEvent(new ContentCaptureEvent(sessionId, type), FORCE_FLUSH);
    }

    void notifyContextUpdated(int sessionId, @Nullable ContentCaptureContext context) {
+5 −0
Original line number Diff line number Diff line
@@ -161,6 +161,11 @@ public class ContentCaptureSessionTest {
            throw new UnsupportedOperationException("should not have been called");
        }

        @Override
        public void internalNotifySessionLifecycle(boolean started) {
            throw new UnsupportedOperationException("Should not have been called");
        }

        @Override
        public void updateContentCaptureContext(ContentCaptureContext context) {
            throw new UnsupportedOperationException("should not have been called");