Skip to content

Keep Android downloads running and prevents sleep - #2587

Open
hahn-kev-bot wants to merge 2 commits into
developfrom
cursor/keep-awake-android
Open

Keep Android downloads running and prevents sleep#2587
hahn-kev-bot wants to merge 2 commits into
developfrom
cursor/keep-awake-android

Conversation

@hahn-kev-bot

@hahn-kev-bot hahn-kev-bot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

replaces #2445, keeps the screen awake when a download is running.


AI summary

On Android, a long download used to stop silently when the screen slept. This wraps user-visible work (today: project download) in a refcounted keep-awake scope: a dataSync foreground service plus a partial wake lock while any such work is in flight, released when the last item finishes. Other platforms no-op. Work items run concurrently; only start/stop of the OS protection is serialized.

If keep-awake cannot start, the download still runs (fail open) and a copyable error toast is shown via a new UserNotificationEvent.

Call site: CombinedProjectsService.DownloadProject (still uses Task.Run so create+sync stay off the MAUI UI thread).

Test plan

  • dotnet test backend/FwLite/FwLiteShared.Tests --filter FullyQualifiedName~RefCountedKeepAwakeTests
  • Start a large project download on an Android device or emulator
  • Turn the screen off, wait past the normal sleep window, turn it back on
  • Download completed or showed a real error — it did not silently stop
  • Ongoing download notification appeared and disappeared when work finished

Made with Cursor

hahn-kev and others added 2 commits August 20, 2026 12:09
Screen-off suspended the process mid-download. User-visible long-running
work now runs inside IKeepAwake.RunAsync, which reference counts a
dataSync foreground service plus a partial wake lock on Android and does
nothing elsewhere. Work items still run concurrently; only the
acquire/release transitions are serialized. If keep-awake cannot be
established the work still runs and the user gets a copyable error toast.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Enter/Leave paired after a failed acquire so a later download can still protect the device, and drop the arena notes file from the tree.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f93dcc80-5cac-4100-a69b-d36616977811


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Aug 20, 2026
}

if (releaseFailure is not null)
logger.LogError(releaseFailure, "Failed to stop keeping the device awake after {WorkTitle}", work.Title);

private void ReportAcquireFailure(KeepAwakeWork work, Exception exception)
{
logger.LogError(exception, "Failed to keep the device awake for {WorkTitle}", work.Title);
@argos-ci

argos-ci Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Aug 20, 2026, 7:38 AM
e2e (Inspect) ✅ No changes detected - Aug 20, 2026, 7:46 AM

@hahn-kev hahn-kev changed the title Keep Android downloads running when the screen turns off Keep Android downloads running and prevents sleep Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants