Skip to content

Add battery optimization exemption setting#54

Closed
Xitee1 wants to merge 1 commit into
mainfrom
claude/zen-keller-cyf07f
Closed

Add battery optimization exemption setting#54
Xitee1 wants to merge 1 commit into
mainfrom
claude/zen-keller-cyf07f

Conversation

@Xitee1

@Xitee1 Xitee1 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an opt-in settings row to request exemption from battery optimization (Doze/App-Standby), which can defer or kill the foreground service on aggressive OEM builds and cause the timer to silently stop mid-countdown.

Changes

  • New BatteryOptimizationHelper (core:service): Singleton that queries the battery-optimization exemption status via PowerManager.isIgnoringBatteryOptimizations() and provides intents to request exemption or access the system battery-optimization settings list.
  • Settings UI: Added a new "System" section with a toggle row for battery optimization. The toggle reflects live system state (not a persisted preference) and launches the appropriate system UI—exemption dialog when enabling, optimization settings list when disabling.
  • ViewModel integration:
    • Renamed adminRefreshTicker to systemStateRefreshTicker to cover both device-admin and battery-exemption state.
    • Renamed refreshDeviceAdminState() to refreshSystemState() and bumped it on ON_RESUME to reflect changes made in system Settings.
    • Added batteryExemptionRequestIntent() and batteryOptimizationSettingsIntent() methods.
  • Manifest: Added REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission with BatteryLife lint suppression (justified because the app ships via F-Droid/GitHub, not Play Store, and the request is only triggered from an opt-in settings row).
  • Strings: Added English and German localized strings for the battery optimization category and toggle states.

Implementation Details

  • The exemption is optional because stock Android usually keeps a foreground service alive without it.
  • The row updates via refreshSystemState() once the user returns from the system UI, ensuring the UI reflects the actual OS state.
  • Activity result launcher (batteryLauncher) is used to detect when the user returns from the exemption dialog or settings, triggering a refresh.

https://claude.ai/code/session_01SqqopAw7r7eu5BrrvHFMau

Adds an "Ignore battery optimization" toggle under a new System section
in settings. The row reflects live system state via PowerManager (not a
persisted preference): toggling on launches the exemption request
dialog, toggling off opens the system's battery optimization list since
Android offers no way to re-optimize programmatically. State refreshes
on resume and on return from the system UI, mirroring the device-admin
row.

The exemption is never requested automatically — some devices don't
need it, so it stays fully opt-in from settings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqqopAw7r7eu5BrrvHFMau
@Xitee1
Xitee1 force-pushed the claude/zen-keller-cyf07f branch from 88cc3f2 to fad047d Compare July 17, 2026 21:42
@Xitee1 Xitee1 closed this Jul 17, 2026
@Xitee1

Xitee1 commented Jul 17, 2026

Copy link
Copy Markdown
Owner Author

Closing as it's useless. The users can just go into android settings and disable it there if it's a problem.

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