From dc74eb4bc5f88b69e66df042c4642a371e286b58 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Fri, 31 Jul 2026 23:38:37 +0300 Subject: [PATCH] notification: harden reply + content PendingIntents (explicit action, FLAG_ONE_SHOT) (#753) --- .../notification/ChatNotificationService.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt b/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt index c304f1c4..71af6dfe 100644 --- a/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt +++ b/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt @@ -133,6 +133,7 @@ class ChatNotificationService : Service() { val replyIntent = Intent(this, NotificationReplyReceiver::class.java).apply { + action = "$packageName.ACTION_NOTIFICATION_REPLY" putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId) } @@ -141,7 +142,7 @@ class ChatNotificationService : Service() { this, sessionId.hashCode(), replyIntent, - PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT, + PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT, ) val action = @@ -161,8 +162,11 @@ class ChatNotificationService : Service() { } private fun buildContentIntent(sessionId: String?): PendingIntent { - val intent = Intent(this, MainActivity::class.java) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP + val intent = + Intent(this, MainActivity::class.java).apply { + action = "$packageName.ACTION_OPEN_CHAT_FROM_NOTIFICATION" + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP + } if (!sessionId.isNullOrBlank()) { intent.putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId) } @@ -170,7 +174,7 @@ class ChatNotificationService : Service() { this, sessionId?.hashCode() ?: 0, intent, - PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT, + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT, ) }