From ae52ae61037b227a888c713541648d19fd7ea053 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 28 Jun 2020 09:50:49 +0200 Subject: [PATCH] Prevent crash --- .../java/eu/faircode/email/ContactInfo.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ContactInfo.java b/app/src/main/java/eu/faircode/email/ContactInfo.java index 90c01c8a9a..62d28fdd84 100644 --- a/app/src/main/java/eu/faircode/email/ContactInfo.java +++ b/app/src/main/java/eu/faircode/email/ContactInfo.java @@ -309,9 +309,21 @@ public class ContactInfo { } }); - Uri uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI; - Log.i("Observing uri=" + uri); - context.getContentResolver().registerContentObserver(uri, true, observer); + try { + Uri uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI; + Log.i("Observing uri=" + uri); + context.getContentResolver().registerContentObserver(uri, true, observer); + } catch (SecurityException ex) { + Log.w(ex); + /* + Should never happen, but: + Caused by: android.os.RemoteException: + at com.android.server.content.ContentService.registerContentObserver (ContentService.java:340) + at android.content.IContentService$Stub.onTransact (IContentService.java:76) + at com.android.server.content.ContentService.onTransact (ContentService.java:262) + at android.os.Binder.execTransact (Binder.java:731) + */ + } } }