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

Commit a9ccf347 authored by Adam He's avatar Adam He Committed by Automerger Merge Worker
Browse files

Merge "Content Capture change to send window token on creating session." into...

Merge "Content Capture change to send window token on creating session." into sc-v2-dev am: b9eafd3c am: ba74f172

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15875817

Change-Id: I00cab1e2fbd4c42dbc41aa57f26b570f7b93a4aa
parents 6d70c078 ba74f172
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14399,6 +14399,7 @@ package android.view.contentcapture {
    method public int getFlags();
    method @Nullable public android.view.contentcapture.ContentCaptureSessionId getParentSessionId();
    method public int getTaskId();
    method @Nullable public android.os.IBinder getWindowToken();
    field public static final int FLAG_DISABLED_BY_APP = 1; // 0x1
    field public static final int FLAG_DISABLED_BY_FLAG_SECURE = 2; // 0x2
    field public static final int FLAG_RECONNECTED = 4; // 0x4
+25 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.LocusId;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.Display;
@@ -105,6 +106,7 @@ public final class ContentCaptureContext implements Parcelable {
    private final int mFlags;
    private final int mDisplayId;
    private final ActivityId mActivityId;
    private final IBinder mWindowToken;

    // Fields below are set by the service upon "delivery" and are not marshalled in the parcel
    private int mParentSessionId = NO_SESSION_ID;
@@ -112,7 +114,7 @@ public final class ContentCaptureContext implements Parcelable {
    /** @hide */
    public ContentCaptureContext(@Nullable ContentCaptureContext clientContext,
            @NonNull ActivityId activityId, @NonNull ComponentName componentName, int displayId,
            int flags) {
            IBinder windowToken, int flags) {
        if (clientContext != null) {
            mHasClientContext = true;
            mExtras = clientContext.mExtras;
@@ -126,6 +128,7 @@ public final class ContentCaptureContext implements Parcelable {
        mFlags = flags;
        mDisplayId = displayId;
        mActivityId = activityId;
        mWindowToken = windowToken;
    }

    private ContentCaptureContext(@NonNull Builder builder) {
@@ -137,6 +140,7 @@ public final class ContentCaptureContext implements Parcelable {
        mFlags = 0;
        mDisplayId = Display.INVALID_DISPLAY;
        mActivityId = null;
        mWindowToken = null;
    }

    /** @hide */
@@ -148,6 +152,7 @@ public final class ContentCaptureContext implements Parcelable {
        mFlags = original.mFlags | extraFlags;
        mDisplayId = original.mDisplayId;
        mActivityId = original.mActivityId;
        mWindowToken = original.mWindowToken;
    }

    /**
@@ -229,6 +234,20 @@ public final class ContentCaptureContext implements Parcelable {
        return mDisplayId;
    }

    /**
     * Gets the window token of the activity associated with this context.
     *
     * <p>The token can be used to attach relevant overlay views to the activity's window. This can
     * be done through {@link android.view.WindowManager.LayoutParams#token}.
     *
     * @hide
     */
    @SystemApi
    @Nullable
    public IBinder getWindowToken() {
        return mWindowToken;
    }

    /**
     * Gets the flags associated with this context.
     *
@@ -328,6 +347,7 @@ public final class ContentCaptureContext implements Parcelable {
        }
        pw.print(", activityId="); pw.print(mActivityId);
        pw.print(", displayId="); pw.print(mDisplayId);
        pw.print(", windowToken="); pw.print(mWindowToken);
        if (mParentSessionId != NO_SESSION_ID) {
            pw.print(", parentId="); pw.print(mParentSessionId);
        }
@@ -352,6 +372,7 @@ public final class ContentCaptureContext implements Parcelable {
            builder.append("act=").append(ComponentName.flattenToShortString(mComponentName))
                .append(", activityId=").append(mActivityId)
                .append(", displayId=").append(mDisplayId)
                .append(", windowToken=").append(mWindowToken)
                .append(", flags=").append(mFlags);
        } else {
            builder.append("id=").append(mId);
@@ -381,6 +402,7 @@ public final class ContentCaptureContext implements Parcelable {
        parcel.writeParcelable(mComponentName, flags);
        if (fromServer()) {
            parcel.writeInt(mDisplayId);
            parcel.writeStrongBinder(mWindowToken);
            parcel.writeInt(mFlags);
            mActivityId.writeToParcel(parcel, flags);
        }
@@ -411,11 +433,12 @@ public final class ContentCaptureContext implements Parcelable {
                return clientContext;
            } else {
                final int displayId = parcel.readInt();
                final IBinder windowToken = parcel.readStrongBinder();
                final int flags = parcel.readInt();
                final ActivityId activityId = new ActivityId(parcel);

                return new ContentCaptureContext(clientContext, activityId, componentName,
                        displayId, flags);
                        displayId, windowToken, flags);
            }
        }

+3 −1
Original line number Diff line number Diff line
@@ -39,9 +39,10 @@ public class ContentCaptureContextTest {
    public void testConstructorAdditionalFlags() {
        final ComponentName componentName = new ComponentName("component", "name");
        final IBinder token = new Binder();
        final IBinder windowToken = new Binder();
        final ContentCaptureContext ctx = new ContentCaptureContext(/* clientContext= */ null,
                new ActivityId(/* taskId= */ 666, token), componentName, /* displayId= */
                42, /* flags= */ 1);
                42, windowToken, /* flags= */ 1);
        final ContentCaptureContext newCtx = new ContentCaptureContext(ctx, /* extraFlags= */ 2);
        assertThat(newCtx.getFlags()).isEqualTo(3);
        assertThat(newCtx.getActivityComponent()).isEqualTo(componentName);
@@ -50,6 +51,7 @@ public class ContentCaptureContextTest {
        assertThat(activityId.getTaskId()).isEqualTo(666);
        assertThat(activityId.getToken()).isEqualTo(token);
        assertThat(newCtx.getDisplayId()).isEqualTo(42);
        assertThat(newCtx.getWindowToken()).isEqualTo(windowToken);
        assertThat(newCtx.getExtras()).isNull();
        assertThat(newCtx.getLocusId()).isNull();
        assertThat(newCtx.getParentSessionId()).isNull();
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ final class ContentCaptureServerSession {
        mId = sessionId;
        mUid = uid;
        mContentCaptureContext = new ContentCaptureContext(/* clientContext= */ null,
                activityId, appComponentName, displayId, flags);
                activityId, appComponentName, displayId, activityToken, flags);
        mSessionStateReceiver = sessionStateReceiver;
        try {
            sessionStateReceiver.asBinder().linkToDeath(() -> onClientDeath(), 0);