notification: harden reply + content PendingIntents (explicit action, FLAG_ONE_SHOT) (#753)
This commit is contained in:
1 file changed
+8
-4
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user