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
|
if (artworkIcon.getType() == Icon.TYPE_BITMAP
|
||||||
|| artworkIcon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) {
|
|| artworkIcon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) {
|
||||||
// Avoids extra processing if this is already a valid bitmap
|
// Avoids extra processing if this is already a valid bitmap
|
||||||
return WallpaperColors
|
Bitmap artworkBitmap = artworkIcon.getBitmap();
|
||||||
.fromBitmap(artworkIcon.getBitmap());
|
if (artworkBitmap.isRecycled()) {
|
||||||
|
Log.d(TAG, "Cannot load wallpaper color from a recycled bitmap");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return WallpaperColors.fromBitmap(artworkBitmap);
|
||||||
} else {
|
} else {
|
||||||
Drawable artworkDrawable = artworkIcon.loadDrawable(mContext);
|
Drawable artworkDrawable = artworkIcon.loadDrawable(mContext);
|
||||||
if (artworkDrawable != null) {
|
if (artworkDrawable != null) {
|
||||||
return WallpaperColors
|
return WallpaperColors.fromDrawable(artworkDrawable);
|
||||||
.fromDrawable(artworkIcon.loadDrawable(mContext));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -730,6 +730,19 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
.isNotEqualTo(greenArtwork.getDrawable(1).constantState)
|
.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
|
@Test
|
||||||
fun bind_seekBarDisabled_hasActions_seekBarVisibilityIsSetToInvisible() {
|
fun bind_seekBarDisabled_hasActions_seekBarVisibilityIsSetToInvisible() {
|
||||||
useRealConstraintSets()
|
useRealConstraintSets()
|
||||||
|
|||||||
Reference in New Issue
Block a user