Merge "Add Content Capture event TYPE_WINDOW_BOUNDS_CHANGED to notify window bounds." into sc-v2-dev am: 8e2e8608a1 am: 5148940766
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15856579 Change-Id: I67ce5198d7ee024ade71adcc7196c2481e24cc17
This commit is contained in:
@@ -14406,6 +14406,7 @@ package android.view.contentcapture {
|
||||
|
||||
public final class ContentCaptureEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @Nullable public android.graphics.Rect getBounds();
|
||||
method @Nullable public android.view.contentcapture.ContentCaptureContext getContentCaptureContext();
|
||||
method public long getEventTime();
|
||||
method @Nullable public android.view.autofill.AutofillId getId();
|
||||
@@ -14425,6 +14426,7 @@ package android.view.contentcapture {
|
||||
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_APPEARING = 4; // 0x4
|
||||
field public static final int TYPE_WINDOW_BOUNDS_CHANGED = 10; // 0xa
|
||||
}
|
||||
|
||||
public final class ContentCaptureManager {
|
||||
|
||||
@@ -4269,6 +4269,14 @@ public final class ViewRootImpl implements ViewParent,
|
||||
try {
|
||||
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!
|
||||
rootView.dispatchInitialProvideContentCaptureStructure();
|
||||
} finally {
|
||||
@@ -7803,6 +7811,14 @@ public final class ViewRootImpl implements ViewParent,
|
||||
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
|
||||
mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
|
||||
mTempControls, mSurfaceSize);
|
||||
|
||||
if (mAttachInfo.mContentCaptureManager != null) {
|
||||
MainContentCaptureSession mainSession = mAttachInfo.mContentCaptureManager
|
||||
.getMainContentCaptureSession();
|
||||
mainSession.notifyWindowBoundsChanged(mainSession.getId(),
|
||||
getConfiguration().windowConfiguration.getBounds());
|
||||
}
|
||||
|
||||
mPendingBackDropFrame.set(mTmpFrames.backdropFrame);
|
||||
if (mSurfaceControl.isValid()) {
|
||||
if (!useBLAST()) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.Selection;
|
||||
@@ -121,6 +122,12 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
*/
|
||||
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 */
|
||||
@IntDef(prefix = { "TYPE_" }, value = {
|
||||
TYPE_VIEW_APPEARED,
|
||||
@@ -131,7 +138,8 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
TYPE_CONTEXT_UPDATED,
|
||||
TYPE_SESSION_PAUSED,
|
||||
TYPE_SESSION_RESUMED,
|
||||
TYPE_VIEW_INSETS_CHANGED
|
||||
TYPE_VIEW_INSETS_CHANGED,
|
||||
TYPE_WINDOW_BOUNDS_CHANGED,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface EventType{}
|
||||
@@ -149,6 +157,7 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
private int mParentSessionId = NO_SESSION_ID;
|
||||
private @Nullable ContentCaptureContext mClientContext;
|
||||
private @Nullable Insets mInsets;
|
||||
private @Nullable Rect mBounds;
|
||||
|
||||
private int mComposingStart = MAX_INVALID_VALUE;
|
||||
private int mComposingEnd = MAX_INVALID_VALUE;
|
||||
@@ -345,6 +354,13 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
public ContentCaptureEvent setBounds(@NonNull Rect bounds) {
|
||||
mBounds = bounds;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the event.
|
||||
*
|
||||
@@ -417,6 +433,16 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
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}
|
||||
* or {@link #TYPE_VIEW_DISAPPEARED}.
|
||||
@@ -488,6 +514,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
if (mInsets != null) {
|
||||
pw.print(", insets="); pw.println(mInsets);
|
||||
}
|
||||
if (mBounds != null) {
|
||||
pw.print(", bounds="); pw.println(mBounds);
|
||||
}
|
||||
if (mComposingStart > MAX_INVALID_VALUE) {
|
||||
pw.print(", composing("); pw.print(mComposingStart);
|
||||
pw.print(", "); pw.print(mComposingEnd); pw.print(")");
|
||||
@@ -532,6 +561,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
if (mInsets != null) {
|
||||
string.append(", insets=").append(mInsets);
|
||||
}
|
||||
if (mBounds != null) {
|
||||
string.append(", bounds=").append(mBounds);
|
||||
}
|
||||
if (mComposingStart > MAX_INVALID_VALUE) {
|
||||
string.append(", composing=[")
|
||||
.append(mComposingStart).append(",").append(mComposingEnd).append("]");
|
||||
@@ -567,6 +599,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
if (mType == TYPE_VIEW_INSETS_CHANGED) {
|
||||
parcel.writeParcelable(mInsets, flags);
|
||||
}
|
||||
if (mType == TYPE_WINDOW_BOUNDS_CHANGED) {
|
||||
parcel.writeParcelable(mBounds, flags);
|
||||
}
|
||||
if (mType == TYPE_VIEW_TEXT_CHANGED) {
|
||||
parcel.writeInt(mComposingStart);
|
||||
parcel.writeInt(mComposingEnd);
|
||||
@@ -607,6 +642,9 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
if (type == TYPE_VIEW_INSETS_CHANGED) {
|
||||
event.setInsets(parcel.readParcelable(null));
|
||||
}
|
||||
if (type == TYPE_WINDOW_BOUNDS_CHANGED) {
|
||||
event.setBounds(parcel.readParcelable(null));
|
||||
}
|
||||
if (type == TYPE_VIEW_TEXT_CHANGED) {
|
||||
event.setComposingIndex(parcel.readInt(), parcel.readInt());
|
||||
event.restoreComposingSpan();
|
||||
@@ -648,6 +686,8 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
return "CONTEXT_UPDATED";
|
||||
case TYPE_VIEW_INSETS_CHANGED:
|
||||
return "VIEW_INSETS_CHANGED";
|
||||
case TYPE_WINDOW_BOUNDS_CHANGED:
|
||||
return "TYPE_WINDOW_BOUNDS_CHANGED";
|
||||
default:
|
||||
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_TREE_APPEARED;
|
||||
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.sDebug;
|
||||
import static android.view.contentcapture.ContentCaptureHelper.sVerbose;
|
||||
@@ -38,6 +39,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -776,6 +778,14 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
||||
.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
|
||||
void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
||||
super.dump(prefix, pw);
|
||||
|
||||
Reference in New Issue
Block a user