Check for existing dimming before stop dimming.
Add a test to make sure that we are dimming before we send the message
to stop it. This prevents a CPU consuming loop when dimming is already on.
Fixes bug 6320003.
Change-Id: If26dc5b0800300d8e38c166824651223eded4cfa
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index 1198a77..0be6612 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -453,7 +453,7 @@
mDimAnimator.updateParameters(mContext.getResources(), mDimParams, mCurrentTime);
}
if (mDimAnimator != null && mDimAnimator.mDimShown) {
- mAnimating |= mDimAnimator.updateSurface(mDimParams != null, mCurrentTime,
+ mAnimating |= mDimAnimator.updateSurface(isDimming(), mCurrentTime,
!mService.okToDisplay());
}
@@ -501,6 +501,10 @@
mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, null));
}
+ boolean isDimming() {
+ return mDimParams != null;
+ }
+
public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
if (mWindowDetachedWallpaper != null) {
pw.print(" mWindowDetachedWallpaper="); pw.println(mWindowDetachedWallpaper);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 8d65dc3..d9425aab 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -8021,16 +8021,18 @@
if (!mInnerFields.mDimming) {
//Slog.i(TAG, "DIM BEHIND: " + w);
mInnerFields.mDimming = true;
- final int width, height;
- if (attrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
- width = mCurDisplayWidth;
- height = mCurDisplayHeight;
- } else {
- width = innerDw;
- height = innerDh;
+ if (!mAnimator.isDimming()) {
+ final int width, height;
+ if (attrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
+ width = mCurDisplayWidth;
+ height = mCurDisplayHeight;
+ } else {
+ width = innerDw;
+ height = innerDh;
+ }
+ mAnimator.startDimming(w.mWinAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount,
+ width, height);
}
- mAnimator.startDimming(w.mWinAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount,
- width, height);
}
}
}
@@ -8180,7 +8182,7 @@
updateWallpaperVisibilityLocked();
}
}
- if (!mInnerFields.mDimming && mAnimator.mDimParams != null) {
+ if (!mInnerFields.mDimming && mAnimator.isDimming()) {
mAnimator.stopDimming();
}
} catch (RuntimeException e) {