From 8e588bf800df8cf76b613c79944b4a996ef99a42 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 6 Aug 2024 16:15:16 +0200 Subject: [PATCH] Added missing pending intent for keep alive service --- .../notifications/NotificationsManager.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index ea657bc3f..64c16716f 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -1000,6 +1000,9 @@ class NotificationsManager @MainThread constructor(private val context: Context) setSmallIcon(smallIcon) setCategory(NotificationCompat.CATEGORY_CALL) setVisibility(NotificationCompat.VISIBILITY_PUBLIC) + if (isIncoming) { + setPriority(NotificationCompat.PRIORITY_MAX) + } setWhen(System.currentTimeMillis()) setAutoCancel(false) setOngoing(true) @@ -1270,14 +1273,27 @@ class NotificationsManager @MainThread constructor(private val context: Context) val service = keepAliveService if (service != null) { + val pendingIntent = TaskStackBuilder.create(context).run { + addNextIntentWithParentStack( + Intent(context, MainActivity::class.java).apply { + setAction(Intent.ACTION_MAIN) // Needed as well + } + ) + getPendingIntent( + KEEP_ALIVE_FOR_THIRD_PARTY_ACCOUNTS_ID, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + )!! + } + val builder = NotificationCompat.Builder(context, channelId) - .setContentTitle(context.getString(R.string.app_name)) .setSmallIcon(R.drawable.linphone_notification) .setAutoCancel(false) .setOngoing(true) .setCategory(NotificationCompat.CATEGORY_SERVICE) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) + .setPriority(NotificationCompat.PRIORITY_LOW) .setShowWhen(false) + .setContentIntent(pendingIntent) val notification = builder.build() Log.i(