From a78421d79a2d35ff4500b68b3f12d2c753e0ec16 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 23 Oct 2023 13:59:52 +0200 Subject: [PATCH] Fixed incoming call style notification not always displayed --- app/src/main/assets/linphonerc_factory | 3 +++ .../org/linphone/contacts/ContactsManager.kt | 3 +++ .../org/linphone/core/CoreForegroundService.kt | 12 ++++++++++++ .../notifications/NotificationsManager.kt | 16 ++++++++++++++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/linphonerc_factory b/app/src/main/assets/linphonerc_factory index 85b543074..1e6e02d4f 100644 --- a/app/src/main/assets/linphonerc_factory +++ b/app/src/main/assets/linphonerc_factory @@ -28,6 +28,9 @@ rls_uri=sips:rls@sip.linphone.org #remove this property for any application that is not Linphone public version itself ec_calibrator_cool_tones=1 +[audio] +android_disable_audio_focus_requests=1 + [video] displaytype=MSAndroidTextureDisplay auto_resize_preview_to_keep_ratio=1 diff --git a/app/src/main/java/org/linphone/contacts/ContactsManager.kt b/app/src/main/java/org/linphone/contacts/ContactsManager.kt index 59804102b..9db118bb3 100644 --- a/app/src/main/java/org/linphone/contacts/ContactsManager.kt +++ b/app/src/main/java/org/linphone/contacts/ContactsManager.kt @@ -366,6 +366,9 @@ fun Friend.getPerson(): Person { val bm: Bitmap? = getAvatarBitmap() personBuilder.setIcon( if (bm == null) { + Log.i( + "[Friend] Can't use friend [$name] picture path, generating avatar based on initials" + ) AvatarGenerator(coreContext.context).setInitials(AppUtils.getInitials(name.orEmpty())).buildIcon() } else { IconCompat.createWithAdaptiveBitmap(bm) diff --git a/app/src/main/java/org/linphone/core/CoreForegroundService.kt b/app/src/main/java/org/linphone/core/CoreForegroundService.kt index f6b9d6312..8d0c05a49 100644 --- a/app/src/main/java/org/linphone/core/CoreForegroundService.kt +++ b/app/src/main/java/org/linphone/core/CoreForegroundService.kt @@ -61,4 +61,16 @@ class CoreForegroundService : CoreService() { override fun onBind(p0: Intent?): IBinder? { return null } + + override fun createServiceNotification() { + // Do nothing, app's Notifications Manager will do the job + } + + override fun showForegroundServiceNotification() { + // Do nothing, app's Notifications Manager will do the job + } + + override fun hideForegroundServiceNotification() { + // Do nothing, app's Notifications Manager will do the job + } } diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 5c9f30cdf..6bd3e45b9 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -349,6 +349,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) Log.w("$TAG No call anymore, stopping service") stopCallForeground() } else { + Log.i("$TAG At least a call is still running") startCallForeground() } } @@ -401,6 +402,8 @@ class NotificationsManager @MainThread constructor(private val context: Context) @WorkerThread private fun startCallForeground() { + Log.i("$TAG Trying to start foreground Service using call notification") + val channelId = context.getString(R.string.notification_channel_call_id) val channel = notificationManager.getNotificationChannel(channelId) val importance = channel?.importance ?: NotificationManagerCompat.IMPORTANCE_NONE @@ -415,7 +418,12 @@ class NotificationsManager @MainThread constructor(private val context: Context) val notification = notificationManager.activeNotifications.find { it.id == notifiable.notificationId } - notification ?: return + + if (notification == null) { + Log.w("$TAG No existing notification found for current Call, aborting") + return + } + Log.i("$TAG Found notification [${notification.id}] for current Call") val service = coreService if (service != null) { @@ -726,6 +734,10 @@ class NotificationsManager @MainThread constructor(private val context: Context) } } + Log.i( + "Creating notification for ${if (isIncoming) "incoming" else "outgoing"} call with video ${if (isVideo) "enabled" else "disabled"} on channel [$channel]" + ) + val builder = NotificationCompat.Builder( context, channel @@ -741,7 +753,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) setStyle(style) } catch (iae: IllegalArgumentException) { Log.e( - "$TAG Can't use notification call style: $iae, using API 26 notification instead" + "$TAG Can't use notification call style: $iae" ) } setSmallIcon(smallIcon)