Clear lock bitmaps when wallpaper applied to home+lock

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
This commit is contained in:
Aurélien Pomini
2023-06-08 12:58:20 +00:00
parent a5dc9ce04a
commit f8af5a2f54

View File

@@ -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);
}
}