1
0
Fork 1

Check if path for URI is accessible

The path extracted from the Cursor might not be accessible for Conversations. FileUtils accesses URI information through the ContentProvider, so this wouldn't be noticed.
Fixes sharing from open-keychain's TemporaryContentProvider
This commit is contained in:
fiaxh 2016-03-15 11:09:28 +01:00
parent 25a8a3f0dc
commit cc0052c088

View file

@ -10,6 +10,8 @@ import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import java.io.File;
public class FileUtils {
/**
@ -77,7 +79,14 @@ public class FileUtils {
}
// MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) {
return getDataColumn(context, uri, null, null);
String path = getDataColumn(context, uri, null, null);
if (path != null) {
File file = new File(path);
if (!file.canRead()) {
return null;
}
}
return path;
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {