1

Background

I have an application that uses Storage Access Framework.

It prompts a user to pick a directory to obtain permissions to work with files:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);

Then allow user to select a JPG image in the directory:

DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);
DocumentFile[] files = pickedDir.listFiles();
...
DocumentFile file = files[0]; // for example

Problem

One user has the following problem on Android 7.

When the program try to read the content of the file (JPEG image):

InputStream is = getContentResolver().openInputStream(file.getUri());
... // then read the stream in a standard way

The content is not the true content of the file, but some random garbage with word "CONSOLE" followed by zeros:

enter image description here

The file has the correct length and no error is risen, only the content is nonsense.

This behavior is unique and it's not reproducible on any other device.

Has anyone encounter anything like this?

Quark
  • 1,578
  • 2
  • 19
  • 34
  • 1. What file picker was used to select the file? How does Uri look like? 2. Are you sure, that this isn't actual content of file? Does it look differently when open by other means? – user1643723 Sep 17 '17 at 12:10
  • @user1643723 The user does not communicate anymore, so I don't know the exact URI. The device is Galaxy S7 (Android 7) and directory is default photo directory (the JPEGs are photos from the device). – Quark Oct 08 '17 at 07:51

0 Answers0