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

Commit 42ec1d86 authored by Adam He's avatar Adam He
Browse files

Changed notifySessionLifecycle() API to notifySessionResumed() and

notifySessionPaused().

Bug: 139811826
Fixes: 141568144
Test: atest CtsAutoFillServiceTestCases
Test: atest android.contentcaptureservice.cts.CustomViewActivityTest#testSessionLifecycleEvents
Change-Id: Id5ed40a538020c5a7087556dccbda26909ffd3c2
parent 2ee7cf73
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -53052,7 +53052,8 @@ 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 notifySessionPaused();
    method public final void notifySessionResumed();
    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);
+7 −2
Original line number Diff line number Diff line
@@ -89,8 +89,13 @@ final class ChildContentCaptureSession extends ContentCaptureSession {
    }

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

    @Override
    void internalNotifySessionPaused() {
        getMainCaptureSession().notifySessionPaused();
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -404,14 +404,14 @@ public final class ContentCaptureManager {
    @UiThread
    public void onActivityResumed() {
        if (mOptions.lite) return;
        getMainContentCaptureSession().notifySessionLifecycle(/* started= */ true);
        getMainContentCaptureSession().notifySessionResumed();
    }

    /** @hide */
    @UiThread
    public void onActivityPaused() {
        if (mOptions.lite) return;
        getMainContentCaptureSession().notifySessionLifecycle(/* started= */ false);
        getMainContentCaptureSession().notifySessionPaused();
    }

    /** @hide */
+15 −6
Original line number Diff line number Diff line
@@ -439,17 +439,26 @@ public abstract class ContentCaptureSession implements AutoCloseable {
    public abstract void internalNotifyViewTreeEvent(boolean started);

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

        internalNotifySessionResumed();
    }

    abstract void internalNotifySessionResumed();

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

        internalNotifySessionLifecycle(started);
        internalNotifySessionPaused();
    }

    abstract void internalNotifySessionLifecycle(boolean started);
    abstract void internalNotifySessionPaused();

    /**
     * Creates a {@link ViewStructure} for a "standard" view.
+13 −5
Original line number Diff line number Diff line
@@ -583,8 +583,13 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
    }

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

    @Override
    public void internalNotifySessionPaused() {
        notifySessionPaused(mId);
    }

    @Override
@@ -642,9 +647,12 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        sendEvent(new ContentCaptureEvent(sessionId, type), FORCE_FLUSH);
    }

    void notifySessionLifecycle(int sessionId, boolean started) {
        final int type = started ? TYPE_SESSION_RESUMED : TYPE_SESSION_PAUSED;
        sendEvent(new ContentCaptureEvent(sessionId, type), FORCE_FLUSH);
    void notifySessionResumed(int sessionId) {
        sendEvent(new ContentCaptureEvent(sessionId, TYPE_SESSION_RESUMED), FORCE_FLUSH);
    }

    void notifySessionPaused(int sessionId) {
        sendEvent(new ContentCaptureEvent(sessionId, TYPE_SESSION_PAUSED), FORCE_FLUSH);
    }

    void notifyContextUpdated(int sessionId, @Nullable ContentCaptureContext context) {
Loading