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

Commit cc35c516 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Automerger Merge Worker
Browse files

Increase maximum allowed size for status bar icons am: 8875da52

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

Change-Id: Iad171ba42818085e0eef2fe98e357a6e0962fcfa
parents 264dea63 8875da52
Loading
Loading
Loading
Loading
+21 −4
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import android.graphics.Color;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.graphics.drawable.Icon;
import android.os.Parcelable;
import android.os.Parcelable;
@@ -79,8 +80,15 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
    public static final int STATE_DOT = 1;
    public static final int STATE_DOT = 1;
    public static final int STATE_HIDDEN = 2;
    public static final int STATE_HIDDEN = 2;


    /** Maximum allowed width or height for an icon drawable */
    /**
    private static final int MAX_IMAGE_SIZE = 500;
     * Maximum allowed byte count for an icon bitmap
     * @see android.graphics.RecordingCanvas.MAX_BITMAP_SIZE
     */
    private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB
    /**
     * Maximum allowed width or height for an icon drawable, if we can't get byte count
     */
    private static final int MAX_IMAGE_SIZE = 5000;


    private static final String TAG = "StatusBarIconView";
    private static final String TAG = "StatusBarIconView";
    private static final Property<StatusBarIconView, Float> ICON_APPEAR_AMOUNT
    private static final Property<StatusBarIconView, Float> ICON_APPEAR_AMOUNT
@@ -346,9 +354,18 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
            return false;
            return false;
        }
        }


        if (drawable.getIntrinsicWidth() > MAX_IMAGE_SIZE
        if (drawable instanceof BitmapDrawable && ((BitmapDrawable) drawable).getBitmap() != null) {
            // If it's a bitmap we can check the size directly
            int byteCount = ((BitmapDrawable) drawable).getBitmap().getByteCount();
            if (byteCount > MAX_BITMAP_SIZE) {
                Log.w(TAG, "Drawable is too large (" + byteCount + " bytes) " + mIcon);
                return false;
            }
        } else if (drawable.getIntrinsicWidth() > MAX_IMAGE_SIZE
                || drawable.getIntrinsicHeight() > MAX_IMAGE_SIZE) {
                || drawable.getIntrinsicHeight() > MAX_IMAGE_SIZE) {
            Log.w(TAG, "Drawable is too large " + mIcon);
            // Otherwise, check dimensions
            Log.w(TAG, "Drawable is too large (" + drawable.getIntrinsicWidth() + "x"
                    + drawable.getIntrinsicHeight() + ") " + mIcon);
            return false;
            return false;
        }
        }


+1 −1
Original line number Original line Diff line number Diff line
@@ -126,7 +126,7 @@ public class StatusBarIconViewTest extends SysuiTestCase {


    @Test
    @Test
    public void testGiantImageNotAllowed() {
    public void testGiantImageNotAllowed() {
        Bitmap largeBitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
        Bitmap largeBitmap = Bitmap.createBitmap(6000, 6000, Bitmap.Config.ARGB_8888);
        Icon icon = Icon.createWithBitmap(largeBitmap);
        Icon icon = Icon.createWithBitmap(largeBitmap);
        StatusBarIcon largeIcon = new StatusBarIcon(UserHandle.ALL, "mockPackage",
        StatusBarIcon largeIcon = new StatusBarIcon(UserHandle.ALL, "mockPackage",
                icon, 0, 0, "");
                icon, 0, 0, "");