Created attachment 12393 [details] [PATCH] Poperly read streams associated with content: URIs E.g. attachments from K-9 Mail (recent builds) cannot be opened because InputStream.available() used MuPDFActivity.java always reports 0 for streams that have no buffered data and therefore cannot be read without blocking. The attached patch fixes the problem.
Fixed in: commit 537a467dfd6392d70624805943ac65182ec881b4 Author: Robin Watts <robin.watts@artifex.com> Date: Mon Jul 18 12:11:45 2016 +0100 Bug 696662: Android viewer: data from URI stream fix. Apparently, if MuPDF is invoked on a content stream that comes from a URI, then is.available() can report 0 bytes (as there is no data buffered). Use a modified formulation that reads as much data as possible from the stream into a BufferedOutputStream and then makes a byte array from that. Would be nicer if the core could actually read from the stream directly, perhaps, but that can wait for the new JNI based version. Thanks to Marc K for identifying the problem and supplying the patch.