From 067ca32a526113bdae8756cda0369883f8227199 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Fri, 18 May 2012 17:19:51 -0700 Subject: [PATCH] Prevent dim surface from flashing. This fix keeps the dim surface below the highest shown layer. If two shown layers were both dim it was ambiguous where the dim surface would appear causing dialogs to first be dimmed and then flash when the dim was put behind them. Fixes bug 6497476. Change-Id: I360cf2d23d58fc4c03edbbed16d79c08c29e48b9 --- .../java/com/android/server/wm/WindowAnimator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java index 480992beaa150..cf3a5d2845f0e 100644 --- a/services/java/com/android/server/wm/WindowAnimator.java +++ b/services/java/com/android/server/wm/WindowAnimator.java @@ -538,8 +538,16 @@ public class WindowAnimator { if (mDimAnimator == null) { mDimAnimator = new DimAnimator(mService.mFxSession); } - mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, - new DimAnimator.Parameters(winAnimator, width, height, target))); + // Only set dim params on the highest dimmed layer. + final WindowStateAnimator dimWinAnimator = mDimParams == null + ? null : mDimParams.mDimWinAnimator; + // Don't turn on for an unshown surface, or for any layer but the highest dimmed one. + if (winAnimator.mSurfaceShown && + (dimWinAnimator == null || !dimWinAnimator.mSurfaceShown + || dimWinAnimator.mAnimLayer < winAnimator.mAnimLayer)) { + mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, + new DimAnimator.Parameters(winAnimator, width, height, target))); + } } // TODO(cmautner): Move into Handler