From 35c54f0ae968ba76b78fed6c7081d52d2404c9ef Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Feb 2022 12:16:49 +0100 Subject: [PATCH] delete pre lolipop weOwnFile() --- .../persistance/FileBackend.java | 21 ++----------------- .../ui/ConversationFragment.java | 4 ++-- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 0648aaa62..a5a904c75 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -354,32 +354,15 @@ public class FileBackend { } } - public static boolean weOwnFile(Context context, Uri uri) { + public static boolean weOwnFile(final Uri uri) { if (uri == null || !ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { return false; - } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - return fileIsInFilesDir(context, uri); } else { return weOwnFileLollipop(uri); } } - /** - * This is more than hacky but probably way better than doing nothing Further 'optimizations' - * might contain to get the parents of CacheDir and NoBackupDir and check against those as well - */ - private static boolean fileIsInFilesDir(Context context, Uri uri) { - try { - final String haystack = context.getFilesDir().getParentFile().getCanonicalPath(); - final String needle = new File(uri.getPath()).getCanonicalPath(); - return needle.startsWith(haystack); - } catch (IOException e) { - return false; - } - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static boolean weOwnFileLollipop(Uri uri) { + private static boolean weOwnFileLollipop(final Uri uri) { try { File file = new File(uri.getPath()); FileDescriptor fd = diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index a42fa6766..073e77cc3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2255,10 +2255,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private List cleanUris(final List uris) { - Iterator iterator = uris.iterator(); + final Iterator iterator = uris.iterator(); while (iterator.hasNext()) { final Uri uri = iterator.next(); - if (FileBackend.weOwnFile(getActivity(), uri)) { + if (FileBackend.weOwnFile(uri)) { iterator.remove(); Toast.makeText(getActivity(), R.string.security_violation_not_attaching_file, Toast.LENGTH_SHORT).show(); } -- 2.45.2