Merge "Fix crash when loading album art by resource" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
531b63c1a6
@@ -682,9 +682,22 @@ public class MediaControlPanel {
|
||||
Drawable artwork;
|
||||
boolean isArtworkBound;
|
||||
Icon artworkIcon = data.getArtwork();
|
||||
WallpaperColors wallpaperColors = null;
|
||||
if (artworkIcon != null) {
|
||||
WallpaperColors wallpaperColors = WallpaperColors
|
||||
.fromBitmap(artworkIcon.getBitmap());
|
||||
if (artworkIcon.getType() == Icon.TYPE_BITMAP
|
||||
|| artworkIcon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) {
|
||||
// Avoids extra processing if this is already a valid bitmap
|
||||
wallpaperColors = WallpaperColors
|
||||
.fromBitmap(artworkIcon.getBitmap());
|
||||
} else {
|
||||
Drawable artworkDrawable = artworkIcon.loadDrawable(mContext);
|
||||
if (artworkDrawable != null) {
|
||||
wallpaperColors = WallpaperColors
|
||||
.fromDrawable(artworkIcon.loadDrawable(mContext));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wallpaperColors != null) {
|
||||
mutableColorScheme = new ColorScheme(wallpaperColors, true, Style.CONTENT);
|
||||
Drawable albumArt = getScaledBackground(artworkIcon, width, height);
|
||||
GradientDrawable gradient = (GradientDrawable) mContext
|
||||
|
||||
@@ -560,6 +560,19 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
verify(albumView).setLayerType(View.LAYER_TYPE_HARDWARE, null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bindAlbumView_artUsesResource() {
|
||||
val albumArt = Icon.createWithResource(context, R.drawable.ic_android)
|
||||
val state = mediaData.copy(artwork = albumArt)
|
||||
|
||||
player.attachPlayer(viewHolder)
|
||||
player.bindPlayer(state, PACKAGE)
|
||||
bgExecutor.runAllReady()
|
||||
mainExecutor.runAllReady()
|
||||
|
||||
verify(albumView).setImageDrawable(any(Drawable::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bindAlbumView_setAfterExecutors() {
|
||||
val bmp = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888)
|
||||
|
||||
Reference in New Issue
Block a user