Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b14b8f1e authored by Michael Mikhail's avatar Michael Mikhail Committed by Automerger Merge Worker
Browse files

Merge "Add a recycle bitmap check before extracting wallpaper color" into tm-qpr-dev am: aee5a433

parents 68ba3e5a aee5a433
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -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));
                }
                }
            }
            }
        }
        }
+13 −0
Original line number Original line Diff line number Diff line
@@ -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()