Skip to content
Snippets Groups Projects
Unverified Commit e30a95ee authored by Kolya Opahle's avatar Kolya Opahle Committed by GitHub
Browse files

Notification to open app from time to time comes back every few minutes (EXPOSUREAPP-4623) #2128


* changed ExistingPeriodicWorkPolicy to KEEP for deadman check task to stop notification loop on every app open

Signed-off-by: default avatarKolya Opahle <k.opahle@sap.com>

* fixed tests

Signed-off-by: default avatarKolya Opahle <k.opahle@sap.com>

* Added info text to the schedulePeriodic doc ...

... to explain the change to ExistingPeriodicWorkPolicy

* Fixed linting

Co-authored-by: default avatarRalf Gehrer <ralfgehrer@users.noreply.github.com>
Co-authored-by: default avatarharambasicluka <64483219+harambasicluka@users.noreply.github.com>
parent 71012378
No related branches found
No related tags found
No related merge requests found
...@@ -35,13 +35,17 @@ class DeadmanNotificationScheduler @Inject constructor( ...@@ -35,13 +35,17 @@ class DeadmanNotificationScheduler @Inject constructor(
/** /**
* Enqueue background deadman notification onetime work * Enqueue background deadman notification onetime work
* Replace with new if older work exists. * Do -NOT- Replace with new if older work exists.
* As this will result in the notification spam seen in the past
* because running a new check every time the app is opened
* spawns a notification every time the last check
* was more than 35 Hours ago.
*/ */
fun schedulePeriodic() { fun schedulePeriodic() {
// Create unique work and enqueue // Create unique work and enqueue
workManager.enqueueUniquePeriodicWork( workManager.enqueueUniquePeriodicWork(
PERIODIC_WORK_NAME, PERIODIC_WORK_NAME,
ExistingPeriodicWorkPolicy.REPLACE, ExistingPeriodicWorkPolicy.KEEP,
workBuilder.buildPeriodicWork() workBuilder.buildPeriodicWork()
) )
} }
......
...@@ -36,7 +36,7 @@ class DeadmanNotificationSchedulerTest : BaseTest() { ...@@ -36,7 +36,7 @@ class DeadmanNotificationSchedulerTest : BaseTest() {
every { every {
workManager.enqueueUniquePeriodicWork( workManager.enqueueUniquePeriodicWork(
DeadmanNotificationScheduler.PERIODIC_WORK_NAME, DeadmanNotificationScheduler.PERIODIC_WORK_NAME,
ExistingPeriodicWorkPolicy.REPLACE, ExistingPeriodicWorkPolicy.KEEP,
any() any()
) )
} returns operation } returns operation
...@@ -104,7 +104,7 @@ class DeadmanNotificationSchedulerTest : BaseTest() { ...@@ -104,7 +104,7 @@ class DeadmanNotificationSchedulerTest : BaseTest() {
verifySequence { verifySequence {
workManager.enqueueUniquePeriodicWork( workManager.enqueueUniquePeriodicWork(
DeadmanNotificationScheduler.PERIODIC_WORK_NAME, DeadmanNotificationScheduler.PERIODIC_WORK_NAME,
ExistingPeriodicWorkPolicy.REPLACE, ExistingPeriodicWorkPolicy.KEEP,
periodicWorkRequest periodicWorkRequest
) )
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment