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

Commit 16fe19aa 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...

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21673827



Change-Id: I04041a027afed0bee6f0539ec6e551001301e8bd
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8d0fb463 edad0ac9
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -931,13 +931,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);
                }
            }
        }
+13 −0
Original line number Diff line number Diff line
@@ -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()