Skip to content
Commit ed074fd7 authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Support using ImageDecoder with ContentResolver + URI

Bug: 63909536
Test: CTS: I0f36ce34c968fd7fae4d8edebabea3a421859615

Add ImageDecoder.createSource(ContentResolver, URI), allowing a client
to decode images from files, content, resources, etc.

Prefer using a file descriptor to using an InputStream so the input can
be cheaply seeked and rewound if necessary.

Make ImageDecoder implement AutoCloseable to handle closing the input.

Make decodeDrawable/decodeBitmap always return an object or throw an
IOException. Avoid checking for a file in the Source constructor.

Fix a bug where inner Exception classes were not static.

Update JavaInputStreamAdaptor to be usable by ImageDecoder:
- previously it always swallowed exceptions. Allow them to propagate
  (optionally) so that they can be reported back to the client.
- Add refs to the InputStream and byte[]. ImageDecoder returns from
  native and then uses the JavaInputStreamAdaptor again, making the
  local refs go out of scope.
- Hold on to the JavaVM and convert to the JNIEnv when necessary. Pass
  local env pointers to avoid looking it up multiple times in one call.
- If an exception is thrown inside the doRead() loop, return the number
  of bytes successfully read.

Change-Id: I869dad55521cf942efd010c06baf3f44c1c08374
parent 5c72a77b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment