From 0378272bfe2266d4a42c22f8836e7461df9c8e31 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 18 Apr 2023 09:16:04 -0500 Subject: [PATCH] If unregister fails we should log but not crash Often this isn't even needed since most contact removals are not of a PSTN gateway. Worst case they end up with an extra phone account in system, but if we can't remove probably it's not there or owned by us anyway. --- .../java/eu/siacs/conversations/entities/Contact.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 8971ab50f8e245919e429bf53191fadbe8999dda..5e87149a382de004af53b21adf3464d79a1320a4 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -13,6 +13,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.text.TextUtils; +import android.util.Log; import androidx.annotation.NonNull; @@ -687,7 +688,12 @@ public class Contact implements ListItem, Blockable { } TelecomManager telecomManager = ctx.getSystemService(TelecomManager.class); - telecomManager.unregisterPhoneAccount(phoneAccountHandle()); + + try { + telecomManager.unregisterPhoneAccount(phoneAccountHandle()); + } catch (final SecurityException e) { + Log.w(Config.LOGTAG, "Could not unregister " + getJid() + " as phone account: " + e); + } } public static int getOption(Class clazz) {