Skip to content

Fix automatic downloads when Lagrange is backgrounded - #396

Merged
van-geaux merged 2 commits into
van-geaux:mainfrom
JBWortley:fix/automatic-download-background
Nov 5, 2026
Merged

van-geaux merged 2 commits into
van-geaux:mainfrom
JBWortley:fix/automatic-download-background

Conversation

@JBWortley

Copy link
Copy Markdown
Contributor

Automatic downloads were failing on Android 14 when Lagrange was in the background. WorkManager tried to start its foreground service and Android rejected it, leaving the durable queue stuck. A cold worker could also mistake a valid saved profile for a signed-out session because it did not restore the stored session before checking authentication.

This keeps manual downloads foregrounded, but runs automatic transfers as ordinary constrained WorkManager jobs. A terminal failure is recorded and the bounded scan continues with the rest of the queue. The planner now uses the current authenticated session when it has one, restores the active profile's saved session when it does not, and retries temporary verification failures instead of asking the user to sign in again.

I installed the exact branch APK on a Sony XQ-CQ44 running Android 14. With Lagrange backgrounded, it completed a 9,701,925-byte PDF in the selected SD-card folder, removed the completed queue entry, and automatically advanced to the next file. I also tested a five-item Article batch with the phone locked and confirmed that transient network interruptions retained the durable queue for retry. There were no Lagrange foreground-service start denials.

The existing periodic planner remains a persistent 24-hour WorkManager job. It survives ordinary process death and reboot, and continues scanning in bounded batches after each download queue drains.

This does not add byte-range resume. Very large single files still depend on WorkManager's normal execution window and retry behavior.

Checks:

  • 1,327 JVM tests pass
  • Android lint passes
  • Android instrumentation tests compile
  • Debug APK assembles
  • Localization and hardcoded-string checks pass

@van-geaux van-geaux left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@JBWortley, this looks good to merge. Thanks for the thorough work on the background-download fix!

@van-geaux
van-geaux merged commit 7ac09bc into van-geaux:main Nov 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants