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

Commit 25eef890 authored by Jim Miller's avatar Jim Miller
Browse files

Fix 3309250: Don't crash when thumbnail is null

This fixes a bug where Recents would crash when the
thumbnail for the given app isn't available.  The
defined behavior for this situation should be just
the app icon on top of the default glow background.

Change-Id: Ie5a3a7878381a6b8fc640319fccfc16387e3d4cc
parent 1451862b
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnC

    private Bitmap compositeBitmap(Bitmap background, Bitmap thumbnail) {
        Bitmap outBitmap = background.copy(background.getConfig(), true);
        if (thumbnail != null) {
            Canvas canvas = new Canvas(outBitmap);
            Paint paint = new Paint();
            paint.setAntiAlias(true);
@@ -264,13 +265,15 @@ public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnC
            paint.setAlpha(255);
            final int srcWidth = thumbnail.getWidth();
            final int height = thumbnail.getHeight();
        final int srcHeight = srcWidth > height ? height : (height - height * srcWidth / height);
            final int srcHeight = srcWidth > height ? height
                    : (height - height * srcWidth / height);
            canvas.drawBitmap(thumbnail,
                    new Rect(0, 0, srcWidth-1, srcHeight-1),
                    new RectF(GLOW_PADDING,
                            GLOW_PADDING - 4.0f,
                            outBitmap.getWidth() - GLOW_PADDING + 2.0f,
                            outBitmap.getHeight() - GLOW_PADDING + 3.0f), paint);
        }
        return outBitmap;
    }