diff options
| author | Adam He <adamhe@google.com> | 2021-09-22 20:13:53 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-09-22 20:13:53 +0000 |
| commit | b9eafd3c02bc7edfd8dce8591dddfb146ecb1b76 (patch) | |
| tree | a8ef5c29141f9d1f9a6cef6aca1bc0a762c2bc82 /core/java/android | |
| parent | 8e2e8608a1342a3f1ff6852515d0d5ade9a09299 (diff) | |
| parent | d9e69e2b50dd0d1756774edaddecc3dc2d4b9547 (diff) | |
Merge "Content Capture change to send window token on creating session." into sc-v2-dev
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/contentcapture/ContentCaptureContext.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/core/java/android/view/contentcapture/ContentCaptureContext.java b/core/java/android/view/contentcapture/ContentCaptureContext.java index 9998fbc02d12..0da54e57ed79 100644 --- a/core/java/android/view/contentcapture/ContentCaptureContext.java +++ b/core/java/android/view/contentcapture/ContentCaptureContext.java @@ -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; } /** @@ -230,6 +235,20 @@ public final class ContentCaptureContext implements Parcelable { } /** + * 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. * * @return any combination of {@link #FLAG_DISABLED_BY_FLAG_SECURE}, @@ -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); } } |
