diff --git a/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java b/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java index 71ea897c2..99f565ff1 100644 --- a/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java @@ -1,9 +1,11 @@ package eu.siacs.conversations.services; +import android.Manifest; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -17,6 +19,7 @@ import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.util.Log; +import android.widget.Toast; import androidx.annotation.NonNull; @@ -25,6 +28,7 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import eu.siacs.conversations.Config; +import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.ui.RtpSessionActivity; import eu.siacs.conversations.xmpp.Jid; @@ -221,7 +225,6 @@ public class CallIntegrationConnectionService extends ConnectionService { final Account account, final Jid with, final Set media) { - Log.d(Config.LOGTAG, "place call media=" + media); if (CallIntegration.selfManaged()) { final var extras = new Bundle(); extras.putParcelable( @@ -231,6 +234,12 @@ public class CallIntegrationConnectionService extends ConnectionService { Media.audioOnly(media) ? VideoProfile.STATE_AUDIO_ONLY : VideoProfile.STATE_BIDIRECTIONAL); + if (service.checkSelfPermission(Manifest.permission.MANAGE_OWN_CALLS) + != PackageManager.PERMISSION_GRANTED) { + Toast.makeText(service, R.string.no_permission_to_place_call, Toast.LENGTH_SHORT) + .show(); + return; + } service.getSystemService(TelecomManager.class) .placeCall(CallIntegration.address(with), extras); } else { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index a00a47209..6eea73d39 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1981,26 +1981,22 @@ public class ConversationFragment extends XmppFragment } private boolean hasPermissions(int requestCode, List permissions) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - final List missingPermissions = new ArrayList<>(); - for (String permission : permissions) { - if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU || Config.ONLY_INTERNAL_STORAGE) && permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - continue; - } - if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { - missingPermissions.add(permission); - } + final List missingPermissions = new ArrayList<>(); + for (String permission : permissions) { + if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU || Config.ONLY_INTERNAL_STORAGE) && permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { + continue; } - if (missingPermissions.size() == 0) { - return true; - } else { - requestPermissions( - missingPermissions.toArray(new String[0]), - requestCode); - return false; + if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { + missingPermissions.add(permission); } - } else { + } + if (missingPermissions.size() == 0) { return true; + } else { + requestPermissions( + missingPermissions.toArray(new String[0]), + requestCode); + return false; } } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 3ee875fcf..996977eab 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -595,6 +595,7 @@ Me Contact asks for presence subscription Allow + No permission to place phone call No permission to access %s Remote server not found Remote server timeout