From eb917324e4f552f3b9c4894edcda38487f06b353 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Tue, 10 Nov 2015 14:05:40 -0800 Subject: [PATCH] Fix crash on invalid dimlayer If the app is already removed, don't apply any more dim on the window that's pending removal. It causes invalid DimState to be added back to the controller, and we crash as these don't have valid dimlayers. bug: 25570092 Change-Id: I7e3c56c6eb636fdcb01d9bba90f77b3885e216fb --- services/core/java/com/android/server/wm/WindowState.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 6d05921c386c..161f959f2d4b 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1355,6 +1355,14 @@ final class WindowState implements WindowManagerPolicy.WindowState { } void applyDimLayerIfNeeded() { + // When the app is terminated (eg. from Recents), the task might have already been + // removed with the window pending removal. Don't apply dim in such cases, as there + // will be no more updateDimLayer() calls, which leaves the dimlayer invalid. + final AppWindowToken token = mAppToken; + if (token != null && token.removed) { + return; + } + if (!mExiting && mAppDied) { // If app died visible, apply a dim over the window to indicate that it's inactive mDisplayContent.mDimLayerController.applyDimAbove(getDimLayerUser(), mWinAnimator); -- 2.11.0