-
Notifications
You must be signed in to change notification settings - Fork 497
Wrap EncryptedSharedPreferences initialization in a retry mechanism (EXPOSUREAPP-1851) #1235
Wrap EncryptedSharedPreferences initialization in a retry mechanism (EXPOSUREAPP-1851) #1235
Conversation
…between the last and the new delay.
very good decision. |
Hi @d4rken , And related to #642 (comment) : Chapeau! Looks like a very thorough and nice research and analysis. [preceeding comment accidently pinged wrong person. Sorry for that.] |
It will probably make sense to have that FAQ entry even after the mitigation is deployed. My fix will only prevent it from affecting new users. There is no recovery for anyone already affected by this as the original encryption key is lost. The only thing that could be done for existing users affected by this issue, is to possibly automate the recovery procedure. Simply resetting the necessary data is not enough though, we don't want to surprise the user with suddenly "reset" app, so there would have to be additional UI components to inform the user about what happened too. 🤔 |
} | ||
} | ||
|
||
private const val DEFAULT_TOTAL_MAX_RETRY = 15 * 1000L // 15 seconds total delay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but shouldn't constants be on top of the class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. For classes they should be in the companion object which are supposed to be at the end of the class according to KotlinStyleGuide. Here this is an object
already. I placed it where it is so it is close to where it is used. I would go with your suggestion if it were used in other locations too. Here it seems beneficial to view it all without scrolling, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All testes passed, no formatting issues, smoke test passed.
Hi @d4rken , thanks very much for your response. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
New PR to merge into 1.4.x instead of 1.5.x
Description
Wrapped the
EncryptedSharedPreferences
initialization in an exponential backoff mechanism with randomized delay, to mitigate issues caused by the system's keystore being busy. The idea is that after a few retries the congestion has cleared and we can get access to the system's keystore.We'll retry for a maximum of 15s, delay at least 25ms and at most 3s between tries.
Should mitigate #642, possibly also #1214, #1121.
Bug description:
How to test
Example log output