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

Fix refresh check and improve test menu (EXPOSUREAPP-4049) #1772

Merged
merged 5 commits into from
Dec 1, 2020

Conversation

d4rken
Copy link
Member

@d4rken d4rken commented Dec 1, 2020

Remove "lastTimeDiagnosisKeysFromServerFetch" and replace it with less missleading data.

While it was called "lastTimeDiagnosisKeysFromServerFetch" it was actually "last time we submitted keys for exposure detection". Which was also missleading because it does not directly relate to what the risk card is displaying. It's neither the last download (because it only get's set on submission) and it get's set on start of submission so it likely does not represent the latest risk level until the second risk level calculation has been executed.

  • To decide whether to refresh in "onResume", we now use "has there been any submission to the ENF?" (exposure detection startedAt).
  • To display a timestamp on the risk card, we take the last successful submission (finishedAt) to the ENF as the risk card displays the calculation results, which in turn are based on the latest submission. While we could use the last calculated risk level result timestamp, we currently also trigger risk calculations if there are no new submissions to the ENF, which would mean the timestamp is updated even though the result is not based on new data.
    • When we deem it no longer necessary to launch the risk level task in onResume we should consider displaying the last risk level result timestamp on the card. This is only viable though when the risk level task only get's launched as reaction to finished exposure detections.

I've also fixed the test fragment button behavior and added descriptions, the "Reset risk level" button surfaced the initial issue because it behaved like a "do a 75% data reset" button.

@harambasicluka the bug you described here was likely caused by the incorrectly working test menu button "Reset risklevel", did more than just reset the risk level, it reset LocalData. This lead to downloaded diagnosis keys existing such that no new download was deemed necessary. As no new downloaded happened the "lastTimeDiagnosisKeysFromServerFetch" used for detecting new installs was never set again despite being reset by "Reset risk level", this meant that val wasNotYetFetched = LocalData.lastTimeDiagnosisKeysFromServerFetch() == null always returned true and let the risk level calculation be launched.

…s missleading data.

While it was called "lastTimeDiagnosisKeysFromServerFetch" it was actually "last time we submitted keys to google".

* To decide whether to refresh in "onResume", we now use "has there been any submission to the ENF?"
* To display a timestamp on the risk card, we take the last successful submission to the ENF as the risk card displays the calculation results based on the latest submission. While we could use the last calculated risk level result timestamp, we currently also trigger risk calculations if there are no new submissions to the ENF, which would mean the timestamp is updated even though the result is not based on new data.

I've also fixed the test fragment button behavior and added descriptions, the "Reset risk level" button surfaced the initial issue because it behaved like a "do a 75% data reset" button.
@d4rken d4rken added bug Something isn't working enhancement Improvement of an existing feature maintainers Tag pull requests created by maintainers labels Dec 1, 2020
@d4rken d4rken added this to the 1.8.0 milestone Dec 1, 2020
@d4rken d4rken requested review from harambasicluka and a team December 1, 2020 06:57
@harambasicluka harambasicluka added the prio PRs to review first. label Dec 1, 2020
@ralfgehrer ralfgehrer self-assigned this Dec 1, 2020
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map

suspend fun ExposureDetectionTracker.lastSubmission(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not mind moving this into the same file as the interface itself. Was shortly confused about the location of lastSubmission when reviewing this PR

@harambasicluka harambasicluka self-assigned this Dec 1, 2020
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2020

Kudos, SonarCloud Quality Gate passed!

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

50.0% 50.0% Coverage
0.0% 0.0% Duplication

@harambasicluka harambasicluka merged commit dc5d765 into release/1.8.x Dec 1, 2020
@harambasicluka harambasicluka deleted the fix/onResume-refresh-check branch December 1, 2020 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement Improvement of an existing feature 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.

3 participants