Prevent WallpaperManager#getBitmap return recycled bitmap.

The returned bitmap object could be recycled from client, check
isRecycled and re-create a new bitmap object if needed.

Bug: 176573309
Test: atest WallpaperManagerTests
Change-Id: I71d99d21836b73c93979685f3f7a6f49ba0df3e4
This commit is contained in:
wilsonshih
2021-09-14 15:21:37 +08:00
parent bdb91bf0d6
commit db4dce333d

View File

@@ -562,7 +562,7 @@ public class WallpaperManager {
}
if (returnDefault) {
Bitmap defaultWallpaper = mDefaultWallpaper;
if (defaultWallpaper == null) {
if (defaultWallpaper == null || defaultWallpaper.isRecycled()) {
defaultWallpaper = getDefaultWallpaper(context, which);
synchronized (this) {
mDefaultWallpaper = defaultWallpaper;