Repository navigation
Keep chapter downloads running after the app leaves the screen - #82
Merged
Merged
Conversation
On Samsung devices, app sleep force-stops the process about a minute after the app leaves the screen, and queued downloads sit idle until the next launch. Each chapter worker now promotes itself to a dataSync foreground service before it waits for a download slot, so the service stays up between chapters. If Android refuses the promotion, the download runs as a plain job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Downloads seemed to give up partway through. On the S22, Samsung's app sleep sets the package to
DISABLED_UNTIL_USEDand force-stops it about 65 seconds after the app goes to the background (am_kill ... change io.aatricks.novelscraper). JobScheduler then drops the queued jobs. WorkManager still holds the work, so nothing is lost, but nothing runs until the app is opened again. The library database was not involved: on relaunch WorkManager logs "Found unfinished work, scheduling it" and the chapters pick up where they stopped.Change
ChapterDownloadWorkercallssetForegroundwith adataSyncforeground service before it waits onChapterDownloadLimiter. Workers queued behind the limiter keep the service alive between chapters.FOREGROUND_SERVICEandFOREGROUND_SERVICE_DATA_SYNCpermissions, plus adataSynctype on WorkManager'sSystemForegroundService.Test plan
testStandardDebugUnitTest), detekt clean, standard and ai flavors assembleNot covered
Three mangabats chapters (Hand Jumper 40.1, 40.5, 41.1) still fail with 0 images. Their images are served only from
img-r2.2xstorage.com, which returns HTTP 503 to the app's request. Chapters onimgs-2.2xstorage.comdownload normally. The worker retries with backoff and then shows the failure badge, which is the intended behavior.