fix system feature detection for call integration

This commit is contained in:
Daniel Gultsch 2024-03-16 16:30:57 +01:00
parent 72d194d8ff
commit 3d5d257707
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
2 changed files with 18 additions and 5 deletions

View file

@ -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) {

View file

@ -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;