Merge "Add a recycle bitmap check before extracting wallpaper color" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aee5a4332a
@@ -928,13 +928,16 @@ public class MediaControlPanel {
|
||||
if (artworkIcon.getType() == Icon.TYPE_BITMAP
|
||||
|| artworkIcon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) {
|
||||
// Avoids extra processing if this is already a valid bitmap
|
||||
return WallpaperColors
|
||||
.fromBitmap(artworkIcon.getBitmap());
|
||||
Bitmap artworkBitmap = artworkIcon.getBitmap();
|
||||
if (artworkBitmap.isRecycled()) {
|
||||
Log.d(TAG, "Cannot load wallpaper color from a recycled bitmap");
|
||||
return null;
|
||||
}
|
||||
return WallpaperColors.fromBitmap(artworkBitmap);
|
||||
} else {
|
||||
Drawable artworkDrawable = artworkIcon.loadDrawable(mContext);
|
||||
if (artworkDrawable != null) {
|
||||
return WallpaperColors
|
||||
.fromDrawable(artworkIcon.loadDrawable(mContext));
|
||||
return WallpaperColors.fromDrawable(artworkDrawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,6 +730,19 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
.isNotEqualTo(greenArtwork.getDrawable(1).constantState)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getWallpaperColor_recycledBitmap_notCrashing() {
|
||||
// Setup redArt icon.
|
||||
val redBmp = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888)
|
||||
val redArt = Icon.createWithBitmap(redBmp)
|
||||
|
||||
// Recycle bitmap of redArt icon.
|
||||
redArt.bitmap.recycle()
|
||||
|
||||
// get wallpaperColor without illegal exception.
|
||||
player.getWallpaperColor(redArt)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bind_seekBarDisabled_hasActions_seekBarVisibilityIsSetToInvisible() {
|
||||
useRealConstraintSets()
|
||||
|
||||
Reference in New Issue
Block a user