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

Commit 4eecbe6e authored by Felipe Leme's avatar Felipe Leme
Browse files

Add new ContentCapture APIs to let apps change the ContentCaptureContext.

Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.LoginActivityTest#testSimpleLifecycle_changeContextOnCreate \
   CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.LoginActivityTest#testSimpleLifecycle_changeContextAfterCreate
Test: atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureEventTest

Bug: 124266664

Change-Id: I0348e81e1b2bac01363cf615d2ab32e5bab8aee1
parent 7c2f5716
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -53462,6 +53462,7 @@ package android.view.contentcapture {
    method public void close();
    method @NonNull public final android.view.contentcapture.ContentCaptureSession createContentCaptureSession(@NonNull android.view.contentcapture.ContentCaptureContext);
    method public final void destroy();
    method @Nullable public final android.view.contentcapture.ContentCaptureContext getContentCaptureContext();
    method public final android.view.contentcapture.ContentCaptureSessionId getContentCaptureSessionId();
    method @NonNull public android.view.autofill.AutofillId newAutofillId(@NonNull android.view.autofill.AutofillId, long);
    method @NonNull public final android.view.ViewStructure newVirtualViewStructure(@NonNull android.view.autofill.AutofillId, long);
@@ -53469,6 +53470,7 @@ package android.view.contentcapture {
    method public final void notifyViewDisappeared(@NonNull android.view.autofill.AutofillId);
    method public final void notifyViewTextChanged(@NonNull android.view.autofill.AutofillId, @Nullable CharSequence);
    method public final void notifyViewsDisappeared(@NonNull android.view.autofill.AutofillId, @NonNull long[]);
    method public final void setContentCaptureContext(@Nullable android.view.contentcapture.ContentCaptureContext);
  }
  public final class ContentCaptureSessionId implements android.os.Parcelable {
+2 −0
Original line number Diff line number Diff line
@@ -9317,6 +9317,7 @@ package android.view.contentcapture {
  public final class ContentCaptureEvent implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.view.contentcapture.ContentCaptureContext getContentCaptureContext();
    method public long getEventTime();
    method @Nullable public android.view.autofill.AutofillId getId();
    method @Nullable public java.util.List<android.view.autofill.AutofillId> getIds();
@@ -9325,6 +9326,7 @@ package android.view.contentcapture {
    method @Nullable public android.view.contentcapture.ViewNode getViewNode();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.contentcapture.ContentCaptureEvent> CREATOR;
    field public static final int TYPE_CONTEXT_UPDATED = 6; // 0x6
    field public static final int TYPE_INITIAL_VIEW_TREE_APPEARED = 5; // 0x5
    field public static final int TYPE_INITIAL_VIEW_TREE_APPEARING = 4; // 0x4
    field public static final int TYPE_VIEW_APPEARED = 1; // 0x1
+2 −0
Original line number Diff line number Diff line
@@ -2725,6 +2725,7 @@ package android.view.contentcapture {

  public final class ContentCaptureEvent implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.view.contentcapture.ContentCaptureContext getContentCaptureContext();
    method public long getEventTime();
    method @Nullable public android.view.autofill.AutofillId getId();
    method @Nullable public java.util.List<android.view.autofill.AutofillId> getIds();
@@ -2733,6 +2734,7 @@ package android.view.contentcapture {
    method @Nullable public android.view.contentcapture.ViewNode getViewNode();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.contentcapture.ContentCaptureEvent> CREATOR;
    field public static final int TYPE_CONTEXT_UPDATED = 6; // 0x6
    field public static final int TYPE_INITIAL_VIEW_TREE_APPEARED = 5; // 0x5
    field public static final int TYPE_INITIAL_VIEW_TREE_APPEARING = 4; // 0x4
    field public static final int TYPE_VIEW_APPEARED = 1; // 0x1
+3 −3
Original line number Diff line number Diff line
@@ -339,7 +339,7 @@ public abstract class ContentCaptureService extends Service {
            }
            switch (event.getType()) {
                case ContentCaptureEvent.TYPE_SESSION_STARTED:
                    final ContentCaptureContext clientContext = event.getClientContext();
                    final ContentCaptureContext clientContext = event.getContentCaptureContext();
                    clientContext.setParentSessionId(event.getParentSessionId());
                    mSessionUids.put(sessionIdString, uid);
                    onCreateContentCaptureSession(clientContext, sessionId);
@@ -383,8 +383,8 @@ public abstract class ContentCaptureService extends Service {
        }
        final Integer rightUid = mSessionUids.get(sessionId);
        if (rightUid == null) {
            if (DEBUG) {
                Log.d(TAG, "handleIsRightCallerFor(" + event + "): no session for " + sessionId
            if (VERBOSE) {
                Log.v(TAG, "handleIsRightCallerFor(" + event + "): no session for " + sessionId
                        + ": " + mSessionUids);
            }
            // Just ignore, as the session could have been finished already
+1 −1
Original line number Diff line number Diff line
@@ -9366,7 +9366,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Gets the session used to notify Content Capture events.
     *
     * @return session explicitly set by {@link #setContentCaptureSession(ContentCaptureSession)},
     * inherited by ancestore, default session or {@code null} if content capture is disabled for
     * inherited by ancestors, default session or {@code null} if content capture is disabled for
     * this view.
     */
    @Nullable
Loading