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

Commit c5c9881d authored by Julia Tuttle's avatar Julia Tuttle Committed by Android (Google) Code Review
Browse files

Merge "Icon: don't create Drawables with null Bitmaps" into main

parents 232bd75e bdc8c266
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.graphics.drawable;
import static android.content.Context.CONTEXT_INCLUDE_CODE;
import static android.content.Context.CONTEXT_RESTRICTED;

import static com.android.graphics.flags.Flags.iconLoadDrawableReturnNullWhenUriDecodeFails;

import android.annotation.ColorInt;
import android.annotation.DrawableRes;
import android.annotation.IntDef;
@@ -497,6 +499,9 @@ public final class Icon implements Parcelable {
                    final Bitmap bitmap = BitmapFactory.decodeStream(is);
                    if (bitmap == null) {
                        Log.w(TAG, "Unable to decode image from URI: " + getUriString());
                        if (iconLoadDrawableReturnNullWhenUriDecodeFails()) {
                            return null;
                        }
                    }
                    return new BitmapDrawable(context.getResources(), fixMaxBitmapSize(bitmap));
                }
@@ -507,6 +512,9 @@ public final class Icon implements Parcelable {
                    final Bitmap bitmap = BitmapFactory.decodeStream(is);
                    if (bitmap == null) {
                        Log.w(TAG, "Unable to decode image from URI: " + getUriString());
                        if (iconLoadDrawableReturnNullWhenUriDecodeFails()) {
                            return null;
                        }
                    }
                    return new AdaptiveIconDrawable(null, new BitmapDrawable(context.getResources(),
                            fixMaxBitmapSize(bitmap)));