tink
tink copied to clipboard
Allow AndroidKeySetManager to accept SharedPreferences interface
Problem
Currently, AndroidKeysetManager accepts a file name string to initialize a SharedPreferences object via Context.getSharedPreferences(). However, there is no way to provide a custom SharedPreference object for third-party implementations. This PR provides a way to provide a SharedPreference object to use for the keyset.
Use Case
I have a custom SharedPreference implementation that is meant to make it multi-process safe (https://github.com/pablobaxter/Harmony). The problem I ran into is that the AndroidKeysetManager could be created in multiple processes, which would use the Android SharedPreferences object (which is not process safe). In order for me to work around this, I would need to provide my own SharedPreferences to be used instead.
The changes are relatively small, and do not change any internal logic. Thank you in advance for the PR review!
Please let me know if there is anything more I need to nudge this PR through. Thank you!
We decided that we don't want to add this to the AndroidKeysetManager. If you need additional flexibility, then you will need to implement that yourself, by duplicating some of the functionality of AndroidKeysetManager.