(un)register phone account on xmpp account creation/deletion

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java | 4 
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java            | 2 
2 files changed, 6 insertions(+)

Detailed changes

src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java 🔗

@@ -181,6 +181,10 @@ public class CallIntegrationConnectionService extends ConnectionService {
         }
     }
 
+    public static void unregisterPhoneAccount(final Context context, final Account account) {
+        context.getSystemService(TelecomManager.class).unregisterPhoneAccount(getHandle(context, account));
+    }
+
     public static PhoneAccountHandle getHandle(final Context context, final Account account) {
         final var competentName =
                 new ComponentName(context, CallIntegrationConnectionService.class);

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java 🔗

@@ -2460,6 +2460,7 @@ public class XmppConnectionService extends Service {
     public void createAccount(final Account account) {
         account.initAccountServices(this);
         databaseBackend.createAccount(account);
+        CallIntegrationConnectionService.registerPhoneAccount(this, account);
         this.accounts.add(account);
         this.reconnectAccountInBackground(account);
         updateAccountUi();
@@ -2644,6 +2645,7 @@ public class XmppConnectionService extends Service {
             };
             mDatabaseWriterExecutor.execute(runnable);
             this.accounts.remove(account);
+            CallIntegrationConnectionService.unregisterPhoneAccount(this, account);
             this.mRosterSyncTaskManager.clear(account);
             updateAccountUi();
             mNotificationService.updateErrorNotification();