From 8312b1d2c1338c7519494d3341164a1a2aee6820 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 24 Jun 2019 11:57:22 -0700 Subject: [PATCH] Fix crash while animating removed stack Bug: 135711060 Test: atest PinnedStackTests Change-Id: Ie1f3acb9d2152435dc018360ad5120f1ee678d3c --- services/core/java/com/android/server/wm/TaskStack.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 481c3ba24fcad..114a56feaf73e 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -1936,8 +1936,12 @@ public class TaskStack extends WindowContainer implements public boolean setPinnedStackAlpha(float alpha) { // Hold the lock since this is called from the BoundsAnimator running on the UiThread synchronized (mWmService.mGlobalLock) { - getPendingTransaction().setAlpha(getSurfaceControl(), - mCancelCurrentBoundsAnimation ? 1 : alpha); + final SurfaceControl sc = getSurfaceControl(); + if (sc == null || !sc.isValid()) { + // If the stack is already removed, don't bother updating any stack animation + return false; + } + getPendingTransaction().setAlpha(sc, mCancelCurrentBoundsAnimation ? 1 : alpha); scheduleAnimation(); return !mCancelCurrentBoundsAnimation; }