synchronized void animate() { mPendingLayoutChanges = 0; mCurrentTime = SystemClock.uptimeMillis(); mBulkUpdateParams = 0; boolean wasAnimating = mAnimating; mAnimating = false; if (WindowManagerService.DEBUG_WINDOW_TRACE) { Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime); } // Update animations of all applications, including those // associated with exiting/removed apps Surface.openTransaction(); try { updateWindowsAppsAndRotationAnimationsLocked(); performAnimationsLocked(); testWallpaperAndBackgroundLocked(); // THIRD LOOP: Update the surfaces of all windows. if (mScreenRotationAnimation != null) { mScreenRotationAnimation.updateSurfaces(); } final int N = mWinAnimators.size(); for (int i = 0; i < N; i++) { mWinAnimators.get(i).prepareSurfaceLocked(true); } if (mDimParams != null) { mDimAnimator.updateParameters(mContext.getResources(), mDimParams, mCurrentTime); } if (mDimAnimator != null && mDimAnimator.mDimShown) { mAnimating |= mDimAnimator.updateSurface(isDimming(), mCurrentTime, !mService.okToDisplay()); } if (mService.mBlackFrame != null) { if (mScreenRotationAnimation != null) { mService.mBlackFrame.setMatrix( mScreenRotationAnimation.getEnterTransformation().getMatrix()); } else { mService.mBlackFrame.clearMatrix(); } } if (mService.mWatermark != null) { mService.mWatermark.drawIfNeeded(); } } catch (RuntimeException e) { Log.wtf(TAG, "Unhandled exception in Window Manager", e); } finally { Surface.closeTransaction(); } mService.bulkSetParameters(mBulkUpdateParams, mPendingLayoutChanges); if (mAnimating) { mService.scheduleAnimationLocked(); } else if (wasAnimating) { mService.requestTraversalLocked(); } if (WindowManagerService.DEBUG_WINDOW_TRACE) { Slog.i( TAG, "!!! animate: exit mAnimating=" + mAnimating + " mBulkUpdateParams=" + Integer.toHexString(mBulkUpdateParams) + " mPendingLayoutChanges=" + Integer.toHexString(mPendingLayoutChanges)); } }