@@ -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
@@ -7621,53 +7624,53 @@ void makeWindowFreezingScreenIfNeededLocked(WindowState w) {
76217624 * @param innerDh Height of app window.
76227625 * @return true if rotation has stopped, false otherwise
76237626 */
7624- private boolean updateAppsAndRotationAnimationsLocked (long currentTime ,
7627+ private void updateWindowsAppsAndRotationAnimationsLocked (long currentTime ,
76257628 int innerDw , int innerDh ) {
76267629 int i ;
7630+ for (i = mWindows .size () - 1 ; i >= 0 ; i --) {
7631+ mInnerFields .mAnimating |= mWindows .get (i ).stepAnimationLocked (currentTime );
7632+ }
7633+
76277634 final int NAT = mAppTokens .size ();
76287635 for (i =0 ; i <NAT ; i ++) {
7629- if (mAppTokens .get (i ).stepAnimationLocked (currentTime ,
7630- innerDw , innerDh )) {
7631- mInnerFields .mAnimating = true ;
7632- }
7636+ mInnerFields .mAnimating |=
7637+ mAppTokens .get (i ).stepAnimationLocked (currentTime , innerDw , innerDh );
76337638 }
76347639 final int NEAT = mExitingAppTokens .size ();
76357640 for (i =0 ; i <NEAT ; i ++) {
7636- if (mExitingAppTokens .get (i ).stepAnimationLocked (currentTime ,
7637- innerDw , innerDh )) {
7638- mInnerFields .mAnimating = true ;
7639- }
7641+ mInnerFields .mAnimating |=
7642+ mExitingAppTokens .get (i ).stepAnimationLocked (currentTime , innerDw , innerDh );
76407643 }
76417644
7642- boolean updateRotation = false ;
76437645 if (mScreenRotationAnimation != null ) {
76447646 if (mScreenRotationAnimation .isAnimating ()) {
76457647 if (mScreenRotationAnimation .stepAnimation (currentTime )) {
7648+ mInnerFields .mUpdateRotation = false ;
76467649 mInnerFields .mAnimating = true ;
76477650 } else {
7648- updateRotation = true ;
7651+ mInnerFields . mUpdateRotation = true ;
76497652 mScreenRotationAnimation .kill ();
76507653 mScreenRotationAnimation = null ;
76517654 }
76527655 }
76537656 }
7654-
7655- return updateRotation ;
76567657 }
76577658
76587659 /**
76597660 * Extracted from {@link #performLayoutAndPlaceSurfacesLockedInner} to reduce size of method.
76607661 *
76617662 * @param currentTime The time which animations use for calculating transitions.
7663+ * @param dw Width of app window.
7664+ * @param dh Height of app window.
76627665 * @param innerDw Width of app window.
76637666 * @param innerDh Height of app window.
76647667 */
7665- private void updateWindowsAndWallpaperLocked (final long currentTime ,
7666- final int innerDw , final int innerDh ) {
7667- int i ;
7668- final int N = mWindows . size ( );
7668+ private int updateWindowsAndWallpaperLocked (final long currentTime , final int dw , final int dh ,
7669+ final int innerDw , final int innerDh ) {
7670+
7671+ mPolicy . beginAnimationLw ( dw , dh );
76697672
7670- for (i = N - 1 ; i >= 0 ; i --) {
7673+ for (int i = mWindows . size () - 1 ; i >= 0 ; i --) {
76717674 WindowState w = mWindows .get (i );
76727675
76737676 final WindowManager .LayoutParams attrs = w .mAttrs ;
@@ -7685,9 +7688,6 @@ private void updateWindowsAndWallpaperLocked(final long currentTime,
76857688
76867689 final boolean wasAnimating = w .mAnimating ;
76877690
7688- int animDw = innerDw ;
7689- int animDh = innerDh ;
7690-
76917691 // If the window has moved due to its containing
76927692 // content frame changing, then we'd like to animate
76937693 // it. The checks here are ordered by what is least
@@ -7699,13 +7699,15 @@ private void updateWindowsAndWallpaperLocked(final long currentTime,
76997699 Animation a = AnimationUtils .loadAnimation (mContext ,
77007700 com .android .internal .R .anim .window_move_from_decor );
77017701 w .setAnimation (a );
7702- animDw = w .mLastFrame .left - w .mFrame .left ;
7703- animDh = w .mLastFrame .top - w .mFrame .top ;
7702+ w .mAnimDw = w .mLastFrame .left - w .mFrame .left ;
7703+ w .mAnimDh = w .mLastFrame .top - w .mFrame .top ;
7704+ } else {
7705+ w .mAnimDw = innerDw ;
7706+ w .mAnimDh = innerDh ;
77047707 }
77057708
77067709 // Execute animation.
7707- final boolean nowAnimating = w .stepAnimationLocked (currentTime ,
7708- animDw , animDh );
7710+ final boolean nowAnimating = w .isAnimating ();
77097711
77107712 // If this window is animating, make a note that we have
77117713 // an animating window and take care of a request to run
@@ -7847,6 +7849,8 @@ private void updateWindowsAndWallpaperLocked(final long currentTime,
78477849 w .performShowLocked ();
78487850 }
78497851 } // end forall windows
7852+
7853+ return mPolicy .finishAnimationLw ();
78507854 }
78517855
78527856 /**
@@ -8117,7 +8121,7 @@ public int handleAppTransitionReadyLocked() {
81178121 *
81188122 * @return bitmap indicating if another pass through layout must be made.
81198123 */
8120- private int handleAnimatingAndTransitionLocked () {
8124+ private int handleAnimatingStoppedAndTransitionLocked () {
81218125 int changes = 0 ;
81228126
81238127 mAppTransitionRunning = false ;
@@ -8653,7 +8657,6 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86538657 boolean focusDisplayed = false ;
86548658 mInnerFields .mAnimating = false ;
86558659 boolean createWatermark = false ;
8656- boolean updateRotation = false ;
86578660
86588661 if (mFxSession == null ) {
86598662 mFxSession = new SurfaceSession ();
@@ -8707,22 +8710,13 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87078710
87088711 // FIRST LOOP: Perform a layout, if needed.
87098712 if (repeats < 4 ) {
8710- performLayoutLockedInner (repeats == 0 , false /*updateInputWindows*/ );
8713+ performLayoutLockedInner (repeats == 1 , false /*updateInputWindows*/ );
87118714 } else {
87128715 Slog .w (TAG , "Layout repeat skipped after too many iterations" );
87138716 }
87148717
8715- changes = 0 ;
87168718 ++mTransactionSequence ;
87178719
8718- // Update animations of all applications, including those
8719- // associated with exiting/removed apps
8720- mInnerFields .mAnimating = false ;
8721-
8722- // SECOND LOOP: Execute animations and update visibility of windows.
8723- updateRotation |=
8724- updateAppsAndRotationAnimationsLocked (currentTime , innerDw , innerDh );
8725-
87268720 if (DEBUG_APP_TRANSITIONS ) Slog .v (TAG , "*** ANIM STEP: seq="
87278721 + mTransactionSequence + " mAnimating="
87288722 + mInnerFields .mAnimating );
@@ -8734,11 +8728,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87348728 mInnerFields .mWindowAnimationBackground = null ;
87358729 mInnerFields .mWindowAnimationBackgroundColor = 0 ;
87368730
8737- mPolicy .beginAnimationLw (dw , dh );
8738-
8739- updateWindowsAndWallpaperLocked (currentTime , innerDw , innerDh );
8740-
8741- changes |= mPolicy .finishAnimationLw ();
8731+ changes = updateWindowsAndWallpaperLocked (currentTime , dw , dh , innerDw , innerDh );
87428732
87438733 if (mInnerFields .mTokenMayBeDrawn ) {
87448734 changes |= testTokenMayBeDrawnLocked ();
@@ -8760,7 +8750,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87608750 // reflects the correct Z-order, but the window list may now
87618751 // be out of sync with it. So here we will just rebuild the
87628752 // entire app window list. Fun!
8763- changes |= handleAnimatingAndTransitionLocked ();
8753+ changes |= handleAnimatingStoppedAndTransitionLocked ();
87648754 }
87658755
87668756 if (mInnerFields .mWallpaperForceHidingChanged && changes == 0 && !mAppTransitionReady ) {
@@ -8783,6 +8773,12 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
87838773 + Integer .toHexString (changes ));
87848774 } while (changes != 0 );
87858775
8776+ // Update animations of all applications, including those
8777+ // associated with exiting/removed apps
8778+ mInnerFields .mAnimating = false ;
8779+
8780+ updateWindowsAppsAndRotationAnimationsLocked (currentTime , innerDw , innerDh );
8781+
87868782 // THIRD LOOP: Update the surfaces of all windows.
87878783
87888784 final boolean someoneLosingFocus = mLosingFocus .size () != 0 ;
@@ -9024,16 +9020,17 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
90249020 mTurnOnScreen = false ;
90259021 }
90269022
9027- if (updateRotation ) {
9023+ if (mInnerFields . mUpdateRotation ) {
90289024 if (DEBUG_ORIENTATION ) Slog .d (TAG , "Performing post-rotate rotation" );
90299025 if (updateRotationUncheckedLocked (false )) {
90309026 mH .sendEmptyMessage (H .SEND_NEW_CONFIGURATION );
90319027 } else {
9032- updateRotation = false ;
9028+ mInnerFields . mUpdateRotation = false ;
90339029 }
90349030 }
90359031
9036- if (mInnerFields .mOrientationChangeComplete && !needRelayout && !updateRotation ) {
9032+ if (mInnerFields .mOrientationChangeComplete && !needRelayout &&
9033+ !mInnerFields .mUpdateRotation ) {
90379034 checkDrawnWindowsLocked ();
90389035 }
90399036
0 commit comments