You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment it's possible to send some messages with a delivery listener, then closing the app, then reopening it, and messageCounter could have a value equal or slightly lower than the one it had in the previous instance of the app (it's rare, but could still happen, the more messages are sent in a single instance of the app, the more likely are the values of messageCounter to overlap with the values it had in the previous instance), since it's chosen randomly. If we then send some other messages with delivery listeners, the intent filter of the new SMSDeliveredBroadcastReceivers will contain the same actionName used in some of the messages sent in the previous instance of the application, so if the delivery confirmations of previous messages are received while this new instance of the app is open, the new messages we just sent will be considered delivered, even though the confirmation was for the previous messages.
To avoid this issue, we should provide a cleanup() method for the app to call when it's destroyed, so that messageCounter can be written to secondary memory. When a new instance of SMSManager is created, it should read from memory to restore the previous value if it exists, otherwise choose a new starting value. We could then remove the random generation of messageCounter and start counting from 0 or Integer.MIN_VALUE. We should also update the README and the documentation of class SMSManager to tell developers using this library that they should call cleanup() when their app is destroyed.
The text was updated successfully, but these errors were encountered:
At the moment it's possible to send some messages with a delivery listener, then closing the app, then reopening it, and
messageCounter
could have a value equal or slightly lower than the one it had in the previous instance of the app (it's rare, but could still happen, the more messages are sent in a single instance of the app, the more likely are the values ofmessageCounter
to overlap with the values it had in the previous instance), since it's chosen randomly. If we then send some other messages with delivery listeners, the intent filter of the newSMSDeliveredBroadcastReceiver
s will contain the sameactionName
used in some of the messages sent in the previous instance of the application, so if the delivery confirmations of previous messages are received while this new instance of the app is open, the new messages we just sent will be considered delivered, even though the confirmation was for the previous messages.To avoid this issue, we should provide a
cleanup()
method for the app to call when it's destroyed, so thatmessageCounter
can be written to secondary memory. When a new instance ofSMSManager
is created, it should read from memory to restore the previous value if it exists, otherwise choose a new starting value. We could then remove the random generation ofmessageCounter
and start counting from 0 orInteger.MIN_VALUE
. We should also update the README and the documentation of classSMSManager
to tell developers using this library that they should callcleanup()
when their app is destroyed.The text was updated successfully, but these errors were encountered: