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

Commit e8da8b12 authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Handle null assetFd like a FNF

Bug: 140961740
Test: TODO

We already catch an FNF and attempt to open the file as an InputStream.
Do the same if null is returned.

I haven't figured out a way to make assetFd set to null and yet opening
an InputStream succeeds, so this is untested.

Change-Id: Iabd05db714bc693ead2dc8cc4c0b46fef9f33d5a
parent a3b702fa
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -277,6 +277,10 @@ public final class ImageDecoder implements AutoCloseable {
                    assetFd = mResolver.openAssetFileDescriptor(mUri, "r");
                }
            } catch (FileNotFoundException e) {
                // Handled below, along with the case where assetFd was set to null.
            }

            if (assetFd == null) {
                // Some images cannot be opened as AssetFileDescriptors (e.g.
                // bmp, ico). Open them as InputStreams.
                InputStream is = mResolver.openInputStream(mUri);
@@ -286,9 +290,7 @@ public final class ImageDecoder implements AutoCloseable {

                return createFromStream(is, true, preferAnimation, this);
            }
            if (assetFd == null) {
                throw new FileNotFoundException(mUri.toString());
            }

            return createFromAssetFileDescriptor(assetFd, preferAnimation, this);
        }
    }