Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messageCounter from class SMSManager should be written to memory when the app using this library is closed #44

Open
giovannivelludo opened this issue Jan 2, 2020 · 0 comments

Comments

@giovannivelludo
Copy link
Contributor

giovannivelludo commented Jan 2, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant