@@ -99,16 +99,19 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
9999 private Handler mHandler ;
100100 private KeyguardStateController mKeyguardStateController ;
101101
102+ private WindowManagerProxy mWindowManagerProxy ;
103+
102104 private final ArrayList <WeakReference <Consumer <Boolean >>> mDockedStackExistsListeners =
103105 new ArrayList <>();
104106
105107 private SplitScreenTaskOrganizer mSplits = new SplitScreenTaskOrganizer (this );
106108
107109 private DisplayChangeController .OnDisplayChangingListener mRotationController =
108- (display , fromRotation , toRotation , t ) -> {
109- if (!mSplits .isSplitScreenSupported ()) {
110+ (display , fromRotation , toRotation , wct ) -> {
111+ if (!mSplits .isSplitScreenSupported () || mWindowManagerProxy == null ) {
110112 return ;
111113 }
114+ WindowContainerTransaction t = new WindowContainerTransaction ();
112115 DisplayLayout displayLayout =
113116 new DisplayLayout (mDisplayController .getDisplayLayout (display ));
114117 SplitDisplayLayout sdl = new SplitDisplayLayout (mContext , displayLayout , mSplits );
@@ -127,6 +130,17 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
127130 if (isSplitActive ()) {
128131 WindowManagerProxy .applyHomeTasksMinimized (sdl , mSplits .mSecondary .token , t );
129132 }
133+ if (mWindowManagerProxy .queueSyncTransactionIfWaiting (t )) {
134+ // Because sync transactions are serialized, its possible for an "older"
135+ // bounds-change to get applied after a screen rotation. In that case, we
136+ // want to actually defer on that rather than apply immediately. Of course,
137+ // this means that the bounds may not change until after the rotation so
138+ // the user might see some artifacts. This should be rare.
139+ Slog .w (TAG , "Screen rotated while other operations were pending, this may"
140+ + " result in some graphical artifacts." );
141+ } else {
142+ wct .merge (t , true /* transfer */ );
143+ }
130144 };
131145
132146 private final DividerImeController mImePositionProcessor ;
@@ -159,6 +173,7 @@ public Divider(Context context, Optional<Lazy<Recents>> recentsOptionalLazy,
159173 mRecentsOptionalLazy = recentsOptionalLazy ;
160174 mForcedResizableController = new ForcedResizableInfoActivityController (context , this );
161175 mTransactionPool = transactionPool ;
176+ mWindowManagerProxy = new WindowManagerProxy (mTransactionPool , mHandler );
162177 mImePositionProcessor = new DividerImeController (mSplits , mTransactionPool , mHandler );
163178 }
164179
@@ -278,9 +293,9 @@ private void addDivider(Configuration configuration) {
278293 LayoutInflater .from (dctx ).inflate (R .layout .docked_stack_divider , null );
279294 DisplayLayout displayLayout = mDisplayController .getDisplayLayout (mContext .getDisplayId ());
280295 mView .injectDependencies (mWindowManager , mDividerState , this , mSplits , mSplitLayout ,
281- mImePositionProcessor );
296+ mImePositionProcessor , mWindowManagerProxy );
282297 mView .setVisibility (mVisible ? View .VISIBLE : View .INVISIBLE );
283- mView .setMinimizedDockStack (mMinimized , mHomeStackResizable );
298+ mView .setMinimizedDockStack (mMinimized , mHomeStackResizable , null /* transaction */ );
284299 final int size = dctx .getResources ().getDimensionPixelSize (
285300 com .android .internal .R .dimen .docked_stack_divider_thickness );
286301 final boolean landscape = configuration .orientation == ORIENTATION_LANDSCAPE ;
@@ -303,7 +318,7 @@ private void update(Configuration configuration) {
303318 addDivider (configuration );
304319
305320 if (mMinimized ) {
306- mView .setMinimizedDockStack (true , mHomeStackResizable );
321+ mView .setMinimizedDockStack (true , mHomeStackResizable , null /* transaction */ );
307322 updateTouchable ();
308323 }
309324 mView .setHidden (isDividerHidden );
@@ -327,11 +342,13 @@ private void updateVisibility(final boolean visible) {
327342 if (visible ) {
328343 mView .enterSplitMode (mHomeStackResizable );
329344 // Update state because animations won't finish.
330- mView .setMinimizedDockStack (mMinimized , mHomeStackResizable );
345+ mWindowManagerProxy .runInSync (
346+ t -> mView .setMinimizedDockStack (mMinimized , mHomeStackResizable , t ));
347+
331348 } else {
332349 mView .exitSplitMode ();
333- // un-minimize so that next entry triggers minimize anim.
334- mView .setMinimizedDockStack (false /* minimized */ , mHomeStackResizable );
350+ mWindowManagerProxy . runInSync (
351+ t -> mView .setMinimizedDockStack (false , mHomeStackResizable , t ) );
335352 }
336353 // Notify existence listeners
337354 synchronized (mDockedStackExistsListeners ) {
@@ -344,12 +361,6 @@ private void updateVisibility(final boolean visible) {
344361 }
345362 }
346363
347- void onSplitDismissed () {
348- updateVisibility (false /* visible */ );
349- mMinimized = false ;
350- removeDivider ();
351- }
352-
353364 /** Switch to minimized state if appropriate */
354365 public void setMinimized (final boolean minimized ) {
355366 if (DEBUG ) Slog .d (TAG , "posting ext setMinimized " + minimized + " vis:" + mVisible );
@@ -405,7 +416,7 @@ private void setHomeMinimized(final boolean minimized, boolean homeStackResizabl
405416 }
406417 }
407418 updateTouchable ();
408- WindowOrganizer . applyTransaction (wct );
419+ mWindowManagerProxy . applySyncTransaction (wct );
409420 }
410421
411422 void setAdjustedForIme (boolean adjustedForIme ) {
@@ -501,7 +512,14 @@ void startEnterSplit() {
501512 update (mDisplayController .getDisplayContext (
502513 mContext .getDisplayId ()).getResources ().getConfiguration ());
503514 // Set resizable directly here because applyEnterSplit already resizes home stack.
504- mHomeStackResizable = WindowManagerProxy .applyEnterSplit (mSplits , mSplitLayout );
515+ mHomeStackResizable = mWindowManagerProxy .applyEnterSplit (mSplits , mSplitLayout );
516+ }
517+
518+ void startDismissSplit () {
519+ mWindowManagerProxy .applyDismissSplit (mSplits , mSplitLayout , true /* dismissOrMaximize */ );
520+ updateVisibility (false /* visible */ );
521+ mMinimized = false ;
522+ removeDivider ();
505523 }
506524
507525 void ensureMinimizedSplit () {
@@ -530,6 +548,10 @@ SplitDisplayLayout getSplitLayout() {
530548 return mSplitLayout ;
531549 }
532550
551+ WindowManagerProxy getWmProxy () {
552+ return mWindowManagerProxy ;
553+ }
554+
533555 /** @return the container token for the secondary split root task. */
534556 public WindowContainerToken getSecondaryRoot () {
535557 if (mSplits == null || mSplits .mSecondary == null ) {
0 commit comments