Skip to content

Conversation

@AndreaDiazCorreia
Copy link
Member

@AndreaDiazCorreia AndreaDiazCorreia commented Jan 28, 2026

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

    • Enhanced Android background notification system for improved reliability when managing active trades and during idle periods.
  • Chores

    • Added necessary system permissions to support enhanced background operations and device wake management.
    • Updated documentation outlining the background notification architecture and operational scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Walkthrough

This 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

Cohort / File(s) Summary
Android Manifest Permissions
android/app/src/main/AndroidManifest.xml
Added three background service permissions: WAKE_LOCK, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, and RECEIVE_BOOT_COMPLETED for managing background process lifecycle and battery optimization handling
Background Notifications Architecture
docs/architecture/BACKGROUND_NOTIFICATIONS_FIX.md
New comprehensive documentation detailing hybrid approach combining smart foreground service (active trades) with FCM wake-ups (inactive states), including logic rules, permission requirements, notification strategies, scenario flows, testing checklists, and rollback plan

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • Issue #420: Directly addresses missing Android background permissions (WAKE_LOCK, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, RECEIVE_BOOT_COMPLETED) that this PR implements

Suggested reviewers

  • Catrya
  • grunch

Poem

🐰 A hop through the manifest we go,
Three permissions help the background flow,
With foreground services and FCM's chime,
Mostro trades run even when we're offline!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: adding Android permissions for background reliability. It matches the primary modification in the changeset and accurately represents the work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

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