do not use Dialer UI for incoming calls if audio permission is not granted
We cannot request new permissions when Dialer UI is shown. For incoming calls, if the Dialer UI is displayed over keyguard, then the user may not even be able to see the permission notifications that we use for outgoing calls. If we just do not use the Dialer UI when the permission is not granted, it is at most a minor annoyance for the first time. After the user has accepted an incoming call even just once, the permission will be granted, and the Dialer integration will start to work just fine.
This commit is contained in:
parent
729b86a2fc
commit
bb281ab7e0
|
@ -273,31 +273,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
xmppConnectionService.getJingleConnectionManager()
|
||||
.findJingleRtpConnection(account, with, sessionId);
|
||||
|
||||
// Request recording permission only when answering
|
||||
PermissionManager permissionManager = PermissionManager.getInstance(ConnectionService.this);
|
||||
permissionManager.setNotificationSettings(
|
||||
new NotificationSettings.Builder()
|
||||
.withMessage(R.string.microphone_permission_for_call)
|
||||
.withSmallIcon(R.drawable.ic_notification).build()
|
||||
);
|
||||
|
||||
Set<String> permissions = new HashSet<>();
|
||||
permissions.add(Manifest.permission.RECORD_AUDIO);
|
||||
permissionManager.checkPermissions(permissions, new PermissionManager.PermissionRequestListener() {
|
||||
@Override
|
||||
public void onPermissionGranted() {
|
||||
if (rtpConnection == null || rtpConnection.get() == null) {
|
||||
setDisconnected(new DisconnectCause(DisconnectCause.ERROR));
|
||||
} else {
|
||||
rtpConnection.get().acceptCall();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionDenied(DeniedPermissions deniedPermissions) {
|
||||
setDisconnected(new DisconnectCause(DisconnectCause.ERROR));
|
||||
}
|
||||
});
|
||||
rtpConnection.get().acceptCall();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.siacs.conversations.services;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
|
@ -8,6 +9,7 @@ import android.app.PendingIntent;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -427,6 +429,13 @@ public class NotificationService {
|
|||
}
|
||||
|
||||
private synchronized boolean tryRingingWithDialerUI(final AbstractJingleConnection.Id id, final Set<Media> media) {
|
||||
if (mXmppConnectionService.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||
// We cannot request audio permission in Dialer UI
|
||||
// when Dialer is shown over keyguard, the user cannot even necessarily
|
||||
// see notifications.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (media.size() != 1 || !media.contains(Media.AUDIO)) {
|
||||
// Currently our ConnectionService only handles single audio calls
|
||||
Log.w(Config.LOGTAG, "only audio calls can be handled by cheogram connection service");
|
||||
|
|
Loading…
Reference in a new issue