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

Background/Async TEK submission (EXPOSUREAPP-3620) #2008

Merged
merged 18 commits into from
Jan 5, 2021

Conversation

d4rken
Copy link
Member

@d4rken d4rken commented Dec 29, 2020

This PR adds background submission of TEKs to increase chance of submission if the user "forgets" or in some other capacity allows submission but does not finish it.

Once consent is given, and TEKs are available there will be a periodic background worker "lurking", waiting for ~30min of user inactivity. Once 30min is reached, or if the user completes submission themselves, or if the app is restarted, submission is performed.

There are two time values to note, the 15min interval at which we can execute the submission worker, and the 30min of user inactivity that is required before we automatically submit the keys.

Interesting classes:

Testing

For testing the 30min inactivity timeout may be reduced to 15min for testing (see SubmissionTask.USER_INACTIVITY_TIMEOUT).

  • Normal submission should work as before, direct and blocking, on submission success, home screen shows "thank you" card etc. (monitor logcat, there should be no more SubmissionTask executions.)
  • Normal submission, but server throws error, user should land on home screen, home screen should show positive test result, when the worker runs the next time (every 15min) and user activity has timed out, keys should be submitted and home screen should show "thank you" card.
  • Normal submission, server throws error, user should land on home screen, but user re-enters submission flow, automatic submission should be delayed again until 30min of inactivity.
  • Device on desk, user in submission flow (e.g. Symptom input), nothing happening (e.g. AFK), after 30 minutes submission should happen anyways. User should stay in submission flow, and when submitting, no error should be shown (because submission already happened).
  • User is in submission flow and has given consent, but app is put into background and then killed by the system (e.g. swipe it away), submission should happen in the background after the inactivity timeout is reached and when the background worker is executed the next time.
  • User is in submission flow, has given consent, puts app in background (swipe app away), open it again, "positive test result" should be shown, but if the user does nothing, automatic submission should happen once the user inactivity timeout is reached and the background worker is executed the next time.
  • Submission was attempted, but failed or user swiped app away, app is reopened, positive test result is still shown, but app will try to submit in the background, if the user goes back into the submission flow and removes consent, the task will execute, but not perform submission and just deactivate automatic submission.

@d4rken d4rken added enhancement Improvement of an existing feature maintainers Tag pull requests created by maintainers labels Dec 29, 2020
@d4rken d4rken added this to the 1.11.0 milestone Dec 29, 2020
@d4rken d4rken marked this pull request as ready for review December 30, 2020 19:39
@d4rken d4rken requested review from a team and mlenkeit December 30, 2020 19:39
@ralfgehrer ralfgehrer self-assigned this Jan 4, 2021
@ralfgehrer
Copy link
Contributor

Very nice and readable code! Double checked all scenarios I could come up with (cold start, resuming the app, initial states, second submissions) from a coding POV. Device testing still ongoing.

ralfgehrer
ralfgehrer previously approved these changes Jan 4, 2021
Copy link
Contributor

@ralfgehrer ralfgehrer left a comment

Choose a reason for hiding this comment

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

Device test successful on a Pixel (Android 10).

@BMItr BMItr self-requested a review January 4, 2021 14:53
@BMItr BMItr self-assigned this Jan 4, 2021
BMItr
BMItr previously approved these changes Jan 4, 2021
Copy link
Contributor

@BMItr BMItr left a comment

Choose a reason for hiding this comment

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

Code lgtm, tested on pixel 2 device.
Little questions, but no urgent.

@d4rken d4rken dismissed stale reviews from BMItr and ralfgehrer via 3eed069 January 5, 2021 08:43
@BMItr
Copy link
Contributor

BMItr commented Jan 5, 2021

Please adjust SubmissionWorkerTest at last
Will reapprove then.
thx for good work ☕

BMItr
BMItr previously approved these changes Jan 5, 2021
ralfgehrer
ralfgehrer previously approved these changes Jan 5, 2021
@d4rken d4rken dismissed stale reviews from ralfgehrer and BMItr via 5b8242d January 5, 2021 14:45
@sonarcloud
Copy link

sonarcloud bot commented Jan 5, 2021

Kudos, SonarCloud Quality Gate passed!

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

60.1% 60.1% Coverage
0.0% 0.0% Duplication

@ralfgehrer ralfgehrer merged commit 5c7ec06 into release/1.11.x Jan 5, 2021
@ralfgehrer ralfgehrer deleted the feature/3620-background-submission branch January 5, 2021 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improvement of an existing feature maintainers Tag pull requests created by maintainers
Development

Successfully merging this pull request may close these issues.

None yet

3 participants