Fixed wrong exception being catched

This commit is contained in:
Sylvain Berfini 2022-07-26 13:06:34 +02:00
parent 6eed295c5c
commit 0aa44f8c39

View file

@ -90,17 +90,27 @@ class Api31Compatibility {
val isVideoAutomaticallyAccepted = call.core.videoActivationPolicy.automaticallyAccept val isVideoAutomaticallyAccepted = call.core.videoActivationPolicy.automaticallyAccept
val isVideo = isVideoEnabledInRemoteParams && isVideoAutomaticallyAccepted val isVideo = isVideoEnabledInRemoteParams && isVideoAutomaticallyAccepted
val builder = Notification.Builder(context, context.getString(R.string.notification_channel_incoming_call_id)) val builder = Notification.Builder(context, context.getString(R.string.notification_channel_incoming_call_id)).apply {
.setStyle(Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent).setIsVideo(isVideo)) try {
.setSmallIcon(R.drawable.topbar_call_notification) style = Notification.CallStyle.forIncomingCall(
.setCategory(Notification.CATEGORY_CALL) caller,
.setVisibility(Notification.VISIBILITY_PUBLIC) declineIntent,
.setWhen(System.currentTimeMillis()) answerIntent
.setAutoCancel(false) ).setIsVideo(isVideo)
.setShowWhen(true) } catch (iae: IllegalArgumentException) {
.setOngoing(true) Log.e("[Api31 Compatibility] Can't use notification call style: $iae, using API 26 notification instead")
.setColor(ContextCompat.getColor(context, R.color.primary_color)) return Api26Compatibility.createIncomingCallNotification(context, call, notifiable, pendingIntent, notificationsManager)
.setFullScreenIntent(pendingIntent, true) }
setSmallIcon(R.drawable.topbar_call_notification)
setCategory(Notification.CATEGORY_CALL)
setVisibility(Notification.VISIBILITY_PUBLIC)
setWhen(System.currentTimeMillis())
setAutoCancel(false)
setShowWhen(true)
setOngoing(true)
setColor(ContextCompat.getColor(context, R.color.primary_color))
setFullScreenIntent(pendingIntent, true)
}
if (!corePreferences.preventInterfaceFromShowingUp) { if (!corePreferences.preventInterfaceFromShowingUp) {
builder.setContentIntent(pendingIntent) builder.setContentIntent(pendingIntent)
@ -168,8 +178,9 @@ class Api31Compatibility {
try { try {
style = Notification.CallStyle.forOngoingCall(caller, declineIntent) style = Notification.CallStyle.forOngoingCall(caller, declineIntent)
.setIsVideo(isVideo) .setIsVideo(isVideo)
} catch (ise: IllegalStateException) { } catch (iae: IllegalArgumentException) {
Log.e("[Api31 Compatibility] Can't use notification call style: $ise") Log.e("[Api31 Compatibility] Can't use notification call style: $iae, using API 26 notification instead")
return Api26Compatibility.createCallNotification(context, call, notifiable, pendingIntent, channel, notificationsManager)
} }
setSmallIcon(iconResourceId) setSmallIcon(iconResourceId)
setAutoCancel(false) setAutoCancel(false)