Browse Source
Implement unique work names to prevent duplicate WorkManager tasks
from being enqueued when multiple notifications are scheduled for
the same time or when the receiver is triggered multiple times.
Changes:
- DailyNotificationReceiver: Use enqueueUniqueWork with unique names
("display_{id}", "dismiss_{id}") and ExistingWorkPolicy.KEEP/REPLACE
- DailyNotificationFetcher: Use unique work names based on scheduled
time rounded to minutes ("fetch_{minutes}") with ExistingWorkPolicy.REPLACE
This resolves the issue where ~25+ concurrent workers were being
enqueued for the same notification, leading to race conditions and
resource waste. Now only one worker processes each notification/fetch
at a time.
Verified in logcat: Worker count reduced from 25+ to 1 per notification.
master
2 changed files with 51 additions and 8 deletions
Loading…
Reference in new issue