Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Conversation

@jurajkusnier
Copy link
Contributor

@jurajkusnier jurajkusnier commented Mar 10, 2021

  • Move encrypted shared preferences from LocalData object to other classes

Testing

  • Exhaustive Regression testing necessary
  • Test upgrade from the older version
  • Check if files are removed from the device
    databases/coronawarnapp-db
    shared_preferences/shared_preferences_cwa.xml

jurajkusnier and others added 4 commits March 4, 2021 22:15
* 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]>
@jurajkusnier jurajkusnier added maintainers Tag pull requests created by maintainers do not merge labels Mar 10, 2021
@jurajkusnier jurajkusnier added this to the 1.15.0 milestone Mar 10, 2021
@harambasicluka harambasicluka added the prio PRs to review first. label Mar 10, 2021
* 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]>
@BMItr BMItr self-assigned this Mar 10, 2021
@jurajkusnier jurajkusnier marked this pull request as ready for review March 10, 2021 20:16
@jurajkusnier jurajkusnier requested review from a team March 10, 2021 20:16
@d4rken d4rken self-assigned this Mar 11, 2021
@d4rken d4rken self-requested a review March 11, 2021 09:10
Copy link
Member

@d4rken d4rken left a 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.

.addOnSuccessListener { cont.resume(it) }
.addOnFailureListener { cont.resumeWithException(it) }
.also {
tracingSettings.isConsentGiven = true
Copy link
Member

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?

Copy link
Contributor Author

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.


@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal val encryptedPreferencesProvider: (ApplicationComponent) -> SharedPreferences = {
internal val encryptedPreferencesProvider: (ApplicationComponent) -> SharedPreferences? = {
Copy link
Member

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`.

Copy link
Contributor Author

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

@harambasicluka
Copy link
Contributor

harambasicluka commented Mar 11, 2021

@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 send you the logs of the corresponding device via email to not expose any internal urls.

@harambasicluka
Copy link
Contributor

I have this flickering in the submission flow: teletan & qr code.
In the video you can see it twice in the end. I'll send you the logs via email.

flickering_dialog_fragment_stuff.mp4

@harambasicluka
Copy link
Contributor

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 release/1.15.x to check if this PR is the cause.

@harambasicluka
Copy link
Contributor

harambasicluka commented Mar 11, 2021

The flickering is already in release/1.15.x but not in release/1.14.x
#2569 (comment)

Fixed in: #2583

Copy link
Member

@d4rken d4rken left a 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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

21.4% 21.4% Coverage
0.0% 0.0% Duplication

@harambasicluka harambasicluka merged commit f9f22f3 into release/1.15.x Mar 11, 2021
@harambasicluka harambasicluka deleted the feature/2850-refactor-localdata branch March 11, 2021 17:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

maintainers Tag pull requests created by maintainers prio PRs to review first.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants