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 =
|
val replyIntent =
|
||||||
Intent(this, NotificationReplyReceiver::class.java).apply {
|
Intent(this, NotificationReplyReceiver::class.java).apply {
|
||||||
|
action = "$packageName.ACTION_NOTIFICATION_REPLY"
|
||||||
putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId)
|
putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ class ChatNotificationService : Service() {
|
|||||||
this,
|
this,
|
||||||
sessionId.hashCode(),
|
sessionId.hashCode(),
|
||||||
replyIntent,
|
replyIntent,
|
||||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
|
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT,
|
||||||
)
|
)
|
||||||
|
|
||||||
val action =
|
val action =
|
||||||
@@ -161,8 +162,11 @@ class ChatNotificationService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildContentIntent(sessionId: String?): PendingIntent {
|
private fun buildContentIntent(sessionId: String?): PendingIntent {
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
val intent =
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
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()) {
|
if (!sessionId.isNullOrBlank()) {
|
||||||
intent.putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId)
|
intent.putExtra(NotificationReplyReceiver.EXTRA_SESSION_ID, sessionId)
|
||||||
}
|
}
|
||||||
@@ -170,7 +174,7 @@ class ChatNotificationService : Service() {
|
|||||||
this,
|
this,
|
||||||
sessionId?.hashCode() ?: 0,
|
sessionId?.hashCode() ?: 0,
|
||||||
intent,
|
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