-
Notifications
You must be signed in to change notification settings - Fork 487
Refactor LocalData (EXPOSUREAPP-2850) #2569
Refactor LocalData (EXPOSUREAPP-2850) #2569
Conversation
* Migrate Shared Preferences (SETTINGS) * Code refactoring * Fix tests * Migrate Shared Preferences (SETTINGS) * Cleaning code * Cleaning code
* EncryptedPreferencesMigration skeleton class * SecurityHelper return nullable SharedPreferences not an exception
# Conflicts: # Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/util/security/DBPasswordTest.kt # Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/storage/legacy/RiskLevelResultMigrator.kt # Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/security/SecurityHelper.kt
…#2470 * Removed Onboarding related Properties from LocalData Added OnboardingData which provides the FlowPreferences that were defined in LocalData beforehand Currently no migration for these values is implemented Signed-off-by: Kolya Opahle <[email protected]> * Turns out MockFlowPreference and MockSharedPreferences were not usable in the device test flavour moved them into testShared Signed-off-by: Kolya Opahle <[email protected]> * OnboardingData -> OnboardingSettings OnboardingSettings: moved to get / set instead of FlowPreferences when subscribing is not needed isOnboarded is now based on onboardingCompletedTimestamp != null instead of set seperately Signed-off-by: Kolya Opahle <[email protected]> * Removed Onboarding Preference key strings from all languages Signed-off-by: Kolya Opahle <[email protected]> * Added Singleton annotation to OnboardingSettings Added migration code for OnboardingSettings to EncryptedPreferencesMigration Signed-off-by: Kolya Opahle <[email protected]>
# Conflicts: # Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/MainActivityTest.kt
… into feature/2850-refactor-localdata
* migrate LocalData tracing preferences to TracingSettings * update tests * Remove old code * Update tests
* Moved submission related settings from LocalData to SubmissionSettings Made BackgroundNoise injectable Refactored some of the SubmissionSettings Signed-off-by: Kolya Opahle <[email protected]> * Replaced isBeforeNow in BackgroundNoisePeriodicWorker with timeStamper.nowUTC to help with testing Signed-off-by: Kolya Opahle <[email protected]> * Fixed MainActivityTest by providing SubmissionSettings as a mockk Signed-off-by: Kolya Opahle <[email protected]> * Removed all Preference keys removed from LocalData Signed-off-by: Kolya Opahle <[email protected]> * Added migration code for SubmissionSettings to EncryptedPreferencesMigration Signed-off-by: Kolya Opahle <[email protected]> * Moved Instant conversion to extension function to satisfy detekt Signed-off-by: Kolya Opahle <[email protected]> * Removed lazy from dagger injection in BackgroundWorkSchedulerBase * Cleaned up TestResultDonorTest (Removed Instant.now() calls, fixed shouldBe case where Instant.now() would break the calculation) * Moved toInstantOrNull into TimeAndDateExtensions and used it in a few more places * Fixed a unit test that was added by the merge and fixed a merge diff that was resolved wrongly Signed-off-by: Kolya Opahle <[email protected]> * Format on commit got rid of these imports for some reason Signed-off-by: Kolya Opahle <[email protected]>
d4rken
left a comment
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.
Code looks good, still need to test on device. Few changes I'd like to discuss, see comments.
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/CoronaWarnApplication.kt
Show resolved
Hide resolved
| .addOnSuccessListener { cont.resume(it) } | ||
| .addOnFailureListener { cont.resumeWithException(it) } | ||
| .also { | ||
| tracingSettings.isConsentGiven = true |
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.
Where was this set before?
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.
It was there all the time. It was called initialTracingActivationTimestamp() before, but as we always used it only as a boolean value in TracingPermissionHelper.isConsentGiven() I rename it.
It was removed by mistake in previous PR 1b61142#diff-429f8ee04350d96dcf9c0b0176310a0cf1db823097983b0ae865463833b267dc
So you can't see the proper diff here.
...-App/src/main/java/de/rki/coronawarnapp/storage/preferences/EncryptedPreferencesMigration.kt
Outdated
Show resolved
Hide resolved
...-App/src/main/java/de/rki/coronawarnapp/storage/preferences/EncryptedPreferencesMigration.kt
Outdated
Show resolved
Hide resolved
...-App/src/main/java/de/rki/coronawarnapp/storage/preferences/EncryptedPreferencesMigration.kt
Outdated
Show resolved
Hide resolved
...-App/src/main/java/de/rki/coronawarnapp/storage/preferences/EncryptedPreferencesMigration.kt
Show resolved
Hide resolved
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/preferences/PreferencesModule.kt
Outdated
Show resolved
Hide resolved
|
|
||
| @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) | ||
| internal val encryptedPreferencesProvider: (ApplicationComponent) -> SharedPreferences = { | ||
| internal val encryptedPreferencesProvider: (ApplicationComponent) -> SharedPreferences? = { |
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.
Please make the access & retry mechanism part of EncryptedPreferencesHelper, I think the whole object SecurityHelper can then be deleted. I think EncryptionErrorResetToolcan then also be almost deleted,EncryptedPreferencesFactoryshould then likely also be simplified and made part ofEncryptedPreferencesHelper`.
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.
I moved SecurityHelper to EncryptedPreferencesHelper and EncryptionErrorResetTool was updated as well
.../src/test/java/de/rki/coronawarnapp/worker/DiagnosisTestResultRetrievalPeriodicWorkerTest.kt
Outdated
Show resolved
Hide resolved
…0-refactor-localdata
|
@jurajkusnier test on an OnePlus 8 (Android 11). The app closed (no crash) after scanning a pending test (WRU-XD). Negative, invalid and positive work as expected. Can't reproduce it. |
|
I have this flickering in the submission flow: teletan & qr code. flickering_dialog_fragment_stuff.mp4 |
|
Tested an update scenario on a Xiamoi MI9 (Android 9, WRU-XD), had a tested registered and changed some default settings and everything was like it was before the update 👍 But I also have here the flickering, will now test |
|
The flickering is already in Fixed in: #2583 |
d4rken
left a comment
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.
We will follow up with another PR tomorrow.
|
Kudos, SonarCloud Quality Gate passed! |
LocalDataobject to other classesTesting
databases/coronawarnapp-dbshared_preferences/shared_preferences_cwa.xml