From 86af30a1d60dc1e3afaf97690baf834de9ca2f98 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 4 Nov 2022 11:07:20 +0100 Subject: [PATCH] Require calendar read permission when testing write permission --- app/src/main/java/eu/faircode/email/Helper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 9367aa69d1..dc55bf7fec 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -414,7 +414,12 @@ public class Helper { // Features static boolean hasPermission(Context context, String name) { - return (ContextCompat.checkSelfPermission(context, name) == PackageManager.PERMISSION_GRANTED); + if (Manifest.permission.WRITE_CALENDAR.equals(name)) + if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CALENDAR) != + PackageManager.PERMISSION_GRANTED) + return false; + return (ContextCompat.checkSelfPermission(context, name) == + PackageManager.PERMISSION_GRANTED); } static boolean hasPermissions(Context context, String[] permissions) {