From f8af5a2f54c612c44aa33a17821b495a251bfedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pomini?= Date: Thu, 8 Jun 2023 12:58:20 +0000 Subject: [PATCH] Clear lock bitmaps when wallpaper applied to home+lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's never keep old bitmap in files. Otherwise if a user has a live wallpaper on lock screen only, and backups & restore to an older device, the old bitmap will reappear. Also otherwise, getWallpaperFile() may return an old bitmap even if the user has a lockscreen live wallpaper. Only effective with the lockscreen lwp flag Flag: lockscreen live wallpaper Bug: 283091821 Test: atest WallpaperManagerTest Change-Id: I8cd9af52e1a5f3a0388b3af22ab6c8c441520a8e --- .../android/server/wallpaper/WallpaperManagerService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 1769f060807af..26cac79f16384 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -366,6 +366,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (lockedWallpaper != null) { detachWallpaperLocked(lockedWallpaper); } + clearWallpaperBitmaps(mWallpaper.userId, FLAG_LOCK); mLockWallpaperMap.remove(wallpaper.userId); notifyColorsWhich |= FLAG_LOCK; } @@ -3318,8 +3319,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub }); } } + boolean lockBitmapCleared = false; if (!mImageWallpaper.equals(newWallpaper.wallpaperComponent)) { clearWallpaperBitmaps(newWallpaper); + lockBitmapCleared = newWallpaper.mWhich == FLAG_LOCK; } newWallpaper.wallpaperId = makeWallpaperIdLocked(); notifyCallbacksLocked(newWallpaper); @@ -3337,6 +3340,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub updateEngineFlags(newWallpaper); } } + if (!lockBitmapCleared) { + clearWallpaperBitmaps(newWallpaper.userId, FLAG_LOCK); + } mLockWallpaperMap.remove(newWallpaper.userId); } }