Loading core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -14450,6 +14450,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 core/java/android/view/contentcapture/ContentCaptureContext.java +25 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; Loading @@ -126,6 +128,7 @@ public final class ContentCaptureContext implements Parcelable { mFlags = flags; mDisplayId = displayId; mActivityId = activityId; mWindowToken = windowToken; } private ContentCaptureContext(@NonNull Builder builder) { Loading @@ -137,6 +140,7 @@ public final class ContentCaptureContext implements Parcelable { mFlags = 0; mDisplayId = Display.INVALID_DISPLAY; mActivityId = null; mWindowToken = null; } /** @hide */ Loading @@ -148,6 +152,7 @@ public final class ContentCaptureContext implements Parcelable { mFlags = original.mFlags | extraFlags; mDisplayId = original.mDisplayId; mActivityId = original.mActivityId; mWindowToken = original.mWindowToken; } /** Loading Loading @@ -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. * Loading Loading @@ -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); } Loading @@ -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); Loading Loading @@ -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); } Loading Loading @@ -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); } } Loading core/tests/coretests/src/android/view/contentcapture/ContentCaptureContextTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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(); Loading services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -14450,6 +14450,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
core/java/android/view/contentcapture/ContentCaptureContext.java +25 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; Loading @@ -126,6 +128,7 @@ public final class ContentCaptureContext implements Parcelable { mFlags = flags; mDisplayId = displayId; mActivityId = activityId; mWindowToken = windowToken; } private ContentCaptureContext(@NonNull Builder builder) { Loading @@ -137,6 +140,7 @@ public final class ContentCaptureContext implements Parcelable { mFlags = 0; mDisplayId = Display.INVALID_DISPLAY; mActivityId = null; mWindowToken = null; } /** @hide */ Loading @@ -148,6 +152,7 @@ public final class ContentCaptureContext implements Parcelable { mFlags = original.mFlags | extraFlags; mDisplayId = original.mDisplayId; mActivityId = original.mActivityId; mWindowToken = original.mWindowToken; } /** Loading Loading @@ -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. * Loading Loading @@ -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); } Loading @@ -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); Loading Loading @@ -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); } Loading Loading @@ -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); } } Loading
core/tests/coretests/src/android/view/contentcapture/ContentCaptureContextTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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(); Loading
services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading