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

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

Merge changes from topic "cc_virtual_id"

* changes:
  New, minor ContentCapture APIs for virtual views management.
  Implemented missing methods on android.view.contentcapture.ViewNode
parents 6aae482c 2057c38a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52323,6 +52323,8 @@ package android.view.contentcapture {
    method public final android.view.contentcapture.ContentCaptureSession createContentCaptureSession(android.view.contentcapture.ContentCaptureContext);
    method public final void destroy();
    method public final android.view.contentcapture.ContentCaptureSessionId getContentCaptureSessionId();
    method public android.view.autofill.AutofillId newAutofillId(android.view.autofill.AutofillId, int);
    method public final android.view.ViewStructure newVirtualViewStructure(android.view.autofill.AutofillId, int);
    method public final void notifyViewAppeared(android.view.ViewStructure);
    method public final void notifyViewDisappeared(android.view.autofill.AutofillId);
    method public final void notifyViewTextChanged(android.view.autofill.AutofillId, java.lang.CharSequence, int);
+2 −1
Original line number Diff line number Diff line
@@ -1699,7 +1699,8 @@ public class AssistStructure implements Parcelable {

        @Override
        public void setVisibility(int visibility) {
            mNode.mFlags = (mNode.mFlags&~ViewNode.FLAGS_VISIBILITY_MASK) | visibility;
            mNode.mFlags = (mNode.mFlags & ~ViewNode.FLAGS_VISIBILITY_MASK)
                    | (visibility & ViewNode.FLAGS_VISIBILITY_MASK);
        }

        @Override
+5 −5
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ public abstract class ContentCaptureService extends Service {
     */
    public final void setContentCaptureWhitelist(@Nullable List<String> packages,
            @Nullable List<ComponentName> activities) {
        //TODO(b/111276913): implement
        //TODO(b/122595322): implement
    }

    /**
@@ -177,7 +177,7 @@ public abstract class ContentCaptureService extends Service {
     */
    public final void setActivityContentCaptureEnabled(@NonNull ComponentName activity,
            boolean enabled) {
        //TODO(b/111276913): implement
        //TODO(b/122595322): implement
    }

    /**
@@ -188,7 +188,7 @@ public abstract class ContentCaptureService extends Service {
     */
    public final void setPackageContentCaptureEnabled(@NonNull String packageName,
            boolean enabled) {
        //TODO(b/111276913): implement
        //TODO(b/122595322): implement
    }

    /**
@@ -197,7 +197,7 @@ public abstract class ContentCaptureService extends Service {
     */
    @NonNull
    public final Set<ComponentName> getContentCaptureDisabledActivities() {
        //TODO(b/111276913): implement
        //TODO(b/122595322): implement
        return null;
    }

@@ -207,7 +207,7 @@ public abstract class ContentCaptureService extends Service {
     */
    @NonNull
    public final Set<String> getContentCaptureDisabledPackages() {
        //TODO(b/111276913): implement
        //TODO(b/122595322): implement
        return null;
    }

+13 −4
Original line number Diff line number Diff line
@@ -8199,6 +8199,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * <p>The populated structure is then passed to the service through
     * {@link ContentCaptureSession#notifyViewAppeared(ViewStructure)}.
     *
     * <p><b>Note: </b>views that manage a virtual structure under this view must populate just
     * the node representing this view and return right away, then asynchronously report (not
     * necessarily in the UI thread) when the children nodes appear, disappear or have their text
     * changed by calling
     * {@link ContentCaptureSession#notifyViewAppeared(ViewStructure)},
     * {@link ContentCaptureSession#notifyViewDisappeared(AutofillId)}, and
     * {@link ContentCaptureSession#notifyViewTextChanged(AutofillId, CharSequence, int)}
     * respectively. The structure for the a child must be created using
     * {@link ContentCaptureSession#newVirtualViewStructure(AutofillId, int)}, and the
     * {@code autofillId} for a child can be obtained either through
     * {@code childStructure.getAutofillId()} or
     * {@link ContentCaptureSession#newAutofillId(AutofillId, int)}.
     *
     * <p><b>Note: </b>the following methods of the {@code structure} will be ignored:
     * <ul>
     *   <li>{@link ViewStructure#setChildCount(int)}
@@ -8235,10 +8248,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        } else {
            structure.setId(id, null, null, null);
        }
        if (viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
            //TODO(b/111276913): STOPSHIP - don't set it if not needed
            structure.setDataIsSensitive(false);
        }
        if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL
                || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {
+23 −5
Original line number Diff line number Diff line
@@ -46,8 +46,7 @@ public abstract class ContentCaptureSession implements AutoCloseable {

    /**
     * Used on {@link #notifyViewTextChanged(AutofillId, CharSequence, int)} to indicate that the
     *
     * thext change was caused by user input (for example, through IME).
     * text change was caused by user input (for example, through IME).
     */
    public static final int FLAG_USER_INPUT = 0x1;

@@ -301,6 +300,26 @@ public abstract class ContentCaptureSession implements AutoCloseable {
        return new ViewNode.ViewStructureImpl(view);
    }

    /**
     * Creates a new {@link AutofillId} for a virtual child, so it can be used to uniquely identify
     * the children in the session.
     *
     * @param parentId id of the virtual view parent (it can be obtained by calling
     * {@link ViewStructure#getAutofillId()} on the parent).
     * @param virtualChildId id of the virtual child, relative to the parent.
     *
     * @return if for the virtual child
     *
     * @throws IllegalArgumentException if the {@code parentId} is a virtual child id.
     */
    public @NonNull AutofillId newAutofillId(@NonNull AutofillId parentId, int virtualChildId) {
        Preconditions.checkNotNull(parentId);
        Preconditions.checkArgument(!parentId.isVirtual(), "virtual ids cannot have children");
        // TODO(b/121197119): we need to add the session id to the AutofillId to make them unique
        // per session
        return new AutofillId(parentId, virtualChildId);
    }

    /**
     * Creates a {@link ViewStructure} for a "virtual" view, so it can be passed to
     * {@link #notifyViewAppeared(ViewStructure)} by the view managing the virtual view hierarchy.
@@ -310,12 +329,11 @@ public abstract class ContentCaptureSession implements AutoCloseable {
     * @param virtualId id of the virtual child, relative to the parent.
     *
     * @return a new {@link ViewStructure} that can be used for Content Capture purposes.
     *
     * @hide
     */
    @NonNull
    public final ViewStructure newVirtualViewStructure(@NonNull AutofillId parentId,
            int virtualId) {
        // TODO(b/121197119): use the constructor that takes a session id / assert on unit test.
        return new ViewNode.ViewStructureImpl(parentId, virtualId);
    }

Loading