From 08da091ac7b1305584b000de7e6c7c369ffd1aaa Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 4 Jan 2023 19:49:09 +0000 Subject: [PATCH] Fix some visibility issues with tasks & task overlays - Make the overlay host surface visibility mirror the actual visibility of the task. Currently WM may show the task surface prior to any children being shown, which can lead to a flash of the overlay when launching tasks - Also prevent the task visibilty from being clobbered by the Shell when a task changes windowing modes. The task visibility is updated by WM in Task#prepareSurfaces(), but the Shell will still try to show the task surface in the WCT transaction callback Bug: 255777383 Test: Launch game with existing visible task overlay Test: Split app that shows a task overlay (ie. game dashboard button), then dismiss split Change-Id: I950df0d88a56617369e6c15f66268455fd52d8b4 --- .../wm/shell/fullscreen/FullscreenTaskListener.java | 4 +++- services/core/java/com/android/server/wm/Task.java | 7 ++++++- .../java/com/android/server/wm/TrustedOverlayHost.java | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java index 6623f5ca84eef..94c8a367a9f1e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java @@ -114,7 +114,9 @@ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener { t.setPosition(leash, positionInParent.x, positionInParent.y); t.setAlpha(leash, 1f); t.setMatrix(leash, 1, 0, 0, 1); - t.show(leash); + if (taskInfo.isVisible) { + t.show(leash); + } }); } } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index ea6f2442a9197..809b2a86204a4 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -3327,12 +3327,17 @@ class Task extends TaskFragment { // We intend to let organizer manage task visibility but it doesn't // have enough information until we finish shell transitions. // In the mean time we do an easy fix here. - final boolean show = isVisible() || isAnimating(TRANSITION | PARENTS | CHILDREN); + final boolean visible = isVisible(); + final boolean show = visible || isAnimating(TRANSITION | PARENTS | CHILDREN); if (mSurfaceControl != null) { if (show != mLastSurfaceShowing) { t.setVisibility(mSurfaceControl, show); } } + // Only show the overlay if the task has other visible children + if (mOverlayHost != null) { + mOverlayHost.setVisibility(t, visible); + } mLastSurfaceShowing = show; } diff --git a/services/core/java/com/android/server/wm/TrustedOverlayHost.java b/services/core/java/com/android/server/wm/TrustedOverlayHost.java index 975b21c6f02c0..88c410b263ca9 100644 --- a/services/core/java/com/android/server/wm/TrustedOverlayHost.java +++ b/services/core/java/com/android/server/wm/TrustedOverlayHost.java @@ -80,6 +80,12 @@ class TrustedOverlayHost { } } + void setVisibility(SurfaceControl.Transaction t, boolean visible) { + if (mSurfaceControl != null) { + t.setVisibility(mSurfaceControl, visible); + } + } + void addOverlay(SurfaceControlViewHost.SurfacePackage p, SurfaceControl currentParent) { requireOverlaySurfaceControl(); mOverlays.add(p);