1616import android .os .SystemClock ;
1717import android .util .Log ;
1818import android .util .Slog ;
19+ import android .util .SparseIntArray ;
1920import android .view .Display ;
2021import android .view .Surface ;
2122import android .view .WindowManagerPolicy ;
2223import android .view .animation .Animation ;
2324
24- import com .android .internal .policy .impl .PhoneWindowManager ;
2525import com .android .server .wm .WindowManagerService .AppWindowAnimParams ;
2626import com .android .server .wm .WindowManagerService .LayoutToAnimatorParams ;
2727
@@ -47,7 +47,8 @@ public class WindowAnimator {
4747
4848 int mAdjResult ;
4949
50- int mPendingLayoutChanges ;
50+ // Layout changes for individual Displays. Indexed by displayId.
51+ SparseIntArray mPendingLayoutChanges = new SparseIntArray ();
5152
5253 /** Overall window dimensions */
5354 int mDw , mDh ;
@@ -97,7 +98,7 @@ public class WindowAnimator {
9798 static class AnimatorToLayoutParams {
9899 boolean mUpdateQueued ;
99100 int mBulkUpdateParams ;
100- int mPendingLayoutChanges ;
101+ SparseIntArray mPendingLayoutChanges ;
101102 WindowState mWindowDetachedWallpaper ;
102103 }
103104 /** Do not modify unless holding mService.mWindowMap or this and mAnimToLayout in that order */
@@ -137,7 +138,7 @@ void updateAnimToLayoutLocked() {
137138 final AnimatorToLayoutParams animToLayout = mAnimToLayout ;
138139 synchronized (animToLayout ) {
139140 animToLayout .mBulkUpdateParams = mBulkUpdateParams ;
140- animToLayout .mPendingLayoutChanges = mPendingLayoutChanges ;
141+ animToLayout .mPendingLayoutChanges = mPendingLayoutChanges . clone () ;
141142 animToLayout .mWindowDetachedWallpaper = mWindowDetachedWallpaper ;
142143
143144 if (!animToLayout .mUpdateQueued ) {
@@ -214,7 +215,8 @@ void hideWallpapersLocked(final WindowState w) {
214215 if (!winAnimator .mLastHidden ) {
215216 winAnimator .hide ();
216217 mService .dispatchWallpaperVisibility (wallpaper , false );
217- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
218+ setPendingLayoutChanges (Display .DEFAULT_DISPLAY ,
219+ WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER );
218220 }
219221 }
220222 token .hidden = true ;
@@ -233,11 +235,8 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
233235 mAnimating = true ;
234236 } else if (wasAnimating ) {
235237 // stopped animating, do one more pass through the layout
236- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
237- if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
238- mService .debugLayoutRepeats ("appToken " + appAnimator .mAppToken + " done" ,
239- mPendingLayoutChanges );
240- }
238+ setAppLayoutChanges (appAnimator , WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ,
239+ "appToken " + appAnimator .mAppToken + " done" );
241240 if (WindowManagerService .DEBUG_ANIM ) Slog .v (TAG ,
242241 "updateWindowsApps...: done animating " + appAnimator .mAppToken );
243242 }
@@ -252,11 +251,8 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
252251 mAnimating = true ;
253252 } else if (wasAnimating ) {
254253 // stopped animating, do one more pass through the layout
255- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
256- if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
257- mService .debugLayoutRepeats ("exiting appToken " + appAnimator .mAppToken
258- + " done" , mPendingLayoutChanges );
259- }
254+ setAppLayoutChanges (appAnimator , WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ,
255+ "exiting appToken " + appAnimator .mAppToken + " done" );
260256 if (WindowManagerService .DEBUG_ANIM ) Slog .v (TAG ,
261257 "updateWindowsApps...: done animating exiting " + appAnimator .mAppToken );
262258 }
@@ -302,10 +298,11 @@ private void updateWindowsLocked(final WinAnimatorList winAnimatorList) {
302298
303299 if (wasAnimating && !winAnimator .mAnimating && mWallpaperTarget == win ) {
304300 mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE ;
305- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
301+ setPendingLayoutChanges (Display .DEFAULT_DISPLAY ,
302+ WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER );
306303 if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
307304 mService .debugLayoutRepeats ("updateWindowsAndWallpaperLocked 2" ,
308- mPendingLayoutChanges );
305+ mPendingLayoutChanges . get ( Display . DEFAULT_DISPLAY ) );
309306 }
310307 }
311308
@@ -315,10 +312,12 @@ private void updateWindowsLocked(final WinAnimatorList winAnimatorList) {
315312 WindowManagerService .DEBUG_VISIBILITY ) Slog .v (TAG ,
316313 "Animation started that could impact force hide: " + win );
317314 mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED ;
318- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
315+ final int displayId = win .mDisplayContent .getDisplayId ();
316+ setPendingLayoutChanges (displayId ,
317+ WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER );
319318 if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
320319 mService .debugLayoutRepeats ("updateWindowsAndWallpaperLocked 3" ,
321- mPendingLayoutChanges );
320+ mPendingLayoutChanges . get ( displayId ) );
322321 }
323322 mService .mFocusMayChange = true ;
324323 }
@@ -377,10 +376,11 @@ private void updateWindowsLocked(final WinAnimatorList winAnimatorList) {
377376 }
378377 if (changed && (flags & FLAG_SHOW_WALLPAPER ) != 0 ) {
379378 mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE ;
380- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
379+ setPendingLayoutChanges (Display .DEFAULT_DISPLAY ,
380+ WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER );
381381 if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
382382 mService .debugLayoutRepeats ("updateWindowsAndWallpaperLocked 4" ,
383- mPendingLayoutChanges );
383+ mPendingLayoutChanges . get ( Display . DEFAULT_DISPLAY ) );
384384 }
385385 }
386386 }
@@ -390,10 +390,12 @@ private void updateWindowsLocked(final WinAnimatorList winAnimatorList) {
390390 if (winAnimator .mDrawState == WindowStateAnimator .READY_TO_SHOW ) {
391391 if (atoken == null || atoken .allDrawn ) {
392392 if (winAnimator .performShowLocked ()) {
393- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_ANIM ;
393+ final int displayId = win .mDisplayContent .getDisplayId ();
394+ mPendingLayoutChanges .put (displayId ,
395+ WindowManagerPolicy .FINISH_LAYOUT_REDO_ANIM );
394396 if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
395397 mService .debugLayoutRepeats ("updateWindowsAndWallpaperLocked 5" ,
396- mPendingLayoutChanges );
398+ mPendingLayoutChanges . get ( displayId ) );
397399 }
398400 }
399401 }
@@ -536,14 +538,14 @@ private void testTokenMayBeDrawnLocked() {
536538 + wtoken + " numInteresting=" + wtoken .numInterestingWindows
537539 + " numDrawn=" + wtoken .numDrawnWindows );
538540 // This will set mOrientationChangeComplete and cause a pass through layout.
539- mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ;
541+ setAppLayoutChanges (appAnimator ,
542+ WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ,
543+ "testTokenMayBeDrawnLocked: freezingScreen" );
540544 } else {
541- mPendingLayoutChanges |= PhoneWindowManager .FINISH_LAYOUT_REDO_ANIM ;
542- if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
543- mService .debugLayoutRepeats ("testTokenMayBeDrawnLocked" ,
544- mPendingLayoutChanges );
545- }
546-
545+ setAppLayoutChanges (appAnimator ,
546+ WindowManagerPolicy .FINISH_LAYOUT_REDO_ANIM ,
547+ "testTokenMayBeDrawnLocked" );
548+
547549 // We can now show all of the drawn windows!
548550 if (!mService .mOpeningApps .contains (wtoken )) {
549551 mAnimating |= appAnimator .showAllWindowsLocked ();
@@ -558,8 +560,11 @@ private void performAnimationsLocked(final WinAnimatorList winAnimatorList) {
558560 updateWindowsLocked (winAnimatorList );
559561 updateWallpaperLocked (winAnimatorList );
560562
561- if ((mPendingLayoutChanges & WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ) != 0 ) {
562- mPendingActions |= WALLPAPER_ACTION_PENDING ;
563+ for (int i = mPendingLayoutChanges .size () - 1 ; i >= 0 ; i --) {
564+ if ((mPendingLayoutChanges .valueAt (i )
565+ & WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER ) != 0 ) {
566+ mPendingActions |= WALLPAPER_ACTION_PENDING ;
567+ }
563568 }
564569
565570 testTokenMayBeDrawnLocked ();
@@ -577,7 +582,7 @@ private void animateLocked() {
577582 }
578583
579584 private void animateLocked (final WinAnimatorList winAnimatorList ) {
580- mPendingLayoutChanges = 0 ;
585+ mPendingLayoutChanges . clear () ;
581586 mCurrentTime = SystemClock .uptimeMillis ();
582587 mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE ;
583588 boolean wasAnimating = mAnimating ;
@@ -631,7 +636,7 @@ private void animateLocked(final WinAnimatorList winAnimatorList) {
631636 Surface .closeTransaction ();
632637 }
633638
634- if (mBulkUpdateParams != 0 || mPendingLayoutChanges != 0 ) {
639+ if (mBulkUpdateParams != 0 || mPendingLayoutChanges . size () > 0 ) {
635640 updateAnimToLayoutLocked ();
636641 }
637642
@@ -645,7 +650,8 @@ private void animateLocked(final WinAnimatorList winAnimatorList) {
645650 if (WindowManagerService .DEBUG_WINDOW_TRACE ) {
646651 Slog .i (TAG , "!!! animate: exit mAnimating=" + mAnimating
647652 + " mBulkUpdateParams=" + Integer .toHexString (mBulkUpdateParams )
648- + " mPendingLayoutChanges=" + Integer .toHexString (mPendingLayoutChanges ));
653+ + " mPendingLayoutChanges(DEFAULT_DISPLAY)="
654+ + Integer .toHexString (mPendingLayoutChanges .get (Display .DEFAULT_DISPLAY )));
649655 }
650656 }
651657
@@ -705,7 +711,30 @@ public SetAnimationParams(final WindowStateAnimator winAnimator,
705711 }
706712 }
707713
708- synchronized void clearPendingActions () {
709- mPendingActions = 0 ;
714+ void clearPendingActions () {
715+ synchronized (this ) {
716+ mPendingActions = 0 ;
717+ }
718+ }
719+
720+ void setPendingLayoutChanges (final int displayId , final int changes ) {
721+ mPendingLayoutChanges .put (displayId , mPendingLayoutChanges .get (displayId ) | changes );
722+ }
723+
724+ void setAppLayoutChanges (final AppWindowAnimator appAnimator , final int changes , String s ) {
725+ // Used to track which displays layout changes have been done.
726+ SparseIntArray displays = new SparseIntArray ();
727+ for (int i = appAnimator .mAllAppWinAnimators .size () - 1 ; i >= 0 ; i --) {
728+ WindowStateAnimator winAnimator = appAnimator .mAllAppWinAnimators .get (i );
729+ final int displayId = winAnimator .mWin .mDisplayContent .getDisplayId ();
730+ if (displays .indexOfKey (displayId ) < 0 ) {
731+ setPendingLayoutChanges (displayId , changes );
732+ if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
733+ mService .debugLayoutRepeats (s , mPendingLayoutChanges .get (displayId ));
734+ }
735+ // Keep from processing this display again.
736+ displays .put (displayId , changes );
737+ }
738+ }
710739 }
711740}
0 commit comments