Merge "Content Capture change to send window token on creating session." into sc-v2-dev
This commit is contained in:
@@ -14450,6 +14450,7 @@ package android.view.contentcapture {
|
|||||||
method public int getFlags();
|
method public int getFlags();
|
||||||
method @Nullable public android.view.contentcapture.ContentCaptureSessionId getParentSessionId();
|
method @Nullable public android.view.contentcapture.ContentCaptureSessionId getParentSessionId();
|
||||||
method public int getTaskId();
|
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_APP = 1; // 0x1
|
||||||
field public static final int FLAG_DISABLED_BY_FLAG_SECURE = 2; // 0x2
|
field public static final int FLAG_DISABLED_BY_FLAG_SECURE = 2; // 0x2
|
||||||
field public static final int FLAG_RECONNECTED = 4; // 0x4
|
field public static final int FLAG_RECONNECTED = 4; // 0x4
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.LocusId;
|
import android.content.LocusId;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.IBinder;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@@ -105,6 +106,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
private final int mFlags;
|
private final int mFlags;
|
||||||
private final int mDisplayId;
|
private final int mDisplayId;
|
||||||
private final ActivityId mActivityId;
|
private final ActivityId mActivityId;
|
||||||
|
private final IBinder mWindowToken;
|
||||||
|
|
||||||
// Fields below are set by the service upon "delivery" and are not marshalled in the parcel
|
// Fields below are set by the service upon "delivery" and are not marshalled in the parcel
|
||||||
private int mParentSessionId = NO_SESSION_ID;
|
private int mParentSessionId = NO_SESSION_ID;
|
||||||
@@ -112,7 +114,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
public ContentCaptureContext(@Nullable ContentCaptureContext clientContext,
|
public ContentCaptureContext(@Nullable ContentCaptureContext clientContext,
|
||||||
@NonNull ActivityId activityId, @NonNull ComponentName componentName, int displayId,
|
@NonNull ActivityId activityId, @NonNull ComponentName componentName, int displayId,
|
||||||
int flags) {
|
IBinder windowToken, int flags) {
|
||||||
if (clientContext != null) {
|
if (clientContext != null) {
|
||||||
mHasClientContext = true;
|
mHasClientContext = true;
|
||||||
mExtras = clientContext.mExtras;
|
mExtras = clientContext.mExtras;
|
||||||
@@ -126,6 +128,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
mFlags = flags;
|
mFlags = flags;
|
||||||
mDisplayId = displayId;
|
mDisplayId = displayId;
|
||||||
mActivityId = activityId;
|
mActivityId = activityId;
|
||||||
|
mWindowToken = windowToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContentCaptureContext(@NonNull Builder builder) {
|
private ContentCaptureContext(@NonNull Builder builder) {
|
||||||
@@ -137,6 +140,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
mFlags = 0;
|
mFlags = 0;
|
||||||
mDisplayId = Display.INVALID_DISPLAY;
|
mDisplayId = Display.INVALID_DISPLAY;
|
||||||
mActivityId = null;
|
mActivityId = null;
|
||||||
|
mWindowToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -148,6 +152,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
mFlags = original.mFlags | extraFlags;
|
mFlags = original.mFlags | extraFlags;
|
||||||
mDisplayId = original.mDisplayId;
|
mDisplayId = original.mDisplayId;
|
||||||
mActivityId = original.mActivityId;
|
mActivityId = original.mActivityId;
|
||||||
|
mWindowToken = original.mWindowToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,6 +234,20 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
return mDisplayId;
|
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.
|
* 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(", activityId="); pw.print(mActivityId);
|
||||||
pw.print(", displayId="); pw.print(mDisplayId);
|
pw.print(", displayId="); pw.print(mDisplayId);
|
||||||
|
pw.print(", windowToken="); pw.print(mWindowToken);
|
||||||
if (mParentSessionId != NO_SESSION_ID) {
|
if (mParentSessionId != NO_SESSION_ID) {
|
||||||
pw.print(", parentId="); pw.print(mParentSessionId);
|
pw.print(", parentId="); pw.print(mParentSessionId);
|
||||||
}
|
}
|
||||||
@@ -352,6 +372,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
builder.append("act=").append(ComponentName.flattenToShortString(mComponentName))
|
builder.append("act=").append(ComponentName.flattenToShortString(mComponentName))
|
||||||
.append(", activityId=").append(mActivityId)
|
.append(", activityId=").append(mActivityId)
|
||||||
.append(", displayId=").append(mDisplayId)
|
.append(", displayId=").append(mDisplayId)
|
||||||
|
.append(", windowToken=").append(mWindowToken)
|
||||||
.append(", flags=").append(mFlags);
|
.append(", flags=").append(mFlags);
|
||||||
} else {
|
} else {
|
||||||
builder.append("id=").append(mId);
|
builder.append("id=").append(mId);
|
||||||
@@ -381,6 +402,7 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
parcel.writeParcelable(mComponentName, flags);
|
parcel.writeParcelable(mComponentName, flags);
|
||||||
if (fromServer()) {
|
if (fromServer()) {
|
||||||
parcel.writeInt(mDisplayId);
|
parcel.writeInt(mDisplayId);
|
||||||
|
parcel.writeStrongBinder(mWindowToken);
|
||||||
parcel.writeInt(mFlags);
|
parcel.writeInt(mFlags);
|
||||||
mActivityId.writeToParcel(parcel, flags);
|
mActivityId.writeToParcel(parcel, flags);
|
||||||
}
|
}
|
||||||
@@ -411,11 +433,12 @@ public final class ContentCaptureContext implements Parcelable {
|
|||||||
return clientContext;
|
return clientContext;
|
||||||
} else {
|
} else {
|
||||||
final int displayId = parcel.readInt();
|
final int displayId = parcel.readInt();
|
||||||
|
final IBinder windowToken = parcel.readStrongBinder();
|
||||||
final int flags = parcel.readInt();
|
final int flags = parcel.readInt();
|
||||||
final ActivityId activityId = new ActivityId(parcel);
|
final ActivityId activityId = new ActivityId(parcel);
|
||||||
|
|
||||||
return new ContentCaptureContext(clientContext, activityId, componentName,
|
return new ContentCaptureContext(clientContext, activityId, componentName,
|
||||||
displayId, flags);
|
displayId, windowToken, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ public class ContentCaptureContextTest {
|
|||||||
public void testConstructorAdditionalFlags() {
|
public void testConstructorAdditionalFlags() {
|
||||||
final ComponentName componentName = new ComponentName("component", "name");
|
final ComponentName componentName = new ComponentName("component", "name");
|
||||||
final IBinder token = new Binder();
|
final IBinder token = new Binder();
|
||||||
|
final IBinder windowToken = new Binder();
|
||||||
final ContentCaptureContext ctx = new ContentCaptureContext(/* clientContext= */ null,
|
final ContentCaptureContext ctx = new ContentCaptureContext(/* clientContext= */ null,
|
||||||
new ActivityId(/* taskId= */ 666, token), componentName, /* displayId= */
|
new ActivityId(/* taskId= */ 666, token), componentName, /* displayId= */
|
||||||
42, /* flags= */ 1);
|
42, windowToken, /* flags= */ 1);
|
||||||
final ContentCaptureContext newCtx = new ContentCaptureContext(ctx, /* extraFlags= */ 2);
|
final ContentCaptureContext newCtx = new ContentCaptureContext(ctx, /* extraFlags= */ 2);
|
||||||
assertThat(newCtx.getFlags()).isEqualTo(3);
|
assertThat(newCtx.getFlags()).isEqualTo(3);
|
||||||
assertThat(newCtx.getActivityComponent()).isEqualTo(componentName);
|
assertThat(newCtx.getActivityComponent()).isEqualTo(componentName);
|
||||||
@@ -50,6 +51,7 @@ public class ContentCaptureContextTest {
|
|||||||
assertThat(activityId.getTaskId()).isEqualTo(666);
|
assertThat(activityId.getTaskId()).isEqualTo(666);
|
||||||
assertThat(activityId.getToken()).isEqualTo(token);
|
assertThat(activityId.getToken()).isEqualTo(token);
|
||||||
assertThat(newCtx.getDisplayId()).isEqualTo(42);
|
assertThat(newCtx.getDisplayId()).isEqualTo(42);
|
||||||
|
assertThat(newCtx.getWindowToken()).isEqualTo(windowToken);
|
||||||
assertThat(newCtx.getExtras()).isNull();
|
assertThat(newCtx.getExtras()).isNull();
|
||||||
assertThat(newCtx.getLocusId()).isNull();
|
assertThat(newCtx.getLocusId()).isNull();
|
||||||
assertThat(newCtx.getParentSessionId()).isNull();
|
assertThat(newCtx.getParentSessionId()).isNull();
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ final class ContentCaptureServerSession {
|
|||||||
mId = sessionId;
|
mId = sessionId;
|
||||||
mUid = uid;
|
mUid = uid;
|
||||||
mContentCaptureContext = new ContentCaptureContext(/* clientContext= */ null,
|
mContentCaptureContext = new ContentCaptureContext(/* clientContext= */ null,
|
||||||
activityId, appComponentName, displayId, flags);
|
activityId, appComponentName, displayId, activityToken, flags);
|
||||||
mSessionStateReceiver = sessionStateReceiver;
|
mSessionStateReceiver = sessionStateReceiver;
|
||||||
try {
|
try {
|
||||||
sessionStateReceiver.asBinder().linkToDeath(() -> onClientDeath(), 0);
|
sessionStateReceiver.asBinder().linkToDeath(() -> onClientDeath(), 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user