diff options
| author | 2019-09-26 12:24:09 -0700 | |
|---|---|---|
| committer | 2019-09-30 16:46:12 -0700 | |
| commit | 42ec1d868f380d3b76bb103251ad01f33f6e51f7 (patch) | |
| tree | ba6d88464d9ea18654b0efb78491c3a93d582d2a | |
| parent | 2ee7cf7386d337e4f9cbe6001f22f47c84634a7d (diff) | |
Changed notifySessionLifecycle() API to notifySessionResumed() and
notifySessionPaused().
Bug: 139811826
Fixes: 141568144
Test: atest CtsAutoFillServiceTestCases
Test: atest android.contentcaptureservice.cts.CustomViewActivityTest#testSessionLifecycleEvents
Change-Id: Id5ed40a538020c5a7087556dccbda26909ffd3c2
6 files changed, 46 insertions, 18 deletions
diff --git a/api/current.txt b/api/current.txt index fc7685d2da97..ea521aa26ffa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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); diff --git a/core/java/android/view/contentcapture/ChildContentCaptureSession.java b/core/java/android/view/contentcapture/ChildContentCaptureSession.java index 5e02de451fa3..7487ec4d921c 100644 --- a/core/java/android/view/contentcapture/ChildContentCaptureSession.java +++ b/core/java/android/view/contentcapture/ChildContentCaptureSession.java @@ -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 diff --git a/core/java/android/view/contentcapture/ContentCaptureManager.java b/core/java/android/view/contentcapture/ContentCaptureManager.java index d22fac996dbb..6040abd4f5f6 100644 --- a/core/java/android/view/contentcapture/ContentCaptureManager.java +++ b/core/java/android/view/contentcapture/ContentCaptureManager.java @@ -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 */ diff --git a/core/java/android/view/contentcapture/ContentCaptureSession.java b/core/java/android/view/contentcapture/ContentCaptureSession.java index cf08c18b019a..232d96ba7f43 100644 --- a/core/java/android/view/contentcapture/ContentCaptureSession.java +++ b/core/java/android/view/contentcapture/ContentCaptureSession.java @@ -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. diff --git a/core/java/android/view/contentcapture/MainContentCaptureSession.java b/core/java/android/view/contentcapture/MainContentCaptureSession.java index 349ef09cf059..96f224fef251 100644 --- a/core/java/android/view/contentcapture/MainContentCaptureSession.java +++ b/core/java/android/view/contentcapture/MainContentCaptureSession.java @@ -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) { diff --git a/core/tests/coretests/src/android/view/contentcapture/ContentCaptureSessionTest.java b/core/tests/coretests/src/android/view/contentcapture/ContentCaptureSessionTest.java index c5da54936653..02a88fc8aecb 100644 --- a/core/tests/coretests/src/android/view/contentcapture/ContentCaptureSessionTest.java +++ b/core/tests/coretests/src/android/view/contentcapture/ContentCaptureSessionTest.java @@ -162,8 +162,13 @@ public class ContentCaptureSessionTest { } @Override - public void internalNotifySessionLifecycle(boolean started) { - throw new UnsupportedOperationException("Should not have been called"); + void internalNotifySessionResumed() { + throw new UnsupportedOperationException("should not have been called"); + } + + @Override + void internalNotifySessionPaused() { + throw new UnsupportedOperationException("should not have been called"); } @Override |