klinker41 / android-smsmms

Library for easily sending SMS and MMS for Android devices
678 stars 249 forks source link

fix: update messages PendingIntent to use FLAG_IMMUTABLE #200

Closed good-idea closed 1 month ago

good-idea commented 1 month ago

Currently, LP3 messages are failing to send. This is what appears in logcat:

10-18 16:27:46.369  7500  7675 W System.err: java.lang.IllegalArgumentException: com.lightos: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
10-18 16:27:46.369  7500  7675 W System.err: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
10-18 16:27:46.370  7500  7675 W System.err:    at android.app.PendingIntent.checkPendingIntent(PendingIntent.java:430)
10-18 16:27:46.370  7500  7675 W System.err:    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:733)
10-18 16:27:46.370  7500  7675 W System.err:    at android.app.PendingIntent.getBroadcast(PendingIntent.java:720)
10-18 16:27:46.370  7500  7675 W System.err:    at com.klinker.android.send_message.Transaction.sendSmsMessage(Transaction.java:293)
10-18 16:27:46.370  7500  7675 W System.err:    at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:173)
10-18 16:27:46.370  7500  7675 W System.err:    at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:192)
10-18 16:27:46.370  7500  7675 W System.err:    at com.lightos.messages.LightOSMessagesModule.triggerSendSms(LightOSMessagesModule.java:770)
10-18 16:27:46.371  7500  7675 W System.err:    at com.lightos.messages.LightOSMessagesModule.sendSms(LightOSMessagesModule.java:392)
10-18 16:27:46.371  7500  7675 W System.err:    at com.lightos.messages.LightOSMessagesModule.sendMessage(LightOSMessagesModule.java:143)

This PR sets all PendingIntents in Transaction.java to use FLAG_IMMUTABLE. This was tested by making changes in the LP3 branch, and messages now send. (However, they appear twice in the message queue, that's another todo that may be android-smsmms sending the intent multiple times)

good-idea commented 1 month ago

Oops, this was meant for a private fork