aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 143505e9a..b4a758b07 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -578,8 +578,7 @@ public class FileBackend {
public static Uri getUriForFile(Context context, File file) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
- String packageId = context.getPackageName();
- return FileProvider.getUriForFile(context, packageId + FILE_PROVIDER, file);
+ return FileProvider.getUriForFile(context, getAuthority(context), file);
} catch (IllegalArgumentException e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
throw new SecurityException(e);
@@ -592,6 +591,10 @@ public class FileBackend {
}
}
+ public static String getAuthority(Context context) {
+ return context.getPackageName() + FILE_PROVIDER;
+ }
+
public static Uri getIndexableTakePhotoUri(Uri original) {
if ("file".equals(original.getScheme())) {
return original;
@@ -776,9 +779,7 @@ public class FileBackend {
input = rotate(input, getRotation(image));
return cropCenterSquare(input, size);
}
- } catch (SecurityException e) {
- return null; // happens for example on Android 6.0 if contacts permissions get revoked
- } catch (FileNotFoundException e) {
+ } catch (FileNotFoundException | SecurityException e) {
return null;
} finally {
close(is);