Skip to content

Commit d7d2ef7

Browse files
committed
[messages] allow to mutate message status PendingIntents
1 parent c159554 commit d7d2ef7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/src/main/java/me/capcom/smsgateway/modules/messages/MessagesService.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ class MessagesService(
132132
"Status intent received with action ${intent.action} and result code $resultCode",
133133
mapOf(
134134
"data" to intent.dataString,
135-
"extras" to intent.extras?.toString(),
135+
"extras" to intent.extras?.keySet()
136+
?.associate { key -> key to intent.extras?.get(key)?.toString() },
136137
)
137138
)
138139

@@ -294,31 +295,31 @@ class MessagesService(
294295

295296
request.recipients
296297
.filter { it.state == ProcessingState.Pending }
297-
.forEach { rcp ->
298+
.forEachIndexed { i, rcp ->
298299
val sourcePhoneNumber = rcp.phoneNumber
299300
val sentIntent = PendingIntent.getBroadcast(
300301
context,
301-
0,
302+
id.hashCode() + i,
302303
Intent(
303304
EventsReceiver.ACTION_SENT,
304305
Uri.parse("$id|$sourcePhoneNumber"),
305306
context,
306307
EventsReceiver::class.java
307308
),
308-
PendingIntent.FLAG_IMMUTABLE
309+
PendingIntent.FLAG_MUTABLE
309310
)
310311
val deliveredIntent = when (message.withDeliveryReport) {
311312
false -> null
312313
true -> PendingIntent.getBroadcast(
313314
context,
314-
0,
315+
id.hashCode() + i,
315316
Intent(
316317
EventsReceiver.ACTION_DELIVERED,
317318
Uri.parse("$id|$sourcePhoneNumber"),
318319
context,
319320
EventsReceiver::class.java
320321
),
321-
PendingIntent.FLAG_IMMUTABLE
322+
PendingIntent.FLAG_MUTABLE
322323
)
323324
}
324325

0 commit comments

Comments
 (0)