From c2ec6faaec4c8f2cc43aaa9d528e32f2ef41afc5 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 22 Mar 2024 23:54:43 +0800 Subject: Skip collecting wallpaper to transition for non collected app Currently wallpaper is not fully handled by shell transition. Because the wallpaper target can be any window that requests to show wallpaper. And the window can be not handled by transition. So the visibility change of wallpaper may come from legacy path. Such as when launching app from home, the visibility change will happen after the open transition is finished, i.e. home received to stop or invisible (IWindow#dispatchAppVisibility). There are 2 possible entries to hide wallpaper: WMS#relayoutWindow -> adjustWallpaperWindows WindowStateAnimator#prepareSurfaceLocked -> hideWallpapers If there is another transition starts before that, the wallpaper will be collected into the unrelated transition. Bug: 330457044 Test: atest ActivityTransitionTests# \ testCustomTransitionCanOverrideBackgroundColor Test: Launch an activity from home, and it delay tens~hundred millisecond to start next activity in the same task. The second transition info should not contain wallpaper. Change-Id: I07c887be55f4e0a20c92965ad5504e9c542bc8d3 --- .../java/com/android/server/wm/WallpaperWindowToken.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WallpaperWindowToken.java b/services/core/java/com/android/server/wm/WallpaperWindowToken.java index dc500a2748cf..55eeaf22cca8 100644 --- a/services/core/java/com/android/server/wm/WallpaperWindowToken.java +++ b/services/core/java/com/android/server/wm/WallpaperWindowToken.java @@ -192,7 +192,18 @@ class WallpaperWindowToken extends WindowToken { void setVisibility(boolean visible) { if (mVisibleRequested != visible) { // Before setting mVisibleRequested so we can track changes. - mTransitionController.collect(this); + final WindowState wpTarget = mDisplayContent.mWallpaperController.getWallpaperTarget(); + final boolean isTargetNotCollectedActivity = wpTarget != null + && wpTarget.mActivityRecord != null + && !mTransitionController.isCollecting(wpTarget.mActivityRecord); + // Skip collecting requesting-invisible wallpaper if the wallpaper target is an activity + // and it is not collected. Because the visibility change may be called after the + // transition of activity is finished, e.g. WallpaperController#hideWallpapers from + // hiding surface of the target. Then if there is a next transition, the wallpaper + // change may be collected into the unrelated transition and cause a weird animation. + if (!isTargetNotCollectedActivity || visible) { + mTransitionController.collect(this); + } setVisibleRequested(visible); } -- cgit v1.2.3-59-g8ed1b