-
Notifications
You must be signed in to change notification settings - Fork 17
Add Android permissions for background reliability #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Move analysis.md and fix-01-foreground-service.md into consolidated BACKGROUND_NOTIFICATIONS_FIX.md under docs/architecture/. The new document describes a hybrid approach combining smart foreground service (only during active trades) with FCM-based reactive wake-up, addressing the persistent notification UX concerns from the previous implementation while maintaining reliability.
Add WAKE_LOCK, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, and RECEIVE_BOOT_COMPLETED permissions to AndroidManifest.xml to improve background service reliability. These permissions enable: - WAKE_LOCK: Keep CPU awake during critical operations - REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: Allow user to exempt app from battery restrictions - RECEIVE_BOOT_COMPLETED: Restore background services after device restart
WalkthroughThis change adds three Android background-related permissions (WAKE_LOCK, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, RECEIVE_BOOT_COMPLETED) to the manifest and introduces comprehensive documentation detailing a hybrid notification strategy that combines foreground services for active trades with FCM wake-ups for inactive periods. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@android/app/src/main/AndroidManifest.xml`:
- Around line 66-69: Add a BroadcastReceiver implementation named
BootCompletedReceiver with an onReceive(Context, Intent) that reacts to
Intent.ACTION_BOOT_COMPLETED and restarts or reschedules the app's background
work (call the existing restartService/startBackgroundWork/scheduleWork helper
you already use for starting services), then register this receiver in
AndroidManifest.xml with an <receiver> entry for BootCompletedReceiver including
an <intent-filter> for android.intent.action.BOOT_COMPLETED and proper
exported/permission attributes so RECEIVE_BOOT_COMPLETED is honored; ensure the
receiver uses the same service-starting helper function to avoid duplicating
start logic.
- Line 68: The manifest declares
android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS but there is no runtime
handling; either remove that <uses-permission> entry from the manifest or
implement a proper runtime flow: import permission_handler and check/request
Permission.ignoreBatteryOptimizations at the moment it’s actually needed (e.g.,
inside your trade-start handler like startTradeFlow or
TradeManager.requestBatteryExemption), show a user rationale dialog before
requesting, handle PermissionStatus (granted/denied/permanentlyDenied) with
graceful fallback and persist the user decision, and only keep the manifest
entry if this runtime path exists.
In `@docs/architecture/BACKGROUND_NOTIFICATIONS_FIX.md`:
- Line 236: Replace the emphasized line "*Last updated: January 2026*" with a
proper markdown heading (e.g., "## Last updated: January 2026") to satisfy
MD036; locate the emphasized text in BACKGROUND_NOTIFICATIONS_FIX.md and convert
the asterisk-wrapped text to a heading level appropriate for the document
structure.
- Around line 22-39: The markdown file has multiple fenced code blocks missing
language tags (MD040); update each fence in BACKGROUND_NOTIFICATIONS_FIX.md to
include the appropriate language: mark the ASCII diagrams (e.g., the "HYBRID
APPROACH" box) as ```text, mark the Dart example containing the
MobileBackgroundService call (the block with if (!isRunning) { await
MobileBackgroundService.instance.startService(); ... }) as ```dart, and mark
Android manifest snippets like <uses-permission
android:name="android.permission.WAKE_LOCK" /> as ```xml; apply the same pattern
to the other affected blocks noted in the comment (lines 60-65, 71-85, 90-95,
102-104, 115-131, 135-147, 151-162) so every fenced block has the correct
language tag.
Add WAKE_LOCK, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, and RECEIVE_BOOT_COMPLETED
permissions to AndroidManifest.xml.
These permissions enable future improvements for reliable background notifications.
Part of background notifications fix effort.
Summary by CodeRabbit
Release Notes
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.