diff options
| author | 2021-11-24 19:57:52 +0100 | |
|---|---|---|
| committer | 2021-11-24 19:58:32 +0100 | |
| commit | e644ff610220c9f8196cfa982d735e678b121bdc (patch) | |
| tree | f6cfcef3f3423496384c5d60a8e317a2b805c3e9 | |
| parent | 7644c9c20cd6349946d944c0cda3aa20956e1b36 (diff) | |
Don't set background color if TDA doesn't have a valid surface
This is something that sometimes occurs in tests since the detaching of the TDA in not necesseraily synchronized with animations
Test: atest CtsWindowManagerDeviceTestCases:MultiDisplaySystemDecorationTests
Bug: 207667555
Change-Id: I9881453ba14cba4f219861ec4449f2baa8058b57
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskDisplayArea.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index 600545e41e47..4af0ecc16414 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -905,18 +905,24 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { mBackgroundColor = colorInt; Color color = Color.valueOf(colorInt); mColorLayerCounter++; - getPendingTransaction() - .setColor(mSurfaceControl, new float[]{color.red(), color.green(), color.blue()}); - scheduleAnimation(); + // Only apply the background color if the TDA is actually attached and has a valid surface + // to set the background color on. We still want to keep track of the background color state + // even if we are not showing it for when/if the TDA is reattached and gets a valid surface + if (mSurfaceControl != null) { + getPendingTransaction() + .setColor(mSurfaceControl, + new float[]{color.red(), color.green(), color.blue()}); + scheduleAnimation(); + } } void clearBackgroundColor() { mColorLayerCounter--; // Only clear the color layer if we have received the same amounts of clear as set - // requests. - if (mColorLayerCounter == 0) { + // requests and TDA has a non null surface control (i.e. is attached) + if (mColorLayerCounter == 0 && mSurfaceControl != null) { getPendingTransaction().unsetColor(mSurfaceControl); scheduleAnimation(); } |