OSDN Git Service

Fix crash on invalid dimlayer
authorChong Zhang <chz@google.com>
Tue, 10 Nov 2015 22:05:40 +0000 (14:05 -0800)
committerChong Zhang <chz@google.com>
Tue, 10 Nov 2015 22:09:09 +0000 (14:09 -0800)
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

index 6d05921..161f959 100644 (file)
@@ -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);