Fix the wallpaper not hiding immediately
When the application switches to the foreground, the wallpaper should
immediately hide after the shell transition ends. However, the current
issue arises because we are collecting the wallpaper target as
WindowState instead of its corresponding token, which causes the hiding
operation to be delayed.
To address this, we can add some checks: if the target is WindowState,
we will attempt to convert its token to WallpaperWindowToken in order
to resolve this issue.
Bug: 381804828
Test: Manual
Flag: EXEMPT bugfix
Change-Id: I5679a759811b7acb44909d840579fd7fb291412d
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 84df11a..9ff9e34 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -1337,7 +1337,16 @@
// Commit wallpaper visibility after activity, because usually the wallpaper target token is
// an activity, and wallpaper's visibility depends on activity's visibility.
for (int i = mParticipants.size() - 1; i >= 0; --i) {
- final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken();
+ final WindowContainer<?> wc = mParticipants.valueAt(i);
+ WallpaperWindowToken wt = wc.asWallpaperToken();
+ if (!Flags.ensureWallpaperInTransitions()) {
+ if (wt == null) {
+ final WindowState windowState = wc.asWindowState();
+ if (windowState != null) {
+ wt = windowState.mToken.asWallpaperToken();
+ }
+ }
+ }
if (wt == null) continue;
final WindowState target = wt.mDisplayContent.mWallpaperController.getWallpaperTarget();
final boolean isTargetInvisible = target == null || !target.mToken.isVisible();