From 3d5d257707613aa4b35bc29ee22d614f4dc9b4c6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 16 Mar 2024 16:30:57 +0100 Subject: [PATCH] fix system feature detection for call integration --- .../conversations/services/CallIntegration.java | 11 +++++++++-- .../services/XmppConnectionService.java | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/CallIntegration.java b/src/main/java/eu/siacs/conversations/services/CallIntegration.java index 1777e9fd0..67ea605f5 100644 --- a/src/main/java/eu/siacs/conversations/services/CallIntegration.java +++ b/src/main/java/eu/siacs/conversations/services/CallIntegration.java @@ -447,9 +447,16 @@ public class CallIntegration extends Connection { } public static boolean selfManaged(final Context context) { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && hasSystemFeature(context); + } + + public static boolean hasSystemFeature(final Context context) { final var packageManager = context.getPackageManager(); - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + return packageManager.hasSystemFeature(PackageManager.FEATURE_TELECOM); + } else { + return packageManager.hasSystemFeature(PackageManager.FEATURE_CONNECTION_SERVICE); + } } public static boolean notSelfManaged(final Context context) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 887ffe937..35b831eb4 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1286,7 +1286,9 @@ public class XmppConnectionService extends Service { toggleSetProfilePictureActivity(hasEnabledAccounts); reconfigurePushDistributor(); - CallIntegrationConnectionService.togglePhoneAccountsAsync(this, this.accounts); + if (CallIntegration.hasSystemFeature(this)) { + CallIntegrationConnectionService.togglePhoneAccountsAsync(this, this.accounts); + } restoreFromDatabase(); @@ -2465,7 +2467,9 @@ public class XmppConnectionService extends Service { public void createAccount(final Account account) { account.initAccountServices(this); databaseBackend.createAccount(account); - CallIntegrationConnectionService.togglePhoneAccountAsync(this, account); + if (CallIntegration.hasSystemFeature(this)) { + CallIntegrationConnectionService.togglePhoneAccountAsync(this, account); + } this.accounts.add(account); this.reconnectAccountInBackground(account); updateAccountUi(); @@ -2589,7 +2593,9 @@ public class XmppConnectionService extends Service { toggleForegroundService(); syncEnabledAccountSetting(); mChannelDiscoveryService.cleanCache(); - CallIntegrationConnectionService.togglePhoneAccountAsync(this, account); + if (CallIntegration.hasSystemFeature(this)) { + CallIntegrationConnectionService.togglePhoneAccountAsync(this, account); + } return true; } else { return false;