@@ -268,6 +268,7 @@ public class WindowManagerService extends IWindowManager.Stub
268268
269269 final TokenWatcher mKeyguardTokenWatcher = new TokenWatcher (
270270 new Handler (), "WindowManagerService.mKeyguardTokenWatcher" ) {
271+ @ Override
271272 public void acquired () {
272273 if (shouldAllowDisableKeyguard ()) {
273274 mPolicy .enableKeyguard (false );
@@ -276,6 +277,7 @@ public void acquired() {
276277 Log .v (TAG , "Not disabling keyguard since device policy is enforced" );
277278 }
278279 }
280+ @ Override
279281 public void released () {
280282 mPolicy .enableKeyguard (true );
281283 synchronized (mKeyguardTokenWatcher ) {
@@ -599,6 +601,7 @@ private class LayoutAndSurfaceFields {
599601 private boolean mSyswin = false ;
600602 private float mScreenBrightness = -1 ;
601603 private float mButtonBrightness = -1 ;
604+ private boolean mUpdateRotation = false ;
602605 }
603606 private LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields ();
604607
@@ -7620,53 +7623,53 @@ void makeWindowFreezingScreenIfNeededLocked(WindowState w) {
76207623 * @param innerDh Height of app window.
76217624 * @return true if rotation has stopped, false otherwise
76227625 */
7623- private boolean updateAppsAndRotationAnimationsLocked (long currentTime ,
7626+ private void updateWindowsAppsAndRotationAnimationsLocked (long currentTime ,
76247627 int innerDw , int innerDh ) {
76257628 int i ;
7629+ for (i = mWindows .size () - 1 ; i >= 0 ; i --) {
7630+ mInnerFields .mAnimating |= mWindows .get (i ).stepAnimationLocked (currentTime );
7631+ }
7632+
76267633 final int NAT = mAppTokens .size ();
76277634 for (i =0 ; i <NAT ; i ++) {
7628- if (mAppTokens .get (i ).stepAnimationLocked (currentTime ,
7629- innerDw , innerDh )) {
7630- mInnerFields .mAnimating = true ;
7631- }
7635+ mInnerFields .mAnimating |=
7636+ mAppTokens .get (i ).stepAnimationLocked (currentTime , innerDw , innerDh );
76327637 }
76337638 final int NEAT = mExitingAppTokens .size ();
76347639 for (i =0 ; i <NEAT ; i ++) {
7635- if (mExitingAppTokens .get (i ).stepAnimationLocked (currentTime ,
7636- innerDw , innerDh )) {
7637- mInnerFields .mAnimating = true ;
7638- }
7640+ mInnerFields .mAnimating |=
7641+ mExitingAppTokens .get (i ).stepAnimationLocked (currentTime , innerDw , innerDh );
76397642 }
76407643
7641- boolean updateRotation = false ;
76427644 if (mScreenRotationAnimation != null ) {
76437645 if (mScreenRotationAnimation .isAnimating ()) {
76447646 if (mScreenRotationAnimation .stepAnimation (currentTime )) {
7647+ mInnerFields .mUpdateRotation = false ;
76457648 mInnerFields .mAnimating = true ;
76467649 } else {
7647- updateRotation = true ;
7650+ mInnerFields . mUpdateRotation = true ;
76487651 mScreenRotationAnimation .kill ();
76497652 mScreenRotationAnimation = null ;
76507653 }
76517654 }
76527655 }
7653-
7654- return updateRotation ;
76557656 }
76567657
76577658 /**
76587659 * Extracted from {@link #performLayoutAndPlaceSurfacesLockedInner} to reduce size of method.
76597660 *
76607661 * @param currentTime The time which animations use for calculating transitions.
7662+ * @param dw Width of app window.
7663+ * @param dh Height of app window.
76617664 * @param innerDw Width of app window.
76627665 * @param innerDh Height of app window.
76637666 */
7664- private void updateWindowsAndWallpaperLocked (final long currentTime ,
7665- final int innerDw , final int innerDh ) {
7666- int i ;
7667- final int N = mWindows . size ( );
7667+ private int updateWindowsAndWallpaperLocked (final long currentTime , final int dw , final int dh ,
7668+ final int innerDw , final int innerDh ) {
7669+
7670+ mPolicy . beginAnimationLw ( dw , dh );
76687671
7669- for (i = N - 1 ; i >= 0 ; i --) {
7672+ for (int i = mWindows . size () - 1 ; i >= 0 ; i --) {
76707673 WindowState w = mWindows .get (i );
76717674
76727675 final WindowManager .LayoutParams attrs = w .mAttrs ;
@@ -7684,9 +7687,6 @@ private void updateWindowsAndWallpaperLocked(final long currentTime,
76847687
76857688 final boolean wasAnimating = w .mAnimating ;
76867689
7687- int animDw = innerDw ;
7688- int animDh = innerDh ;
7689-
76907690 // If the window has moved due to its containing
76917691 // content frame changing, then we'd like to animate
76927692 // it. The checks here are ordered by what is least
@@ -7698,13 +7698,15 @@ private void updateWindowsAndWallpaperLocked(final long currentTime,
76987698 Animation a = AnimationUtils .loadAnimation (mContext ,
76997699 com .android .internal .R .anim .window_move_from_decor );
77007700 w .setAnimation (a );
7701- animDw = w .mLastFrame .left - w .mFrame .left ;
7702- animDh = w .mLastFrame .top - w .mFrame .top ;
7701+ w .mAnimDw = w .mLastFrame .left - w .mFrame .left ;
7702+ w .mAnimDh = w .mLastFrame .top - w .mFrame .top ;
7703+ } else {
7704+ w .mAnimDw = innerDw ;
7705+ w .mAnimDh = innerDh ;
77037706 }
77047707
77057708 // Execute animation.
7706- final boolean nowAnimating = w .stepAnimationLocked (currentTime ,
7707- animDw , animDh );
7709+ final boolean nowAnimating = w .isAnimating ();
77087710
77097711 // If this window is animating, make a note that we have
77107712 // an animating window and take care of a request to run
@@ -7846,6 +7848,8 @@ private void updateWindowsAndWallpaperLocked(final long currentTime,
78467848 w .performShowLocked ();
78477849 }
78487850 } // end forall windows
7851+
7852+ return mPolicy .finishAnimationLw ();
78497853 }
78507854
78517855 /**
@@ -8116,7 +8120,7 @@ public int handleAppTransitionReadyLocked() {
81168120 *
81178121 * @return bitmap indicating if another pass through layout must be made.
81188122 */
8119- private int handleAnimatingAndTransitionLocked () {
8123+ private int handleAnimatingStoppedAndTransitionLocked () {
81208124 int changes = 0 ;
81218125
81228126 mAppTransitionRunning = false ;
@@ -8652,7 +8656,6 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86528656 boolean focusDisplayed = false ;
86538657 mInnerFields .mAnimating = false ;
86548658 boolean createWatermark = false ;
8655- boolean updateRotation = false ;
86568659
86578660 if (mFxSession == null ) {
86588661 mFxSession = new SurfaceSession ();
@@ -8706,22 +8709,13 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87068709
87078710 // FIRST LOOP: Perform a layout, if needed.
87088711 if (repeats < 4 ) {
8709- performLayoutLockedInner (repeats == 0 , false /*updateInputWindows*/ );
8712+ performLayoutLockedInner (repeats == 1 , false /*updateInputWindows*/ );
87108713 } else {
87118714 Slog .w (TAG , "Layout repeat skipped after too many iterations" );
87128715 }
87138716
8714- changes = 0 ;
87158717 ++mTransactionSequence ;
87168718
8717- // Update animations of all applications, including those
8718- // associated with exiting/removed apps
8719- mInnerFields .mAnimating = false ;
8720-
8721- // SECOND LOOP: Execute animations and update visibility of windows.
8722- updateRotation |=
8723- updateAppsAndRotationAnimationsLocked (currentTime , innerDw , innerDh );
8724-
87258719 if (DEBUG_APP_TRANSITIONS ) Slog .v (TAG , "*** ANIM STEP: seq="
87268720 + mTransactionSequence + " mAnimating="
87278721 + mInnerFields .mAnimating );
@@ -8733,11 +8727,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87338727 mInnerFields .mWindowAnimationBackground = null ;
87348728 mInnerFields .mWindowAnimationBackgroundColor = 0 ;
87358729
8736- mPolicy .beginAnimationLw (dw , dh );
8737-
8738- updateWindowsAndWallpaperLocked (currentTime , innerDw , innerDh );
8739-
8740- changes |= mPolicy .finishAnimationLw ();
8730+ changes = updateWindowsAndWallpaperLocked (currentTime , dw , dh , innerDw , innerDh );
87418731
87428732 if (mInnerFields .mTokenMayBeDrawn ) {
87438733 changes |= testTokenMayBeDrawnLocked ();
@@ -8759,7 +8749,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87598749 // reflects the correct Z-order, but the window list may now
87608750 // be out of sync with it. So here we will just rebuild the
87618751 // entire app window list. Fun!
8762- changes |= handleAnimatingAndTransitionLocked ();
8752+ changes |= handleAnimatingStoppedAndTransitionLocked ();
87638753 }
87648754
87658755 if (mInnerFields .mWallpaperForceHidingChanged && changes == 0 && !mAppTransitionReady ) {
@@ -8782,6 +8772,12 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87828772 + Integer .toHexString (changes ));
87838773 } while (changes != 0 );
87848774
8775+ // Update animations of all applications, including those
8776+ // associated with exiting/removed apps
8777+ mInnerFields .mAnimating = false ;
8778+
8779+ updateWindowsAppsAndRotationAnimationsLocked (currentTime , innerDw , innerDh );
8780+
87858781 // THIRD LOOP: Update the surfaces of all windows.
87868782
87878783 final boolean someoneLosingFocus = mLosingFocus .size () != 0 ;
@@ -9023,16 +9019,17 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
90239019 mTurnOnScreen = false ;
90249020 }
90259021
9026- if (updateRotation ) {
9022+ if (mInnerFields . mUpdateRotation ) {
90279023 if (DEBUG_ORIENTATION ) Slog .d (TAG , "Performing post-rotate rotation" );
90289024 if (updateRotationUncheckedLocked (false )) {
90299025 mH .sendEmptyMessage (H .SEND_NEW_CONFIGURATION );
90309026 } else {
9031- updateRotation = false ;
9027+ mInnerFields . mUpdateRotation = false ;
90329028 }
90339029 }
90349030
9035- if (mInnerFields .mOrientationChangeComplete && !needRelayout && !updateRotation ) {
9031+ if (mInnerFields .mOrientationChangeComplete && !needRelayout &&
9032+ !mInnerFields .mUpdateRotation ) {
90369033 checkDrawnWindowsLocked ();
90379034 }
90389035
0 commit comments