Merge "Add Content Capture event TYPE_WINDOW_BOUNDS_CHANGED to notify window bounds." into sc-v2-dev am: 8e2e8608a1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15856579 Change-Id: Ic66995a013565492a45f6dc675ababc09ad91e60
This commit is contained in:
@@ -14499,6 +14499,7 @@ package android.view.contentcapture {
|
|||||||
|
|
||||||
public final class ContentCaptureEvent implements android.os.Parcelable {
|
public final class ContentCaptureEvent implements android.os.Parcelable {
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
|
method @Nullable public android.graphics.Rect getBounds();
|
||||||
method @Nullable public android.view.contentcapture.ContentCaptureContext getContentCaptureContext();
|
method @Nullable public android.view.contentcapture.ContentCaptureContext getContentCaptureContext();
|
||||||
method public long getEventTime();
|
method public long getEventTime();
|
||||||
method @Nullable public android.view.autofill.AutofillId getId();
|
method @Nullable public android.view.autofill.AutofillId getId();
|
||||||
@@ -14518,6 +14519,7 @@ package android.view.contentcapture {
|
|||||||
field public static final int TYPE_VIEW_TEXT_CHANGED = 3; // 0x3
|
field public static final int TYPE_VIEW_TEXT_CHANGED = 3; // 0x3
|
||||||
field public static final int TYPE_VIEW_TREE_APPEARED = 5; // 0x5
|
field public static final int TYPE_VIEW_TREE_APPEARED = 5; // 0x5
|
||||||
field public static final int TYPE_VIEW_TREE_APPEARING = 4; // 0x4
|
field public static final int TYPE_VIEW_TREE_APPEARING = 4; // 0x4
|
||||||
|
field public static final int TYPE_WINDOW_BOUNDS_CHANGED = 10; // 0xa
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class ContentCaptureManager {
|
public final class ContentCaptureManager {
|
||||||
|
|||||||
@@ -4273,6 +4273,14 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
try {
|
try {
|
||||||
if (!isContentCaptureEnabled()) return;
|
if (!isContentCaptureEnabled()) return;
|
||||||
|
|
||||||
|
// Initial dispatch of window bounds to content capture
|
||||||
|
if (mAttachInfo.mContentCaptureManager != null) {
|
||||||
|
MainContentCaptureSession session =
|
||||||
|
mAttachInfo.mContentCaptureManager.getMainContentCaptureSession();
|
||||||
|
session.notifyWindowBoundsChanged(session.getId(),
|
||||||
|
getConfiguration().windowConfiguration.getBounds());
|
||||||
|
}
|
||||||
|
|
||||||
// Content capture is a go!
|
// Content capture is a go!
|
||||||
rootView.dispatchInitialProvideContentCaptureStructure();
|
rootView.dispatchInitialProvideContentCaptureStructure();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -7804,6 +7812,14 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
|
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
|
||||||
mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
|
mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
|
||||||
mTempControls, mSurfaceSize);
|
mTempControls, mSurfaceSize);
|
||||||
|
|
||||||
|
if (mAttachInfo.mContentCaptureManager != null) {
|
||||||
|
MainContentCaptureSession mainSession = mAttachInfo.mContentCaptureManager
|
||||||
|
.getMainContentCaptureSession();
|
||||||
|
mainSession.notifyWindowBoundsChanged(mainSession.getId(),
|
||||||
|
getConfiguration().windowConfiguration.getBounds());
|
||||||
|
}
|
||||||
|
|
||||||
mPendingBackDropFrame.set(mTmpFrames.backdropFrame);
|
mPendingBackDropFrame.set(mTmpFrames.backdropFrame);
|
||||||
if (mSurfaceControl.isValid()) {
|
if (mSurfaceControl.isValid()) {
|
||||||
if (!useBLAST()) {
|
if (!useBLAST()) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.text.Selection;
|
import android.text.Selection;
|
||||||
@@ -122,6 +123,12 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public static final int TYPE_VIEW_INSETS_CHANGED = 9;
|
public static final int TYPE_VIEW_INSETS_CHANGED = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before {@link #TYPE_VIEW_TREE_APPEARING}, or after the size of the window containing
|
||||||
|
* the views changed.
|
||||||
|
*/
|
||||||
|
public static final int TYPE_WINDOW_BOUNDS_CHANGED = 10;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@IntDef(prefix = { "TYPE_" }, value = {
|
@IntDef(prefix = { "TYPE_" }, value = {
|
||||||
TYPE_VIEW_APPEARED,
|
TYPE_VIEW_APPEARED,
|
||||||
@@ -132,7 +139,8 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
TYPE_CONTEXT_UPDATED,
|
TYPE_CONTEXT_UPDATED,
|
||||||
TYPE_SESSION_PAUSED,
|
TYPE_SESSION_PAUSED,
|
||||||
TYPE_SESSION_RESUMED,
|
TYPE_SESSION_RESUMED,
|
||||||
TYPE_VIEW_INSETS_CHANGED
|
TYPE_VIEW_INSETS_CHANGED,
|
||||||
|
TYPE_WINDOW_BOUNDS_CHANGED,
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface EventType{}
|
public @interface EventType{}
|
||||||
@@ -150,6 +158,7 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
private int mParentSessionId = NO_SESSION_ID;
|
private int mParentSessionId = NO_SESSION_ID;
|
||||||
private @Nullable ContentCaptureContext mClientContext;
|
private @Nullable ContentCaptureContext mClientContext;
|
||||||
private @Nullable Insets mInsets;
|
private @Nullable Insets mInsets;
|
||||||
|
private @Nullable Rect mBounds;
|
||||||
|
|
||||||
private int mComposingStart = MAX_INVALID_VALUE;
|
private int mComposingStart = MAX_INVALID_VALUE;
|
||||||
private int mComposingEnd = MAX_INVALID_VALUE;
|
private int mComposingEnd = MAX_INVALID_VALUE;
|
||||||
@@ -346,6 +355,13 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@NonNull
|
||||||
|
public ContentCaptureEvent setBounds(@NonNull Rect bounds) {
|
||||||
|
mBounds = bounds;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type of the event.
|
* Gets the type of the event.
|
||||||
*
|
*
|
||||||
@@ -418,6 +434,16 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
return mInsets;
|
return mInsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Rect} bounds of the window associated with the event. Valid bounds will only
|
||||||
|
* be returned if the type of the event is {@link #TYPE_WINDOW_BOUNDS_CHANGED}, otherwise they
|
||||||
|
* will be null.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Rect getBounds() {
|
||||||
|
return mBounds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges event of the same type, either {@link #TYPE_VIEW_TEXT_CHANGED}
|
* Merges event of the same type, either {@link #TYPE_VIEW_TEXT_CHANGED}
|
||||||
* or {@link #TYPE_VIEW_DISAPPEARED}.
|
* or {@link #TYPE_VIEW_DISAPPEARED}.
|
||||||
@@ -489,6 +515,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
if (mInsets != null) {
|
if (mInsets != null) {
|
||||||
pw.print(", insets="); pw.println(mInsets);
|
pw.print(", insets="); pw.println(mInsets);
|
||||||
}
|
}
|
||||||
|
if (mBounds != null) {
|
||||||
|
pw.print(", bounds="); pw.println(mBounds);
|
||||||
|
}
|
||||||
if (mComposingStart > MAX_INVALID_VALUE) {
|
if (mComposingStart > MAX_INVALID_VALUE) {
|
||||||
pw.print(", composing("); pw.print(mComposingStart);
|
pw.print(", composing("); pw.print(mComposingStart);
|
||||||
pw.print(", "); pw.print(mComposingEnd); pw.print(")");
|
pw.print(", "); pw.print(mComposingEnd); pw.print(")");
|
||||||
@@ -533,6 +562,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
if (mInsets != null) {
|
if (mInsets != null) {
|
||||||
string.append(", insets=").append(mInsets);
|
string.append(", insets=").append(mInsets);
|
||||||
}
|
}
|
||||||
|
if (mBounds != null) {
|
||||||
|
string.append(", bounds=").append(mBounds);
|
||||||
|
}
|
||||||
if (mComposingStart > MAX_INVALID_VALUE) {
|
if (mComposingStart > MAX_INVALID_VALUE) {
|
||||||
string.append(", composing=[")
|
string.append(", composing=[")
|
||||||
.append(mComposingStart).append(",").append(mComposingEnd).append("]");
|
.append(mComposingStart).append(",").append(mComposingEnd).append("]");
|
||||||
@@ -568,6 +600,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
if (mType == TYPE_VIEW_INSETS_CHANGED) {
|
if (mType == TYPE_VIEW_INSETS_CHANGED) {
|
||||||
parcel.writeParcelable(mInsets, flags);
|
parcel.writeParcelable(mInsets, flags);
|
||||||
}
|
}
|
||||||
|
if (mType == TYPE_WINDOW_BOUNDS_CHANGED) {
|
||||||
|
parcel.writeParcelable(mBounds, flags);
|
||||||
|
}
|
||||||
if (mType == TYPE_VIEW_TEXT_CHANGED) {
|
if (mType == TYPE_VIEW_TEXT_CHANGED) {
|
||||||
parcel.writeInt(mComposingStart);
|
parcel.writeInt(mComposingStart);
|
||||||
parcel.writeInt(mComposingEnd);
|
parcel.writeInt(mComposingEnd);
|
||||||
@@ -608,6 +643,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
if (type == TYPE_VIEW_INSETS_CHANGED) {
|
if (type == TYPE_VIEW_INSETS_CHANGED) {
|
||||||
event.setInsets(parcel.readParcelable(null));
|
event.setInsets(parcel.readParcelable(null));
|
||||||
}
|
}
|
||||||
|
if (type == TYPE_WINDOW_BOUNDS_CHANGED) {
|
||||||
|
event.setBounds(parcel.readParcelable(null));
|
||||||
|
}
|
||||||
if (type == TYPE_VIEW_TEXT_CHANGED) {
|
if (type == TYPE_VIEW_TEXT_CHANGED) {
|
||||||
event.setComposingIndex(parcel.readInt(), parcel.readInt());
|
event.setComposingIndex(parcel.readInt(), parcel.readInt());
|
||||||
event.restoreComposingSpan();
|
event.restoreComposingSpan();
|
||||||
@@ -649,6 +687,8 @@ public final class ContentCaptureEvent implements Parcelable {
|
|||||||
return "CONTEXT_UPDATED";
|
return "CONTEXT_UPDATED";
|
||||||
case TYPE_VIEW_INSETS_CHANGED:
|
case TYPE_VIEW_INSETS_CHANGED:
|
||||||
return "VIEW_INSETS_CHANGED";
|
return "VIEW_INSETS_CHANGED";
|
||||||
|
case TYPE_WINDOW_BOUNDS_CHANGED:
|
||||||
|
return "TYPE_WINDOW_BOUNDS_CHANGED";
|
||||||
default:
|
default:
|
||||||
return "UKNOWN_TYPE: " + type;
|
return "UKNOWN_TYPE: " + type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_INSETS_C
|
|||||||
import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_TEXT_CHANGED;
|
import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_TEXT_CHANGED;
|
||||||
import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_TREE_APPEARED;
|
import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_TREE_APPEARED;
|
||||||
import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_TREE_APPEARING;
|
import static android.view.contentcapture.ContentCaptureEvent.TYPE_VIEW_TREE_APPEARING;
|
||||||
|
import static android.view.contentcapture.ContentCaptureEvent.TYPE_WINDOW_BOUNDS_CHANGED;
|
||||||
import static android.view.contentcapture.ContentCaptureHelper.getSanitizedString;
|
import static android.view.contentcapture.ContentCaptureHelper.getSanitizedString;
|
||||||
import static android.view.contentcapture.ContentCaptureHelper.sDebug;
|
import static android.view.contentcapture.ContentCaptureHelper.sDebug;
|
||||||
import static android.view.contentcapture.ContentCaptureHelper.sVerbose;
|
import static android.view.contentcapture.ContentCaptureHelper.sVerbose;
|
||||||
@@ -38,6 +39,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -776,6 +778,14 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
|||||||
.setClientContext(context), FORCE_FLUSH));
|
.setClientContext(context), FORCE_FLUSH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** public because is also used by ViewRootImpl */
|
||||||
|
public void notifyWindowBoundsChanged(int sessionId, @NonNull Rect bounds) {
|
||||||
|
mHandler.post(() -> sendEvent(
|
||||||
|
new ContentCaptureEvent(sessionId, TYPE_WINDOW_BOUNDS_CHANGED)
|
||||||
|
.setBounds(bounds)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
||||||
super.dump(prefix, pw);
|
super.dump(prefix, pw);
|
||||||
|
|||||||
Reference in New Issue
Block a user