-
Notifications
You must be signed in to change notification settings - Fork 487
Don't limit the DownloadDiagnosisKeysTask to once a day (EXPOSUREAPP-3771) #1616
Don't limit the DownloadDiagnosisKeysTask to once a day (EXPOSUREAPP-3771) #1616
Conversation
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingRepository.kt
Show resolved
Hide resolved
|
I couldn't test on a device (do not have one yet) |
|
Will do the device testing for @chiljamgossow . |
| ) | ||
| return (LocalData.lastTimeDiagnosisKeysFromServerFetch() == null || | ||
| currentDate.withTimeAtStartOfDay() != lastFetch.withTimeAtStartOfDay()).also { | ||
| currentDate.isAfter(lastFetch)).also { |
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.
What effect will this have? Won't this always be true, unless we have a sub-milliseconds racecondition (unlikely).
timeStamper.nowUTC will always be after LocalData.lastTimeDiagnosisKeysFromServerFetch().
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 agree. what harm would it do if we just delete the complete condition?
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 think it's already effectively removed, because currentDate.isAfter(lastFetch) will almost always return 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.
Yes, my thinking too. The check solely protects us from someone time traveling backward.
IMHO all these checks should not be implemented by the Task but rather by the KeyPackageSyncTool.
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.
Yes, I tested again and it seems it is always returning 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.
Removed it entirely while ensuring that the task is only being run once every hour.
| val keysWereNotAlreadyRetrieved = | ||
| LocalData.lastTimeDiagnosisKeysFromServerFetch() == null || | ||
| currentDate.withTimeAtStartOfDay() != lastFetch.withTimeAtStartOfDay() | ||
| currentDate.isAfter(lastFetch) |
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.
Same here, against what case of unwated execution does the check of currentDate.isAfter(lastFetch) protect us?
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.
see above. Same check.
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.
Implemented this differently now. Making sure the task is only run once every hour.
|
It should be tested how often the task is now executed, especially when opening/closing the UI. We should observe the webrequests in the log. Even if we run the task more often:
After that, before submission we would evaluate these conditions and abort if called too often: Lines 90 to 103 in 996121d
|
it seems D4rken is correct about the condition always returning true
harambasicluka
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.
Could you please add some tests. Will let it run over the night and check the logs tomorrow.
Fixed. |
|
Download looks better, I'll keep it running for some time. See screenshot below: |
harambasicluka
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.
Coding looks fine, ticket is solved, tested it over night, logs & exposure logs in os settings looks as expected. Also the initial wrong state is resolved.
And it never changed back to the red card? |
I'll tell you in 30 minutes when the next Risk Calculation runs... |
It's a bit chaotic.
I have logs, videos, etc. |
At 11:05 - the download task run - hence it won't run for another hour (with the current implementation) IF the app is not terminated (next "regular" download would be at 12:05) At 12:01 - app was killed, download triggered by opening the app - next download should be expected at 13:01 To my understanding, the download task runs as expected BUT there seems to be some issue regarding the UI states and their update. |
|
Kudos, SonarCloud Quality Gate passed!
|
Expected result:
Note for testing: