@@ -140,6 +140,36 @@ public WindowContainerTransaction setBoundsChangeTransaction(
140140 return this ;
141141 }
142142
143+ /**
144+ * Like {@link #setBoundsChangeTransaction} but instead queues up a setPosition/WindowCrop
145+ * on a container's surface control. This is useful when a boundsChangeTransaction needs to be
146+ * queued up on a Task that won't be organized until the end of this window-container
147+ * transaction.
148+ *
149+ * This requires that, at the end of this transaction, `task` will be organized; otherwise
150+ * the server will throw an IllegalArgumentException.
151+ *
152+ * WARNING: Use this carefully. Whatever is set here should match the expected bounds after
153+ * the transaction completes since it will likely be replaced by it. This call is
154+ * intended to pre-emptively set bounds on a surface in sync with a buffer when
155+ * otherwise the new bounds and the new buffer would update on different frames.
156+ *
157+ * TODO(b/134365562): remove once TaskOrg drives full-screen or BLAST is enabled.
158+ *
159+ * @hide
160+ */
161+ @ NonNull
162+ public WindowContainerTransaction setBoundsChangeTransaction (
163+ @ NonNull WindowContainerToken task , @ NonNull Rect surfaceBounds ) {
164+ Change chg = getOrCreateChange (task .asBinder ());
165+ if (chg .mBoundsChangeSurfaceBounds == null ) {
166+ chg .mBoundsChangeSurfaceBounds = new Rect ();
167+ }
168+ chg .mBoundsChangeSurfaceBounds .set (surfaceBounds );
169+ chg .mChangeMask |= Change .CHANGE_BOUNDS_TRANSACTION_RECT ;
170+ return this ;
171+ }
172+
143173 /**
144174 * Set the windowing mode of children of a given root task, without changing
145175 * the windowing mode of the Task itself. This can be used during transitions
@@ -287,6 +317,7 @@ public static class Change implements Parcelable {
287317 public static final int CHANGE_BOUNDS_TRANSACTION = 1 << 1 ;
288318 public static final int CHANGE_PIP_CALLBACK = 1 << 2 ;
289319 public static final int CHANGE_HIDDEN = 1 << 3 ;
320+ public static final int CHANGE_BOUNDS_TRANSACTION_RECT = 1 << 4 ;
290321
291322 private final Configuration mConfiguration = new Configuration ();
292323 private boolean mFocusable = true ;
@@ -297,6 +328,7 @@ public static class Change implements Parcelable {
297328
298329 private Rect mPinnedBounds = null ;
299330 private SurfaceControl .Transaction mBoundsChangeTransaction = null ;
331+ private Rect mBoundsChangeSurfaceBounds = null ;
300332
301333 private int mActivityWindowingMode = -1 ;
302334 private int mWindowingMode = -1 ;
@@ -318,6 +350,10 @@ protected Change(Parcel in) {
318350 mBoundsChangeTransaction =
319351 SurfaceControl .Transaction .CREATOR .createFromParcel (in );
320352 }
353+ if ((mChangeMask & Change .CHANGE_BOUNDS_TRANSACTION_RECT ) != 0 ) {
354+ mBoundsChangeSurfaceBounds = new Rect ();
355+ mBoundsChangeSurfaceBounds .readFromParcel (in );
356+ }
321357
322358 mWindowingMode = in .readInt ();
323359 mActivityWindowingMode = in .readInt ();
@@ -377,6 +413,10 @@ public SurfaceControl.Transaction getBoundsChangeTransaction() {
377413 return mBoundsChangeTransaction ;
378414 }
379415
416+ public Rect getBoundsChangeSurfaceBounds () {
417+ return mBoundsChangeSurfaceBounds ;
418+ }
419+
380420 @ Override
381421 public String toString () {
382422 final boolean changesBounds =
@@ -408,6 +448,9 @@ public String toString() {
408448 if ((mChangeMask & CHANGE_FOCUSABLE ) != 0 ) {
409449 sb .append ("focusable:" + mFocusable + "," );
410450 }
451+ if (mBoundsChangeTransaction != null ) {
452+ sb .append ("hasBoundsTransaction," );
453+ }
411454 sb .append ("}" );
412455 return sb .toString ();
413456 }
@@ -427,6 +470,9 @@ public void writeToParcel(Parcel dest, int flags) {
427470 if (mBoundsChangeTransaction != null ) {
428471 mBoundsChangeTransaction .writeToParcel (dest , flags );
429472 }
473+ if (mBoundsChangeSurfaceBounds != null ) {
474+ mBoundsChangeSurfaceBounds .writeToParcel (dest , flags );
475+ }
430476
431477 dest .writeInt (mWindowingMode );
432478 dest .writeInt (mActivityWindowingMode );
0 commit comments