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

Commit 5835157d authored by John Reck's avatar John Reck
Browse files

Remove FD optimization case for decodeStream

 Bug: 10677727
 The problem is that the FileInputStream may be wrapping a pipe or
 AssetFileDescriptor which fails if handed to decodeFileDescriptor.
 The problem is that AFDs can start in the middle of a file, whereas
 decodeFileDescriptor assumes it can mmap() the FD and start at
 the beginning.

Change-Id: I98a3c5f789865145e25a99b32d205e290808c1cf
parent 23ae1461
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -565,24 +565,10 @@ public class BitmapFactory {

        Trace.traceBegin(Trace.TRACE_TAG_GRAPHICS, "decodeBitmap");
        try {
            boolean decodeGenericStream = true;
            if (is instanceof AssetManager.AssetInputStream) {
                final int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
                bm = nativeDecodeAsset(asset, outPadding, opts);
                // Do not follow the normal case.
                decodeGenericStream = false;
            } else if (is instanceof FileInputStream) {
                try {
                    FileDescriptor fd = ((FileInputStream) is).getFD();
                    // decodeFileDescriptor will take care of throwing the IAE and
                    // calling setDensityFromOptions.
                    return decodeFileDescriptor(fd, outPadding, opts);
                } catch (IOException e) {
                    // Fall through to nativeDecodeStream.
                }
            }

            if (decodeGenericStream) {
            } else {
                byte [] tempStorage = null;
                if (opts != null) tempStorage = opts.inTempStorage;
                if (tempStorage == null) tempStorage = new byte[DECODE_BUFFER_SIZE];