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

Commit 34f8cc5f authored by Adam He's avatar Adam He
Browse files

Add notifySessionLifecycle() to ContentCaptureSession.

Fixes: 139811826
Test: atest CtsContentCaptureServiceTestCases
Change-Id: Ia318ff220a8b13462655eb584fb400414163774f
parent 945b6893
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53033,6 +53033,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");