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

Commit 619c3cde authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Close InputStreams when loading icons." into main

parents f4e69562 446f2f6d
Loading
Loading
Loading
Loading
+24 −17
Original line number Diff line number Diff line
@@ -494,7 +494,7 @@ public final class Icon implements Parcelable {
                        BitmapFactory.decodeByteArray(getDataBytes(), getDataOffset(),
                                getDataLength())));
            case TYPE_URI:
                InputStream is = getUriInputStream(context);
                try (InputStream is = getUriInputStream(context)) {
                    if (is != null) {
                        final Bitmap bitmap = BitmapFactory.decodeStream(is);
                        if (bitmap == null) {
@@ -505,9 +505,12 @@ public final class Icon implements Parcelable {
                        }
                        return new BitmapDrawable(context.getResources(), fixMaxBitmapSize(bitmap));
                    }
                } catch (IOException e) {
                    throw new IllegalStateException(e);
                }
                break;
            case TYPE_URI_ADAPTIVE_BITMAP:
                is = getUriInputStream(context);
                try (InputStream is = getUriInputStream(context)) {
                    if (is != null) {
                        final Bitmap bitmap = BitmapFactory.decodeStream(is);
                        if (bitmap == null) {
@@ -516,9 +519,13 @@ public final class Icon implements Parcelable {
                                return null;
                            }
                        }
                    return new AdaptiveIconDrawable(null, new BitmapDrawable(context.getResources(),
                        return new AdaptiveIconDrawable(
                                        null, new BitmapDrawable(context.getResources(),
                                fixMaxBitmapSize(bitmap)));
                    }
                } catch (IOException e) {
                    throw new IllegalStateException(e);
                }
                break;
        }
        return null;