fix(android): battery exemption request opened nothing; add settings entry #1528

Merged
chris merged 1 commit from feat/settings-power-exemption into main 2026-11-15 20:26:01 +01:00
Owner

Problem

User report (Android 13, stock): tapping the battery-optimization exemption button („Kør altid i baggrunden" on the onboarding card / backup tab) did nothing — no dialog, no crash.

Root cause

PowerExemptionImpl.requestExemption resolved the system dialog intent before starting it. On Android 11+ package visibility hides that system activity unless the manifest declares <queries> — it did not — so the guard misread "hidden" as "OEM-stripped" and silently returned.

Fix

  • Start the dialog intent unconditionally (try/catch ActivityNotFoundException).
  • Manifest <queries> block for the dialog + app-info settings action.
  • Genuinely stripped OEM builds fall back to the app-info battery screen; if even that fails, quiet no-op (never a crash).
  • Regression test pins the start-even-when-unresolvable contract (Robolectric can't simulate the throw, so the fallback stays a reviewed two-liner).

Also: settings entry (third surface)

The exemption now shows in MEHR → Einstellungen as its own SectionCard (between Appearance and About): the wizard's background_run_* copy (de/en/da, zero new strings), a „Tillad/Erlauben" button (≥48dp) while missing, and the calm granted check row once allowed. State re-polls on every ON_RESUME via rememberExemptState — same as the other two surfaces. Wired in MemoriesApp.kt exactly like BackupScreen.

Verification

rtk ./gradlew :core:test :app:testDebugUnitTest — green in the worktree (includes the rewritten PowerExemptionRobolectricTest).

Notes

  • KNOWN_ISSUES: ISSUE-226 (mitigated).
  • No versionName bump / CHANGELOG section — that belongs to the release flow per convention (android-vX.Y.Z tag).
## Problem User report (Android 13, stock): tapping the battery-optimization exemption button („Kør altid i baggrunden" on the onboarding card / backup tab) did **nothing** — no dialog, no crash. ## Root cause `PowerExemptionImpl.requestExemption` resolved the system dialog intent before starting it. On Android 11+ package visibility hides that system activity unless the manifest declares `<queries>` — it did not — so the guard misread "hidden" as "OEM-stripped" and silently returned. ## Fix - Start the dialog intent **unconditionally** (try/catch `ActivityNotFoundException`). - Manifest `<queries>` block for the dialog + app-info settings action. - Genuinely stripped OEM builds fall back to the app-info battery screen; if even that fails, quiet no-op (never a crash). - Regression test pins the start-even-when-unresolvable contract (Robolectric can't simulate the throw, so the fallback stays a reviewed two-liner). ## Also: settings entry (third surface) The exemption now shows in **MEHR → Einstellungen** as its own SectionCard (between Appearance and About): the wizard's `background_run_*` copy (de/en/da, zero new strings), a „Tillad/Erlauben" button (≥48dp) while missing, and the calm granted check row once allowed. State re-polls on every ON_RESUME via `rememberExemptState` — same as the other two surfaces. Wired in `MemoriesApp.kt` exactly like `BackupScreen`. ## Verification `rtk ./gradlew :core:test :app:testDebugUnitTest` — green in the worktree (includes the rewritten `PowerExemptionRobolectricTest`). ## Notes - KNOWN_ISSUES: ISSUE-226 (mitigated). - No versionName bump / CHANGELOG section — that belongs to the release flow per convention (android-vX.Y.Z tag).
fix(android): battery exemption request opened nothing; add settings entry
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 7s
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Deploy review instance (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 7s
Build and Deploy / Android unit tests and debug APK (push) Successful in 13m14s
01f5a4f4f8
The exemption button (onboarding card, backup tab hint) silently did
nothing on stock Android 13+: requestExemption resolved the system
dialog intent first, but Android 11+ package visibility hides that
activity unless the manifest declares <queries> — the guard misread
'hidden' as 'OEM-stripped' and returned. Now the dialog intent starts
unconditionally, the manifest makes it resolvable, and a genuinely
stripped OEM build falls back to the app-info battery screen
(AssertionError-free; Robolectric cannot simulate the throw).

Also surfaces the exemption in the MEHR settings tab as a third
surface: a SectionCard with the wizard's background-run copy, a
Tillad button (>=48dp) while missing and the calm granted check row
once allowed — state re-polls on every ON_RESUME.

KNOWN_ISSUES: ISSUE-226. Test regression pins the
start-even-when-unresolvable contract.
chris merged commit 36392da78f into main 2026-11-15 20:26:01 +01:00
chris referenced this pull request from a commit 2026-11-15 20:32:33 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1528
No description provided.