From 95aea4291e2690f9e39c75eaf7cddbd0cbbc0ffd Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 5 Oct 2023 20:28:47 +0200 Subject: [PATCH] don't attempt to figure out file path on Android 11+ fixes #117 --- .../eu/siacs/conversations/persistance/FileBackend.java | 9 +++++++-- .../java/eu/siacs/conversations/utils/FileUtils.java | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 3c193219e..d8050646a 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -648,8 +648,13 @@ public class FileBackend { } } - public String getOriginalPath(Uri uri) { - return FileUtils.getPath(mXmppConnectionService, uri); + public String getOriginalPath(final Uri uri) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + // On Android 11+ we don’t have access to the original file + return null; + } else { + return FileUtils.getPath(mXmppConnectionService, uri); + } } private void copyFileToPrivateStorage(File file, Uri uri) throws FileCopyException { diff --git a/src/main/java/eu/siacs/conversations/utils/FileUtils.java b/src/main/java/eu/siacs/conversations/utils/FileUtils.java index 43e3da118..e439ab030 100644 --- a/src/main/java/eu/siacs/conversations/utils/FileUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/FileUtils.java @@ -34,10 +34,8 @@ public class FileUtils { return null; } - final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - // DocumentProvider - if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { + if (DocumentsContract.isDocumentUri(context, uri)) { // ExternalStorageProvider if (isExternalStorageDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri);