From 7b1c22cde1cf54d8f4124a9d6aac5a2c528a2330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pomini?= Date: Wed, 14 Jun 2023 18:43:13 +0000 Subject: [PATCH] Force rebind live wallpapers when destination change When a live wallpaper is on system-only, and the same wallpaper component is reapplied to system+lock, the binding would be skipped due to the "changingToSame(...)" check. Given that the picker will call clear(FLAG_LOCK) after applying the wallpaper to system+lock, and given the lockscreen wallpaper current implementation, this would lead to a black screen. Forcing the rebind prevents the black screen issue. Also, log the "which" flag in setWallpaperComponent since it's often useful. Test: atest WallpaperManagerTest Test: manual: follow the repro steps of b/286428230 with/without this CL Bug: 286428230 Change-Id: I7f70f676ae0c4eb480e3049af49d2b5232d9360b --- .../android/server/wallpaper/WallpaperManagerService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 9e9b3444006cd..e31b53cf4a29d 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -3293,7 +3293,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub WallpaperData wallpaper; synchronized (mLock) { - Slog.v(TAG, "setWallpaperComponent name=" + name); + Slog.v(TAG, "setWallpaperComponent name=" + name + ", which=" + which); wallpaper = mWallpaperMap.get(userId); if (wallpaper == null) { throw new IllegalStateException("Wallpaper not yet initialized for user " + userId); @@ -3324,7 +3324,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub wallpaper.mWhich = which; wallpaper.fromForegroundApp = isFromForegroundApp(callingPackage); boolean same = changingToSame(name, wallpaper); - if (bindWallpaperComponentLocked(name, false, true, wallpaper, null)) { + + // force rebind when reapplying a system-only wallpaper to system+lock + boolean forceRebind = same && mLockWallpaperMap.get(userId) != null + && which == (FLAG_SYSTEM | FLAG_LOCK); + if (bindWallpaperComponentLocked(name, forceRebind, true, wallpaper, null)) { if (!same) { wallpaper.primaryColors = null; } else {